@livedigital/client 3.41.0-test-rejoins.4 → 3.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
27
27
 
28
28
  See the Apache Version 2.0 License for specific language governing permissions
29
29
  and limitations under the License.
30
- ***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof f?f:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==r.Reflect&&(n=i(r.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,d={create:o?function(){return le(Object.create(null))}:a?function(){return le({__proto__:null})}:function(){return le({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:de(),h="function"==typeof WeakMap?WeakMap:ue(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),g=se(m);function v(e,t,r,n){if(F(r)){if(!G(e))throw new TypeError;if(!$(t))throw new TypeError;return T(e,t)}if(!G(e))throw new TypeError;if(!B(t))throw new TypeError;if(!B(n)&&!F(n)&&!j(n))throw new TypeError;return j(n)&&(n=void 0),k(e,t,r=z(r),n)}function y(e,t){function r(r,n){if(!B(r))throw new TypeError;if(!F(n)&&!K(n))throw new TypeError;L(e,t,r,n)}return r}function _(e,t,r,n){if(!B(r))throw new TypeError;return F(n)||(n=z(n)),L(e,t,r,n)}function b(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),D(e,t,r)}function w(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),I(e,t,r)}function S(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),O(e,t,r)}function E(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),A(e,t,r)}function C(e,t){if(!B(e))throw new TypeError;return F(t)||(t=z(t)),M(e,t)}function R(e,t){if(!B(e))throw new TypeError;return F(t)||(t=z(t)),N(e,t)}function P(e,t,r){if(!B(t))throw new TypeError;if(F(r)||(r=z(r)),!B(t))throw new TypeError;F(r)||(r=z(r));var n=ae(t,r,!1);return!F(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function T(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!F(n)&&!j(n)){if(!$(n))throw new TypeError;t=n}}return t}function k(e,t,r,n){for(var i=e.length-1;i>=0;--i){var s=(0,e[i])(t,r,n);if(!F(s)&&!j(s)){if(!B(s))throw new TypeError;n=s}}return n}function D(e,t,r){if(I(e,t,r))return!0;var n=re(t);return!j(n)&&D(e,n,r)}function I(e,t,r){var n=ae(t,r,!1);return!F(n)&&W(n.OrdinaryHasOwnMetadata(e,t,r))}function O(e,t,r){if(I(e,t,r))return A(e,t,r);var n=re(t);return j(n)?void 0:O(e,n,r)}function A(e,t,r){var n=ae(t,r,!1);if(!F(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function L(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function M(e,t){var r=N(e,t),n=re(e);if(null===n)return r;var i=M(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var s=new p,o=[],a=0,c=r;a<c.length;a++){var d=c[a];s.has(d)||(s.add(d),o.push(d))}for(var u=0,l=i;u<l.length;u++){d=l[u];s.has(d)||(s.add(d),o.push(d))}return o}function N(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function x(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function F(e){return void 0===e}function j(e){return null===e}function U(e){return"symbol"==typeof e}function B(e){return"object"==typeof e?null!==e:"function"==typeof e}function V(e,t){switch(x(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",n=Q(e,i);if(void 0!==n){var s=n.call(e,r);if(B(s))throw new TypeError;return s}return H(e,"default"===r?"number":r)}function H(e,t){if("string"===t){var r=e.toString;if(Y(r))if(!B(i=r.call(e)))return i;if(Y(n=e.valueOf))if(!B(i=n.call(e)))return i}else{var n;if(Y(n=e.valueOf))if(!B(i=n.call(e)))return i;var i,s=e.toString;if(Y(s))if(!B(i=s.call(e)))return i}throw new TypeError}function W(e){return!!e}function q(e){return""+e}function z(e){var t=V(e,3);return U(t)?t:q(t)}function G(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function Y(e){return"function"==typeof e}function $(e){return"function"==typeof e}function K(e){switch(x(e)){case 3:case 4:return!0;default:return!1}}function J(e,t){return e===t||e!=e&&t!=t}function Q(e,t){var r=e[t];if(null!=r){if(!Y(r))throw new TypeError;return r}}function Z(e){var t=Q(e,s);if(!Y(t))throw new TypeError;var r=t.call(e);if(!B(r))throw new TypeError;return r}function X(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function ne(){var e,r,n,i;F(f)||void 0===t.Reflect||f in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=oe(t.Reflect));var s=new h,o={registerProvider:a,getProvider:d,setProvider:m};return o;function a(t){if(!Object.isExtensible(o))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case F(r):r=t;break;case r===t:break;case F(n):n=t;break;case n===t:break;default:void 0===i&&(i=new p),i.add(t)}}function c(t,s){if(!F(r)){if(r.isProviderFor(t,s))return r;if(!F(n)){if(n.isProviderFor(t,s))return r;if(!F(i))for(var o=Z(i);;){var a=ee(o);if(!a)return;var c=X(a);if(c.isProviderFor(t,s))return te(o),c}}}if(!F(e)&&e.isProviderFor(t,s))return e}function d(e,t){var r,n=s.get(e);return F(n)||(r=n.get(t)),F(r)?(F(r=c(e,t))||(F(n)&&(n=new l,s.set(e,n)),n.set(t,r)),r):r}function u(e){if(F(e))throw new TypeError;return r===e||n===e||!F(i)&&i.has(e)}function m(e,t,r){if(!u(r))throw new Error("Metadata provider not registered.");var n=d(e,t);if(n!==r){if(!F(n))return!1;var i=s.get(e);F(i)&&(i=new l,s.set(e,i)),i.set(t,r)}return!0}}function ie(){var e;return!F(f)&&B(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),F(e)&&(e=ne()),!F(f)&&B(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,f,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!F(n)&&n.has(r)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return m.registerProvider(r),r;function n(n,i,s){var o=t.get(n),a=!1;if(F(o)){if(!s)return;o=new l,t.set(n,o),a=!0}var c=o.get(i);if(F(c)){if(!s)return;if(c=new l,o.set(i,c),!e.setProvider(n,i,r))throw o.delete(i),a&&t.delete(n),new Error("Wrong provider for target.")}return c}function i(e,t,r){var i=n(t,r,!1);return!F(i)&&W(i.has(e))}function s(e,t,r){var i=n(t,r,!1);if(!F(i))return i.get(e)}function o(e,t,r,i){n(r,i,!0).set(e,t)}function a(e,t){var r=[],i=n(e,t,!1);if(F(i))return r;for(var s=Z(i.keys()),o=0;;){var a=ee(s);if(!a)return r.length=o,r;var c=X(a);try{r[o]=c}catch(e){try{te(s)}finally{throw e}}o++}}function c(e,r,i){var s=n(r,i,!1);if(F(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var o=t.get(r);F(o)||(o.delete(i),0===o.size&&t.delete(o))}return!0}}function oe(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,s=e.deleteMetadata,o=new h,a={isProviderFor:function(e,t){var r=o.get(e);return!(F(r)||!r.has(t))||!!i(e,t).length&&(F(r)&&(r=new p,o.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:s};return a}function ae(e,t,r){var n=m.getProvider(e,t);if(!F(n))return n;if(r){if(m.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),n=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,J(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,o)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!J(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(J(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return n;function i(e,t){return e}function o(e,t){return t}function a(e,t){return[e,t]}}function de(){var e=function(){function e(){this._map=new l}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}();return e}function ue(){var e=16,t=d.create(),n=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&d.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?d.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do{e="@@WeakMap@@"+c()}while(d.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:d.create()})}return e[n]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function le(e){return e.__=void 0,delete e.__,e}e("decorate",v),e("metadata",y),e("defineMetadata",_),e("hasMetadata",b),e("hasOwnMetadata",w),e("getMetadata",S),e("getOwnMetadata",E),e("getMetadataKeys",C),e("getOwnMetadataKeys",R),e("deleteMetadata",P)}(n,r),void 0===r.Reflect&&(r.Reflect=e)}()}(h||(h={}));var v=["inject","multi_inject","name","unmanaged","named","optional"],y="Request",_="Singleton",b="Transient",w="ConstantValue",S="Constructor",E="DynamicValue",C="Factory",R="Function",P="Instance",T="Invalid",k="Provider",D="ClassProperty",I="ConstructorArgument",O="Variable",A=0;function L(){return A++}var M=function(){function e(e,t){this.id=L(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=T,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.onDeactivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===_&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.onDeactivation=this.onDeactivation,t.cache=this.cache,t},e}(),N="No matching bindings found for serviceIdentifier:",x="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",F=function(e,t){return"onDeactivation() error in class "+e+": "+t},j=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata("inversify:paramtypes",e),userGeneratedMetadata:Reflect.getMetadata("inversify:tagged",e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata("inversify:tagged_props",e)||[]},e}(),U=0,B=1;function V(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function H(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function W(e,t,r){var n="",i=r(e,t);return 0!==i.length&&(n="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=G(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function q(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||q(e.parentRequest,t))}function z(e){e.childRequests.forEach((function(e){if(q(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=H(t.serviceIdentifier);return r.push(n),null!==t.parentRequest?e(t.parentRequest,r):r}(e).reverse().join(" --\x3e ")}(e);throw new Error("Circular dependency found: "+t)}z(e)}))}function G(e){if(e.name)return e.name;var t=e.toString(),r=t.match(/^function\s*([^\s(]+)/);return r?r[1]:"Anonymous function: "+t}var Y=function(){function e(e){this.id=L(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),$=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return"named"===this.key?"named: "+String(this.value).toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+String(this.value)+" }"},e}(),K=function(e,t){this.parentContext=e,this.rootRequest=t},J=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),Q=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,r=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},r)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}(),Z=function(){function e(e,t,r,n){this.id=L(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?function(e){return e.toString().slice(7,-1)}(t):t;this.name=new Q(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new $("named",n):n instanceof $&&(s=n),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,r=this.metadata;t<r.length;t++){if(r[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag("multi_inject")},e.prototype.matchesArray=function(e){return this.matchesTag("multi_inject")(e)},e.prototype.isNamed=function(){return this.hasTag("named")},e.prototype.isTagged=function(){return this.metadata.some((function(e){return v.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag("optional")(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return"named"===e.key}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return v.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag("named")(e)},e.prototype.matchesTag=function(e){var t=this;return function(r){for(var n=0,i=t.metadata;n<i.length;n++){var s=i[n];if(s.key===e&&s.value===r)return!0}return!1}},e}(),X=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function ee(e,t,r,n){var i=e.getConstructorMetadata(r),s=i.compilerGeneratedMetadata;if(void 0===s)throw new Error("Missing required @injectable annotation in: "+t+".");var o=i.userGeneratedMetadata,a=Object.keys(o),c=0===r.length&&a.length>0,d=a.length>r.length,u=function(e,t,r,n,i){for(var s=[],o=0;o<i;o++){var a=te(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=ne(e,r,t);return X(X([],u,!0),l,!0)}function te(e,t,r,n,i){var s=i[e.toString()]||[],o=se(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof J&&(c=c.unwrap()),a){if(!t&&(c===Object||c===Function||void 0===c))throw new Error("Missing required @inject or @multiInject annotation in: argument "+e+" in class "+r+".");var u=new Z(I,o.targetName,c);return u.metadata=s,u}return null}function re(e,t,r,n){var i=e||t;if(void 0===i){var s="Missing required @injectable annotation in: for property "+String(r)+" in class "+n+".";throw new Error(s)}return i}function ne(e,t,r){for(var n=e.getPropertiesMetadata(t),i=[],s=Object.getOwnPropertySymbols(n),o=0,a=Object.keys(n).concat(s);o<a.length;o++){var c=a[o],d=n[c],u=se(d),l=u.targetName||c,p=re(u.inject,u.multiInject,c,r),h=new Z(D,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=ne(e,f,r);i=X(X([],i,!0),m,!0)}return i}function ie(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=ee(e,G(r),r,!0),i=n.map((function(e){return e.metadata.filter((function(e){return"unmanaged"===e.key}))})),s=[].concat.apply([],i).length,o=n.length-s;return o>0?o:ie(e,r)}return 0}function se(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t.inject,multiInject:t.multi_inject,targetName:t.name,unmanaged:t.unmanaged}}var oe=function(){function e(e,t,r,n,i){this.id=L(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=r,this.target=i,this.childRequests=[],this.bindings=Array.isArray(n)?n:[n],this.requestScope=null===r?new Map:null}return e.prototype.addChildRequest=function(t,r,n){var i=new e(t,this.parentContext,this,r,n);return this.childRequests.push(i),i},e}();function ae(e){return e._bindingDictionary}function ce(e,t,r,n,i){var s=ue(r.container,i.serviceIdentifier),o=[];return s.length===U&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=ue(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new oe(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case U:if(r.isOptional())return t;var i=H(e),s=N;throw s+=function(e,t){if(t.isTagged()||t.isNamed()){var r="",n=t.getNamedTag(),i=t.getCustomTags();return null!==n&&(r+=n.toString()+"\n"),null!==i&&i.forEach((function(e){r+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+r}return" "+e}(i,r),s+=W(n,i,ue),new Error(s);case B:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=H(e));throw s+=W(n,i,ue),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function de(e,t,r,n,i,s){var o,a;if(null===i){o=ce(e,t,n,null,s),a=new oe(r,n,null,o,s);var c=new K(n,a);n.addPlan(c)}else o=ce(e,t,n,i,s),a=i.addChildRequest(s.serviceIdentifier,o,s);o.forEach((function(t){var r=null;if(s.isArray())r=a.addChildRequest(t.serviceIdentifier,t,s);else{if(t.cache)return;r=a}if(t.type===P&&null!==t.implementationType){var i=function(e,t){return ee(e,G(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=ie(e,t.implementationType);if(i.length<o){var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."}(G(t.implementationType));throw new Error(c)}}i.forEach((function(t){de(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function ue(e,t){var r=[],n=ae(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=ue(e.parent,t)),r}function le(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new Y(t),d=function(e,t,r,n,i,s){var o=new $(e?"multi_inject":"inject",r),a=new Z(t,n,r,o);if(void 0!==i){var c=new $(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return de(e,a,i,c,null,d),c}catch(e){throw V(e)&&z(c.plan.rootRequest),e}}function pe(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function he(e){return!!pe(e)||Array.isArray(e)&&e.some(pe)}var fe,me=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},ge=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},ve=function(e,t,r){e.has(t.id)||e.set(t.id,r)},ye=function(e,t){e.cache=t,e.activated=!0,pe(t)&&_e(e,t)},_e=function(e,t){return me(void 0,void 0,void 0,(function(){var r,n;return ge(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t];case 1:return r=i.sent(),e.cache=r,[3,3];case 2:throw n=i.sent(),e.cache=null,e.activated=!1,n;case 3:return[2]}}))}))};!function(e){e.DynamicValue="toDynamicValue",e.Factory="toFactory",e.Provider="toProvider"}(fe||(fe={}));var be=function(){return be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},be.apply(this,arguments)},we=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},Se=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},Ee=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Ce(e,t,r){var n;if(t.length>0){var i=function(e,t){return e.reduce((function(e,r){var n=t(r);return r.target.type===I?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=he(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=be(be({},i),{constr:e});n=i.isAsync?function(e){return we(this,void 0,void 0,(function(){var t,r;return Se(this,(function(n){switch(n.label){case 0:return[4,Pe(e.constructorInjections)];case 1:return t=n.sent(),[4,Pe(e.propertyInjections)];case 2:return r=n.sent(),[2,Re(be(be({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):Re(s)}else n=new e;return n}function Re(e){var t,r=new((t=e.constr).bind.apply(t,Ee([void 0],e.constructorInjections,!1)));return e.propertyRequests.forEach((function(t,n){var i=t.target.identifier,s=e.propertyInjections[n];t.target.isOptional()&&void 0===s||(r[i]=s)})),r}function Pe(e){return we(this,void 0,void 0,(function(){var t,r,n,i;return Se(this,(function(s){for(t=[],r=0,n=e;r<n.length;r++)i=n[r],Array.isArray(i)?t.push(Promise.all(i)):t.push(i);return[2,Promise.all(t)]}))}))}function Te(e,t){var r=function(e,t){var r,n;if(Reflect.hasMetadata("post_construct",e)){var i=Reflect.getMetadata("post_construct",e);try{return null===(n=(r=t)[i.value])||void 0===n?void 0:n.call(r)}catch(t){if(t instanceof Error)throw new Error((s=e.name,o=t.message,"@postConstruct error in class "+s+": "+o))}}var s,o}(e,t);return pe(r)?r.then((function(){return t})):t}function ke(e,t){e.scope!==_&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===y?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(F(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var De=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},Ie=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},Oe=function(e){return function(t){t.parentContext.setCurrentRequest(t);var r=t.bindings,n=t.childRequests,i=t.target&&t.target.isArray(),s=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(i&&s)return n.map((function(t){return Oe(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return Ne(e,t,o)}}},Ae=function(e,t){var r=function(e){switch(e.type){case C:return{factory:e.factory,factoryType:fe.Factory};case k:return{factory:e.provider,factoryType:fe.Provider};case E:return{factory:e.dynamicValue,factoryType:fe.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw V(e)&&(e=t()),e}}((function(){return r.factory.bind(e)(t)}),(function(){return new Error((e=r.factoryType,n=t.currentRequest.serviceIdentifier.toString(),"It looks like there is a circular dependency in one of the '"+e+"' bindings. Please investigate bindings with service identifier '"+n+"'."));var e,n}))},Le=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case w:case R:t=e.cache;break;case S:case P:t=e.implementationType;break;case E:t=e.dynamicValue;break;case k:t=e.provider;break;case C:t=e.factory}if(null===t){var r=H(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case w:case R:n=r.cache;break;case S:n=r.implementationType;break;case P:n=function(e,t,r,n){ke(e,t);var i=Ce(t,r,n);return pe(i)?i.then((function(e){return Te(t,e)})):Te(t,i)}(r,r.implementationType,i,Oe(e));break;default:n=Ae(r,t.parentContext)}return n},Me=function(e,t,r){var n=function(e,t){return t.scope===_&&t.activated?t.cache:t.scope===y&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===_&&ye(t,r),t.scope===y&&ve(e,t,r)}(e,t,n=r()),n},Ne=function(e,t,r){return Me(e,r,(function(){var n=Le(e,t,r);return n=pe(n)?n.then((function(e){return xe(t,r,e)})):xe(t,r,n)}))};function xe(e,t,r){var n,i=Fe(e.parentContext,t,r),s=Ve(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=Be(n,c);i=pe(i)?Ue(d,a,i):je(d,a,i),o=s.next()}while(!0!==o.done&&!ae(n).hasKey(e.serviceIdentifier));return i}var Fe=function(e,t,r){return"function"==typeof t.onActivation?t.onActivation(e,r):r},je=function(e,t,r){for(var n=e.next();!n.done;){if(pe(r=n.value(t,r)))return Ue(e,t,r);n=e.next()}return r},Ue=function(e,t,r){return De(void 0,void 0,void 0,(function(){var n,i;return Ie(this,(function(s){switch(s.label){case 0:return[4,r];case 1:n=s.sent(),i=e.next(),s.label=2;case 2:return i.done?[3,4]:[4,i.value(t,n)];case 3:return n=s.sent(),i=e.next(),[3,2];case 4:return[2,n]}}))}))},Be=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},Ve=function(e){for(var t=[e],r=e.parent;null!==r;)t.push(r),r=r.parent;return{next:function(){var e=t.pop();return void 0!==e?{done:!1,value:e}:{done:!0,value:void 0}}}};var He=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||He(r,t))},We=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new $(e,t),r}},qe=We("named"),ze=function(e){return function(t){var r=null;if(null!==t){if(r=t.bindings[0],"string"==typeof e)return r.serviceIdentifier===e;var n=t.bindings[0].implementationType;return e===n}return!1}},Ge=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new Ye(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=qe(e),new Ye(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e&&(null!==e.target&&!e.target.isNamed()&&!e.target.isTagged())},new Ye(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=We(e)(t),new Ye(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&ze(e)(t.parentRequest)},new Ye(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&qe(e)(t.parentRequest)},new Ye(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&We(e)(t)(r.parentRequest)},new Ye(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&He(t,ze(e))},new Ye(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!He(t,ze(e))},new Ye(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&He(t,qe(e))},new Ye(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!He(t,qe(e))},new Ye(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&He(r,We(e)(t))},new Ye(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!He(r,We(e)(t))},new Ye(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&He(t,e)},new Ye(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!He(t,e)},new Ye(this._binding)},e}(),Ye=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new Ge(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new Ge(this._binding)},e}(),$e=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ge(this._binding),this._bindingOnSyntax=new Ye(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),Ke=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=y,new $e(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=_,new $e(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=b,new $e(this._binding)},e}(),Je=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ge(this._binding),this._bindingOnSyntax=new Ye(this._binding),this._bindingInSyntax=new Ke(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),Qe=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=P,this._binding.implementationType=e,new Je(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error("The toSelf function can only be applied when a constructor is used as service identifier");var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=w,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=_,new $e(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=E,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new Je(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=S,this._binding.implementationType=e,this._binding.scope=_,new $e(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=C,this._binding.factory=e,this._binding.scope=_,new $e(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error("Value provided to function binding must be a function!");var t=this.toConstantValue(e);return this._binding.type=R,this._binding.scope=_,t},e.prototype.toAutoFactory=function(e){return this._binding.type=C,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=_,new $e(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=C,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new $e(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=k,this._binding.provider=e,this._binding.scope=_,new $e(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Ze=function(){function e(){}return e.of=function(t,r,n,i,s){var o=new e;return o.bindings=t,o.middleware=r,o.deactivations=i,o.activations=n,o.moduleActivationStore=s,o},e}();var Xe=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error("NULL argument");if(null==t)throw new Error("NULL argument");var r=this._map.get(e);void 0!==r?r.push(t):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error("NULL argument");var t=this._map.get(e);if(void 0!==t)return t;throw new Error("Key Not Found")},e.prototype.remove=function(e){if(null==e)throw new Error("NULL argument");if(!this._map.delete(e))throw new Error("Key Not Found")},e.prototype.removeIntersection=function(e){var t=this;this.traverse((function(r,n){var i=e.hasKey(r)?e.get(r):void 0;if(void 0!==i){var s=n.filter((function(e){return!i.some((function(t){return e===t}))}));t._setValue(r,s)}}))},e.prototype.removeByCondition=function(e){var t=this,r=[];return this._map.forEach((function(n,i){for(var s=[],o=0,a=n;o<a.length;o++){var c=a[o];e(c)?r.push(c):s.push(c)}t._setValue(i,s)})),r},e.prototype.hasKey=function(e){if(null==e)throw new Error("NULL argument");return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){e.forEach((function(e){return t.add(r,"object"==typeof(n=e)&&null!==n&&"clone"in n&&"function"==typeof n.clone?e.clone():e);var n}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,r){e(r,t)}))},e.prototype._setValue=function(e,t){t.length>0?this._map.set(e,t):this._map.delete(e)},e}(),et=function(){function e(){this._map=new Map}return e.prototype.remove=function(e){if(this._map.has(e)){var t=this._map.get(e);return this._map.delete(e),t}return this._getEmptyHandlersStore()},e.prototype.addDeactivation=function(e,t,r){this._getModuleActivationHandlers(e).onDeactivations.add(t,r)},e.prototype.addActivation=function(e,t,r){this._getModuleActivationHandlers(e).onActivations.add(t,r)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){t._map.set(r,{onActivations:e.onActivations.clone(),onDeactivations:e.onDeactivations.clone()})})),t},e.prototype._getModuleActivationHandlers=function(e){var t=this._map.get(e);return void 0===t&&(t=this._getEmptyHandlersStore(),this._map.set(e,t)),t},e.prototype._getEmptyHandlersStore=function(){return{onActivations:new Xe,onDeactivations:new Xe}},e}(),tt=function(){return tt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},tt.apply(this,arguments)},rt=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},nt=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},it=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},st=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error("Invalid Container constructor argument. Container options must be an object.");if(void 0===t.defaultScope)t.defaultScope=b;else if(t.defaultScope!==_&&t.defaultScope!==b&&t.defaultScope!==y)throw new Error('Invalid Container option. Default scope must be a string ("singleton" or "transient").');if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error("Invalid Container option. Auto bind injectable must be a boolean");if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error("Invalid Container option. Skip base check must be a boolean");this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=L(),this._bindingDictionary=new Xe,this._snapshots=[],this._middleware=null,this._activations=new Xe,this._deactivations=new Xe,this.parent=null,this._metadataReader=new j,this._moduleActivationStore=new et}return e.merge=function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=new e,o=it([t,r],n,!0).map((function(e){return ae(e)})),a=ae(s);function c(e,t){e.traverse((function(e,r){r.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return o.forEach((function(e){c(e,a)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=this._getContainerModuleHelpersFactory(),n=0,i=e;n<i.length;n++){var s=i[n],o=r(s.id);s.registry(o.bindFunction,o.unbindFunction,o.isboundFunction,o.rebindFunction,o.unbindAsyncFunction,o.onActivationFunction,o.onDeactivationFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rt(this,void 0,void 0,(function(){var t,r,n,i,s;return nt(this,(function(o){switch(o.label){case 0:t=this._getContainerModuleHelpersFactory(),r=0,n=e,o.label=1;case 1:return r<n.length?(i=n[r],s=t(i.id),[4,i.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction,s.unbindAsyncFunction,s.onActivationFunction,s.onDeactivationFunction)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.forEach((function(t){var r=e._removeModuleBindings(t.id);e._deactivateSingletons(r),e._removeModuleHandlers(t.id)}))},e.prototype.unloadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rt(this,void 0,void 0,(function(){var t,r,n,i;return nt(this,(function(s){switch(s.label){case 0:t=0,r=e,s.label=1;case 1:return t<r.length?(n=r[t],i=this._removeModuleBindings(n.id),[4,this._deactivateSingletonsAsync(i)]):[3,4];case 2:s.sent(),this._removeModuleHandlers(n.id),s.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},e.prototype.bind=function(e){var t=this.options.defaultScope||b,r=new M(e,t);return this._bindingDictionary.add(e,r),new Qe(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return rt(this,void 0,void 0,(function(){return nt(this,(function(t){switch(t.label){case 0:return[4,this.unbindAsync(e)];case 1:return t.sent(),[2,this.bind(e)]}}))}))},e.prototype.unbind=function(e){if(this._bindingDictionary.hasKey(e)){var t=this._bindingDictionary.get(e);this._deactivateSingletons(t)}this._removeServiceFromDictionary(e)},e.prototype.unbindAsync=function(e){return rt(this,void 0,void 0,(function(){var t;return nt(this,(function(r){switch(r.label){case 0:return this._bindingDictionary.hasKey(e)?(t=this._bindingDictionary.get(e),[4,this._deactivateSingletonsAsync(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return this._removeServiceFromDictionary(e),[2]}}))}))},e.prototype.unbindAll=function(){var e=this;this._bindingDictionary.traverse((function(t,r){e._deactivateSingletons(r)})),this._bindingDictionary=new Xe},e.prototype.unbindAllAsync=function(){return rt(this,void 0,void 0,(function(){var e,t=this;return nt(this,(function(r){switch(r.label){case 0:return e=[],this._bindingDictionary.traverse((function(r,n){e.push(t._deactivateSingletonsAsync(n))})),[4,Promise.all(e)];case 1:return r.sent(),this._bindingDictionary=new Xe,[2]}}))}))},e.prototype.onActivation=function(e,t){this._activations.add(e,t)},e.prototype.onDeactivation=function(e,t){this._deactivations.add(e,t)},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isCurrentBound=function(e){return this._bindingDictionary.hasKey(e)},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,"named",t)},e.prototype.isBoundTagged=function(e,t,r){var n=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),s=function(e,t,r,n){var i=new Z(O,"",t,new $(r,n)),s=new Y(e);return new oe(t,s,null,[],i)}(this,e,t,r);n=i.some((function(e){return e.constraint(s)}))}return!n&&this.parent&&(n=this.parent.isBoundTagged(e,t,r)),n},e.prototype.snapshot=function(){this._snapshots.push(Ze.of(this._bindingDictionary.clone(),this._middleware,this._activations.clone(),this._deactivations.clone(),this._moduleActivationStore.clone()))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error("No snapshot available to restore.");this._bindingDictionary=e.bindings,this._activations=e.activations,this._deactivations=e.deactivations,this._middleware=e.middleware,this._moduleActivationStore=e.moduleActivationStore},e.prototype.createChild=function(t){var r=new e(t||this.options);return r.parent=this,r},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),r)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){var t=this._getNotAllArgs(e,!1);return this._getButThrowIfAsync(t)},e.prototype.getAsync=function(e){return rt(this,void 0,void 0,(function(){var t;return nt(this,(function(r){return t=this._getNotAllArgs(e,!1),[2,this._get(t)]}))}))},e.prototype.getTagged=function(e,t,r){var n=this._getNotAllArgs(e,!1,t,r);return this._getButThrowIfAsync(n)},e.prototype.getTaggedAsync=function(e,t,r){return rt(this,void 0,void 0,(function(){var n;return nt(this,(function(i){return n=this._getNotAllArgs(e,!1,t,r),[2,this._get(n)]}))}))},e.prototype.getNamed=function(e,t){return this.getTagged(e,"named",t)},e.prototype.getNamedAsync=function(e,t){return this.getTaggedAsync(e,"named",t)},e.prototype.getAll=function(e){var t=this._getAllArgs(e);return this._getButThrowIfAsync(t)},e.prototype.getAllAsync=function(e){var t=this._getAllArgs(e);return this._getAll(t)},e.prototype.getAllTagged=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getButThrowIfAsync(n)},e.prototype.getAllTaggedAsync=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getAll(n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,"named",t)},e.prototype.getAllNamedAsync=function(e,t){return this.getAllTaggedAsync(e,"named",t)},e.prototype.resolve=function(e){var t=this.isBound(e);t||this.bind(e).toSelf();var r=this.get(e);return t||this.unbind(e),r},e.prototype._preDestroy=function(e,t){var r,n;if(Reflect.hasMetadata("pre_destroy",e))return null===(n=(r=t)[Reflect.getMetadata("pre_destroy",e).value])||void 0===n?void 0:n.call(r)},e.prototype._removeModuleHandlers=function(e){var t=this._moduleActivationStore.remove(e);this._activations.removeIntersection(t.onActivations),this._deactivations.removeIntersection(t.onDeactivations)},e.prototype._removeModuleBindings=function(e){return this._bindingDictionary.removeByCondition((function(t){return t.moduleId===e}))},e.prototype._deactivate=function(e,t){var r=this,n=Object.getPrototypeOf(t).constructor;try{if(this._deactivations.hasKey(e.serviceIdentifier)){var i=this._deactivateContainer(t,this._deactivations.get(e.serviceIdentifier).values());if(pe(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(pe(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(F(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return rt(this,void 0,void 0,(function(){var r;return nt(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e];case 1:return n.sent(),[3,3];case 2:if((r=n.sent())instanceof Error)throw new Error(F(t.name,r.message));return[3,3];case 3:return[2]}}))}))},e.prototype._deactivateContainer=function(e,t){for(var r=this,n=t.next();n.value;){var i=n.value(e);if(pe(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return rt(this,void 0,void 0,(function(){var r;return nt(this,(function(n){switch(n.label){case 0:r=t.next(),n.label=1;case 1:return r.value?[4,r.value(e)]:[3,3];case 2:return n.sent(),r=t.next(),[3,1];case 3:return[2]}}))}))},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},r=function(r){return function(n){var i=e.rebind(n);return t(i,r),i}},n=function(t){return function(r,n){e._moduleActivationStore.addActivation(t,r,n),e.onActivation(r,n)}},i=function(t){return function(r,n){e._moduleActivationStore.addDeactivation(t,r,n),e.onDeactivation(r,n)}};return function(s){return{bindFunction:(o=s,function(r){var n=e.bind(r);return t(n,o),n}),isboundFunction:function(t){return e.isBound(t)},onActivationFunction:n(s),onDeactivationFunction:i(s),rebindFunction:r(s),unbindFunction:function(t){return e.unbind(t)},unbindAsyncFunction:function(t){return e.unbindAsync(t)}};var o}},e.prototype._getAll=function(e){return Promise.all(this._get(e))},e.prototype._get=function(e){var t=tt(tt({},e),{contextInterceptor:function(e){return e},targetType:O});if(this._middleware){var r=this._middleware(t);if(null==r)throw new Error("Invalid return type in middleware. Middleware must return!");return r}return this._planAndResolve()(t)},e.prototype._getButThrowIfAsync=function(e){var t=this._get(e);if(he(t))throw new Error("You are attempting to construct '"+e.serviceIdentifier+"' in a synchronous way\n but it has asynchronous dependencies.");return t},e.prototype._getAllArgs=function(e){return{avoidConstraints:!0,isMultiInject:!0,serviceIdentifier:e}},e.prototype._getNotAllArgs=function(e,t,r,n){return{avoidConstraints:!1,isMultiInject:t,serviceIdentifier:e,key:r,value:n}},e.prototype._planAndResolve=function(){var e=this;return function(t){var r=le(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return Oe(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return pe(e.cache)?e.cache.then((function(r){return t._deactivate(e,r)})):this._deactivate(e,e.cache)},e.prototype._deactivateSingletons=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(pe(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return rt(this,void 0,void 0,(function(){var t=this;return nt(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return t._deactivateIfSingleton(e)})))];case 1:return r.sent(),[2]}}))}))},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroy=function(e,t,r){return this.parent?this._deactivate.bind(this.parent)(e,t):this._bindingDeactivationAndPreDestroy(e,t,r)},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroyAsync=function(e,t,r){return rt(this,void 0,void 0,(function(){return nt(this,(function(n){switch(n.label){case 0:return this.parent?[4,this._deactivate.bind(this.parent)(e,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this._bindingDeactivationAndPreDestroyAsync(e,t,r)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.prototype._removeServiceFromDictionary=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error("Could not unbind serviceIdentifier: "+H(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(pe(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return rt(this,void 0,void 0,(function(){return nt(this,(function(n){switch(n.label){case 0:return"function"!=typeof e.onDeactivation?[3,2]:[4,e.onDeactivation(t)];case 1:n.sent(),n.label=2;case 2:return[4,this._preDestroy(r,t)];case 3:return n.sent(),[2]}}))}))},e}();function ot(e,t,r,n){!function(e){if(void 0!==e)throw new Error(x)}(t),ct("inversify:tagged",e,r.toString(),n)}function at(e){var t=[];if(Array.isArray(e)){var r=function(e){for(var t=new Set,r=0,n=e;r<n.length;r++){var i=n[r];if(t.has(i))return i;t.add(i)}}((t=e).map((function(e){return e.key})));if(void 0!==r)throw new Error("Metadata key was used more than once in a parameter: "+r.toString())}else t=[e];return t}function ct(e,t,r,n){var i=at(n),s={};Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var o=s[r];if(void 0===o)o=[];else for(var a=function(e){if(i.some((function(t){return t.key===e.key})))throw new Error("Metadata key was used more than once in a parameter: "+e.key.toString())},c=0,d=o;c<d.length;c++){a(d[c])}o.push.apply(o,i),s[r]=o,Reflect.defineMetadata(e,s,t)}function dt(e){return function(t,r,n){"number"==typeof n?ot(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(x);ct("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function ut(){return function(e){if(Reflect.hasOwnMetadata("inversify:paramtypes",e))throw new Error("Cannot apply @injectable decorator multiple times.");var t=Reflect.getMetadata("design:paramtypes",e)||[];return Reflect.defineMetadata("inversify:paramtypes",t,e),e}}var lt,pt=(lt="inject",function(e){return function(t,r,n){if(void 0===e){var i="function"==typeof t?t.name:t.constructor.name;throw new Error(function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation."}(i))}return dt(new $(lt,e))(t,r,n)}});const ht=3,ft=4,mt=6,gt=7;var vt;!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.OK=200]="OK",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(vt||(vt={}));var yt;const _t={baseURL:"https://lb.livedigital.space/v1",timeout:5e3},bt={customerId:String(process.env.ASDK_CUSTOMER_ID),sdk_url:String("https://effectssdk.ai/sdk/audio/"),api_url:String("https://effectssdk.ai/sdk/session/"),version:"2.3.5"},wt={customerId:String("89c41ecf3b3f46fef5dfa9f96842014c21d4901c"),sdk_url:String("https://effectssdk.ai/sdk/"),api_url:String("https://effectssdk.ai/sdk/session/")},St=()=>{};let Et=class{constructor(e){var t,r,n,i,s,o,a,c,d;yt.set(this,void 0),p(this,yt,{denoiser:null!==(t=e.denoiser)&&void 0!==t?t:"rnnoise",asdk:Object.assign(Object.assign({},bt),e.asdk),loadbalancer:Object.assign(_t,null!==(n=null===(r=e.network)||void 0===r?void 0:r.loadbalancer)&&void 0!==n?n:{}),logLevel:null!==(i=e.logLevel)&&void 0!==i?i:ht,sendAnalytics:null!==(s=e.sendAnalytics)&&void 0!==s&&s,onLogMessage:null!==(o=e.onLogMessage)&&void 0!==o?o:St,onIssues:null!==(a=e.onIssues)&&void 0!==a?a:St,disableWid:null!==(c=e.disableWid)&&void 0!==c&&c,effectsSDKParams:Object.assign(Object.assign({},wt),e.effectsSDKParams),onNetworkScoresUpdated:null!==(d=e.onNetworkScoresUpdated)&&void 0!==d?d:St,staticFilesPath:e.staticFilesPath||window.location.origin},"f")}get(e){return l(this,yt,"f")[e]}set(e,t){l(this,yt,"f")[e]=t}};yt=new WeakMap,Et=a([ut(),d("design:paramtypes",[Object])],Et);var Ct,Rt,Pt,Tt,kt=Et;class Dt extends e.EventEmitter{constructor(){super(),this.addListener=(e,t)=>this.on(e,t),this.removeListener=(e,t)=>this.off(e,t),this.prependListener=(e,t)=>(super.prependListener(e,t),this),this.prependOnceListener=(e,t)=>(super.prependOnceListener(e,t),this),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){try{super.emit("listenererror",e,t)}catch(e){}return!!super.listenerCount(e)}}on(e,t){return super.on(e,t)}off(e,t){return super.off(e,t)}once(e,t){return super.once(e,t)}removeAllListeners(e){return super.removeAllListeners(e),this}}function It(){}function Ot(){Ot.init.call(this)}function At(e){return void 0===e._maxListeners?Ot.defaultMaxListeners:e._maxListeners}function Lt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Vt(e,n),s=0;s<n;++s)i[s].call(r)}function Mt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Vt(e,i),o=0;o<i;++o)s[o].call(r,n)}function Nt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Vt(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function xt(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Vt(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Ft(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Vt(e,i),o=0;o<i;++o)s[o].apply(r,n)}function jt(e,t,r,n){var i,s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=new It,e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=At(e))&&i>0&&o.length>i){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=s[t]=r,++e._eventsCount;return e}function Ut(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Bt(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Vt(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}It.prototype=Object.create(null),Ot.EventEmitter=Ot,Ot.usingDomains=!1,Ot.prototype.domain=void 0,Ot.prototype._events=void 0,Ot.prototype._maxListeners=void 0,Ot.defaultMaxListeners=10,Ot.init=function(){this.domain=null,Ot.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new It,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ot.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Ot.prototype.getMaxListeners=function(){return At(this)},Ot.prototype.emit=function(e){var t,r,n,i,s,o,a,c="error"===e;if(o=this._events)c=c&&null==o.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var d=new Error('Uncaught, unspecified "error" event. ('+t+")");throw d.context=t,d}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=o[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:Lt(r,u,this);break;case 2:Mt(r,u,this,arguments[1]);break;case 3:Nt(r,u,this,arguments[1],arguments[2]);break;case 4:xt(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];Ft(r,u,this,i)}return!0},Ot.prototype.addListener=function(e,t){return jt(this,e,t,!1)},Ot.prototype.on=Ot.prototype.addListener,Ot.prototype.prependListener=function(e,t){return jt(this,e,t,!0)},Ot.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ut(this,e,t)),this},Ot.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ut(this,e,t)),this},Ot.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new It:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new It,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},Ot.prototype.off=function(e,t){return this.removeListener(e,t)},Ot.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new It,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new It:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),s=0;s<i.length;++s)"removeListener"!==(n=i[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new It,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Ot.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Ot.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Bt.call(e,t)},Ot.prototype.listenerCount=Bt,Ot.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Ht extends Ot{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(Ct||(Ct={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(Rt||(Rt={})),function(e){e.OutboundNetworkQuality="outbound-network-quality",e.InboundNetworkQuality="inbound-network-quality",e.OutboundNetworkMediaLatency="outbound-network-media-latency",e.InboundNetworkMediaLatency="inbound-network-media-latency",e.NetworkMediaSyncFailure="network-media-sync-failure",e.OutboundNetworkThroughput="outbound-network-throughput",e.InboundNetworkThroughput="inbound-network-throughput",e.EncoderCPUThrottling="encoder-cpu-throttling",e.DecoderCPUThrottling="decoder-cpu-throttling",e.ServerIssue="server-issue",e.UnknownVideoDecoderIssue="unknown-video-decoder",e.LowInboundMOS="low-inbound-mean-opinion-score",e.LowOutboundMOS="low-outbound-mean-opinion-score",e.FrozenVideoTrack="frozen-video-track",e.MissingVideoStreamData="missing-video-stream-data",e.MissingAudioStreamData="missing-audio-stream-data"}(Pt||(Pt={})),function(e){e[e.BAD=2.1]="BAD",e[e.POOR=2.6]="POOR",e[e.FAIR=3.1]="FAIR",e[e.GOOD=3.8]="GOOD",e[e.EXCELLENT=4.3]="EXCELLENT"}(Tt||(Tt={}));class Wt extends Ot{static STATS_REPORT_READY_EVENT="stats-report-ready";static STATS_REPORTS_PARSED="stats-reports-parsed";isStopped=!1;reportTimer;getStatsInterval;compositeStatsParser;constructor(e){super(),this.compositeStatsParser=e.compositeStatsParser,this.getStatsInterval=e.getStatsInterval??1e4}get isRunning(){return!!this.reportTimer&&!this.isStopped}startReporting(){if(this.reportTimer)return;const e=()=>setTimeout((()=>{this.isStopped?this.reportTimer=void 0:this.parseReports().finally((()=>{this.reportTimer=e()}))}),this.getStatsInterval);this.isStopped=!1,this.reportTimer=e()}stopReporting(){this.isStopped=!0,this.reportTimer&&(clearTimeout(this.reportTimer),this.reportTimer=void 0)}async parseReports(){const e=Date.now(),t=await this.compositeStatsParser.parse(),r=Date.now()-e;this.emit(Wt.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(Wt.STATS_REPORT_READY_EVENT,e)}))}}const qt=(()=>{const e=new Map;return t=>{const{taskId:r,delayMs:n,maxJitterMs:i,callback:s}=t,o=Math.ceil(Math.random()*(i||0)),a=e.get(r);a&&clearTimeout(a);const c=setTimeout((()=>{s(),e.delete(r)}),n+o);e.set(r,c)}})();class zt{#e={};calculate(e){const{connection:{id:t}}=e,{mos:r,stats:n}=this.calculateOutboundScore(e)||{},{mos:i,stats:s}=this.calculateInboundScore(e)||{};return this.#e[t]=e,qt({taskId:t,delayMs:35e3,callback:()=>delete this.#e[t]}),{outbound:r,inbound:i,connectionId:t,statsSamples:{inboundStatsSample:s,outboundStatsSample:n}}}calculateOutboundScore(e){const t=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.remote?.audio.inbound||[],...r.remote?.video.inbound||[]],{packetsSent:i}=e.connection,s=r.connection.packetsSent,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateInboundScore(e){const t=[...e.audio?.inbound,...e.video?.inbound];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.video?.inbound,...r.audio?.inbound],{packetsReceived:i}=e.connection,s=r.connection.packetsReceived,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateMOS({avgJitter:e,rtt:t,packetsLoss:r}){const n=t+2*e+10;let i=n<160?93.2-n/40:93.2-n/120-10;return i-=2.5*r,1+.035*i+7e-6*i*(i-60)*(100-i)}}class Gt{#t=new Map;#r;#n;constructor(e={}){this.#r=e.statsCleanupTtlMs??35e3,this.#n=e.maxParsedStatsStorageSize??5}detect(e,t){const r={...e,networkScores:{...t,statsSamples:t?.statsSamples||{}}},n=this.performDetection(r);return this.setLastProcessedStats(e.connection.id,r),this.performPrevStatsCleanup({connectionId:e.connection.id}),n}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#t.has(t)&&qt({taskId:t,delayMs:this.#r,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){if(!e||t.connection.id!==e)return;const r=this.#t.get(e)??[];r.push(t),r.length>this.#n&&r.shift(),this.#t.set(e,r)}getLastProcessedStats(e){const t=this.#t.get(e);return t?.[t.length-1]}getAllLastProcessedStats(e){return this.#t.get(e)??[]}deleteLastProcessedStats(e){this.#t.delete(e)}}class Yt extends Gt{#i;constructor(e={}){super(e),this.#i=e.availableOutgoingBitrateThreshold??1e5}performDetection(e){const t=[],{availableOutgoingBitrate:r}=e.connection;if(void 0===r)return t;const n=e.audio.outbound.reduce(((e,t)=>e+t.targetBitrate),0),i=e.video.outbound.reduce(((e,t)=>e+t.bitrate),0);if(!n&&!i)return t;const s={availableOutgoingBitrate:r,videoStreamsTotalBitrate:i,audioStreamsTotalTargetBitrate:n};return n>r||i>0&&r<this.#i?(t.push({statsSample:s,type:Rt.Network,reason:Pt.OutboundNetworkThroughput}),t):t}}class $t extends Gt{#s;#o;#a;#c;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200,this.#a=e.highJitterBufferDelayThresholdMs??500,this.#c=e.highRttThresholdMs??250}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.audio?.inbound,...e.video?.inbound];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.video?.inbound,...n.audio?.inbound],{packetsReceived:s}=e.connection,o=n.connection.packetsReceived,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc)),n=r?.jitterBufferDelay||0,s=r?.jitterBufferEmittedCount||0,o=t.jitterBufferDelay-n,a=t.jitterBufferEmittedCount-s,c=o&&a?1e3*o/a:0;return{sumJitter:e.sumJitter+t.jitter,sumJitterBufferDelayMs:e.sumJitterBufferDelayMs+c,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,sumJitterBufferDelayMs:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d,sumJitterBufferDelayMs:u}=a,l=d/r.length,p=u/r.length,h=s-o,f=a.packetsLost-a.lastPacketsLost,m=h&&f?Math.round(100*f/(h+f)):0,g=m>this.#s,v=l>=this.#o,y=c>=this.#c,_=p>this.#a,b=y&&!v&&!g,w=g&&v,S=v&&_,E={rtt:c,packetLossPct:m,avgJitter:l,avgJitterBufferDelay:p};return(v||g)&&t.push({statsSample:E,type:Rt.Network,reason:Pt.InboundNetworkQuality,iceCandidate:e.connection.local.id}),b&&t.push({statsSample:E,type:Rt.Server,reason:Pt.ServerIssue,iceCandidate:e.connection.remote.id}),w&&t.push({statsSample:E,type:Rt.Network,reason:Pt.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),S&&t.push({statsSample:E,type:Rt.Network,reason:Pt.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class Kt extends Gt{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){return this.processData(e)}processData(e){const t=e.audio.inbound,r=[],n=this.getLastProcessedStats(e.connection.id)?.audio.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i=e.track.insertedSamplesForDeceleration+e.track.removedSamplesForAcceleration,s=t.track.insertedSamplesForDeceleration+t.track.removedSamplesForAcceleration;if(i===s)return;const o=e.track.totalSamplesReceived-t.track.totalSamplesReceived,a=i-s,c=Math.round(100*a/o),d={correctedSamplesPct:c};c>this.#d&&r.push({statsSample:d,type:Rt.Network,reason:Pt.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class Jt extends Gt{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.remote?.audio.inbound||[],...n.remote?.video.inbound||[]],{packetsSent:s}=e.connection,o=n.connection.packetsSent,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d}=a,u=d/r.length,l=s-o,p=a.packetsLost-a.lastPacketsLost,h=l&&p?Math.round(100*p/(l+p)):0,f=h>this.#s,m=u>=this.#o,g=!f&&m||m||f,v={rtt:c,avgJitter:u,packetLossPct:h};return f&&m&&t.push({statsSample:v,type:Rt.Network,reason:Pt.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:Rt.Network,reason:Pt.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Qt extends Gt{performDetection(e){return this.processData(e)}processData(e){const t=e.video.outbound.filter((e=>"none"!==e.qualityLimitationReason)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.outbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i={qualityLimitationReason:e.qualityLimitationReason};e.framesSent>t.framesSent||("cpu"===e.qualityLimitationReason&&r.push({statsSample:i,type:Rt.CPU,reason:Pt.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:Rt.Network,reason:Pt.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class Zt extends Gt{UNKNOWN_DECODER="unknown";#u={};performDetection(e){return this.processData(e)}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;super.performPrevStatsCleanup({...e,cleanupCallback:()=>{delete this.#u[t],"function"==typeof r&&r()}})}processData(e){const t=[],{id:r}=e.connection,n=this.getLastProcessedStats(r)?.video.inbound;return e.video.inbound.forEach((e=>{const{decoderImplementation:i,ssrc:s}=e,o=n?.find((e=>e.ssrc===s));if(o)if(i===this.UNKNOWN_DECODER){if(!this.hadLastDecoderWithIssue(r,s)){this.setLastDecoderWithIssue(r,s,this.UNKNOWN_DECODER);const n={mimeType:e.mimeType,decoderImplementation:i};t.push({ssrc:s,statsSample:n,type:Rt.Stream,reason:Pt.UnknownVideoDecoderIssue,trackIdentifier:e.track.trackIdentifier})}}else this.setLastDecoderWithIssue(r,s,void 0)})),t}setLastDecoderWithIssue(e,t,r){const n=this.#u[e]??{};void 0===r?delete n[t]:n[t]=r,this.#u[e]=n}hadLastDecoderWithIssue(e,t){const r=this.#u[e];return(r&&r[t])===this.UNKNOWN_DECODER}}const Xt=e=>e.reduce(((e,t)=>e+t),0)/e.length,er=(e,t,r=30)=>{const n=[];for(let r=1;r<t.length-1;r+=1){const i=t[r]?.video?.inbound.find((t=>t.ssrc===e));if(!i)continue;const s=t[r-1]?.video?.inbound?.find((t=>t.ssrc===e));if(!i||!s)continue;const o=i.timestamp-s.timestamp,a=i.framesDecoded-s.framesDecoded;if(a>0){const e=o/a;n.push(e)}}return!(n.length<=1)&&(e=>{const t=((e,t)=>t.reduce(((t,r)=>t+(r-e)**2),0)/t.length)(Xt(e),e);return Math.sqrt(t)})(n)>r},tr=(e,t)=>{for(let r=1;r<t.length;r+=1){const n=t[r].video.inbound.find((t=>t.ssrc===e));if(!n)continue;const i=t[r-1].video.inbound.find((t=>t.ssrc===e)),s=n.frameWidth!==i?.frameWidth,o=n.frameHeight!==i?.frameHeight;if(s||o)return!0}return!1};class rr extends Gt{#l;#p;#h;constructor(e={}){super(),this.#l=e.avgFreezeDurationThresholdMs??1e3,this.#p=e.frozenDurationThresholdPct??30,this.#h=e.minMosQuality??Tt.BAD}performDetection(e){const t=e.networkScores.inbound;return void 0!==t&&t<=this.#h?[]:this.processData(e)}processData(e){const t=[],r=this.getAllLastProcessedStats(e.connection.id);if(0===r.length)return[];const n=e.video.inbound.map((t=>{const n=r[r.length-1].video.inbound.find((e=>e.ssrc===t.ssrc));if(!n)return;if(tr(t.ssrc,[r[r.length-1],e]))return;if(er(t.ssrc,r))return;const i=t.freezeCount-(n.freezeCount??0),s=1e3*(t.totalFreezesDuration-(n.totalFreezesDuration??0)),o=i>0?s/i:0,a=s/(t.timestamp-n.timestamp)*100;return a>this.#p||o>this.#l?{ssrc:t.ssrc,avgFreezeDurationMs:o,frozenDurationPct:a}:void 0})).filter((e=>void 0!==e));return n.length>0&&(t.push({type:Rt.Stream,reason:Pt.FrozenVideoTrack,statsSample:{ssrcs:n.map((e=>e.ssrc))}}),this.deleteLastProcessedStats(e.connection.id)),t}}class nr extends Gt{#f;#m;#h;constructor(e={}){super(e),this.#f=e.volatilityThreshold??8,this.#m=e.affectedStreamsPercentThreshold??30,this.#h=e.minMosQuality??Tt.BAD}performDetection(e){return[...this.getAllLastProcessedStats(e.connection.id),e].find((e=>void 0!==e.networkScores.inbound&&e.networkScores.inbound<=this.#h))?[]:this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e],n=e.video.inbound.map((e=>{if(r.length<5)return;if(tr(e.ssrc,r))return;const t=[];for(let n=0;n<r.length-1;n+=1){const i=r[n].video.inbound.find((t=>t.ssrc===e.ssrc));void 0!==i?.framesPerSecond&&t.push(i.framesPerSecond)}if(t.length<5)return;if(er(e.ssrc,r))return;const n=(e=>{if(0===e.length)throw new Error("Cannot calculate volatility for empty array");const t=Xt(e);return e.reduce(((e,r)=>e+Math.abs(r-t)),0)/e.length*100/t})(t);return n>this.#f?{ssrc:e.ssrc,allFps:t,volatility:n}:void 0})).filter((e=>Boolean(e)));if(0===n.length)return t;const i=n.length/(e.video.inbound.length/100);return i>this.#m&&(t.push({type:Rt.CPU,reason:Pt.DecoderCPUThrottling,statsSample:{affectedStreamsPercent:i,throtthedStreams:n}}),this.deleteLastProcessedStats(e.connection.id)),t}}const ir=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,sr=(e,t,r)=>8*((e,t,r)=>{if(!t)return 0;const n=e[r],i=t[r];if(null==n||null==i)return 0;const s=Math.floor(e.timestamp)-Math.floor(t.timestamp);return 0===s?0:(Number(n)-Number(i))/s*1e3})(e,t,r);class or{connections=[];statsParser;constructor(e){this.statsParser=e.statsParser}listConnections(){return[...this.connections]}addPeerConnection(e){this.connections.push({id:e.id??String(Date.now()+Math.random().toString(32)),pc:e.pc})}removePeerConnection(e){const t=this.connections.findIndex((({pc:t})=>t===e.pc));t>=0&&this.removeConnectionsByIndexes([t])}async parse(){const e=[],t=this.connections.map((async(t,r)=>{if(!ir(t.pc))return this.statsParser.parse(t);e.unshift(r)}));return e.length&&this.removeConnectionsByIndexes(e),(await Promise.all(t)).filter((e=>void 0!==e))}removeConnectionsByIndexes(e){e.forEach((e=>{this.connections.splice(e,1)}))}}class ar{prevStats=new Map;allowedReportTypes=new Set(["candidate-pair","inbound-rtp","outbound-rtp","remote-outbound-rtp","remote-inbound-rtp","track","transport"]);ignoreSSRCList;logger;constructor(e){this.ignoreSSRCList=e.ignoreSSRCList??[],this.logger=e.logger}get previouslyParsedStatsConnectionsIds(){return[...this.prevStats.keys()]}async parse(e){if(!ir(e.pc))return this.getConnectionStats(e);this.logger.debug("Skip stats parsing. Connection is closed.",{connection:e})}async getConnectionStats(e){const{pc:t,id:r}=e;try{const n=Date.now(),i=t.getReceivers().filter((e=>e.track?.enabled)),s=t.getSenders().filter((e=>e.track?.enabled)),o=await Promise.all(i.map((e=>e.getStats()))),a=await Promise.all(s.map((e=>e.getStats())));return{id:r,stats:this.mapReportsStats([...o,...a],e),timeTaken:Date.now()-n}}catch(e){return void this.logger.error("Failed to get stats for PC",{id:r,pc:t,error:e})}}mapReportsStats(e,t){const r={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]},connection:{},remote:{video:{inbound:[],outbound:[]},audio:{inbound:[],outbound:[]}}};e.forEach((e=>{e.forEach((t=>{this.allowedReportTypes.has(t.type)&&this.updateMappedStatsWithReportItemData(t,r,e)}))}));const{id:n}=t,i=this.prevStats.get(n);return i&&this.propagateStatsWithRateValues(r,i.stats),this.prevStats.set(n,{stats:r,ts:Date.now()}),qt({taskId:n,delayMs:35e3,callback:()=>this.prevStats.delete(n)}),r}updateMappedStatsWithReportItemData(e,t,r){const n=e.type;if("candidate-pair"===n&&"succeeded"===e.state&&e.nominated)return void(t.connection=this.prepareConnectionStats(e,r));const i=this.getMediaType(e);if(!i)return;const s=e.ssrc;if(!s||!this.ignoreSSRCList.includes(s))if("outbound-rtp"!==n)if("inbound-rtp"!==n)"remote-outbound-rtp"!==n?"remote-inbound-rtp"===n&&(this.mapConnectionStatsIfNecessary(t,e,r),t.remote[i].inbound.push({...e})):t.remote[i].outbound.push({...e});else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{};this.mapConnectionStatsIfNecessary(t,e,r);const s={...e,track:{...n}};t[i].inbound.push(s)}else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{},s={...e,track:{...n}};t[i].outbound.push(s)}}getMediaType(e){const t=e.mediaType||e.kind;if(!["audio","video"].includes(t)){const{id:t}=e;if(!t)return;return String(t).includes("Video")?"video":String(t).includes("Audio")?"audio":void 0}return t}propagateStatsWithRateValues(e,t){e.audio.inbound.forEach((e=>{const r=t.audio.inbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesReceived"),e.packetRate=sr(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesSent"),e.packetRate=sr(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesReceived"),e.packetRate=sr(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesSent"),e.packetRate=sr(e,r,"packetsSent")}))}mapConnectionStatsIfNecessary(e,t,r){if(e.connection.id||!t.transportId)return;const n=r.get(t.transportId);if(n&&n.selectedCandidatePairId){const t=r.get(n.selectedCandidatePairId);e.connection=this.prepareConnectionStats(t,r)}}prepareConnectionStats(e,t){if(!e||!t)return{};const r={...e};if(r.remoteCandidateId){const e=t.get(r.remoteCandidateId);r.remote={...e}}if(r.localCandidateId){const e=t.get(r.localCandidateId);r.local={...e}}return r}}class cr extends Gt{#g=new Map;#v;#y;constructor(e={}){super(),this.#v=e.timeoutMs??15e3,this.#y=e.steps??3}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e];if(r.length<this.#y)return t;const n=r.slice(-this.#y),i=n.map((e=>e.video.inbound)),s=n.map((e=>e.audio.inbound));return t.push(...this.detectMissingData(s,Rt.Stream,Pt.MissingAudioStreamData)),t.push(...this.detectMissingData(i,Rt.Stream,Pt.MissingVideoStreamData)),new Set(this.#g.keys()).forEach((e=>{const t=this.#g.get(e);t&&Date.now()-t>this.#v&&this.removeMarkedIssue(e)})),t}detectMissingData(e,t,r){const n=[],i=e.pop(),s=cr.mapStatsByTrackId(e);return i.forEach((e=>{const i=e.track.trackIdentifier,o=s.get(i);if(!Array.isArray(o)||0===o.length)return;if(e.track.detached||e.track.ended)return;if(!cr.isAllBytesReceivedDidntChange(e.bytesReceived,o))return void this.removeMarkedIssue(i);if(!this.markIssue(i))return;const a={bytesReceived:e.bytesReceived};n.push({type:t,reason:r,statsSample:a,trackIdentifier:i})})),n}static mapStatsByTrackId(e){const t=new Map;return e.forEach((e=>{e.forEach((e=>{const r=t.get(e.track.trackIdentifier)||[];r.push(e),t.set(e.track.trackIdentifier,r)}))})),t}static isAllBytesReceivedDidntChange(e,t){for(let r=0;r<t.length;r+=1)if(t[r].bytesReceived!==e)return!1;return!0}markIssue(e){const t=Date.now(),r=this.#g.get(e);return(!r||t-r>this.#v)&&(this.#g.set(e,t),!0)}removeMarkedIssue(e){this.#g.delete(e)}}class dr{eventEmitter;#_=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Ht,e.onIssues&&this.eventEmitter.on(Ct.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(Ct.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Qt,new $t,new Jt,new Kt,new Yt,new Zt,new rr,new nr,new cr],this.networkScoresCalculator=e.networkScoresCalculator??new zt,this.compositeStatsParser=e.compositeStatsParser??new or({statsParser:new ar({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new Wt({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(Wt.STATS_REPORT_READY_EVENT,(e=>{const t=this.calculateNetworkScores(e.stats);this.detectIssues({data:e.stats},t)})),this.statsReporter.on(Wt.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(Ct.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#_?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#_=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#_?(this.logger.info("Stop watching peer connections"),this.#_=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#_||!this.autoAddPeerConnections?(this.#_||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#_=!0,this.statsReporter.startReporting()),this.logger.debug("Handling new peer connection",e),this.compositeStatsParser.addPeerConnection({pc:e,id:t})):this.logger.debug("Skip handling new peer connection. Detector is not running",e)}emitIssues(e){this.eventEmitter.emit(Ct.Issue,e)}detectIssues({data:e},t){const r=this.detectors.reduce(((r,n)=>[...r,...n.detect(e,t)]),[]);r.length>0&&this.emitIssues(r)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);return this.eventEmitter.emit(Ct.NetworkScoresUpdated,t),t}wrapRTCPeerConnection(){if(!window.RTCPeerConnection)return void this.logger.warn("No RTCPeerConnection found in browser window. Skipping");const e=window.RTCPeerConnection,t=e=>this.handleNewPeerConnection(e);function r(r){const n=new e(r);return t(n),n}r.prototype=e.prototype,window.RTCPeerConnection=r}}Error;const ur=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],lr=({from:e,seen:t,to_:r,forceEnumerable:n})=>{const i=r||(Array.isArray(e)?[]:{});t.push(e);for(const[r,s]of Object.entries(e))"function"!=typeof s&&(s&&"object"==typeof s?t.includes(e[r])?i[r]="[Circular]":i[r]=lr({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of ur)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var pr,hr,fr,mr=e=>"object"==typeof e&&null!==e?lr({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;pr=new WeakMap,hr=new WeakMap,fr=new WeakMap;var gr=new class{constructor(){pr.set(this,void 0),hr.set(this,void 0),fr.set(this,void 0)}get meta(){return{peerId:l(this,pr,"f"),channelId:l(this,hr,"f"),appId:l(this,fr,"f")}}setPeerId(e){p(this,pr,e,"f")}setChannelId(e){p(this,hr,e,"f")}setAppId(e){p(this,fr,e,"f")}clear(){p(this,pr,void 0,"f"),p(this,hr,void 0,"f"),p(this,fr,void 0,"f")}};const vr="channel.join",yr="channel.getPeers",_r="channel.triggerStateEvent",br="peer.updateAppData",wr="channel.confirmActivity",Sr="channel.getAudioObserverProducer",Er="peer.changeProducePermissions",Cr="peer.addProducePermissions",Rr="peer.removeProducePermissions",Pr="peer.ping",Tr="channel-event",kr="peer-joined",Dr="peer-left",Ir="channel-activity-confirmation-required",Or="channel-activity-confirmation-acquired",Ar="channel-activity-confirmation-expired",Lr="channel-rejoin-required",Mr="devices-list-updated",Nr="transport-connection-timeout",xr="track-force-closed",Fr="track-failed",jr="active-speaker-changed",Ur="channel-state-inconsistent",Br="connection-lost",Vr="connection-restored",Hr="forced-disconnect",Wr="reject-unauthorized",qr="denoiser-initializing",zr="channel-state-synced",Gr="denoiser-enabled",Yr="denoiser-disabled",$r="denoiser-fallback",Kr="denoiser-failed",Jr="volume-changed",Qr={trackProduced:"track-produced",trackUnproduced:"track-unproduced",trackPaused:"track-paused",trackResumed:"track-resumed",trackClosed:"track-closed",trackReopened:"track-reopened",trackFailed:"track-failed"},Zr="media-published",Xr="media-unpublished",en="publisher-paused",tn="publisher-resumed",rn="track-start",nn="track-end",sn="track-paused",on="track-resumed",an="track-failed",cn="app-data-updated",dn="produce-permissions-changed",un="groups-changed",ln="peer.newProducer",pn="producer.close",hn="producer.pause",fn="producer.resume",mn="producer.setMaxSpatialLayer",gn="producer.requestMaxSpatialLayer",vn="consumer.create",yn="dataConsumer.create",_n="consumer.close",bn="consumer.pause",wn="consumer.resume",Sn="consumer.changeConsumerPreferredLayers",En="consumer.requestKeyFrame",Cn="transport.create",Rn="transport.connect",Pn="transport.produce",Tn="transport.produceData",kn="transport.connectionTimeout",Dn="transport.getIceParameters",In=[Cn,Rn,Pn,Tn,Dn,pn,hn,fn,bn,wn,vn,_n,Pr],On="socket-state",An="transport-state";class Ln extends Error{constructor(e,t,r){super(e),this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class Mn extends Ln{constructor(e,t){super(e,null!=t?t:"unsupported_error")}}Mn.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",Mn.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error";const Nn=e=>{let t;try{t=JSON.stringify(e)}catch(e){throw new Error("Invalid appData")}if(!((new TextEncoder).encode(t).length<=2048))throw new Error("Maximum size appData reached")};function xn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Fn(e,t){const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;let i=!0;return r.forEach((r=>{const n=e[r],s=t[r],o=xn(n)&&xn(s);(o&&!Fn(n,s)||!o&&n!==s)&&(i=!1)})),i}function jn(e,t,r=!1){let n=null;return function(...i){return u(this,void 0,void 0,(function*(){const s=r&&!n;"number"==typeof n&&clearTimeout(n),n=setTimeout((()=>u(this,void 0,void 0,(function*(){n=null,r||(yield e.apply(this,i))}))),t),s&&(yield e.apply(this,i))}))}}var Un={exports:{}},Bn=m(Un.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),o=Math.max(i,s),a=0,c=e.map([t,r],(function(t){var r=o-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(a=o-Math.min(i,s)),o-=1;o>=a;){if(c[0][o]>c[1][o])return 1;if(c[0][o]===c[1][o]){if(o===a)return 0;o-=1}else if(c[0][o]<c[1][o])return-1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var a=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t]}))};for(t=0,r=s.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function o(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,n.key,n)}}var a=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&o(t.prototype,r),n&&o(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=c(r(92)),i=c(r(93)),s=c(r(94)),o=c(r(95)),a=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var o=e[t];"string"==typeof o?(i[t]=o,s+=1):"object"==typeof o&&(r[t]=o,n+=1)})),n>0){var o=Object.keys(r),c=a.default.find(o,(function(e){return t.isOS(e)}));if(c){var d=this.satisfies(r[c]);if(void 0!==d)return d}var u=a.default.find(o,(function(e){return t.isPlatform(e)}));if(u){var l=this.satisfies(r[u]);if(void 0!==l)return l}}if(s>0){var p=Object.keys(i),h=a.default.find(p,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:s.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=o,e.exports=t.default}}));const Vn=e=>{var t,r;return null!==(r=null===(t=e.rtpCapabilities.codecs)||void 0===t?void 0:t.reduce(((e,t)=>{var r;const n=null===(r=t.mimeType)||void 0===r?void 0:r.toLowerCase();return n&&!e.includes(n)&&e.push(n),e}),[]))&&void 0!==r?r:[]},Hn=e=>["video/vp9","vp9"].includes(e.toLowerCase());class Wn{sleepMs(e){return u(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}}const qn=new Wn,zn=(e,...t)=>u(void 0,[e,...t],void 0,(function*(e,t={}){var r,n,i,s;const o=null!==(r=t.maxRetries)&&void 0!==r?r:2,a=null!==(n=t.minBackoffDelayMs)&&void 0!==n?n:50;let c,d=0;for(;d<o;){d+=1;try{return yield e()}catch(e){if(c=e,t.logger&&t.logger.info("Action retry failed",{currentAttempt:d,actionName:t.actionName,error:mr(e)}),null===(i=t.abortOnError)||void 0===i?void 0:i.call(t,e))throw c;if(t.onError&&(yield t.onError(e)),d<o){const e=Math.pow(2,d-1)*a;yield qn.sleepMs(Math.min(e,null!==(s=t.maxBackoffDelayMs)&&void 0!==s?s:e))}}}throw null!=c?c:new Error("retryAsync logic failed")}));var Gn,Yn,$n,Kn,Jn;!function(e){e.Config="Config",e.Engine="Engine",e.System="System",e.Media="Media",e.Network="Network",e.MediaEventHandler="MediaEventHandler",e.ChannelEventHandler="ChannelEventHandler",e.ChannelAudioObserverEventHandler="ChannelAudioObserverEventHandler",e.ChannelStateSynchronizer="ChannelStateSynchronizer",e.ChannelStateSyncEventHandler="ChannelStateSyncEventHandler",e.WebRTCIssueDetector="WebRTCIssueDetector",e.LoggerFactory="LoggerFactory",e.MediaStreamTrackManager="MediaStreamTrackManager",e.SocketIO="SocketIO",e.LoadBalancerApiClient="LoadBalancerApiClient",e.EventsQueue="EventsQueue",e.ClientEventEmitter="ClientEventEmitter",e.Peers="Peers",e.CallState="CallState",e.RemotePeerTracks="RemotePeerTracks",e.MyPeer="MyPeer",e.InternalEventEmitter="InternalEventEmitter",e.PeerTrackFactory="PeerTrackFactory",e.PeerFactory="PeerFactory",e.PeerConsumerFactory="PeerConsumerFactory",e.AudioTrackFactory="AudioTrackFactory",e.VideoTrackFactory="VideoTrackFactory",e.AudioTrackProcessorFactory="AudioTrackProcessorFactory",e.IntegrationsService="IntegrationsService",e.ProcessorsCache="ProcessorsCache",e.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager",e.WIDHandler="WIDHandler",e.AnalyticsApiClient="AnalyticsApiClient",e.TransportsStatsProvider="TransportsStatsProvider",e.LocalMutex="LocalMutex",e.PeersStorage="PeersStorage"}(Gn||(Gn={})),function(e){e.P2P="p2p",e.Common="common"}(Yn||(Yn={})),function(e){e.Camera="camera",e.CameraPreview="camera-preview",e.Microphone="microphone",e.MicrophonePreview="microphone-preview",e.ScreenVideo="screen-video",e.ScreenAudio="screen-audio",e.CustomVideo="custom-video",e.CustomAudio="custom-audio",e.Unknown="unknown"}($n||($n={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Kn||(Kn={})),function(e){e.Connect="connect",e.Connected="connected",e.ConnectError="connect_error",e.Reconnect="reconnect",e.Reconnecting="reconnecting",e.Reconnected="reconnected",e.ReconnectAttempt="reconnect_attempt",e.ReconnectFailed="reconnect_failed",e.ReconnectError="reconnect_error",e.NeedToJoinFirst="need_to_join_first",e.Disconnect="disconnect",e.Disconnected="disconnected",e.Error="error",e.State="state",e.BufferingStart="buffering_start",e.BufferingEnd="buffering_end"}(Jn||(Jn={}));let Qn=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0}};function Zn(){let e=0,t=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(15&r)<<28,t=(112&r)>>4,0==(128&r))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Xn(e,t,r){for(let n=0;n<28;n+=7){const i=e>>>n,s=!(i>>>7==0&&0==t),o=255&(s?128|i:i);if(r.push(o),!s)return}const n=e>>>28&15|(7&t)<<4,i=!(t>>3==0);if(r.push(255&(i?128|n:n)),i){for(let e=3;e<31;e+=7){const n=t>>>e,i=!(n>>>7==0),s=255&(i?128|n:n);if(r.push(s),!i)return}r.push(t>>>31&1)}}Qn=a([ut()],Qn);function ei(e){const t="-"===e[0];t&&(e=e.slice(1));const r=1e6;let n=0,i=0;function s(t,s){const o=Number(e.slice(t,s));i*=r,n=n*r+o,n>=4294967296&&(i+=n/4294967296|0,n%=4294967296)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?ni(n,i):ri(n,i)}function ti(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(4294967296*t+e);const r=16777215&(e>>>24|t<<8),n=t>>16&65535;let i=(16777215&e)+6777216*r+6710656*n,s=r+8147497*n,o=2*n;const a=1e7;return i>=a&&(s+=Math.floor(i/a),i%=a),s>=a&&(o+=Math.floor(s/a),s%=a),o.toString()+ii(s)+ii(i)}function ri(e,t){return{lo:0|e,hi:0|t}}function ni(e,t){return t=~t,e?e=1+~e:t+=1,ri(e,t)}const ii=e=>{const t=String(e);return"0000000".slice(t.length)+t};function si(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let r=0;r<9;r++)t.push(127&e|128),e>>=7;t.push(1)}}function oi(){let e=this.buf[this.pos++],t=127&e;if(0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,0==(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;0!=(128&e)&&t<10;t++)e=this.buf[this.pos++];if(0!=(128&e))throw new Error("invalid varint");return this.assertBounds(),t>>>0}const ai=ci();function ci(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),n=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const n="bigint"==typeof e?e:BigInt(e);if(n>r||n<t)throw new Error(`invalid int64: ${e}`);return n},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>i||t<n)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigInt64(0,!0)),uDec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),di(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),ui(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),di(e),ei(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),ui(e),ei(e)),dec:(e,t)=>function(e,t){let r=ri(e,t);const n=2147483648&r.hi;n&&(r=ni(r.lo,r.hi));const i=ti(r.lo,r.hi);return n?"-"+i:i}(e,t),uDec:(e,t)=>ti(e,t)}}function di(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function ui(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const li=Symbol.for("@bufbuild/protobuf/text-encoding");function pi(){if(null==globalThis[li]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[li]={encodeUtf8:t=>e.encode(t),decodeUtf8:e=>t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[li]}var hi;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(hi||(hi={}));const fi=34028234663852886e22,mi=-34028234663852886e22;class gi{constructor(e=pi().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),r=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],r),r+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(_i(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return yi(e),si(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>fi||e<mi))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){_i(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){yi(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return yi(e),si(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=ai.enc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=ai.uEnc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=ai.enc(e);return Xn(t.lo,t.hi,this.buf),this}sint64(e){const t=ai.enc(e),r=t.hi>>31;return Xn(t.lo<<1^r,(t.hi<<1|t.lo>>>31)^r,this.buf),this}uint64(e){const t=ai.uEnc(e);return Xn(t.lo,t.hi,this.buf),this}}class vi{constructor(e,t=pi().decodeUtf8){this.decodeUtf8=t,this.varint64=Zn,this.uint32=oi,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,r=7&e;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case hi.Varint:for(;128&this.buf[this.pos++];);break;case hi.Bit64:this.pos+=4;case hi.Bit32:this.pos+=4;break;case hi.LengthDelimited:let r=this.uint32();this.pos+=r;break;case hi.StartGroup:for(;;){const[e,r]=this.tag();if(r===hi.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(r,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return ai.dec(...this.varint64())}uint64(){return ai.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(1&e);return e=(e>>>1|(1&t)<<31)^r,t=t>>>1^r,ai.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ai.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ai.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}function yi(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function _i(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const bi={encode:(e,t=new gi)=>(0!==e.time&&t.uint32(8).int64(e.time),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={time:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.time=wi(r.int64());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({time:Si(e.time)?globalThis.Number(e.time):0}),toJSON(e){const t={};return 0!==e.time&&(t.time=Math.round(e.time)),t},create:e=>bi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={time:0};return r.time=null!==(t=e.time)&&void 0!==t?t:0,r}};function wi(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function Si(e){return null!=e}var Ei;function Ci(e){switch(e){case 0:case"NULL_VALUE":return Ei.NULL_VALUE;default:return Ei.UNRECOGNIZED}}!function(e){e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ei||(Ei={}));const Ri={encode:(e,t=new gi)=>(Object.entries(e.fields).forEach((([e,r])=>{void 0!==r&&Pi.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={fields:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=Pi.decode(r,r.uint32());void 0!==t.value&&(i.fields[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({fields:Di(e.fields)?Object.entries(e.fields).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}}),toJSON(e){const t={};if(e.fields){const r=Object.entries(e.fields);r.length>0&&(t.fields={},r.forEach((([e,r])=>{t.fields[e]=r})))}return t},create:e=>Ri.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={fields:{}};return r.fields=Object.entries(null!==(t=e.fields)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r},wrap(e){const t={fields:{}};if(void 0!==e)for(const r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){const t={};if(e.fields)for(const r of Object.keys(e.fields))t[r]=e.fields[r];return t}};const Pi={encode:(e,t=new gi)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&Ti.encode(Ti.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=Ti.unwrap(Ti.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:Ii(e.key)?globalThis.String(e.key):"",value:Ii(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Pi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};const Ti={encode:(e,t=new gi)=>(void 0!==e.nullValue&&t.uint32(8).int32(e.nullValue),void 0!==e.numberValue&&t.uint32(17).double(e.numberValue),void 0!==e.stringValue&&t.uint32(26).string(e.stringValue),void 0!==e.boolValue&&t.uint32(32).bool(e.boolValue),void 0!==e.structValue&&Ri.encode(Ri.wrap(e.structValue),t.uint32(42).fork()).join(),void 0!==e.listValue&&ki.encode(ki.wrap(e.listValue),t.uint32(50).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.nullValue=r.int32();continue;case 2:if(17!==e)break;i.numberValue=r.double();continue;case 3:if(26!==e)break;i.stringValue=r.string();continue;case 4:if(32!==e)break;i.boolValue=r.bool();continue;case 5:if(42!==e)break;i.structValue=Ri.unwrap(Ri.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.listValue=ki.unwrap(ki.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({nullValue:Ii(e.nullValue)?Ci(e.nullValue):void 0,numberValue:Ii(e.numberValue)?globalThis.Number(e.numberValue):void 0,stringValue:Ii(e.stringValue)?globalThis.String(e.stringValue):void 0,boolValue:Ii(e.boolValue)?globalThis.Boolean(e.boolValue):void 0,structValue:Di(e.structValue)?e.structValue:void 0,listValue:globalThis.Array.isArray(e.listValue)?[...e.listValue]:void 0}),toJSON(e){const t={};return void 0!==e.nullValue&&(t.nullValue=function(e){switch(e){case Ei.NULL_VALUE:return"NULL_VALUE";case Ei.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.nullValue)),void 0!==e.numberValue&&(t.numberValue=e.numberValue),void 0!==e.stringValue&&(t.stringValue=e.stringValue),void 0!==e.boolValue&&(t.boolValue=e.boolValue),void 0!==e.structValue&&(t.structValue=e.structValue),void 0!==e.listValue&&(t.listValue=e.listValue),t},create:e=>Ti.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o;const a={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};return a.nullValue=null!==(t=e.nullValue)&&void 0!==t?t:void 0,a.numberValue=null!==(r=e.numberValue)&&void 0!==r?r:void 0,a.stringValue=null!==(n=e.stringValue)&&void 0!==n?n:void 0,a.boolValue=null!==(i=e.boolValue)&&void 0!==i?i:void 0,a.structValue=null!==(s=e.structValue)&&void 0!==s?s:void 0,a.listValue=null!==(o=e.listValue)&&void 0!==o?o:void 0,a},wrap(e){const t={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};if(null===e)t.nullValue=Ei.NULL_VALUE;else if("boolean"==typeof e)t.boolValue=e;else if("number"==typeof e)t.numberValue=e;else if("string"==typeof e)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if("object"==typeof e)t.structValue=e;else if(void 0!==e)throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap:e=>void 0!==e.stringValue?e.stringValue:void 0!==(null==e?void 0:e.numberValue)?e.numberValue:void 0!==(null==e?void 0:e.boolValue)?e.boolValue:void 0!==(null==e?void 0:e.structValue)?e.structValue:void 0!==(null==e?void 0:e.listValue)?e.listValue:void 0!==(null==e?void 0:e.nullValue)?null:void 0};const ki={encode(e,t=new gi){for(const r of e.values)Ti.encode(Ti.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={values:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.values.push(Ti.unwrap(Ti.decode(r,r.uint32())));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({values:globalThis.Array.isArray(null==e?void 0:e.values)?[...e.values]:[]}),toJSON(e){var t;const r={};return(null===(t=e.values)||void 0===t?void 0:t.length)&&(r.values=e.values),r},create:e=>ki.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={values:[]};return r.values=(null===(t=e.values)||void 0===t?void 0:t.map((e=>e)))||[],r},wrap(e){const t={values:[]};return t.values=null!=e?e:[],t},unwrap:e=>(null==e?void 0:e.hasOwnProperty("values"))&&globalThis.Array.isArray(e.values)?e.values:e};function Di(e){return"object"==typeof e&&null!==e}function Ii(e){return null!=e}const Oi={encode:(e,t=new gi)=>(Object.entries(e.event).forEach((([e,r])=>{void 0!==r&&Ai.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={event:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=Ai.decode(r,r.uint32());void 0!==t.value&&(i.event[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({event:Li(e.event)?Object.entries(e.event).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}}),toJSON(e){const t={};if(e.event){const r=Object.entries(e.event);r.length>0&&(t.event={},r.forEach((([e,r])=>{t.event[e]=r})))}return t},create:e=>Oi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={event:{}};return r.event=Object.entries(null!==(t=e.event)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r}};const Ai={encode:(e,t=new gi)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&Ti.encode(Ti.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=Ti.unwrap(Ti.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:Mi(e.key)?globalThis.String(e.key):"",value:Mi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Ai.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function Li(e){return"object"==typeof e&&null!==e}function Mi(e){return null!=e}var Ni,xi;function Fi(e){switch(e){case 0:case"PEER_GROUP_UNSPECIFIED":return Ni.PEER_GROUP_UNSPECIFIED;case 1:case"PEER_GROUP_MODERATOR":return Ni.PEER_GROUP_MODERATOR;case 2:case"PEER_GROUP_USER":return Ni.PEER_GROUP_USER;default:return Ni.UNRECOGNIZED}}function ji(e){switch(e){case Ni.PEER_GROUP_UNSPECIFIED:return"PEER_GROUP_UNSPECIFIED";case Ni.PEER_GROUP_MODERATOR:return"PEER_GROUP_MODERATOR";case Ni.PEER_GROUP_USER:return"PEER_GROUP_USER";case Ni.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function Ui(e){switch(e){case 0:case"PRODUCER_LABEL_UNSPECIFIED":return xi.PRODUCER_LABEL_UNSPECIFIED;case 1:case"PRODUCER_LABEL_CAMERA":return xi.PRODUCER_LABEL_CAMERA;case 2:case"PRODUCER_LABEL_MICROPHONE":return xi.PRODUCER_LABEL_MICROPHONE;case 3:case"PRODUCER_LABEL_SCREEN_VIDEO":return xi.PRODUCER_LABEL_SCREEN_VIDEO;case 4:case"PRODUCER_LABEL_SCREEN_AUDIO":return xi.PRODUCER_LABEL_SCREEN_AUDIO;case 5:case"PRODUCER_LABEL_CUSTOM_VIDEO":return xi.PRODUCER_LABEL_CUSTOM_VIDEO;case 6:case"PRODUCER_LABEL_CUSTOM_AUDIO":return xi.PRODUCER_LABEL_CUSTOM_AUDIO;case 7:case"PRODUCER_LABEL_UNKNOWN":return xi.PRODUCER_LABEL_UNKNOWN;default:return xi.UNRECOGNIZED}}function Bi(e){switch(e){case xi.PRODUCER_LABEL_UNSPECIFIED:return"PRODUCER_LABEL_UNSPECIFIED";case xi.PRODUCER_LABEL_CAMERA:return"PRODUCER_LABEL_CAMERA";case xi.PRODUCER_LABEL_MICROPHONE:return"PRODUCER_LABEL_MICROPHONE";case xi.PRODUCER_LABEL_SCREEN_VIDEO:return"PRODUCER_LABEL_SCREEN_VIDEO";case xi.PRODUCER_LABEL_SCREEN_AUDIO:return"PRODUCER_LABEL_SCREEN_AUDIO";case xi.PRODUCER_LABEL_CUSTOM_VIDEO:return"PRODUCER_LABEL_CUSTOM_VIDEO";case xi.PRODUCER_LABEL_CUSTOM_AUDIO:return"PRODUCER_LABEL_CUSTOM_AUDIO";case xi.PRODUCER_LABEL_UNKNOWN:return"PRODUCER_LABEL_UNKNOWN";case xi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.PEER_GROUP_UNSPECIFIED=0]="PEER_GROUP_UNSPECIFIED",e[e.PEER_GROUP_MODERATOR=1]="PEER_GROUP_MODERATOR",e[e.PEER_GROUP_USER=2]="PEER_GROUP_USER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ni||(Ni={})),function(e){e[e.PRODUCER_LABEL_UNSPECIFIED=0]="PRODUCER_LABEL_UNSPECIFIED",e[e.PRODUCER_LABEL_CAMERA=1]="PRODUCER_LABEL_CAMERA",e[e.PRODUCER_LABEL_MICROPHONE=2]="PRODUCER_LABEL_MICROPHONE",e[e.PRODUCER_LABEL_SCREEN_VIDEO=3]="PRODUCER_LABEL_SCREEN_VIDEO",e[e.PRODUCER_LABEL_SCREEN_AUDIO=4]="PRODUCER_LABEL_SCREEN_AUDIO",e[e.PRODUCER_LABEL_CUSTOM_VIDEO=5]="PRODUCER_LABEL_CUSTOM_VIDEO",e[e.PRODUCER_LABEL_CUSTOM_AUDIO=6]="PRODUCER_LABEL_CUSTOM_AUDIO",e[e.PRODUCER_LABEL_UNKNOWN=7]="PRODUCER_LABEL_UNKNOWN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(xi||(xi={}));const Vi={encode(e,t=new gi){t.uint32(10).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(18).fork();for(const r of e.producePermissions)t.int32(r);t.join(),t.uint32(26).fork();for(const r of e.changedProducePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={groups:[],producePermissions:[],changedProducePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8===e){i.groups.push(r.int32());continue}if(10===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 2:if(16===e){i.producePermissions.push(r.int32());continue}if(18===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}break;case 3:if(24===e){i.changedProducePermissions.push(r.int32());continue}if(26===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.changedProducePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>Fi(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ui(e))):[],changedProducePermissions:globalThis.Array.isArray(null==e?void 0:e.changedProducePermissions)?e.changedProducePermissions.map((e=>Ui(e))):[]}),toJSON(e){var t,r,n;const i={};return(null===(t=e.groups)||void 0===t?void 0:t.length)&&(i.groups=e.groups.map((e=>ji(e)))),(null===(r=e.producePermissions)||void 0===r?void 0:r.length)&&(i.producePermissions=e.producePermissions.map((e=>Bi(e)))),(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.length)&&(i.changedProducePermissions=e.changedProducePermissions.map((e=>Bi(e)))),i},create:e=>Vi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={groups:[],producePermissions:[],changedProducePermissions:[]};return i.groups=(null===(t=e.groups)||void 0===t?void 0:t.map((e=>e)))||[],i.producePermissions=(null===(r=e.producePermissions)||void 0===r?void 0:r.map((e=>e)))||[],i.changedProducePermissions=(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.map((e=>e)))||[],i}};const Hi={encode:(e,t=new gi)=>(0!==e.seconds&&t.uint32(8).int64(e.seconds),0!==e.nanos&&t.uint32(16).int32(e.nanos),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={seconds:0,nanos:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.seconds=Wi(r.int64());continue;case 2:if(16!==e)break;i.nanos=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({seconds:qi(e.seconds)?globalThis.Number(e.seconds):0,nanos:qi(e.nanos)?globalThis.Number(e.nanos):0}),toJSON(e){const t={};return 0!==e.seconds&&(t.seconds=Math.round(e.seconds)),0!==e.nanos&&(t.nanos=Math.round(e.nanos)),t},create:e=>Hi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={seconds:0,nanos:0};return n.seconds=null!==(t=e.seconds)&&void 0!==t?t:0,n.nanos=null!==(r=e.nanos)&&void 0!==r?r:0,n}};function Wi(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function qi(e){return null!=e}var zi;function Gi(e){switch(e){case 0:case"PRODUCER_KIND_UNSPECIFIED":return zi.PRODUCER_KIND_UNSPECIFIED;case 1:case"PRODUCER_KIND_AUDIO":return zi.PRODUCER_KIND_AUDIO;case 2:case"PRODUCER_KIND_VIDEO":return zi.PRODUCER_KIND_VIDEO;default:return zi.UNRECOGNIZED}}!function(e){e[e.PRODUCER_KIND_UNSPECIFIED=0]="PRODUCER_KIND_UNSPECIFIED",e[e.PRODUCER_KIND_AUDIO=1]="PRODUCER_KIND_AUDIO",e[e.PRODUCER_KIND_VIDEO=2]="PRODUCER_KIND_VIDEO",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(zi||(zi={}));const Yi={encode(e,t=new gi){""!==e.id&&t.uint32(10).string(e.id),0!==e.kind&&t.uint32(16).int32(e.kind),0!==e.label&&t.uint32(24).int32(e.label),""!==e.peerId&&t.uint32(34).string(e.peerId),!1!==e.paused&&t.uint32(40).bool(e.paused);for(const r of e.encodings)Ti.encode(Ti.wrap(r),t.uint32(50).fork()).join();return void 0!==e.maxSpatialLayer&&t.uint32(56).uint32(e.maxSpatialLayer),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.kind=r.int32();continue;case 3:if(24!==e)break;i.label=r.int32();continue;case 4:if(34!==e)break;i.peerId=r.string();continue;case 5:if(40!==e)break;i.paused=r.bool();continue;case 6:if(50!==e)break;i.encodings.push(Ti.unwrap(Ti.decode(r,r.uint32())));continue;case 7:if(56!==e)break;i.maxSpatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:$i(e.id)?globalThis.String(e.id):"",kind:$i(e.kind)?Gi(e.kind):0,label:$i(e.label)?Ui(e.label):0,peerId:$i(e.peerId)?globalThis.String(e.peerId):"",paused:!!$i(e.paused)&&globalThis.Boolean(e.paused),encodings:globalThis.Array.isArray(null==e?void 0:e.encodings)?[...e.encodings]:[],maxSpatialLayer:$i(e.maxSpatialLayer)?globalThis.Number(e.maxSpatialLayer):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),0!==e.kind&&(r.kind=function(e){switch(e){case zi.PRODUCER_KIND_UNSPECIFIED:return"PRODUCER_KIND_UNSPECIFIED";case zi.PRODUCER_KIND_AUDIO:return"PRODUCER_KIND_AUDIO";case zi.PRODUCER_KIND_VIDEO:return"PRODUCER_KIND_VIDEO";case zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.kind)),0!==e.label&&(r.label=Bi(e.label)),""!==e.peerId&&(r.peerId=e.peerId),!1!==e.paused&&(r.paused=e.paused),(null===(t=e.encodings)||void 0===t?void 0:t.length)&&(r.encodings=e.encodings),void 0!==e.maxSpatialLayer&&(r.maxSpatialLayer=Math.round(e.maxSpatialLayer)),r},create:e=>Yi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a;const c={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};return c.id=null!==(t=e.id)&&void 0!==t?t:"",c.kind=null!==(r=e.kind)&&void 0!==r?r:0,c.label=null!==(n=e.label)&&void 0!==n?n:0,c.peerId=null!==(i=e.peerId)&&void 0!==i?i:"",c.paused=null!==(s=e.paused)&&void 0!==s&&s,c.encodings=(null===(o=e.encodings)||void 0===o?void 0:o.map((e=>e)))||[],c.maxSpatialLayer=null!==(a=e.maxSpatialLayer)&&void 0!==a?a:void 0,c}};function $i(e){return null!=e}var Ki;function Ji(e){switch(e){case 0:case"PEER_ROLE_UNSPECIFIED":return Ki.PEER_ROLE_UNSPECIFIED;case 1:case"PEER_ROLE_HOST":return Ki.PEER_ROLE_HOST;case 2:case"PEER_ROLE_AUDIENCE":return Ki.PEER_ROLE_AUDIENCE;default:return Ki.UNRECOGNIZED}}!function(e){e[e.PEER_ROLE_UNSPECIFIED=0]="PEER_ROLE_UNSPECIFIED",e[e.PEER_ROLE_HOST=1]="PEER_ROLE_HOST",e[e.PEER_ROLE_AUDIENCE=2]="PEER_ROLE_AUDIENCE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ki||(Ki={}));const Qi={encode(e,t=new gi){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.channelIds)t.uint32(18).string(r);for(const r of e.producers)Yi.encode(r,t.uint32(26).fork()).join();""!==e.uid&&t.uint32(50).string(e.uid),""!==e.appId&&t.uint32(58).string(e.appId),Object.entries(e.appData).forEach((([e,r])=>{void 0!==r&&Zi.encode({key:e,value:r},t.uint32(66).fork()).join()})),0!==e.role&&t.uint32(72).int32(e.role),void 0!==e.loginDate&&Hi.encode(function(e){const t=Math.trunc(e.getTime()/1e3),r=e.getTime()%1e3*1e6;return{seconds:t,nanos:r}}(e.loginDate),t.uint32(82).fork()).join(),t.uint32(90).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(98).fork();for(const r of e.producePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.channelIds.push(r.string());continue;case 3:if(26!==e)break;i.producers.push(Yi.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.uid=r.string();continue;case 7:if(58!==e)break;i.appId=r.string();continue;case 8:{if(66!==e)break;const t=Zi.decode(r,r.uint32());void 0!==t.value&&(i.appData[t.key]=t.value);continue}case 9:if(72!==e)break;i.role=r.int32();continue;case 10:if(82!==e)break;i.loginDate=Xi(Hi.decode(r,r.uint32()));continue;case 11:if(88===e){i.groups.push(r.int32());continue}if(90===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 12:if(96===e){i.producePermissions.push(r.int32());continue}if(98===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:rs(e.id)?globalThis.String(e.id):"",channelIds:globalThis.Array.isArray(null==e?void 0:e.channelIds)?e.channelIds.map((e=>globalThis.String(e))):[],producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>Yi.fromJSON(e))):[],uid:rs(e.uid)?globalThis.String(e.uid):"",appId:rs(e.appId)?globalThis.String(e.appId):"",appData:ts(e.appData)?Object.entries(e.appData).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{},role:rs(e.role)?Ji(e.role):0,loginDate:rs(e.loginDate)?es(e.loginDate):void 0,groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>Fi(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ui(e))):[]}),toJSON(e){var t,r,n,i;const s={};if(""!==e.id&&(s.id=e.id),(null===(t=e.channelIds)||void 0===t?void 0:t.length)&&(s.channelIds=e.channelIds),(null===(r=e.producers)||void 0===r?void 0:r.length)&&(s.producers=e.producers.map((e=>Yi.toJSON(e)))),""!==e.uid&&(s.uid=e.uid),""!==e.appId&&(s.appId=e.appId),e.appData){const t=Object.entries(e.appData);t.length>0&&(s.appData={},t.forEach((([e,t])=>{s.appData[e]=t})))}return 0!==e.role&&(s.role=function(e){switch(e){case Ki.PEER_ROLE_UNSPECIFIED:return"PEER_ROLE_UNSPECIFIED";case Ki.PEER_ROLE_HOST:return"PEER_ROLE_HOST";case Ki.PEER_ROLE_AUDIENCE:return"PEER_ROLE_AUDIENCE";case Ki.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.role)),void 0!==e.loginDate&&(s.loginDate=e.loginDate.toISOString()),(null===(n=e.groups)||void 0===n?void 0:n.length)&&(s.groups=e.groups.map((e=>ji(e)))),(null===(i=e.producePermissions)||void 0===i?void 0:i.length)&&(s.producePermissions=e.producePermissions.map((e=>Bi(e)))),s},create:e=>Qi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a,c,d,u;const l={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};return l.id=null!==(t=e.id)&&void 0!==t?t:"",l.channelIds=(null===(r=e.channelIds)||void 0===r?void 0:r.map((e=>e)))||[],l.producers=(null===(n=e.producers)||void 0===n?void 0:n.map((e=>Yi.fromPartial(e))))||[],l.uid=null!==(i=e.uid)&&void 0!==i?i:"",l.appId=null!==(s=e.appId)&&void 0!==s?s:"",l.appData=Object.entries(null!==(o=e.appData)&&void 0!==o?o:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),l.role=null!==(a=e.role)&&void 0!==a?a:0,l.loginDate=null!==(c=e.loginDate)&&void 0!==c?c:void 0,l.groups=(null===(d=e.groups)||void 0===d?void 0:d.map((e=>e)))||[],l.producePermissions=(null===(u=e.producePermissions)||void 0===u?void 0:u.map((e=>e)))||[],l}};const Zi={encode:(e,t=new gi)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&Ti.encode(Ti.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=Ti.unwrap(Ti.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:rs(e.key)?globalThis.String(e.key):"",value:rs(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Zi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function Xi(e){let t=1e3*(e.seconds||0);return t+=(e.nanos||0)/1e6,new globalThis.Date(t)}function es(e){return e instanceof globalThis.Date?e:"string"==typeof e?new globalThis.Date(e):Xi(Hi.fromJSON(e))}function ts(e){return"object"==typeof e&&null!==e}function rs(e){return null!=e}const ns={encode(e,t=new gi){for(const r of e.peers)Qi.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(Qi.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>Qi.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>Qi.toJSON(e)))),r},create:e=>ns.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>Qi.fromPartial(e))))||[],r}};const is={encode:(e,t=new gi)=>(""!==e.id&&t.uint32(10).string(e.id),!1!==e.paused&&t.uint32(16).bool(e.paused),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",paused:!1};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.paused=r.bool();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:as(e.id)?globalThis.String(e.id):"",paused:!!as(e.paused)&&globalThis.Boolean(e.paused)}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),!1!==e.paused&&(t.paused=e.paused),t},create:e=>is.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={id:"",paused:!1};return n.id=null!==(t=e.id)&&void 0!==t?t:"",n.paused=null!==(r=e.paused)&&void 0!==r&&r,n}};const ss={encode(e,t=new gi){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.producers)is.encode(r,t.uint32(18).fork()).join();return void 0!==e.appDataHash&&t.uint32(26).string(e.appDataHash),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",producers:[],appDataHash:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.producers.push(is.decode(r,r.uint32()));continue;case 3:if(26!==e)break;i.appDataHash=r.string();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:as(e.id)?globalThis.String(e.id):"",producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>is.fromJSON(e))):[],appDataHash:as(e.appDataHash)?globalThis.String(e.appDataHash):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),(null===(t=e.producers)||void 0===t?void 0:t.length)&&(r.producers=e.producers.map((e=>is.toJSON(e)))),void 0!==e.appDataHash&&(r.appDataHash=e.appDataHash),r},create:e=>ss.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={id:"",producers:[],appDataHash:void 0};return i.id=null!==(t=e.id)&&void 0!==t?t:"",i.producers=(null===(r=e.producers)||void 0===r?void 0:r.map((e=>is.fromPartial(e))))||[],i.appDataHash=null!==(n=e.appDataHash)&&void 0!==n?n:void 0,i}};const os={encode(e,t=new gi){for(const r of e.peers)ss.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(ss.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>ss.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>ss.toJSON(e)))),r},create:e=>os.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>ss.fromPartial(e))))||[],r}};function as(e){return null!=e}var cs;function ds(e){switch(e){case 0:case"CHANNEL_EVENT_TYPE_UNSPECIFIED":return cs.CHANNEL_EVENT_TYPE_UNSPECIFIED;case 1:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE":return cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE;case 2:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT":return cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT;case 3:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED;case 4:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED;case 5:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED;case 6:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED;case 7:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED;case 8:case"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT":return cs.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT;case 14:case"CHANNEL_EVENT_TYPE_PEER_JOINED":return cs.CHANNEL_EVENT_TYPE_PEER_JOINED;case 15:case"CHANNEL_EVENT_TYPE_PEER_LEFT":return cs.CHANNEL_EVENT_TYPE_PEER_LEFT;case 16:case"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED":return cs.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED;case 17:case"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED":return cs.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED;case 18:case"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED":return cs.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED;default:return cs.UNRECOGNIZED}}function us(e){switch(e){case cs.CHANNEL_EVENT_TYPE_UNSPECIFIED:return"CHANNEL_EVENT_TYPE_UNSPECIFIED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE";case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT";case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:return"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT";case cs.CHANNEL_EVENT_TYPE_PEER_JOINED:return"CHANNEL_EVENT_TYPE_PEER_JOINED";case cs.CHANNEL_EVENT_TYPE_PEER_LEFT:return"CHANNEL_EVENT_TYPE_PEER_LEFT";case cs.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED";case cs.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED";case cs.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED";case cs.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.CHANNEL_EVENT_TYPE_UNSPECIFIED=0]="CHANNEL_EVENT_TYPE_UNSPECIFIED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE=1]="CHANNEL_EVENT_TYPE_CHANNEL_STATE",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT=2]="CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED=3]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED=4]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED=5]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED=6]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED=7]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT=8]="CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT",e[e.CHANNEL_EVENT_TYPE_PEER_JOINED=14]="CHANNEL_EVENT_TYPE_PEER_JOINED",e[e.CHANNEL_EVENT_TYPE_PEER_LEFT=15]="CHANNEL_EVENT_TYPE_PEER_LEFT",e[e.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED=16]="CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED=17]="CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED=18]="CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(cs||(cs={}));const ls={encode:(e,t=new gi)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.channelState&&ns.encode(e.channelState,t.uint32(18).fork()).join(),void 0!==e.channelStateShort&&os.encode(e.channelStateShort,t.uint32(26).fork()).join(),void 0!==e.channelActivityConfirmationTime&&bi.encode(e.channelActivityConfirmationTime,t.uint32(34).fork()).join(),void 0!==e.channelManagementEvent&&Oi.encode(e.channelManagementEvent,t.uint32(42).fork()).join(),void 0!==e.channelProducePermissions&&Vi.encode(e.channelProducePermissions,t.uint32(50).fork()).join(),void 0!==e.peer&&Qi.encode(e.peer,t.uint32(58).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.channelState=ns.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.channelStateShort=os.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.channelActivityConfirmationTime=bi.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.channelManagementEvent=Oi.decode(r,r.uint32());continue;case 6:if(50!==e)break;i.channelProducePermissions=Vi.decode(r,r.uint32());continue;case 7:if(58!==e)break;i.peer=Qi.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:ps(e.eventType)?ds(e.eventType):0,channelState:ps(e.channelState)?ns.fromJSON(e.channelState):void 0,channelStateShort:ps(e.channelStateShort)?os.fromJSON(e.channelStateShort):void 0,channelActivityConfirmationTime:ps(e.channelActivityConfirmationTime)?bi.fromJSON(e.channelActivityConfirmationTime):void 0,channelManagementEvent:ps(e.channelManagementEvent)?Oi.fromJSON(e.channelManagementEvent):void 0,channelProducePermissions:ps(e.channelProducePermissions)?Vi.fromJSON(e.channelProducePermissions):void 0,peer:ps(e.peer)?Qi.fromJSON(e.peer):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=us(e.eventType)),void 0!==e.channelState&&(t.channelState=ns.toJSON(e.channelState)),void 0!==e.channelStateShort&&(t.channelStateShort=os.toJSON(e.channelStateShort)),void 0!==e.channelActivityConfirmationTime&&(t.channelActivityConfirmationTime=bi.toJSON(e.channelActivityConfirmationTime)),void 0!==e.channelManagementEvent&&(t.channelManagementEvent=Oi.toJSON(e.channelManagementEvent)),void 0!==e.channelProducePermissions&&(t.channelProducePermissions=Vi.toJSON(e.channelProducePermissions)),void 0!==e.peer&&(t.peer=Qi.toJSON(e.peer)),t},create:e=>ls.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.channelState=void 0!==e.channelState&&null!==e.channelState?ns.fromPartial(e.channelState):void 0,r.channelStateShort=void 0!==e.channelStateShort&&null!==e.channelStateShort?os.fromPartial(e.channelStateShort):void 0,r.channelActivityConfirmationTime=void 0!==e.channelActivityConfirmationTime&&null!==e.channelActivityConfirmationTime?bi.fromPartial(e.channelActivityConfirmationTime):void 0,r.channelManagementEvent=void 0!==e.channelManagementEvent&&null!==e.channelManagementEvent?Oi.fromPartial(e.channelManagementEvent):void 0,r.channelProducePermissions=void 0!==e.channelProducePermissions&&null!==e.channelProducePermissions?Vi.fromPartial(e.channelProducePermissions):void 0,r.peer=void 0!==e.peer&&null!==e.peer?Qi.fromPartial(e.peer):void 0,r}};function ps(e){return null!=e}const hs={encode:(e,t=new gi)=>(""!==e.id&&t.uint32(10).string(e.id),""!==e.peerId&&t.uint32(18).string(e.peerId),""!==e.producerPeerId&&t.uint32(26).string(e.producerPeerId),void 0!==e.spatialLayer&&t.uint32(32).uint32(e.spatialLayer),void 0!==e.temporalLayer&&t.uint32(40).uint32(e.temporalLayer),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.peerId=r.string();continue;case 3:if(26!==e)break;i.producerPeerId=r.string();continue;case 4:if(32!==e)break;i.spatialLayer=r.uint32();continue;case 5:if(40!==e)break;i.temporalLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:fs(e.id)?globalThis.String(e.id):"",peerId:fs(e.peerId)?globalThis.String(e.peerId):"",producerPeerId:fs(e.producerPeerId)?globalThis.String(e.producerPeerId):"",spatialLayer:fs(e.spatialLayer)?globalThis.Number(e.spatialLayer):void 0,temporalLayer:fs(e.temporalLayer)?globalThis.Number(e.temporalLayer):void 0}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),""!==e.peerId&&(t.peerId=e.peerId),""!==e.producerPeerId&&(t.producerPeerId=e.producerPeerId),void 0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),void 0!==e.temporalLayer&&(t.temporalLayer=Math.round(e.temporalLayer)),t},create:e=>hs.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s;const o={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};return o.id=null!==(t=e.id)&&void 0!==t?t:"",o.peerId=null!==(r=e.peerId)&&void 0!==r?r:"",o.producerPeerId=null!==(n=e.producerPeerId)&&void 0!==n?n:"",o.spatialLayer=null!==(i=e.spatialLayer)&&void 0!==i?i:void 0,o.temporalLayer=null!==(s=e.temporalLayer)&&void 0!==s?s:void 0,o}};function fs(e){return null!=e}const ms={encode:(e,t=new gi)=>(""!==e.producerId&&t.uint32(10).string(e.producerId),0!==e.spatialLayer&&t.uint32(16).uint32(e.spatialLayer),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={producerId:"",spatialLayer:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.producerId=r.string();continue;case 2:if(16!==e)break;i.spatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({producerId:gs(e.producerId)?globalThis.String(e.producerId):"",spatialLayer:gs(e.spatialLayer)?globalThis.Number(e.spatialLayer):0}),toJSON(e){const t={};return""!==e.producerId&&(t.producerId=e.producerId),0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),t},create:e=>ms.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={producerId:"",spatialLayer:0};return n.producerId=null!==(t=e.producerId)&&void 0!==t?t:"",n.spatialLayer=null!==(r=e.spatialLayer)&&void 0!==r?r:0,n}};function gs(e){return null!=e}var vs,ys;function _s(e){switch(e){case 0:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED":return vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED;case 1:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS":return vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS;case 2:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE":return vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE;default:return vs.UNRECOGNIZED}}function bs(e){switch(e){case 0:case"TRANSPORT_DIRECTION_UNSPECIFIED":return ys.TRANSPORT_DIRECTION_UNSPECIFIED;case 1:case"TRANSPORT_DIRECTION_SEND":return ys.TRANSPORT_DIRECTION_SEND;case 2:case"TRANSPORT_DIRECTION_RECEIVE":return ys.TRANSPORT_DIRECTION_RECEIVE;default:return ys.UNRECOGNIZED}}!function(e){e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED=0]="TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS=1]="TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE=2]="TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(vs||(vs={})),function(e){e[e.TRANSPORT_DIRECTION_UNSPECIFIED=0]="TRANSPORT_DIRECTION_UNSPECIFIED",e[e.TRANSPORT_DIRECTION_SEND=1]="TRANSPORT_DIRECTION_SEND",e[e.TRANSPORT_DIRECTION_RECEIVE=2]="TRANSPORT_DIRECTION_RECEIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(ys||(ys={}));const ws={encode:(e,t=new gi)=>(""!==e.transportId&&t.uint32(10).string(e.transportId),0!==e.timeout&&t.uint32(16).uint32(e.timeout),0!==e.direction&&t.uint32(24).int32(e.direction),0!==e.reason&&t.uint32(32).int32(e.reason),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={transportId:"",timeout:0,direction:0,reason:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.transportId=r.string();continue;case 2:if(16!==e)break;i.timeout=r.uint32();continue;case 3:if(24!==e)break;i.direction=r.int32();continue;case 4:if(32!==e)break;i.reason=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({transportId:Ss(e.transportId)?globalThis.String(e.transportId):"",timeout:Ss(e.timeout)?globalThis.Number(e.timeout):0,direction:Ss(e.direction)?bs(e.direction):0,reason:Ss(e.reason)?_s(e.reason):0}),toJSON(e){const t={};return""!==e.transportId&&(t.transportId=e.transportId),0!==e.timeout&&(t.timeout=Math.round(e.timeout)),0!==e.direction&&(t.direction=function(e){switch(e){case ys.TRANSPORT_DIRECTION_UNSPECIFIED:return"TRANSPORT_DIRECTION_UNSPECIFIED";case ys.TRANSPORT_DIRECTION_SEND:return"TRANSPORT_DIRECTION_SEND";case ys.TRANSPORT_DIRECTION_RECEIVE:return"TRANSPORT_DIRECTION_RECEIVE";case ys.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.direction)),0!==e.reason&&(t.reason=function(e){switch(e){case vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED";case vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS";case vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE";case vs.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.reason)),t},create:e=>ws.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i;const s={transportId:"",timeout:0,direction:0,reason:0};return s.transportId=null!==(t=e.transportId)&&void 0!==t?t:"",s.timeout=null!==(r=e.timeout)&&void 0!==r?r:0,s.direction=null!==(n=e.direction)&&void 0!==n?n:0,s.reason=null!==(i=e.reason)&&void 0!==i?i:0,s}};function Ss(e){return null!=e}var Es;function Cs(e){switch(e){case 0:case"MEDIA_EVENT_TYPE_UNSPECIFIED":return Es.MEDIA_EVENT_TYPE_UNSPECIFIED;case 1:case"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT":return Es.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT;case 2:case"MEDIA_EVENT_TYPE_PRODUCER_CREATED":return Es.MEDIA_EVENT_TYPE_PRODUCER_CREATED;case 3:case"MEDIA_EVENT_TYPE_PRODUCER_PAUSED":return Es.MEDIA_EVENT_TYPE_PRODUCER_PAUSED;case 4:case"MEDIA_EVENT_TYPE_PRODUCER_RESUMED":return Es.MEDIA_EVENT_TYPE_PRODUCER_RESUMED;case 5:case"MEDIA_EVENT_TYPE_PRODUCER_CLOSED":return Es.MEDIA_EVENT_TYPE_PRODUCER_CLOSED;case 6:case"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED":return Es.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED;case 7:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED":return Es.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED;case 8:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED":return Es.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED;case 9:case"MEDIA_EVENT_TYPE_CONSUMER_CLOSED":return Es.MEDIA_EVENT_TYPE_CONSUMER_CLOSED;case 10:case"MEDIA_EVENT_TYPE_CONSUMER_PAUSED":return Es.MEDIA_EVENT_TYPE_CONSUMER_PAUSED;case 11:case"MEDIA_EVENT_TYPE_CONSUMER_RESUMED":return Es.MEDIA_EVENT_TYPE_CONSUMER_RESUMED;case 12:case"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED":return Es.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED;default:return Es.UNRECOGNIZED}}function Rs(e){switch(e){case Es.MEDIA_EVENT_TYPE_UNSPECIFIED:return"MEDIA_EVENT_TYPE_UNSPECIFIED";case Es.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:return"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT";case Es.MEDIA_EVENT_TYPE_PRODUCER_CREATED:return"MEDIA_EVENT_TYPE_PRODUCER_CREATED";case Es.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:return"MEDIA_EVENT_TYPE_PRODUCER_PAUSED";case Es.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:return"MEDIA_EVENT_TYPE_PRODUCER_RESUMED";case Es.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_CLOSED";case Es.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED";case Es.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED";case Es.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED";case Es.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:return"MEDIA_EVENT_TYPE_CONSUMER_CLOSED";case Es.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:return"MEDIA_EVENT_TYPE_CONSUMER_PAUSED";case Es.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:return"MEDIA_EVENT_TYPE_CONSUMER_RESUMED";case Es.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:return"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED";case Es.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.MEDIA_EVENT_TYPE_UNSPECIFIED=0]="MEDIA_EVENT_TYPE_UNSPECIFIED",e[e.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT=1]="MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT",e[e.MEDIA_EVENT_TYPE_PRODUCER_CREATED=2]="MEDIA_EVENT_TYPE_PRODUCER_CREATED",e[e.MEDIA_EVENT_TYPE_PRODUCER_PAUSED=3]="MEDIA_EVENT_TYPE_PRODUCER_PAUSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_RESUMED=4]="MEDIA_EVENT_TYPE_PRODUCER_RESUMED",e[e.MEDIA_EVENT_TYPE_PRODUCER_CLOSED=5]="MEDIA_EVENT_TYPE_PRODUCER_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED=6]="MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED=7]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED=8]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED",e[e.MEDIA_EVENT_TYPE_CONSUMER_CLOSED=9]="MEDIA_EVENT_TYPE_CONSUMER_CLOSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PAUSED=10]="MEDIA_EVENT_TYPE_CONSUMER_PAUSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_RESUMED=11]="MEDIA_EVENT_TYPE_CONSUMER_RESUMED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED=12]="MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Es||(Es={}));const Ps={encode:(e,t=new gi)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.producer&&Yi.encode(e.producer,t.uint32(18).fork()).join(),void 0!==e.consumer&&hs.encode(e.consumer,t.uint32(26).fork()).join(),void 0!==e.producerSpatialLayerRequest&&ms.encode(e.producerSpatialLayerRequest,t.uint32(34).fork()).join(),void 0!==e.transportConnectionTimeout&&ws.encode(e.transportConnectionTimeout,t.uint32(42).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.producer=Yi.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.consumer=hs.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.producerSpatialLayerRequest=ms.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.transportConnectionTimeout=ws.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:Ts(e.eventType)?Cs(e.eventType):0,producer:Ts(e.producer)?Yi.fromJSON(e.producer):void 0,consumer:Ts(e.consumer)?hs.fromJSON(e.consumer):void 0,producerSpatialLayerRequest:Ts(e.producerSpatialLayerRequest)?ms.fromJSON(e.producerSpatialLayerRequest):void 0,transportConnectionTimeout:Ts(e.transportConnectionTimeout)?ws.fromJSON(e.transportConnectionTimeout):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=Rs(e.eventType)),void 0!==e.producer&&(t.producer=Yi.toJSON(e.producer)),void 0!==e.consumer&&(t.consumer=hs.toJSON(e.consumer)),void 0!==e.producerSpatialLayerRequest&&(t.producerSpatialLayerRequest=ms.toJSON(e.producerSpatialLayerRequest)),void 0!==e.transportConnectionTimeout&&(t.transportConnectionTimeout=ws.toJSON(e.transportConnectionTimeout)),t},create:e=>Ps.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.producer=void 0!==e.producer&&null!==e.producer?Yi.fromPartial(e.producer):void 0,r.consumer=void 0!==e.consumer&&null!==e.consumer?hs.fromPartial(e.consumer):void 0,r.producerSpatialLayerRequest=void 0!==e.producerSpatialLayerRequest&&null!==e.producerSpatialLayerRequest?ms.fromPartial(e.producerSpatialLayerRequest):void 0,r.transportConnectionTimeout=void 0!==e.transportConnectionTimeout&&null!==e.transportConnectionTimeout?ws.fromPartial(e.transportConnectionTimeout):void 0,r}};function Ts(e){return null!=e}const ks={encode:(e,t=new gi)=>(0!==e.id&&t.uint32(8).int32(e.id),void 0!==e.channelEvent&&ls.encode(e.channelEvent,t.uint32(18).fork()).join(),void 0!==e.mediaEvent&&Ps.encode(e.mediaEvent,t.uint32(26).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:0,channelEvent:void 0,mediaEvent:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.id=r.int32();continue;case 2:if(18!==e)break;i.channelEvent=ls.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.mediaEvent=Ps.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Ds(e.id)?globalThis.Number(e.id):0,channelEvent:Ds(e.channelEvent)?ls.fromJSON(e.channelEvent):void 0,mediaEvent:Ds(e.mediaEvent)?Ps.fromJSON(e.mediaEvent):void 0}),toJSON(e){const t={};return 0!==e.id&&(t.id=Math.round(e.id)),void 0!==e.channelEvent&&(t.channelEvent=ls.toJSON(e.channelEvent)),void 0!==e.mediaEvent&&(t.mediaEvent=Ps.toJSON(e.mediaEvent)),t},create:e=>ks.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={id:0,channelEvent:void 0,mediaEvent:void 0};return r.id=null!==(t=e.id)&&void 0!==t?t:0,r.channelEvent=void 0!==e.channelEvent&&null!==e.channelEvent?ls.fromPartial(e.channelEvent):void 0,r.mediaEvent=void 0!==e.mediaEvent&&null!==e.mediaEvent?Ps.fromPartial(e.mediaEvent):void 0,r}};function Ds(e){return null!=e}var Is,Os,As,Ls,Ms,Ns,xs,Fs;let js=class{constructor(e){Is.set(this,[]),Os.set(this,!1),As.set(this,!1),Ls.set(this,void 0),Ms.set(this,void 0),Ns.set(this,new Map),xs.set(this,void 0),Fs.set(this,new Set),p(this,xs,e("EventsQueue"),"f")}setMediaEventHandler(e){p(this,Ls,e,"f"),l(this,xs,"f").info("Media event handler set",{case:"EventsQueue"})}setChannelEventHandler(e){p(this,Ms,e,"f"),l(this,xs,"f").info("Channel event handler set",{case:"EventsQueue"})}subscribe(e){p(this,Fs,new Set,"f");let t=0;const r=e=>{try{const r=this.processMessageChunk(e);if(!r||!this.isPendingMessageFullyReceived(r))return;const n=this.finalizeMessageBytes(r),i=ks.decode(n);i.id&&(l(this,Fs,"f").has(i.id)&&l(this,xs,"f").warn("Received duplicate message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id}),i.id>t+1&&l(this,xs,"f").warn("Received out of order message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id})),l(this,Fs,"f").add(i.id),t=i.id,this.push(i)}catch(e){l(this,xs,"f").error("Failed to parse channel message",{error:mr(e),case:"EventsQueue"})}},n=()=>{e.removeListener("message",r),e.removeListener("close",n)};e.on("close",n),e.on("message",r),l(this,xs,"f").info("Subscribed to data channel",{case:"EventsQueue"})}push(e){l(this,Is,"f").push(e),this.process()}process(){return u(this,void 0,void 0,(function*(){if(!l(this,Os,"f")&&!l(this,As,"f")){for(p(this,As,!0,"f");!l(this,Os,"f")&&l(this,Is,"f").length>0;){const e=l(this,Is,"f").shift();if(e)try{if(e.channelEvent&&l(this,Ms,"f")){l(this,xs,"f").debug("Handle channel event",{case:"EventsQueue",id:e.id,type:us(e.channelEvent.eventType),event:e.channelEvent}),yield l(this,Ms,"f").call(this,e.channelEvent);continue}if(e.mediaEvent&&l(this,Ls,"f")){l(this,xs,"f").debug("Handle media event",{case:"EventsQueue",id:e.id,type:Rs(e.mediaEvent.eventType),event:e.mediaEvent}),yield l(this,Ls,"f").call(this,e.mediaEvent);continue}l(this,xs,"f").warn("Received unknown message",{message:e,case:"EventsQueue"})}catch(t){l(this,xs,"f").error("Failed to handle event",{case:"EventsQueue",id:e.id,error:mr(t)})}}p(this,As,!1,"f"),!l(this,Os,"f")&&l(this,Is,"f").length>0&&queueMicrotask((()=>{this.process()}))}}))}processMessageChunk(e){const t=new Uint8Array(e);if(t.length<12)return void l(this,xs,"f").warn("Chunk too small",{case:"EventsQueue",bytesLength:t.length});const{msgId:r,index:n,total:i}=this.parseMessageChunkHeader(t),s=t.slice(12);l(this,Ns,"f").has(r)||l(this,Ns,"f").set(r,{msgId:r,total:i,received:[]});const o=l(this,Ns,"f").get(r);if(o)return o.received[n]=s,o.msgId=r,o;l(this,xs,"f").warn("Chunk buffer entry not found for msgId",{msgId:r,case:"EventsQueue"})}parseMessageChunkHeader(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{msgId:t.getUint32(0),index:t.getUint32(4),total:t.getUint32(8)}}isPendingMessageFullyReceived(e){return e.received.filter(Boolean).length===e.total}finalizeMessageBytes(e){const t=new Uint8Array(e.received.reduce(((e,t)=>e+t.length),0));let r=0;for(const n of e.received)t.set(n,r),r+=n.length;return l(this,Ns,"f").delete(e.msgId),t}pause(){p(this,Os,!0,"f")}size(){return l(this,Is,"f").length}resume(){p(this,Os,!1,"f"),this.process()}isMessageReceived(e){return l(this,Fs,"f").has(e)}};Is=new WeakMap,Os=new WeakMap,As=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,Ns=new WeakMap,xs=new WeakMap,Fs=new WeakMap,js=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],js);var Us=js;function Bs(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let Vs=class{get(){return this.peer}set(e){this.peer=e}delete(){this.peer=void 0}get canPublish(){var e;return"host"===(null===(e=this.peer)||void 0===e?void 0:e.role)}};Vs=a([ut()],Vs);class Hs extends Ln{constructor(e,t,r){super(e,null!=t?t:"something_went_wrong",r)}}const Ws=Object.create(null);Ws.open="0",Ws.close="1",Ws.ping="2",Ws.pong="3",Ws.message="4",Ws.upgrade="5",Ws.noop="6";const qs=Object.create(null);Object.keys(Ws).forEach((e=>{qs[Ws[e]]=e}));const zs={type:"error",data:"parser error"},Gs="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Ys="function"==typeof ArrayBuffer,$s=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Ks=({type:e,data:t},r,n)=>Gs&&t instanceof Blob?r?n(t):Js(t,n):Ys&&(t instanceof ArrayBuffer||$s(t))?r?n(t):Js(new Blob([t]),n):n(Ws[e]+(t||"")),Js=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function Qs(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Zs;const Xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",eo="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<Xs.length;e++)eo[Xs.charCodeAt(e)]=e;const to="function"==typeof ArrayBuffer,ro=(e,t)=>{if("string"!=typeof e)return{type:"message",data:io(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:no(e.substring(1),t)};return qs[r]?e.length>1?{type:qs[r],data:e.substring(1)}:{type:qs[r]}:zs},no=(e,t)=>{if(to){const r=(e=>{let t,r,n,i,s,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const d=new ArrayBuffer(o),u=new Uint8Array(d);for(t=0;t<a;t+=4)r=eo[e.charCodeAt(t)],n=eo[e.charCodeAt(t+1)],i=eo[e.charCodeAt(t+2)],s=eo[e.charCodeAt(t+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return d})(e);return io(r,t)}return{base64:!0,data:e}},io=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,so=String.fromCharCode(30);function oo(){return new TransformStream({transform(e,t){!function(e,t){Gs&&e.data instanceof Blob?e.data.arrayBuffer().then(Qs).then(t):Ys&&(e.data instanceof ArrayBuffer||$s(e.data))?t(Qs(e.data)):Ks(e,!1,(e=>{Zs||(Zs=new TextEncoder),t(Zs.encode(e))}))}(e,(r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,n)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(n))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(r)}))}})}let ao;function co(e){return e.reduce(((e,t)=>e+t.length),0)}function uo(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let i=0;i<t;i++)r[i]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function lo(e){if(e)return function(e){for(var t in lo.prototype)e[t]=lo.prototype[t];return e}(e)}lo.prototype.on=lo.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},lo.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},lo.prototype.off=lo.prototype.removeListener=lo.prototype.removeAllListeners=lo.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<n.length;i++)if((r=n[i])===t||r.fn===t){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},lo.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,t)}return this},lo.prototype.emitReserved=lo.prototype.emit,lo.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},lo.prototype.hasListeners=function(e){return!!this.listeners(e).length};const po="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function ho(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const fo=po.setTimeout,mo=po.clearTimeout;function go(e,t){t.useNativeTimers?(e.setTimeoutFn=fo.bind(po),e.clearTimeoutFn=mo.bind(po)):(e.setTimeoutFn=po.setTimeout.bind(po),e.clearTimeoutFn=po.clearTimeout.bind(po))}class vo extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class yo extends lo{constructor(e){super(),this.writable=!1,go(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new vo(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=ro(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}(e);return t.length?"?"+t:""}}const _o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),bo={};let wo,So=0,Eo=0;function Co(e){let t="";do{t=_o[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Ro(){const e=Co(+new Date);return e!==wo?(So=0,wo=e):e+"."+Co(So++)}for(;Eo<64;Eo++)bo[_o[Eo]]=Eo;let Po=!1;try{Po="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const To=Po;function ko(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||To))return new XMLHttpRequest}catch(e){}if(!t)try{return new(po[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function Do(){}const Io=null!=new ko({xdomain:!1}).responseType;class Oo extends lo{constructor(e,t){super(),go(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=ho(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new ko(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{r.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Oo.requestsCount++,Oo.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Do,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Oo.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Oo.requestsCount=0,Oo.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Ao);else if("function"==typeof addEventListener){addEventListener("onpagehide"in po?"pagehide":"unload",Ao,!1)}function Ao(){for(let e in Oo.requests)Oo.requests.hasOwnProperty(e)&&Oo.requests[e].abort()}const Lo="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Mo=po.WebSocket||po.MozWebSocket,No="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const xo={websocket:class extends yo{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=No?{}:ho(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=No?new Mo(e,t,r):t?new Mo(e,t):new Mo(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;Ks(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}n&&Lo((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ro()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Mo}},webtransport:class extends yo{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){ao||(ao=new TextDecoder);const r=[];let n=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(r.push(o);;){if(0===n){if(co(r)<1)break;const e=uo(r,1);s=128==(128&e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(co(r)<2)break;const e=uo(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(co(r)<8)break;const e=uo(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(zs);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(co(r)<i)break;const e=uo(r,i);a.enqueue(ro(s?e:ao.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(zs);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=oo();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();const i=()=>{r.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;this.writer.write(r).then((()=>{n&&Lo((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends yo{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=Io&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const r=e.split(so),n=[];for(let e=0;e<r.length;e++){const i=ro(r[e],t);if(n.push(i),"error"===i.type)break}return n})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const r=e.length,n=new Array(r);let i=0;e.forEach(((e,s)=>{Ks(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(so))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ro()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Oo(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},Fo=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,jo=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Uo(e){const t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let i=Fo.exec(e||""),s={},o=14;for(;o--;)s[jo[o]]=i[o]||"";return-1!=r&&-1!=n&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1);"/"==t.slice(-1)&&n.splice(n.length-1,1);return n}(0,s.path),s.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(r[t]=n)})),r}(0,s.query),s}class Bo extends lo{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=Uo(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Uo(t.host).host),go(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},r=e.split("&");for(let e=0,n=r.length;e<n;e++){let n=r[e].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new xo[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Bo.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),r=!1;Bo.priorWebsocketSuccess=!1;const n=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!r)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Bo.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){r||(r=!0,d(),t.close(),t=null)}const s=e=>{const r=new Error("probe error: "+e);r.transport=t.name,i(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&i()}const d=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",n),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{r||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",Bo.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const n=this.writeBuffer[r].data;if(n&&(e+="string"==typeof(t=n)?function(e){let t=0,r=0;for(let n=0,i=e.length;n<i;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}(t):Math.ceil(1.33*(t.byteLength||t.size))),r>0&&e>this.maxPayload)return this.writeBuffer.slice(0,r);e+=2}var t;return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(e){Bo.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}Bo.protocol=4;const Vo="function"==typeof ArrayBuffer,Ho=Object.prototype.toString,Wo="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Ho.call(Blob),qo="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Ho.call(File);function zo(e){return Vo&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||Wo&&e instanceof Blob||qo&&e instanceof File}function Go(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(Go(e[t]))return!0;return!1}if(zo(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return Go(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Go(e[t]))return!0;return!1}function Yo(e){const t=[],r=e.data,n=e;return n.data=$o(r,t),n.attachments=t.length,{packet:n,buffers:t}}function $o(e,t){if(!e)return e;if(zo(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=$o(e[n],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=$o(e[n],t));return r}return e}function Ko(e,t){return e.data=Jo(e.data,t),delete e.attachments,e}function Jo(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=Jo(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Jo(e[r],t));return e}const Qo=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Zo;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Zo||(Zo={}));function Xo(e){return"[object Object]"===Object.prototype.toString.call(e)}class ea extends lo{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===Zo.BINARY_EVENT;r||t.type===Zo.BINARY_ACK?(t.type=r?Zo.EVENT:Zo.ACK,this.reconstructor=new ta(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!zo(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===Zo[r.type])throw new Error("unknown packet type "+r.type);if(r.type===Zo.BINARY_EVENT||r.type===Zo.BINARY_ACK){const n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(n,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(t+1)){const n=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(n,t)}else r.nsp="/";const n=e.charAt(t+1);if(""!==n&&Number(n)==n){const n=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){const n=this.tryParse(e.substr(t));if(!ea.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Zo.CONNECT:return Xo(t);case Zo.DISCONNECT:return void 0===t;case Zo.CONNECT_ERROR:return"string"==typeof t||Xo(t);case Zo.EVENT:case Zo.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Qo.indexOf(t[0]));case Zo.ACK:case Zo.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ta{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Ko(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var ra=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Zo},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Zo.EVENT&&e.type!==Zo.ACK||!Go(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Zo.EVENT?Zo.BINARY_EVENT:Zo.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Zo.BINARY_EVENT&&e.type!==Zo.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Yo(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Decoder:ea});function na(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const ia=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sa extends lo{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[na(e,"open",this.onopen.bind(this)),na(e,"packet",this.onpacket.bind(this)),na(e,"error",this.onerror.bind(this)),na(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(ia.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:Zo.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),r.id=e}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const n=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===n)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),n);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const r=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((n,i)=>{t.push(((e,t)=>r?e?i(e):n(t):n(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...n)=>{if(r!==this._queue[0])return;return null!==e?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Zo.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Zo.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Zo.EVENT:case Zo.BINARY_EVENT:this.onevent(e);break;case Zo.ACK:case Zo.BINARY_ACK:this.onack(e);break;case Zo.DISCONNECT:this.ondisconnect();break;case Zo.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...n){r||(r=!0,t.packet({type:Zo.ACK,id:e,data:n}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Zo.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function oa(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}oa.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},oa.prototype.reset=function(){this.attempts=0},oa.prototype.setMin=function(e){this.ms=e},oa.prototype.setMax=function(e){this.max=e},oa.prototype.setJitter=function(e){this.jitter=e};class aa extends lo{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,go(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new oa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||ra;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Bo(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=na(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=na(t,"error",i);if(!1!==this._timeout){const e=this._timeout,r=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(n),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(na(e,"ping",this.onping.bind(this)),na(e,"data",this.ondata.bind(this)),na(e,"error",this.onerror.bind(this)),na(e,"close",this.onclose.bind(this)),na(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){Lo((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new sa(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const ca={};function da(e,t){"object"==typeof e&&(t=e,e=void 0);const r=function(e,t="",r){let n=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),n=Uo(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),n=r.source,i=r.id,s=r.path,o=ca[i]&&s in ca[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new aa(n,t):(ca[i]||(ca[i]=new aa(n,t)),a=ca[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}var ua,la;Object.assign(da,{Manager:aa,Socket:sa,io:da,connect:da});let pa=class{constructor(e){this.reconnectingAttempt=0,this.isConnected=!1,this._observer=new Dt,ua.set(this,void 0),this.knownDisconnectReasonsCodes={"io server disconnect":"server.disconnect","io client disconnect":"client.disconnect","ping timeout":"ping.timeout","transport close":"transport.close","transport error":"transport.error"},la.set(this,!1),p(this,ua,e("Socket"),"f")}get observer(){return this._observer}get id(){var e;return null===(e=this.connection)||void 0===e?void 0:e.id}connect(e,t){const r=da(e,{multiplex:!0,randomizationFactor:.2,reconnectionDelay:1e3,reconnection:!0,transports:["polling","websocket"],upgrade:!0,rememberUpgrade:!1,auth:{token:t,apiVersion:7}});this.connection=r,this.serverUrl=e,r.on(Jn.Connect,(()=>{const e=this.reconnectingAttempt?Jn.Reconnected:Jn.Connected;this.isConnected=!0,this.setReconnectingAttempt(0),l(this,ua,"f").debug(`connection.on('${Jn.Connect}')`,{connectionId:r.id,recovered:r.recovered}),this.observer.safeEmit(Jn.State,{state:e})})),r.on(Jn.ConnectError,(e=>{this.connectionError=e,l(this,ua,"f").error(`connection.on('${Jn.ConnectError}')`,{error:mr(e)}),this.observer.safeEmit(Jn.State,{state:Jn.Error,error:e}),this.reconnectingAttempt>100&&(r.disconnect(),this.observer.safeEmit(Jn.State,{state:Jn.Disconnected,code:"server.disconnect"}))})),r.on(Jn.ReconnectError,(e=>{l(this,ua,"f").error(`connection.on('${Jn.ReconnectError}')`,{case:"SocketReconnect",error:mr(e)})})),r.on(Jn.Disconnect,(e=>{this.isConnected=!1,this.setReconnectingAttempt(0),this.disconnectReason=e,l(this,ua,"f").info(`connection.on('${Jn.Disconnect}')`,{reason:e});const t=this.getDisconnectReasonCode(e);"server.disconnect"===t&&r.disconnect(),this.observer.safeEmit(Jn.State,{state:Jn.Disconnected,code:t})})),r.io.on(Jn.ReconnectAttempt,(e=>{this.setReconnectingAttempt(e),l(this,ua,"f").info(`connection.on('${Jn.ReconnectAttempt}')`,{attempt:e}),this.observer.safeEmit(Jn.State,{state:Jn.Reconnecting})})),r.io.on(Jn.Reconnect,(()=>{l(this,ua,"f").debug(`connection.on('${Jn.Reconnect}')`,{connectionId:r.id}),this.observer.safeEmit(Jn.State,{state:Jn.Reconnect})}))}disconnect(){this.connection&&(this.connection.offAny(),this.connection.volatile.offAny(),this.connection.disconnect(),this.connection.io.removeAllListeners(),this.setReconnectingAttempt(0))}request(e){return u(this,arguments,void 0,(function*(e,t={}){return yield new Promise(((r,n)=>{this.connection?this.connection.timeout(8e3).emit(e,t,((t,i)=>{if(t){const r=In.includes(e);return"operation has timed out"===(null==t?void 0:t.message)&&!l(this,la,"f")&&r&&(p(this,la,!0,"f"),this.observer.safeEmit(Jn.State,{state:Jn.BufferingStart})),void n(t)}i&&i.error?("Need join to channel first"===i.error&&this.observer.safeEmit(Jn.State,{code:Jn.NeedToJoinFirst}),n(new Hs(i.error,i.errorCode,Object.assign({},i)))):(l(this,la,"f")&&(p(this,la,!1,"f"),this.observer.safeEmit(Jn.State,{state:Jn.BufferingEnd})),r(i))})):n(new Error("Socket request: Socket connection is not initialized"))}))}))}getServerUrl(){return this.serverUrl}getDisconnectReasonCode(e){const t=String(e).toLowerCase();return this.knownDisconnectReasonsCodes[t]||t}setReconnectingAttempt(e){this.reconnectingAttempt=e}};ua=new WeakMap,la=new WeakMap,pa=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],pa);var ha,fa=pa;class ma extends Ln{constructor(e,t){super(e,null!=t?t:"invalid_payload")}}!function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(ha||(ha={}));let ga=class{constructor(){this.peers=new Map}has(e){return this.peers.has(e)}set(e,t){this.peers.set(e,t)}get(e){return this.peers.get(e)}delete(e){return this.peers.delete(e)}all(){return Array.from(this.peers.values())}hosts(){return this.all().filter((e=>"host"===e.role))}audience(){return this.all().filter((e=>"audience"===e.role))}clear(){this.peers.clear()}};ga=a([ut()],ga);var va,ya,_a,ba,wa,Sa=ga;let Ea=wa=class{constructor(e,t,r){this.peersStorage=e,this.clientEventEmitter=t,va.set(this,void 0),ya.set(this,void 0),_a.set(this,void 0),ba.set(this,void 0),p(this,va,r("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(wa.validateEventPayload(t),t.event){case ha.DominantSpeaker:this.handleDominantSpeaker(t);break;case ha.PeersVolumes:this.handlePeerVolumes(t);break;case ha.Silence:this.handleSilence()}}catch(t){l(this,va,"f").warn("Failed to handle audio observer event",{error:mr(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peersStorage.get(t);p(this,_a,r,"f"),p(this,ba,r,"f"),this.setActiveSpeaker(r)}handlePeerVolumes(e){e.volumes.forEach((e=>{var t;const{peerId:r,trackLabel:n,value:i}=e,s=this.peersStorage.get(r);if(!s)return;i>0&&!l(this,_a,"f")&&s.id===(null===(t=l(this,ba,"f"))||void 0===t?void 0:t.id)&&(p(this,_a,s,"f"),this.setActiveSpeaker(s));const o=null==s?void 0:s.tracks.get(n);o&&o.setVolume(i)}))}handleSilence(){this.peersStorage.all().flatMap((e=>Array.from(e.tracks.values()))).forEach((e=>e.setVolume(0))),p(this,_a,void 0,"f"),this.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(Dr,(e=>{var t;e===(null===(t=l(this,_a,"f"))||void 0===t?void 0:t.id)&&this.setActiveSpeaker(void 0)}))}setActiveSpeaker(e){l(this,ya,"f")!==(null==e?void 0:e.id)&&(p(this,ya,null==e?void 0:e.id,"f"),this.clientEventEmitter.safeEmit(jr,{peer:e}))}static validateEventPayload(e){switch(e.event){case ha.Silence:break;case ha.DominantSpeaker:{e.data||wa.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===$n.Microphone||wa.throwInvalidPayload();break}case ha.PeersVolumes:Array.isArray(e.volumes)||wa.throwInvalidPayload(),e.volumes.forEach((e=>{const{peerId:t,producerId:r,value:n,trackLabel:i}=e;"string"==typeof t&&"string"==typeof r&&"number"==typeof n&&i===$n.Microphone||wa.throwInvalidPayload()}));break;default:wa.throwInvalidPayload()}}static throwInvalidPayload(){throw new ma("Invalid channel audio observer event handler payload")}};va=new WeakMap,ya=new WeakMap,_a=new WeakMap,ba=new WeakMap,Ea=wa=a([ut(),c(0,pt(Gn.PeersStorage)),c(1,pt(Gn.ClientEventEmitter)),c(2,pt(Gn.LoggerFactory)),d("design:paramtypes",[Sa,Dt,Function])],Ea);var Ca,Ra,Pa,Ta=Ea;let ka=class{constructor(e,t,r,n,i){this.state=e,this.myPeer=r,this.socket=n,this.channelAudioObserverEventHandler=i,Ca.set(this,void 0),Ra.set(this,void 0),Pa.set(this,void 0),p(this,Ca,t("DataChannels"),"f")}get channelMessagesDataConsumer(){return l(this,Pa,"f")}createAudioObserver(e){return u(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{producerId:t}=yield this.getAudioObserverProducer();p(this,Ra,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,transport:e}),"f");const n=this.channelAudioObserverEventHandler.handle.bind(this.channelAudioObserverEventHandler),i=()=>{var e,t;null===(e=l(this,Ra,"f"))||void 0===e||e.removeListener("message",n),null===(t=l(this,Ra,"f"))||void 0===t||t.removeListener("close",i)};l(this,Ra,"f").on("close",i),l(this,Ra,"f").on("message",n),l(this,Ca,"f").debug("Successfully create audio observer",r)}catch(e){l(this,Ca,"f").error("Failed to create audio observer",Object.assign(Object.assign({},r),{error:mr(e)}))}}))}createChannelMessagesDataConsumer(e){return u(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{id:t}=yield this.createDataProducer(e.id,"channel-messages-data-producer");p(this,Pa,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,ordered:!0,transport:e}),"f"),l(this,Ca,"f").debug("Successfully created channel messages data consumer",Object.assign(Object.assign({},r),{producerId:t}))}catch(e){throw l(this,Ca,"f").error("Failed to create channel messages data consumer",Object.assign(Object.assign({},r),{error:e})),e}}))}closeAudioObserver(){var e;null===(e=l(this,Ra,"f"))||void 0===e||e.close()}closeChannelMessagesDataConsumer(){var e;null===(e=l(this,Pa,"f"))||void 0===e||e.close()}createDataProducer(e,t){return u(this,void 0,void 0,(function*(){return yield this.socket.request(Tn,{transportId:e,label:t})}))}createDataConsumer(e){return u(this,arguments,void 0,(function*({producerId:e,appId:t,channelId:r,ordered:n,transport:i}){if(!i)throw l(this,Ca,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");l(this,Ca,"f").debug("createDataConsumer()",{producerId:e});const s=yield this.socket.request(yn,{ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}}),o=yield i.consumeData(s);return l(this,Ca,"f").debug("Data consumer created",{consumerId:o.id}),o}))}getAudioObserverProducer(){return u(this,void 0,void 0,(function*(){return yield this.socket.request(Sr)}))}};Ca=new WeakMap,Ra=new WeakMap,Pa=new WeakMap,ka=a([ut(),c(0,pt(Gn.CallState)),c(1,pt(Gn.LoggerFactory)),c(2,pt(Gn.MyPeer)),c(3,pt(Gn.SocketIO)),c(4,pt(Gn.ChannelAudioObserverEventHandler)),d("design:paramtypes",[Qn,Function,Vs,fa,Ta])],ka);var Da,Ia,Oa,Aa=ka;let La=class{constructor(e,t,r,n,i,s){this.state=e,this.myPeer=t,this.socket=n,this.clientEventEmitter=i,this.dataChannelsManager=s,Da.set(this,new Map),Ia.set(this,void 0),Oa.set(this,void 0),this.peersLoaded=!1,p(this,Oa,r("Network"),"f"),p(this,Ia,new Dt,"f"),this.socket.observer.on(Jn.State,(e=>{l(this,Ia,"f").safeEmit(On,e)}))}get isNetworkActive(){var e,t,r,n,i;return!!(null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&["connected","new"].includes(null!==(r=null===(t=this.receiveTransport)||void 0===t?void 0:t.connectionState)&&void 0!==r?r:"")&&["connected","new"].includes(null!==(i=null===(n=this.sendTransport)||void 0===n?void 0:n.connectionState)&&void 0!==i?i:"")}get observer(){return l(this,Ia,"f")}get isSocketConnectionActive(){try{return this.checkSocketConnectionActivity(),!0}catch(e){return l(this,Oa,"f").warn("isSocketConnectionActive()",{error:mr(e)}),!1}}checkSocketConnectionActivity(){var e;if(!this.state.channelId||this.state.isChannelJoining)throw new Error("Connect to the channel first");if(!(null===(e=this.socket.connection)||void 0===e?void 0:e.active))throw new Error("Socket is inactive");if(!this.socket.connection.connected)throw new Error("Socket disconnected")}removeEventListeners(){const{sendTransport:e,receiveTransport:t,signalingTransport:r}=this;if(e){["connect","produce","connectionstatechange"].forEach((t=>e.removeAllListeners(t)))}if(t){["connect","produce","connectionstatechange"].forEach((e=>t.removeAllListeners(e)))}if(r){["connect","produce","producedata","connectionstatechange"].forEach((e=>r.removeAllListeners(e)))}}reset(){this.stopRestartIceAttempts(),this.removeEventListeners()}closeRemoteProducer(e){return u(this,void 0,void 0,(function*(){yield this.socket.request(pn,{peerId:this.myPeer.id,producerId:e})}))}closeSendTransport(){var e;this.sendTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&this.closeTransport(this.sendTransport),this.sendTransport.close(),this.sendTransport=void 0):l(this,Oa,"f").warn("closeSendTransport()",{message:"No available send transport"})}closeReceiveTransport(){var e;this.receiveTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&this.closeTransport(this.receiveTransport),this.receiveTransport.close(),this.receiveTransport=void 0):l(this,Oa,"f").warn("closeReceiveTransport()",{message:"No available receive transport"})}closeConnectionTransport(){return u(this,void 0,void 0,(function*(){var e;this.signalingTransport?(yield this.closePingConsumer(),(null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&this.closeTransport(this.signalingTransport),this.signalingTransport.close(),this.signalingTransport=void 0):l(this,Oa,"f").warn("closeConnectionTransport()",{message:"No available connection transport"})}))}closeTransport(e){try{e.close(),l(this,Oa,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){l(this,Oa,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}createSendTransport(e){return u(this,void 0,void 0,(function*(){if(this.sendTransport)throw l(this,Oa,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new Ln("Send transport already exists","already_exists");const t=yield this.socket.request(Cn,{sctpCapabilities:e.sctpCapabilities,localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return l(this,Oa,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return u(this,void 0,void 0,(function*(){if(this.receiveTransport)throw l(this,Oa,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new Ln("Receive transport already exists","already_exists");const t=yield this.socket.request(Cn,{localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return l(this,Oa,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}createSignalingTransport(e){return u(this,void 0,void 0,(function*(){if(this.signalingTransport)throw l(this,Oa,"f").warn("createConnectionTransport()",{message:"Connection transport already exists"}),new Ln("Connection transport already exists","already_exists");const t=yield this.socket.request(Cn,{localDirection:"receive",tcpOnly:!0}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return l(this,Oa,"f").debug("createConnectionTransport()",{transportId:r.id,direction:r.direction,tcpOnly:!0}),this.signalingTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return u(this,void 0,void 0,(function*(){const t=yield this.socket.request(Dn,{transportId:e.id}),{error:r}=t;if(r)throw new Error(r);const{iceParameters:n}=t;return l(this,Oa,"f").debug("getIceParameters()",{iceParameters:n}),n}))}restartIce(e){return u(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),l(this,Oa,"f").info("restartIce completed",{iceParameters:t})}catch(e){l(this,Oa,"f").error("restartIce error",{error:e})}}))}createConsumer(e){return u(this,arguments,void 0,(function*({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;const o=this.receiveTransport;if(!o)throw l(this,Oa,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");let a;l(this,Oa,"f").debug("createConsumer()",{producerId:e});try{a=yield this.socket.request(vn,{producerId:e,transportId:o.id,rtpCapabilities:t,appData:{peerId:this.myPeer.id,appId:r,channelId:n},producerPeerId:i})}catch(o){if(!(o instanceof Hs&&(null===(s=o.meta)||void 0===s?void 0:s.existedConsumer)))throw l(this,Oa,"f").error("Failed to get consumer options",{producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i,error:mr(o)}),new Error("Failed to create consumer");a=o.meta.existedConsumer}const c=yield o.consume(a),{producerPaused:d}=a;return d&&c.pause(),l(this,Oa,"f").debug("Consumer created",{consumerId:c.id,label:c.appData.label,isProducerPaused:d}),{consumer:c,isProducerPaused:d}}))}createSignalingConsumer(){return u(this,void 0,void 0,(function*(){var e,t;const r=this.signalingTransport;if(!r)throw l(this,Oa,"f").error("createSignalingConsumer()",{reason:"missing signaling transport"}),new Error("Failed to create data consumer");this.signalingDataProducer=yield r.produceData({label:"heart-beater",protocol:"json"});const n=null===(e=this.signalingDataProducer)||void 0===e?void 0:e.id;if(!n)throw new TypeError("dataProducerId is missing for connectionTransport");try{const e=yield this.socket.request(yn,{ordered:!0,dataProducerId:n,transportId:r.id,appData:{peerId:this.myPeer.id,producerId:n,appId:this.state.appId,channelId:this.state.channelId}});this.signalingConsumerId=e.consumerId}catch(e){l(this,Oa,"f").error("Failed to setup TCP DataChannel for connectionTransport",{transportId:r.id,dataProducerId:null===(t=this.signalingDataProducer)||void 0===t?void 0:t.id,error:mr(e)})}}))}get channelMessagesDataConsumer(){return this.dataChannelsManager.channelMessagesDataConsumer}closePingConsumer(){return u(this,void 0,void 0,(function*(){try{if(!this.signalingConsumerId)return;yield this.closeRemoteConsumer(this.signalingConsumerId)}catch(e){l(this,Oa,"f").debug("closeConsumer()",{track:this,error:mr(e)})}}))}closeRemoteConsumer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(_n,{peerId:this.myPeer.id,consumerId:e})}))}resumeRemoteConsumer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(wn,{consumerId:e})}))}pauseRemoteProducer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(hn,{producerId:e})}))}pauseRemoteConsumer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(bn,{consumerId:e})}))}updatePeerAppData(e){return u(this,arguments,void 0,(function*({peerId:e,appData:t}){return yield this.socket.request(br,{peerId:e,appData:t})}))}getTransportsStateInfo(){return u(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getParsedTransportStats(this.receiveTransport),this.getParsedTransportStats(this.sendTransport)]);return{receive:e,send:t}}))}setPreferRelay(e){this.preferRelay=e}getPreferRelay(){var e;return null!==(e=this.preferRelay)&&void 0!==e&&e}getChannelPeers(e){return u(this,void 0,void 0,(function*(){const t=yield this.socket.request(yr,{role:e});return this.peersLoaded=!0,t}))}createAllDataChannels(){return u(this,void 0,void 0,(function*(){if(!this.receiveTransport)throw new Error("Receive transport is not created");yield Promise.all([this.dataChannelsManager.createAudioObserver(this.receiveTransport),this.dataChannelsManager.createChannelMessagesDataConsumer(this.receiveTransport)])}))}closeAllDataChannels(){this.dataChannelsManager.closeAudioObserver(),this.dataChannelsManager.closeChannelMessagesDataConsumer()}waitForReceiveTransportConnected(){return u(this,void 0,void 0,(function*(){if(!this.receiveTransport)throw new Error("receiveTransport is not initialized");yield this.waitForTransportConnected(this.receiveTransport)}))}triggerChannelStateEvent(e){return u(this,void 0,void 0,(function*(){const{messageId:t}=yield this.socket.request(_r,{peersRole:e});return t}))}waitForChannelMessagesDataConsumerConnected(){return u(this,void 0,void 0,(function*(){if(!this.dataChannelsManager.channelMessagesDataConsumer)throw new Error("channelMessagesDataConsumer is not initialized");yield this.waitForDataConsumerConnected(this.dataChannelsManager.channelMessagesDataConsumer)}))}waitForTransportConnected(e){return u(this,arguments,void 0,(function*(e,t=6e4){"connected"!==e.connectionState&&(yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),n(new Error("Timed out waiting for receiveTransport to connect"))}),t),s=()=>{clearTimeout(i),e.off("connectionstatechange",o)},o=()=>{"connected"===e.connectionState?(s(),r()):"failed"!==e.connectionState&&"closed"!==e.connectionState||(s(),n(new Error(`receiveTransport connection failed: ${e.connectionState}`)))};e.on("connectionstatechange",o)})))}))}waitForDataConsumerConnected(e){return u(this,arguments,void 0,(function*(e,t=6e4){if(!e)throw new Error("Data consumer is not initialized");"open"!==e.readyState&&(yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),n(new Error("Timed out waiting for data consumer to connect"))}),t),s=()=>{clearTimeout(i),e.off("open",o),e.off("close",a)},o=()=>{s(),r()},a=()=>{s(),n(new Error(`Data consumer closed unexpectedly: ${e.readyState}`))};e.on("open",o),e.on("close",a)})))}))}getParsedTransportStats(e){return u(this,void 0,void 0,(function*(){if(e)try{const t=Array.from((yield e.getStats()).values()),r=t.find((e=>"local-candidate"===e.type)),n=t.find((e=>"remote-candidate"===e.type)),i=t.find((e=>"transport"===e.type));return{dtlsState:null==i?void 0:i.dtlsState,iceState:null==i?void 0:i.iceState,dtlsRole:null==i?void 0:i.dtlsRole,iceRole:null==i?void 0:i.iceRole,selectedCandidatePairChanges:null==i?void 0:i.selectedCandidatePairChanges,tlsVersion:null==i?void 0:i.tlsVersion,localCandidateState:{ip:null==r?void 0:r.ip,address:null==r?void 0:r.address,port:null==r?void 0:r.port,protocol:null==r?void 0:r.protocol,candidateType:null==r?void 0:r.candidateType},remoteCandidateState:{ip:null==n?void 0:n.ip,address:null==n?void 0:n.address,port:null==n?void 0:n.port,protocol:null==n?void 0:n.protocol,candidateType:null==n?void 0:n.candidateType}}}catch(e){return void l(this,Oa,"f").warn("getParsedTransportStats()",{error:e})}else l(this,Oa,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){return u(this,void 0,void 0,(function*(){var t,r,n,i;let s;try{s=yield e.getStats()}catch(t){return void l(this,Oa,"f").error("Failed to log detailed WebRTC transport stats",{error:mr(t),transportId:e.id,reason:"failed to parse getStats"})}try{const o=[...s],[,a]=null!==(t=o.find((([,e])=>"transport"===(null==e?void 0:e.type))))&&void 0!==t?t:[],[,c]=null!==(r=o.find((([,e])=>"candidate-pair"===e.type&&"succeeded"===e.state&&e.nominated)))&&void 0!==r?r:[],d=s.get(String(null!==(n=null==c?void 0:c.localCandidateId)&&void 0!==n?n:"-")),u=s.get(String(null!==(i=null==c?void 0:c.remoteCandidateId)&&void 0!==i?i:"-")),p={hasNominatedPair:!!c,transportId:e.id,iceRole:null==a?void 0:a.iceRole,iceState:null==a?void 0:a.iceState,dtlsRole:null==a?void 0:a.dtlsRole,dtlsState:null==a?void 0:a.dtlsState,local:{address:null==d?void 0:d.address,candidateType:null==d?void 0:d.candidateType,foundation:null==d?void 0:d.foundation,networkType:null==d?void 0:d.networkType,isRemote:null==d?void 0:d.isRemote,port:null==d?void 0:d.port,protocol:null==d?void 0:d.protocol,relatedAddress:null==d?void 0:d.relatedAddress,relatedPort:null==d?void 0:d.relatedPort,transportId:null==d?void 0:d.transportId,relayProtocol:null==d?void 0:d.relayProtocol,url:null==d?void 0:d.url},remote:{address:null==u?void 0:u.address,candidateType:null==u?void 0:u.candidateType,foundation:null==u?void 0:u.foundation,isRemote:null==u?void 0:u.isRemote,port:null==u?void 0:u.port,protocol:null==u?void 0:u.protocol,transportId:null==u?void 0:u.transportId}};(null==c?void 0:c.totalRoundTripTime)&&(null==c?void 0:c.responsesReceived)&&(p.pairRoundTripTime=Math.round(c.totalRoundTripTime/c.responsesReceived*1e3)),l(this,Oa,"f").info("Detailed WebRTC transport stats",p)}catch(t){l(this,Oa,"f").error("Failed to log detailed WebRTC transport stats",{error:mr(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAttempts(){Array.from(l(this,Da,"f").values()).forEach((e=>clearInterval(e)))}subscribeCommonTransportEvents(e){e.on("connect",((t,r,n)=>u(this,[t,r,n],void 0,(function*({dtlsParameters:t},r,n){try{yield this.socket.request(Rn,{transportId:e.id,dtlsParameters:t}),r(),l(this,Oa,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>u(this,void 0,void 0,(function*(){return yield this.logTransportDetails(e)}))),2e3),setTimeout((()=>u(this,void 0,void 0,(function*(){return yield this.checkTransportState(e)}))),15e3)}catch(t){l(this,Oa,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>u(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(Pn,{transportId:e.id,kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData});r({id:n}),l(this,Oa,"f").debug(`${e.direction}Transport.produce()`,{producerId:n,transportId:e.id,kind:t.kind})}catch(r){l(this,Oa,"f").error(`${e.direction}Transport.produce()`,{error:mr(r),transportId:e.id,kind:t.kind}),n(r)}})))),e.on("producedata",((t,r,n)=>u(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(Tn,{transportId:e.id,label:t.label,sctpParameters:t.sctpStreamParameters,appData:t.appData});r({id:n}),l(this,Oa,"f").debug(`${e.direction}Transport.produceData()`,{producerId:n,transportId:e.id,label:t.label})}catch(r){l(this,Oa,"f").error(`${e.direction}Transport.produceData()`,{error:mr(r),transportId:e.id,label:t.label}),n(r)}})))),e.on("connectionstatechange",(t=>{if(l(this,Oa,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return l(this,Ia,"f").safeEmit(An,{state:t,direction:e.direction}),l(this,Da,"f").has(e.id)&&(l(this,Oa,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(l(this,Da,"f").get(e.id)),l(this,Da,"f").delete(e.id),"connected"===t&&l(this,Ia,"f").safeEmit(An,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>{this.logTransportDetails(e).catch((e=>{l(this,Oa,"f").debug("Failed to log transport details",{error:mr(e)})}))}),1500));if(l(this,Ia,"f").safeEmit(An,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(l(this,Da,"f").has(e.id))return;"failed"===t&&(l(this,Oa,"f").debug(`${e.id} transport.restartIce()`,{transportId:e.id,direction:e.direction}),this.restartIce(e).catch((t=>{l(this,Oa,"f").debug("Failed to execute restartIce",{error:mr(t),transportId:e.id,direction:e.direction})}))),l(this,Da,"f").set(e.id,setInterval((()=>{this.restartIce(e).catch((t=>{l(this,Oa,"f").debug("Failed to execute restartIce",{error:mr(t),transportId:e.id,direction:e.direction})})),l(this,Oa,"f").debug(`${e.id} transport.restartIce() attempt`,{recvTransportId:e.id,transportId:e.id,direction:e.direction})}),5e3))}})),e.on("icegatheringstatechange",(t=>{l(this,Oa,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}checkTransportState(e){return u(this,void 0,void 0,(function*(){try{const t=yield this.getParsedTransportStats(e);if(!t)return;const r="send"===e.direction?"send":"receive";if("connected"!==t.iceState)return this.clientEventEmitter.emit(Nr,{direction:r,reason:"ice"}),void l(this,Oa,"f").warn(kn,{reason:"ice",transportId:e.id,direction:r});"connected"!==t.dtlsState&&(this.clientEventEmitter.emit(Nr,{direction:r,reason:"dtls"}),l(this,Oa,"f").warn(kn,{reason:"dtls",transportId:e.id,direction:r}))}catch(t){l(this,Oa,"f").error("checkTransportState()",{error:mr(t),transportId:e.id,direction:e.direction})}}))}};Da=new WeakMap,Ia=new WeakMap,Oa=new WeakMap,La=a([ut(),c(0,pt(Gn.CallState)),c(1,pt(Gn.MyPeer)),c(2,pt(Gn.LoggerFactory)),c(3,pt(Gn.SocketIO)),c(4,pt(Gn.ClientEventEmitter)),c(5,pt(Gn.DataChannelsManager)),d("design:paramtypes",[Qn,Vs,Function,fa,Dt,Aa])],La);var Ma=La;let Na=class{constructor(e,t,r,n,i){this.myPeer=e,this.network=t,this.peerFactory=r,this.clientEventEmitter=n,this.peersStorage=i}has(e){return this.peersStorage.has(e)}set(e,t){e===this.myPeer.id&&this.myPeer.set(t),this.peersStorage.set(e,t)}get(e){return this.peersStorage.get(e)}delete(e){return e===this.myPeer.id&&this.myPeer.delete(),this.peersStorage.delete(e)}remove(e){return u(this,void 0,void 0,(function*(){const t=this.get(e);t&&(yield t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(Dr,e))}))}all(){return this.peersStorage.all()}hosts(){return this.peersStorage.hosts()}audience(){return this.peersStorage.audience()}reset(){return u(this,void 0,void 0,(function*(){yield Promise.all(this.peersStorage.all().map((e=>u(this,void 0,void 0,(function*(){return yield e.reset()}))))),this.peersStorage.clear()}))}load(e){return u(this,void 0,void 0,(function*(){const{peers:t}=yield this.network.getChannelPeers(e);t.filter((e=>!this.has(e.id))).forEach((e=>this.add(e,!1)))}))}add(e,t=!0){const r=this.get(e.id);if(r)return r;const n=this.peerFactory(e);return this.set(n.id,n),t&&this.clientEventEmitter.safeEmit(kr,n),n}isModerator(e){if(void 0===e)return!1;const t=this.get(e);return!!t&&t.isModerator}};function xa(e,t){var r,n;if(0===t.length)return e;for(r=0,n=t.length;r<n;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e<0?-2*e:e}function Fa(e,t,r,n){var i=xa(xa(xa(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return xa(i,"null");if(void 0===t)return xa(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return xa(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Fa(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return xa(s,String(t.valueOf()))}catch(e){return xa(s,"[valueOf exception]"+(e.stack||e.message))}}return xa(i,t.toString())}Na=a([ut(),c(0,pt(Gn.MyPeer)),c(1,pt(Gn.Network)),c(2,pt(Gn.PeerFactory)),c(3,pt(Gn.ClientEventEmitter)),c(4,pt(Gn.PeersStorage)),d("design:paramtypes",[Vs,Ma,Function,Dt,Sa])],Na);var ja=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Fa(0,e,"",[]).toString(16),8)};class Ua{constructor(e){this.missingPeers=e.missingPeers,this.missingProducers=e.missingProducers,this.consumersWithInconsistentState=e.consumersWithInconsistentState,this.producersWithInconsistentState=e.producersWithInconsistentState,this.peersWithInconsistentAppData=e.peersWithInconsistentAppData}hasInconsistencyCases(){return this.missingPeers.length>0||this.missingProducers.length>0||this.consumersWithInconsistentState.length>0||this.producersWithInconsistentState.length>0||this.peersWithInconsistentAppData.length>0}}class Ba{constructor(e){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[],this.localState=e.localState,this.remoteState=e.remoteState}check(){return this.resetPreviousCheckResults(),this.remoteState.peers.forEach((e=>{const t=this.findLocalPeerById(e.id);if(!t)return void this.missingPeers.push(e.id);t.appDataHash!==e.appDataHash&&this.peersWithInconsistentAppData.push(e.id),e.producers.forEach((e=>{const r=this.findLocalProducerById(t,e.id);if(!r)return void this.missingProducers.push(e.id);if(this.isLocalProducerStateChangedRecently(r))return;if(r.paused!==e.paused)return void this.producersWithInconsistentState.push(e.id);const n=this.findLocalConsumerByProducerId(t,e.id);n&&n.paused!==e.paused&&this.consumersWithInconsistentState.push(n.id),r||this.missingProducers.push(e.id)}))})),new Ua({missingPeers:this.missingPeers,missingProducers:this.missingProducers,consumersWithInconsistentState:this.consumersWithInconsistentState,producersWithInconsistentState:this.producersWithInconsistentState,peersWithInconsistentAppData:this.peersWithInconsistentAppData})}getMissingPeers(){return this.missingPeers}getMissingProducers(){return this.missingProducers}getConsumersWithInconsistentState(){return this.consumersWithInconsistentState}getProducersWithInconsistentState(){return this.producersWithInconsistentState}getPeersWithInconsistentAppData(){return this.peersWithInconsistentAppData}findLocalPeerById(e){return this.localState.peers.find((t=>t.id===e))}findLocalConsumerByProducerId(e,t){var r;return null===(r=e.consumers)||void 0===r?void 0:r.find((e=>e.producerId===t))}findLocalProducerById(e,t){return e.producers.find((e=>e.id===t))}resetPreviousCheckResults(){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[]}isLocalProducerStateChangedRecently(e){return Date.now()-e.stateChangedAt<5e3}}var Va,Ha,Wa,qa,za,Ga,Ya;!function(e){e.MissingPeer="missing-peer",e.MissingProducer="missing-producer",e.IncorrectProducerState="incorrect-producer-state",e.IncorrectConsumerState="incorrect-consumer-state",e.IncorrectAppData="incorrect-app-data"}(Va||(Va={}));let $a=class{constructor(e,t,r,n,i,s,o){var a;this.network=t,this.callState=r,this.socket=n,this.peersStorage=i,this.clientEventEmitter=s,this.webRtcIssueDetector=o,Ha.set(this,void 0),Wa.set(this,void 0),qa.set(this,[]),za.set(this,!1),Ga.set(this,{inbound:4.3,outbound:4.3}),Ya.set(this,(new Date).getTime()-15e3),p(this,Wa,null===(a=this.webRtcIssueDetector)||void 0===a?void 0:a.eventEmitter,"f"),p(this,Ha,e("ChannelStateSyncEventHandler"),"f"),this.debouncedHandleChannelStateEvent=jn(this.handleChannelStateEvent.bind(this),3e3),this.listenNetworkScoresUpdatedEvents()}handleChannelStateShort(e){return u(this,void 0,void 0,(function*(){try{yield this.debouncedHandleChannelStateEvent(e)}catch(e){l(this,Ha,"f").error("handleChannelStateSyncEvent()",{error:mr(e)})}}))}handleChannelStateEvent(e){return u(this,void 0,void 0,(function*(){if(l(this,za,"f"))l(this,Ha,"f").warn("Channel state event is already being handled, skipping new event",{case:"handleChannelStateEvent"});else{p(this,za,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void l(this,Ha,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{p(this,za,!1,"f")}}}))}getLastInconsistencyCheckResult(){return l(this,qa,"f")[l(this,qa,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{peerId:e,peersLoaded:this.network.peersLoaded,sdkInstances:Array.from(window._sdkMarks||[]).length,type:Va.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{producerId:e,type:Va.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{producerId:e,type:Va.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{peerId:e,type:Va.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new Ua({missingPeers:this.getConfirmedMissingPeers(e.missingPeers),missingProducers:this.getConfirmedMissingProducers(e.missingProducers),consumersWithInconsistentState:this.getConfirmedConsumersWithInconsistencState(e.consumersWithInconsistentState),producersWithInconsistentState:this.getConfirmedProducersWithInconsistencState(e.producersWithInconsistentState),peersWithInconsistentAppData:this.getConfirmedPeersWithInconsistentAppData(e.missingPeers)})}collectProbableInconsistencyCases(e){return u(this,void 0,void 0,(function*(){const t=new Ba({remoteState:e,localState:this.getLocalState()}).check();if(this.rotateLastProbableInconsistencyCheckResults(t),!t.hasInconsistencyCases())return;if(this.isBadNetworkScore())return void this.resetLastProbableInconsistencyCheckResults();(yield this.getIsConnectionActive())&&this.callState.isJoined&&this.network.isNetworkActive||this.resetLastProbableInconsistencyCheckResults()}))}resetLastProbableInconsistencyCheckResults(){p(this,qa,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===l(this,qa,"f").length&&l(this,qa,"f").shift(),l(this,qa,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return l(this,qa,"f").forEach((r=>{r[e].includes(t)&&(n+=1)})),n>=r}getConfirmedMissingPeers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingPeers",e)))}getConfirmedMissingProducers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingProducers",e)))}getConfirmedConsumersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("consumersWithInconsistentState",e,1)))}getConfirmedProducersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("producersWithInconsistentState",e)))}getConfirmedPeersWithInconsistentAppData(e){return e.filter((e=>this.isReachedMaxCheckRetries("peersWithInconsistentAppData",e)))}getLocalState(){return{peers:this.peersStorage.hosts().map((e=>({id:e.id,appDataHash:ja(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused,stateChangedAt:e.getStateChangedAt()}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){return u(this,void 0,void 0,(function*(){var e;try{if(this.network.checkSocketConnectionActivity(),!this.network.isNetworkActive)return!1;const{success:t}=yield null===(e=this.socket.connection)||void 0===e?void 0:e.timeout(1e3).emitWithAck(Pr,{});return t}catch(e){return!1}}))}listenNetworkScoresUpdatedEvents(){l(this,Wa,"f")&&l(this,Wa,"f").on(Ct.NetworkScoresUpdated,(e=>{e.inbound&&(l(this,Ga,"f").inbound=e.inbound),e.outbound&&(l(this,Ga,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=l(this,Ga,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new Ua({missingPeers:e.missingPeers.filter((e=>!t.missingPeers.includes(e))),missingProducers:e.missingProducers.filter((e=>!t.missingProducers.includes(e))),consumersWithInconsistentState:e.consumersWithInconsistentState.filter((e=>!t.fixedConsumersState.includes(e))),producersWithInconsistentState:e.producersWithInconsistentState.filter((e=>!t.fixedProducersState.includes(e))),peersWithInconsistentAppData:e.peersWithInconsistentAppData.filter((e=>!t.restoredAppDataPeers.includes(e)))})}isRestoreStateRequestToEarly(){return(new Date).getTime()-l(this,Ya,"f")<=15e3}};Ha=new WeakMap,Wa=new WeakMap,qa=new WeakMap,za=new WeakMap,Ga=new WeakMap,Ya=new WeakMap,$a=a([ut(),c(0,pt(Gn.LoggerFactory)),c(1,pt(Gn.Network)),c(2,pt(Gn.CallState)),c(3,pt(Gn.SocketIO)),c(4,pt(Gn.PeersStorage)),c(5,pt(Gn.ClientEventEmitter)),c(6,pt(Gn.WebRTCIssueDetector)),d("design:paramtypes",[Function,Ma,Qn,fa,Sa,Dt,dr])],$a);var Ka=$a,Ja={},Qa={exports:{}},Za=1e3,Xa=6e4,ec=60*Xa,tc=24*ec,rc=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*tc;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ec;case"minutes":case"minute":case"mins":case"min":case"m":return r*Xa;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=tc)return nc(e,t,tc,"day");if(t>=ec)return nc(e,t,ec,"hour");if(t>=Xa)return nc(e,t,Xa,"minute");if(t>=1e3)return nc(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=tc)return Math.round(e/tc)+"d";if(t>=ec)return Math.round(e/ec)+"h";if(t>=Xa)return Math.round(e/Xa)+"m";if(t>=Za)return Math.round(e/Za)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function nc(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var ic=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=rc,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ic(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Qa,Qa.exports);var sc={},oc={},ac={exports:{}};!function(e,t){!function(r,n){var i,s="user-agent",o="",a="function",c="undefined",d="object",u="string",l="browser",p="cpu",h="device",f="engine",m="os",g="result",v="name",y="type",_="vendor",b="version",w="architecture",S="major",E="model",C="console",R="mobile",P="tablet",T="smarttv",k="wearable",D="xr",I="embedded",O="inapp",A="brands",L="formFactors",M="fullVersionList",N="platform",x="platformVersion",F="bitness",j="sec-ch-ua",U="sec-ch-ua-platform",B=[A,M,R,E,N,x,w,L,F],V="Amazon",H="Apple",W="ASUS",q="BlackBerry",z="Google",G="Huawei",Y="Lenovo",$="Honor",K="LG",J="Microsoft",Q="Motorola",Z="Nvidia",X="OnePlus",ee="OPPO",te="Samsung",re="Sharp",ne="Sony",ie="Xiaomi",se="Zebra",oe="Chromium",ae="Chromecast",ce="Opera",de="Facebook",ue="Windows",le=typeof r!==c,pe=le&&r.navigator?r.navigator:n,he=pe&&pe.userAgentData?pe.userAgentData:n,fe=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},me=function(e,t){if(typeof e===d&&e.length>0){for(var r in e)if(_e(e[r])==_e(t))return!0;return!1}return!!ve(e)&&-1!==_e(t).indexOf(_e(e))},ge=function(e,t){for(var r in e)return/^(browser|cpu|device|engine|os)$/.test(r)||!!t&&ge(e[r])},ve=function(e){return typeof e===u},ye=function(e){if(!e)return n;for(var t=[],r=Se(/\\?\"/g,e).split(","),i=0;i<r.length;i++)if(r[i].indexOf(";")>-1){var s=Ce(r[i]).split(";v=");t[i]={brand:s[0],version:s[1]}}else t[i]=Ce(r[i]);return t},_e=function(e){return ve(e)?e.toLowerCase():e},be=function(e){return ve(e)?Se(/[^\d\.]/g,e).split(".")[0]:n},we=function(e){for(var t in e){var r=e[t];typeof r==d&&2==r.length?this[r[0]]=r[1]:this[r]=n}return this},Se=function(e,t){return ve(t)?t.replace(e,o):t},Ee=function(e){return Se(/\\?\"/g,e)},Ce=function(e,t){if(ve(e))return e=Se(/^\s\s*/,e),typeof t===c?e:e.substring(0,500)},Re=function(e,t){if(e&&t)for(var r,i,s,o,c,u,l=0;l<t.length&&!c;){var p=t[l],h=t[l+1];for(r=i=0;r<p.length&&!c&&p[r];)if(c=p[r++].exec(e))for(s=0;s<h.length;s++)u=c[++i],typeof(o=h[s])===d&&o.length>0?2===o.length?typeof o[1]==a?this[o[0]]=o[1].call(this,u):this[o[0]]=o[1]:3===o.length?typeof o[1]!==a||o[1].exec&&o[1].test?this[o[0]]=u?u.replace(o[1],o[2]):n:this[o[0]]=u?o[1].call(this,u,o[2]):n:4===o.length&&(this[o[0]]=u?o[3].call(this,u.replace(o[1],o[2])):n):this[o]=u||n;l+=2}},Pe=function(e,t){for(var r in t)if(typeof t[r]===d&&t[r].length>0){for(var i=0;i<t[r].length;i++)if(me(t[r][i],e))return"?"===r?n:r}else if(me(t[r],e))return"?"===r?n:r;return t.hasOwnProperty("*")?t["*"]:e},Te={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},ke={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":n},De={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[b,[v,"Mobile Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[b,[v,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[v,b],[/opios[\/ ]+([\w\.]+)/i],[b,[v,"Opera Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[b,[v,"Opera GX"]],[/\bopr\/([\w\.]+)/i],[b,[v,ce]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[b,[v,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[b,[v,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:lg |qute)browser)\/([-\w\.]+)/i,/(heytap|ovi|115|surf)browser\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[v,b],[/quark(?:pc)?\/([-\w\.]+)/i],[b,[v,"Quark"]],[/\bddg\/([\w\.]+)/i],[b,[v,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[b,[v,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[b,[v,"WeChat"]],[/konqueror\/([\w\.]+)/i],[b,[v,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[b,[v,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[b,[v,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[b,[v,"Smart Lenovo Browser"]],[/(avast|avg)\/([\w\.]+)/i],[[v,/(.+)/,"$1 Secure Browser"],b],[/\bfocus\/([\w\.]+)/i],[b,[v,"Firefox Focus"]],[/\bopt\/([\w\.]+)/i],[b,[v,"Opera Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[b,[v,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[b,[v,"Dolphin"]],[/coast\/([\w\.]+)/i],[b,[v,"Opera Coast"]],[/miuibrowser\/([\w\.]+)/i],[b,[v,"MIUI Browser"]],[/fxios\/([\w\.-]+)/i],[b,[v,"Mobile Firefox"]],[/\bqihoobrowser\/?([\w\.]*)/i],[b,[v,"360"]],[/\b(qq)\/([\w\.]+)/i],[[v,/(.+)/,"$1Browser"],b],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[v,/(.+)/,"$1 Browser"],b],[/samsungbrowser\/([\w\.]+)/i],[b,[v,"Samsung Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[b,[v,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[v,"Sogou Mobile"],b],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[v,b],[/(lbbrowser|rekonq)/i],[v],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[b,v],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[v,de],b,[y,O]],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat)[\/ ]([-\w\.]+)/i],[v,b,[y,O]],[/\bgsa\/([\w\.]+) .*safari\//i],[b,[v,"GSA"],[y,O]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[b,[v,"TikTok"],[y,O]],[/\[(linkedin)app\]/i],[v,[y,O]],[/(chromium)[\/ ]([-\w\.]+)/i],[v,b],[/headlesschrome(?:\/([\w\.]+)| )/i],[b,[v,"Chrome Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[v,"Chrome WebView"],b],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[b,[v,"Android Browser"]],[/chrome\/([\w\.]+) mobile/i],[b,[v,"Mobile Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[v,b],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[b,[v,"Mobile Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[v,"Mobile Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[b,v],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[v,[b,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[v,b],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[v,"Mobile Firefox"],b],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[v,"Netscape"],b],[/(wolvic|librewolf)\/([\w\.]+)/i],[v,b],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[b,[v,"Firefox Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[v,[b,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[v,[b,/[^\d\.]+./,o]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[w,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[w,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[w,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[w,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[w,"arm"]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[w,/ower/,o,_e]],[/ sun4\w[;\)]/i],[[w,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[w,_e]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[E,[_,te],[y,P]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[E,[_,te],[y,R]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[E,[_,H],[y,R]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[E,[_,H],[y,P]],[/(macintosh);/i],[E,[_,H]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[E,[_,re],[y,R]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[E,[_,$],[y,P]],[/honor([-\w ]+)[;\)]/i],[E,[_,$],[y,R]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[E,[_,G],[y,P]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[E,[_,G],[y,R]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[E,/_/g," "],[_,ie],[y,P]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[E,/_/g," "],[_,ie],[y,R]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[E,[_,ee],[y,R]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[E,[_,Pe,{OnePlus:["304","403","203"],"*":ee}],[y,P]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[E,[_,"BLU"],[y,R]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[E,[_,"Vivo"],[y,R]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[E,[_,"Realme"],[y,R]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto(?! 360)[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[E,[_,Q],[y,R]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[E,[_,Q],[y,P]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[E,[_,K],[y,P]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch))(\w+)/i,/\blg-?([\d\w]+) bui/i],[E,[_,K],[y,R]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[E,[_,Y],[y,P]],[/(nokia) (t[12][01])/i],[_,E,[y,P]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[E,/_/g," "],[y,R],[_,"Nokia"]],[/(pixel (c|tablet))\b/i],[E,[_,z],[y,P]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[E,[_,z],[y,R]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[E,[_,ne],[y,R]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[E,"Xperia Tablet"],[_,ne],[y,P]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[E,[_,X],[y,R]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[E,[_,V],[y,P]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[E,/(.+)/g,"Fire Phone $1"],[_,V],[y,R]],[/(playbook);[-\w\),; ]+(rim)/i],[E,_,[y,P]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[E,[_,q],[y,R]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[E,[_,W],[y,P]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[E,[_,W],[y,R]],[/(nexus 9)/i],[E,[_,"HTC"],[y,P]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[_,[E,/_/g," "],[y,R]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[E,[_,"TCL"],[y,P]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[E,[_,"TCL"],[y,R]],[/(itel) ((\w+))/i],[[_,_e],E,[y,Pe,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[E,[_,"Acer"],[y,P]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[E,[_,"Meizu"],[y,R]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[E,[_,"Ulefone"],[y,R]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[E,[_,"Energizer"],[y,R]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[E,[_,"Cat"],[y,R]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[E,[_,"Smartfren"],[y,R]],[/droid.+; (a(?:015|06[35]|142p?))/i],[E,[_,"Nothing"],[y,R]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[E,[_,"Archos"],[y,P]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[E,[_,"Archos"],[y,R]],[/(imo) (tab \w+)/i,/(infinix) (x1101b?)/i],[_,E,[y,P]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|tcl)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,/(oppo) ?([\w ]+) bui/i],[_,E,[y,R]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[_,E,[y,P]],[/(surface duo)/i],[E,[_,J],[y,P]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[E,[_,"Fairphone"],[y,R]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[E,[_,Z],[y,P]],[/(sprint) (\w+)/i],[_,E,[y,R]],[/(kin\.[onetw]{3})/i],[[E,/\./g," "],[_,J],[y,R]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[E,[_,se],[y,P]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[E,[_,se],[y,R]],[/smart-tv.+(samsung)/i],[_,[y,T]],[/hbbtv.+maple;(\d+)/i],[[E,/^/,"SmartTV"],[_,te],[y,T]],[/tcast.+(lg)e?. ([-\w]+)/i],[_,E,[y,T]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[_,K],[y,T]],[/(apple) ?tv/i],[_,[E,"Apple TV"],[y,T]],[/crkey.*devicetype\/chromecast/i],[[E,"Chromecast Third Generation"],[_,z],[y,T]],[/crkey.*devicetype\/([^/]*)/i],[[E,/^/,"Chromecast "],[_,z],[y,T]],[/fuchsia.*crkey/i],[[E,"Chromecast Nest Hub"],[_,z],[y,T]],[/crkey/i],[[E,ae],[_,z],[y,T]],[/(portaltv)/i],[E,[_,de],[y,T]],[/droid.+aft(\w+)( bui|\))/i],[E,[_,V],[y,T]],[/(shield \w+ tv)/i],[E,[_,Z],[y,T]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[E,[_,re],[y,T]],[/(bravia[\w ]+)( bui|\))/i],[E,[_,ne],[y,T]],[/(mi(tv|box)-?\w+) bui/i],[E,[_,ie],[y,T]],[/Hbbtv.*(technisat) (.*);/i],[_,E,[y,T]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[_,Ce],[E,Ce],[y,T]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[E,[y,T]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[y,T]],[/(ouya)/i,/(nintendo) (\w+)/i],[_,E,[y,C]],[/droid.+; (shield)( bui|\))/i],[E,[_,Z],[y,C]],[/(playstation \w+)/i],[E,[_,ne],[y,C]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[E,[_,J],[y,C]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[E,[_,te],[y,k]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[_,E,[y,k]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[E,[_,ee],[y,k]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[E,[_,H],[y,k]],[/(opwwe\d{3})/i],[E,[_,X],[y,k]],[/(moto 360)/i],[E,[_,Q],[y,k]],[/(smartwatch 3)/i],[E,[_,ne],[y,k]],[/(g watch r)/i],[E,[_,K],[y,k]],[/droid.+; (wt63?0{2,3})\)/i],[E,[_,se],[y,k]],[/droid.+; (glass) \d/i],[E,[_,z],[y,D]],[/(pico) (4|neo3(?: link|pro)?)/i],[_,E,[y,D]],[/(quest( \d| pro)?s?).+vr/i],[E,[_,de],[y,D]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[_,[y,I]],[/(aeobc)\b/i],[E,[_,V],[y,I]],[/(homepod).+mac os/i],[E,[_,H],[y,I]],[/windows iot/i],[[y,I]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i],[E,[y,Pe,{mobile:"Mobile",xr:"VR","*":P}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[y,P]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[y,R]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[E,[_,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[b,[v,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[v,b],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[b,[v,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[v,b],[/ladybird\//i],[[v,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[b,v]],os:[[/microsoft (windows) (vista|xp)/i],[v,b],[/(windows (?:phone(?: os)?|mobile|iot))[\/ ]?([\d\.\w ]*)/i],[v,[b,Pe,Te]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[b,Pe,Te],[v,ue]],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[b,/_/g,"."],[v,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[v,"macOS"],[b,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[b,[v,"Chromecast Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[b,[v,"Chromecast Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[b,[v,"Chromecast SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[b,[v,"Chromecast Linux"]],[/crkey\/([\d\.]+)/i],[b,[v,ae]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[b,v],[/(ubuntu) ([\w\.]+) like android/i],[[v,/(.+)/,"$1 Touch"],b],[/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen|webos)\w*[-\/\.; ]?([\d\.]*)/i],[v,b],[/\(bb(10);/i],[b,[v,q]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[b,[v,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[b,[v,"Firefox OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[b,[v,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[b,[v,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[v,"Chrome OS"],b],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux)(?: arm\w*| x86\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[v,b],[/(sunos) ?([\w\.\d]*)/i],[[v,"Solaris"],b],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[v,b]]},Ie=(we.call((i={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[l,[v,b,S,y]],[p,[w]],[h,[y,E,_]],[f,[v,b]],[m,[v,b]]]),we.call(i.isIgnore,[[l,[b,S]],[f,[b]],[m,[b]]]),we.call(i.isIgnoreRgx,[[l,/ ?browser$/i],[m,/ ?os$/i]]),we.call(i.toString,[[l,[v,b]],[p,[w]],[h,[_,E]],[f,[v,b]],[m,[v,b]]]),i),Oe=function(e,t){var r=Ie.init[t],n=Ie.isIgnore[t]||0,i=Ie.isIgnoreRgx[t]||0,s=Ie.toString[t]||0;function a(){we.call(this,r)}return a.prototype.getItem=function(){return e},a.prototype.withClientHints=function(){return he?he.getHighEntropyValues(B).then((function(t){return e.setCH(new Ae(t,!1)).parseCH().get()})):e.parseCH().get()},a.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=g&&(a.prototype.is=function(e){var t=!1;for(var r in this)if(this.hasOwnProperty(r)&&!me(n,r)&&_e(i?Se(i,this[r]):this[r])==_e(i?Se(i,e):e)){if(t=!0,e!=c)break}else if(e==c&&t){t=!t;break}return t},a.prototype.toString=function(){var e=o;for(var t in s)typeof this[s[t]]!==c&&(e+=(e?" ":o)+this[s[t]]);return e||c}),he||(a.prototype.then=function(e){var t=this,r=function(){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])};r.prototype={is:a.prototype.is,toString:a.prototype.toString};var n=new r;return e(n),n}),new a};function Ae(e,t){if(e=e||{},we.call(this,B),t)we.call(this,[[A,ye(e[j])],[M,ye(e["sec-ch-ua-full-version-list"])],[R,/\?1/.test(e["sec-ch-ua-mobile"])],[E,Ee(e["sec-ch-ua-model"])],[N,Ee(e[U])],[x,Ee(e["sec-ch-ua-platform-version"])],[w,Ee(e["sec-ch-ua-arch"])],[L,ye(e["sec-ch-ua-form-factors"])],[F,Ee(e["sec-ch-ua-bitness"])]]);else for(var r in e)this.hasOwnProperty(r)&&typeof e[r]!==c&&(this[r]=e[r])}function Le(e,t,r,i){return this.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:n:this.data},this.set=function(e,t){return this.data[e]=t,this},this.setCH=function(e){return this.uaCH=e,this},this.detectFeature=function(){if(pe&&pe.userAgent==this.ua)switch(this.itemType){case l:pe.brave&&typeof pe.brave.isBrave==a&&this.set(v,"Brave");break;case h:!this.get(y)&&he&&he.mobile&&this.set(y,R),"Macintosh"==this.get(E)&&pe&&typeof pe.standalone!==c&&pe.maxTouchPoints&&pe.maxTouchPoints>2&&this.set(E,"iPad").set(y,P);break;case m:!this.get(v)&&he&&he.platform&&this.set(v,he.platform);break;case g:var e=this.data,t=function(t){return e[t].getItem().detectFeature().get()};this.set(l,t(l)).set(p,t(p)).set(h,t(h)).set(f,t(f)).set(m,t(m))}return this},this.parseUA=function(){return this.itemType!=g&&Re.call(this.data,this.ua,this.rgxMap),this.itemType==l&&this.set(S,be(this.get(b))),this},this.parseCH=function(){var e=this.uaCH,t=this.rgxMap;switch(this.itemType){case l:case f:var r,i=e[M]||e.brands;if(i)for(var s in i){var o=i[s].brand||i[s],a=i[s].version;this.itemType!=l||/not.a.brand/i.test(o)||r&&(!/chrom/i.test(r)||o==oe)||(o=Pe(o,{Chrome:"Google Chrome",Edge:"Microsoft Edge","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome","Huawei Browser":"HuaweiBrowser","MIUI Browser":"Miui Browser","Opera Mobi":"OperaMobile",Yandex:"YaBrowser"}),this.set(v,o).set(b,a).set(S,be(a)),r=o),this.itemType==f&&o==oe&&this.set(b,a)}break;case p:var c=e.architecture;c&&(c&&"64"==e.bitness&&(c+="64"),Re.call(this.data,c+";",t));break;case h:if(e.mobile&&this.set(y,R),e.model&&(this.set(E,e.model),!this.get(y)||!this.get(_))){var d={};Re.call(d,"droid 9; "+e.model+")",t),!this.get(y)&&d.type&&this.set(y,d.type),!this.get(_)&&d.vendor&&this.set(_,d.vendor)}if(e.formFactors){var u;if("string"!=typeof e.formFactors)for(var w=0;!u&&w<e.formFactors.length;)u=Pe(e.formFactors[w++],ke);else u=Pe(e.formFactors,ke);this.set(y,u)}break;case m:var C=e.platform;if(C){var P=e[x];C==ue&&(P=parseInt(be(P),10)>=13?"11":"10"),this.set(v,C).set(b,P)}this.get(v)==ue&&"Xbox"==e.model&&this.set(v,"Xbox").set(b,n);break;case g:var T=this.data,k=function(t){return T[t].getItem().setCH(e).parseCH().get()};this.set(l,k(l)).set(p,k(p)).set(h,k(h)).set(f,k(f)).set(m,k(m))}return this},we.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",r],["data",Oe(this,e)]]),this}function Me(e,t,r){if(typeof e===d?(ge(e,!0)?(typeof t===d&&(r=t),t=e):(r=e,t=n),e=n):typeof e!==u||ge(t,!0)||(r=t,t=n),r&&typeof r.append===a){var i={};r.forEach((function(e,t){i[t]=e})),r=i}if(!(this instanceof Me))return new Me(e,t,r).getResult();var c=typeof e===u?e:r&&r[s]?r[s]:pe&&pe.userAgent?pe.userAgent:o,v=new Ae(r,!0),y=t?function(e,t){var r={},n=t;if(!ge(t))for(var i in n={},t)for(var s in t[i])n[s]=t[i][s].concat(n[s]?n[s]:[]);for(var o in e)r[o]=n[o]&&n[o].length%2==0?n[o].concat(e[o]):e[o];return r}(De,t):De,_=function(e){return e==g?function(){return new Le(e,c,y,v).set("ua",c).set(l,this.getBrowser()).set(p,this.getCPU()).set(h,this.getDevice()).set(f,this.getEngine()).set(m,this.getOS()).get()}:function(){return new Le(e,c,y[e],v).parseUA().get()}};return we.call(this,[["getBrowser",_(l)],["getCPU",_(p)],["getDevice",_(h)],["getEngine",_(f)],["getOS",_(m)],["getResult",_(g)],["getUA",function(){return c}],["setUA",function(e){return ve(e)&&(c=e.length>500?Ce(e,500):e),this}]]).setUA(c),this}Me.VERSION="2.0.3",Me.BROWSER=fe([v,b,S,y]),Me.CPU=fe([w]),Me.DEVICE=fe([E,_,y,C,R,T,P,k,I]),Me.ENGINE=Me.OS=fe([v,b]),e.exports&&(t=e.exports=Me),t.UAParser=Me;var Ne=le&&(r.jQuery||r.Zepto);if(Ne&&!Ne.ua){var xe=new Me;Ne.ua=xe.getResult(),Ne.ua.get=function(){return xe.getUA()},Ne.ua.set=function(e){xe.setUA(e);var t=xe.getResult();for(var r in t)Ne.ua[r]=t[r]}}}("object"==typeof window?window:f)}(ac,ac.exports);var cc={};Object.defineProperty(cc,"__esModule",{value:!0}),cc.Logger=void 0;const dc=Qa.exports,uc="mediasoup-client";cc.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=(0,dc.default)(`${uc}:${e}`),this._warn=(0,dc.default)(`${uc}:WARN:${e}`),this._error=(0,dc.default)(`${uc}:ERROR:${e}`)):(this._debug=(0,dc.default)(uc),this._warn=(0,dc.default)(`${uc}:WARN`),this._error=(0,dc.default)(`${uc}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};var lc,pc={},hc={exports:{}},fc="object"==typeof Reflect?Reflect:null,mc=fc&&"function"==typeof fc.apply?fc.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};lc=fc&&"function"==typeof fc.ownKeys?fc.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var gc=Number.isNaN||function(e){return e!=e};function vc(){vc.init.call(this)}hc.exports=vc,hc.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}Tc(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Tc(e,"error",t,r)}(e,i,{once:!0})}))},vc.EventEmitter=vc,vc.prototype._events=void 0,vc.prototype._eventsCount=0,vc.prototype._maxListeners=void 0;var yc=10;function _c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function bc(e){return void 0===e._maxListeners?vc.defaultMaxListeners:e._maxListeners}function wc(e,t,r,n){var i,s,o,a;if(_c(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=bc(e))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function Sc(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ec(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Sc.bind(n);return i.listener=r,n.wrapFn=i,i}function Cc(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):Pc(i,i.length)}function Rc(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function Pc(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function Tc(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){n.once&&e.removeEventListener(t,i),r(s)}))}}Object.defineProperty(vc,"defaultMaxListeners",{enumerable:!0,get:function(){return yc},set:function(e){if("number"!=typeof e||e<0||gc(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");yc=e}}),vc.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},vc.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||gc(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},vc.prototype.getMaxListeners=function(){return bc(this)},vc.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)mc(a,this,t);else{var c=a.length,d=Pc(a,c);for(r=0;r<c;++r)mc(d[r],this,t)}return!0},vc.prototype.addListener=function(e,t){return wc(this,e,t,!1)},vc.prototype.on=vc.prototype.addListener,vc.prototype.prependListener=function(e,t){return wc(this,e,t,!0)},vc.prototype.once=function(e,t){return _c(t),this.on(e,Ec(this,e,t)),this},vc.prototype.prependOnceListener=function(e,t){return _c(t),this.prependListener(e,Ec(this,e,t)),this},vc.prototype.removeListener=function(e,t){var r,n,i,s,o;if(_c(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},vc.prototype.off=vc.prototype.removeListener,vc.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},vc.prototype.listeners=function(e){return Cc(this,e,!0)},vc.prototype.rawListeners=function(e){return Cc(this,e,!1)},vc.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Rc.call(e,t)},vc.prototype.listenerCount=Rc,vc.prototype.eventNames=function(){return this._eventsCount>0?lc(this._events):[]},Object.defineProperty(pc,"__esModule",{value:!0}),pc.EnhancedEventEmitter=void 0;const kc=hc.exports,Dc=new cc.Logger("EnhancedEventEmitter");class Ic extends kc.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){Dc.error("safeEmit() | event listener threw an error [eventName:%s]:%o",e,t);try{super.emit("listenererror",e,t)}catch(e){}return Boolean(super.listenerCount(e))}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}pc.EnhancedEventEmitter=Ic;var Oc={};Object.defineProperty(Oc,"__esModule",{value:!0}),Oc.InvalidStateError=Oc.UnsupportedError=void 0;class Ac extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,Ac):this.stack=new Error(e).stack}}Oc.UnsupportedError=Ac;class Lc extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,Lc):this.stack=new Error(e).stack}}Oc.InvalidStateError=Lc;var Mc={};Object.defineProperty(Mc,"__esModule",{value:!0}),Mc.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Mc.generateRandomNumber=function(){return Math.round(1e7*Math.random())},Mc.deepFreeze=function e(t){const r=Reflect.ownKeys(t);for(const n of r){const r=t[n];(r&&"object"==typeof r||"function"==typeof r)&&e(r)}return Object.freeze(t)};var Nc={},xc={},Fc={},jc={exports:{}};var Uc=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=rc,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Uc(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(jc,jc.exports);var Bc=f&&f.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fc,"__esModule",{value:!0}),Fc.Logger=void 0;const Vc=Bc(jc.exports),Hc="h264-profile-level-id";Fc.Logger=class{constructor(e){e?(this._debug=(0,Vc.default)(`${Hc}:${e}`),this._warn=(0,Vc.default)(`${Hc}:WARN:${e}`),this._error=(0,Vc.default)(`${Hc}:ERROR:${e}`)):(this._debug=(0,Vc.default)(Hc),this._warn=(0,Vc.default)(`${Hc}:WARN`),this._error=(0,Vc.default)(`${Hc}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Object.defineProperty(xc,"__esModule",{value:!0}),xc.ProfileLevelId=xc.Level=xc.Profile=void 0,xc.parseProfileLevelId=Zc,xc.profileLevelIdToString=Xc,xc.profileToString=function(e){switch(e){case qc.ConstrainedBaseline:return"ConstrainedBaseline";case qc.Baseline:return"Baseline";case qc.Main:return"Main";case qc.ConstrainedHigh:return"ConstrainedHigh";case qc.High:return"High";case qc.PredictiveHigh444:return"PredictiveHigh444";default:return void Wc.warn(`profileToString() | unrecognized profile ${e}`)}},xc.levelToString=function(e){switch(e){case zc.L1_b:return"1b";case zc.L1:return"1";case zc.L1_1:return"1.1";case zc.L1_2:return"1.2";case zc.L1_3:return"1.3";case zc.L2:return"2";case zc.L2_1:return"2.1";case zc.L2_2:return"2.2";case zc.L3:return"3";case zc.L3_1:return"3.1";case zc.L3_2:return"3.2";case zc.L4:return"4";case zc.L4_1:return"4.1";case zc.L4_2:return"4.2";case zc.L5:return"5";case zc.L5_1:return"5.1";case zc.L5_2:return"5.2";default:return void Wc.warn(`levelToString() | unrecognized level ${e}`)}},xc.parseSdpProfileLevelId=ed,xc.isSameProfile=function(e={},t={}){const r=ed(e),n=ed(t);return Boolean(r&&n&&r.profile===n.profile)},xc.isSameProfileAndLevel=function(e={},t={}){const r=ed(e),n=ed(t);return Boolean(r&&n&&r.profile===n.profile&&r.level==n.level)},xc.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void Wc.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=ed(e),n=ed(t);if(!r)throw new TypeError("invalid local_profile_level_id");if(!n)throw new TypeError("invalid remote_profile_level_id");if(r.profile!==n.profile)throw new TypeError("H264 Profile mismatch");const i=rd(e)&&rd(t),s=r.level,o=n.level,a=function(e,t){return function(e,t){if(e===zc.L1_b)return t!==zc.L1&&t!==zc.L1_b;if(t===zc.L1_b)return e!==zc.L1;return e<t}(e,t)?e:t}(s,o),c=i?s:a;return Wc.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${c}]`),Xc(new Gc(r.profile,c))},xc.supportedLevel=function(e,t){for(let r=Qc.length-1;r>=0;--r){const n=Qc[r];if(256*n.max_macroblock_frame_size<=e&&n.max_macroblocks_per_second<=t*n.max_macroblock_frame_size)return Wc.debug(`supportedLevel() | result [max_frame_pixel_count:${e}, max_fps:${t}, level:${n.level}]`),n.level}return void Wc.warn(`supportedLevel() | no level supported [max_frame_pixel_count:${e}, max_fps:${t}]`)};const Wc=new Fc.Logger;var qc,zc;!function(e){e[e.ConstrainedBaseline=1]="ConstrainedBaseline",e[e.Baseline=2]="Baseline",e[e.Main=3]="Main",e[e.ConstrainedHigh=4]="ConstrainedHigh",e[e.High=5]="High",e[e.PredictiveHigh444=6]="PredictiveHigh444"}(qc||(xc.Profile=qc={})),function(e){e[e.L1_b=0]="L1_b",e[e.L1=10]="L1",e[e.L1_1=11]="L1_1",e[e.L1_2=12]="L1_2",e[e.L1_3=13]="L1_3",e[e.L2=20]="L2",e[e.L2_1=21]="L2_1",e[e.L2_2=22]="L2_2",e[e.L3=30]="L3",e[e.L3_1=31]="L3_1",e[e.L3_2=32]="L3_2",e[e.L4=40]="L4",e[e.L4_1=41]="L4_1",e[e.L4_2=42]="L4_2",e[e.L5=50]="L5",e[e.L5_1=51]="L5_1",e[e.L5_2=52]="L5_2"}(zc||(xc.Level=zc={}));class Gc{constructor(e,t){this.profile=e,this.level=t}}xc.ProfileLevelId=Gc;const Yc=new Gc(qc.ConstrainedBaseline,zc.L3_1);class $c{constructor(e){this.mask=~td("x",e),this.masked_value=td("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class Kc{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const Jc=[new Kc(66,new $c("x1xx0000"),qc.ConstrainedBaseline),new Kc(77,new $c("1xxx0000"),qc.ConstrainedBaseline),new Kc(88,new $c("11xx0000"),qc.ConstrainedBaseline),new Kc(66,new $c("x0xx0000"),qc.Baseline),new Kc(88,new $c("10xx0000"),qc.Baseline),new Kc(77,new $c("0x0x0000"),qc.Main),new Kc(100,new $c("00000000"),qc.High),new Kc(100,new $c("00001100"),qc.ConstrainedHigh),new Kc(244,new $c("00000000"),qc.PredictiveHigh444)],Qc=[{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:zc.L1},{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:zc.L1_b},{max_macroblocks_per_second:3e3,max_macroblock_frame_size:396,level:zc.L1_1},{max_macroblocks_per_second:6e3,max_macroblock_frame_size:396,level:zc.L1_2},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:zc.L1_3},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:zc.L2},{max_macroblocks_per_second:19800,max_macroblock_frame_size:792,level:zc.L2_1},{max_macroblocks_per_second:20250,max_macroblock_frame_size:1620,level:zc.L2_2},{max_macroblocks_per_second:40500,max_macroblock_frame_size:1620,level:zc.L3},{max_macroblocks_per_second:108e3,max_macroblock_frame_size:3600,level:zc.L3_1},{max_macroblocks_per_second:216e3,max_macroblock_frame_size:5120,level:zc.L3_2},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:zc.L4},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:zc.L4_1},{max_macroblocks_per_second:522240,max_macroblock_frame_size:8704,level:zc.L4_2},{max_macroblocks_per_second:589824,max_macroblock_frame_size:22080,level:zc.L5},{max_macroblocks_per_second:983040,max_macroblock_frame_size:36864,level:zc.L5_1},{max_macroblocks_per_second:2073600,max_macroblock_frame_size:36864,level:zc.L5_2}];function Zc(e){if("string"!=typeof e||6!==e.length)return;const t=parseInt(e,16);if(0===t)return;const r=255&t,n=t>>8&255,i=t>>16&255;let s;switch(r){case zc.L1_1:s=0!=(16&n)?zc.L1_b:zc.L1_1;break;case zc.L1:case zc.L1_2:case zc.L1_3:case zc.L2:case zc.L2_1:case zc.L2_2:case zc.L3:case zc.L3_1:case zc.L3_2:case zc.L4:case zc.L4_1:case zc.L4_2:case zc.L5:case zc.L5_1:case zc.L5_2:s=r;break;default:return void Wc.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const t of Jc)if(i===t.profile_idc&&t.profile_iop.isMatch(n))return Wc.debug(`parseProfileLevelId() | result [str:${e}, profile:${t.profile}, level:${s}]`),new Gc(t.profile,s);Wc.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function Xc(e){if(e.level==zc.L1_b)switch(e.profile){case qc.ConstrainedBaseline:return"42f00b";case qc.Baseline:return"42100b";case qc.Main:return"4d100b";default:return void Wc.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case qc.ConstrainedBaseline:t="42e0";break;case qc.Baseline:t="4200";break;case qc.Main:t="4d00";break;case qc.ConstrainedHigh:t="640c";break;case qc.High:t="6400";break;case qc.PredictiveHigh444:t="f400";break;default:return void Wc.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function ed(e={}){const t=e["profile-level-id"];return t?Zc(t):Yc}function td(e,t){return Number(t[0]===e)<<7|Number(t[1]===e)<<6|Number(t[2]===e)<<5|Number(t[3]===e)<<4|Number(t[4]===e)<<3|Number(t[5]===e)<<2|Number(t[6]===e)<<1|Number(t[7]===e)<<0}function rd(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}Object.defineProperty(Nc,"__esModule",{value:!0}),Nc.validateRtpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(e.codecs&&!Array.isArray(e.codecs))throw new TypeError("caps.codecs is not an array");e.codecs||(e.codecs=[]);for(const t of e.codecs)od(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("caps.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)cd(t)},Nc.validateRtpParameters=sd,Nc.validateSctpStreamParameters=function(e){if("object"!=typeof e)throw new TypeError("params is not an object");if("number"!=typeof e.streamId)throw new TypeError("missing params.streamId");let t=!1;"boolean"==typeof e.ordered?t=!0:e.ordered=!0;if(e.maxPacketLifeTime&&"number"!=typeof e.maxPacketLifeTime)throw new TypeError("invalid params.maxPacketLifeTime");if(e.maxRetransmits&&"number"!=typeof e.maxRetransmits)throw new TypeError("invalid params.maxRetransmits");if(e.maxPacketLifeTime&&e.maxRetransmits)throw new TypeError("cannot provide both maxPacketLifeTime and maxRetransmits");if(t&&e.ordered&&(e.maxPacketLifeTime||e.maxRetransmits))throw new TypeError("cannot be ordered with maxPacketLifeTime or maxRetransmits");t||!e.maxPacketLifeTime&&!e.maxRetransmits||(e.ordered=!1);if(e.label&&"string"!=typeof e.label)throw new TypeError("invalid params.label");if(e.protocol&&"string"!=typeof e.protocol)throw new TypeError("invalid params.protocol")},Nc.validateSctpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(!e.numStreams||"object"!=typeof e.numStreams)throw new TypeError("missing caps.numStreams");!function(e){if("object"!=typeof e)throw new TypeError("numStreams is not an object");if("number"!=typeof e.OS)throw new TypeError("missing numStreams.OS");if("number"!=typeof e.MIS)throw new TypeError("missing numStreams.MIS")}(e.numStreams)},Nc.getExtendedRtpCapabilities=function(e,t,r){const n={codecs:[],headerExtensions:[]};if(r)for(const r of e.codecs??[]){if(pd(r))continue;const e=(t.codecs??[]).find((e=>hd(e,r,{strict:!0,modify:!0})));if(!e)continue;const i={mimeType:r.mimeType,kind:r.kind,clockRate:r.clockRate,channels:r.channels,localPayloadType:r.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:e.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:r.parameters,remoteParameters:e.parameters,rtcpFeedback:md(r,e)};n.codecs.push(i)}else for(const r of t.codecs??[]){if(pd(r))continue;const t=(e.codecs??[]).find((e=>hd(e,r,{strict:!0,modify:!0})));if(!t)continue;const i={mimeType:t.mimeType,kind:t.kind,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:r.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters,remoteParameters:r.parameters,rtcpFeedback:md(t,r)};n.codecs.push(i)}for(const r of n.codecs){const n=e.codecs.find((e=>pd(e)&&e.parameters.apt===r.localPayloadType)),i=t.codecs.find((e=>pd(e)&&e.parameters.apt===r.remotePayloadType));n&&i&&(r.localRtxPayloadType=n.preferredPayloadType,r.remoteRtxPayloadType=i.preferredPayloadType)}for(const r of t.headerExtensions){const t=e.headerExtensions.find((e=>fd(e,r)));if(!t)continue;const i={kind:r.kind,uri:r.uri,sendId:t.preferredId,recvId:r.preferredId,encrypt:t.preferredEncrypt,direction:"sendrecv"};switch(r.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}n.headerExtensions.push(i)}return n},Nc.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={mimeType:r.mimeType,kind:r.kind,preferredPayloadType:r.remotePayloadType,clockRate:r.clockRate,channels:r.channels,parameters:r.localParameters,rtcpFeedback:r.rtcpFeedback};if(t.codecs.push(e),!r.remoteRtxPayloadType)continue;const n={mimeType:`${r.kind}/rtx`,kind:r.kind,preferredPayloadType:r.remoteRtxPayloadType,clockRate:r.clockRate,parameters:{apt:r.remotePayloadType},rtcpFeedback:[]};t.codecs.push(n)}for(const r of e.headerExtensions){if("sendrecv"!==r.direction&&"recvonly"!==r.direction)continue;const e={kind:r.kind,uri:r.uri,preferredId:r.recvId,preferredEncrypt:r.encrypt,direction:r.direction};t.headerExtensions.push(e)}return t},Nc.getSendingRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.localParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}return r},Nc.getSendingRemoteRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.remoteParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}if(r.headerExtensions.some((e=>"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"goog-remb"!==e.type));else if(r.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type));else for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type&&"goog-remb"!==e.type));return r},Nc.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(hd(e[n],t,{strict:!0})){r.push(e[n]),pd(e[n+1])&&r.push(e[n+1]);break}if(0===r.length)throw new TypeError("no matching codec found")}else r.push(e[0]),pd(e[1])&&r.push(e[1]);return r},Nc.generateProbatorRtpParameters=function(e){sd(e=id.clone(e));const t={mid:"probator",codecs:[],headerExtensions:[],encodings:[{ssrc:1234}],rtcp:{cname:"probator"}};return t.codecs.push(e.codecs[0]),t.codecs[0].payloadType=127,t.headerExtensions=e.headerExtensions,t},Nc.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},Nc.canReceive=function(e,t){if(sd(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const nd=xc,id=Mc;function sd(e){if("object"!=typeof e)throw new TypeError("params is not an object");if(e.mid&&"string"!=typeof e.mid)throw new TypeError("params.mid is not a string");if(!Array.isArray(e.codecs))throw new TypeError("missing params.codecs");for(const t of e.codecs)dd(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("params.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)ud(t);if(e.encodings&&!Array.isArray(e.encodings))throw new TypeError("params.encodings is not an array");e.encodings||(e.encodings=[]);for(const t of e.encodings)ld(t);if(e.rtcp&&"object"!=typeof e.rtcp)throw new TypeError("params.rtcp is not an object");e.rtcp||(e.rtcp={}),function(e){if("object"!=typeof e)throw new TypeError("rtcp is not an object");if(e.cname&&"string"!=typeof e.cname)throw new TypeError("invalid rtcp.cname");e.reducedSize&&"boolean"==typeof e.reducedSize||(e.reducedSize=!0)}(e.rtcp)}function od(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if(e.kind=r[1].toLowerCase(),e.preferredPayloadType&&"number"!=typeof e.preferredPayloadType)throw new TypeError("invalid codec.preferredPayloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===e.kind?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)ad(t)}function ad(e){if("object"!=typeof e)throw new TypeError("fb is not an object");if(!e.type||"string"!=typeof e.type)throw new TypeError("missing fb.type");e.parameter&&"string"==typeof e.parameter||(e.parameter="")}function cd(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if("audio"!==e.kind&&"video"!==e.kind)throw new TypeError("invalid ext.kind");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.preferredId)throw new TypeError("missing ext.preferredId");if(e.preferredEncrypt&&"boolean"!=typeof e.preferredEncrypt)throw new TypeError("invalid ext.preferredEncrypt");if(e.preferredEncrypt||(e.preferredEncrypt=!1),e.direction&&"string"!=typeof e.direction)throw new TypeError("invalid ext.direction");e.direction||(e.direction="sendrecv")}function dd(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if("number"!=typeof e.payloadType)throw new TypeError("missing codec.payloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===r[1].toLowerCase()?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)ad(t)}function ud(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.id)throw new TypeError("missing ext.id");if(e.encrypt&&"boolean"!=typeof e.encrypt)throw new TypeError("invalid ext.encrypt");e.encrypt||(e.encrypt=!1),e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError("invalid header extension parameter")}}function ld(e){if("object"!=typeof e)throw new TypeError("encoding is not an object");if(e.ssrc&&"number"!=typeof e.ssrc)throw new TypeError("invalid encoding.ssrc");if(e.rid&&"string"!=typeof e.rid)throw new TypeError("invalid encoding.rid");if(e.rtx&&"object"!=typeof e.rtx)throw new TypeError("invalid encoding.rtx");if(e.rtx&&"number"!=typeof e.rtx.ssrc)throw new TypeError("missing encoding.rtx.ssrc");if(e.dtx&&"boolean"==typeof e.dtx||(e.dtx=!1),e.scalabilityMode&&"string"!=typeof e.scalabilityMode)throw new TypeError("invalid encoding.scalabilityMode")}function pd(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function hd(e,t,{strict:r=!1,modify:n=!1}={}){const i=e.mimeType.toLowerCase();if(i!==t.mimeType.toLowerCase())return!1;if(e.clockRate!==t.clockRate)return!1;if(e.channels!==t.channels)return!1;switch(i){case"video/h264":if(r){if((e.parameters["packetization-mode"]??0)!==(t.parameters["packetization-mode"]??0))return!1;if(!nd.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=nd.generateProfileLevelIdStringForAnswer(e.parameters,t.parameters)}catch(e){return!1}n&&(r?(e.parameters["profile-level-id"]=r,t.parameters["profile-level-id"]=r):(delete e.parameters["profile-level-id"],delete t.parameters["profile-level-id"]))}break;case"video/vp9":if(r){if((e.parameters["profile-id"]??0)!==(t.parameters["profile-id"]??0))return!1}}return!0}function fd(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function md(e,t){const r=[];for(const n of e.rtcpFeedback??[]){const e=(t.rtcpFeedback??[]).find((e=>e.type===n.type&&(e.parameter===n.parameter||!e.parameter&&!n.parameter)));e&&r.push(e)}return r}var gd={},vd={},yd={},_d={},bd={exports:{}};var wd=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=rc,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=wd(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(bd,bd.exports),Object.defineProperty(_d,"__esModule",{value:!0}),_d.Logger=void 0;const Sd=bd.exports,Ed="awaitqueue";_d.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=Sd(`awaitqueue:${e}`),this._warn=Sd(`awaitqueue:WARN:${e}`),this._error=Sd(`awaitqueue:ERROR:${e}`)):(this._debug=Sd(Ed),this._warn=Sd("awaitqueue:WARN"),this._error=Sd("awaitqueue:ERROR")),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};var Cd={};Object.defineProperty(Cd,"__esModule",{value:!0}),Cd.AwaitQueueRemovedTaskError=Cd.AwaitQueueStoppedError=void 0;class Rd extends Error{constructor(e){super(e??"queue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Rd)}}Cd.AwaitQueueStoppedError=Rd;class Pd extends Error{constructor(e){super(e??"queue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Pd)}}Cd.AwaitQueueRemovedTaskError=Pd,Object.defineProperty(yd,"__esModule",{value:!0}),yd.AwaitQueue=void 0;const Td=Cd,kd=new _d.Logger("AwaitQueue");yd.AwaitQueue=class{pendingTasks=new Map;nextTaskId=0;stopping=!1;constructor(){kd.debug("constructor()")}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,kd.debug(`push() [name:${t}]`),"function"!=typeof e)throw new TypeError("given task is not a function");if(t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={id:this.nextTaskId++,task:e,name:t,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:e=>{if(i.completed)return;i.completed=!0,this.pendingTasks.delete(i.id),kd.debug(`resolving task [name:${i.name}]`),r(e);const[t]=this.pendingTasks.values();t&&!t.executedAt&&this.execute(t)},reject:e=>{if(!i.completed&&(i.completed=!0,this.pendingTasks.delete(i.id),kd.debug(`rejecting task [name:${i.name}]: %s`,String(e)),n(e),!this.stopping)){const[e]=this.pendingTasks.values();e&&!e.executedAt&&this.execute(e)}}};this.pendingTasks.set(i.id,i),1===this.pendingTasks.size&&this.execute(i)}))}stop(){kd.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())kd.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Td.AwaitQueueStoppedError);this.stopping=!1}remove(e){kd.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new Td.AwaitQueueRemovedTaskError):kd.debug(`stop() | no task with given idx [taskIdx:${e}]`)}dump(){const e=Date.now();let t=0;return Array.from(this.pendingTasks.values()).map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt-r.enqueuedAt:e-r.enqueuedAt,executionTime:r.executedAt?e-r.executedAt:0})))}async execute(e){if(kd.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const t=await e.task();e.resolve(t)}catch(t){e.reject(t)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AwaitQueueRemovedTaskError=e.AwaitQueueStoppedError=e.AwaitQueue=void 0;var t=yd;Object.defineProperty(e,"AwaitQueue",{enumerable:!0,get:function(){return t.AwaitQueue}});var r=Cd;Object.defineProperty(e,"AwaitQueueStoppedError",{enumerable:!0,get:function(){return r.AwaitQueueStoppedError}}),Object.defineProperty(e,"AwaitQueueRemovedTaskError",{enumerable:!0,get:function(){return r.AwaitQueueRemovedTaskError}})}(vd);var Dd={};Object.defineProperty(Dd,"__esModule",{value:!0}),Dd.Producer=void 0;const Id=pc,Od=Oc,Ad=new cc.Logger("Producer");class Ld extends Id.EnhancedEventEmitter{_id;_localId;_closed=!1;_rtpSender;_track;_kind;_rtpParameters;_paused;_maxSpatialLayer;_stopTracks;_disableTrackOnPause;_zeroRtpOnPause;_appData;_observer=new Id.EnhancedEventEmitter;constructor({id:e,localId:t,rtpSender:r,track:n,rtpParameters:i,stopTracks:s,disableTrackOnPause:o,zeroRtpOnPause:a,appData:c}){super(),Ad.debug("constructor()"),this._id=e,this._localId=t,this._rtpSender=r,this._track=n,this._kind=n.kind,this._rtpParameters=i,this._paused=!!o&&!n.enabled,this._maxSpatialLayer=void 0,this._stopTracks=s,this._disableTrackOnPause=o,this._zeroRtpOnPause=a,this._appData=c??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get closed(){return this._closed}get kind(){return this._kind}get rtpSender(){return this._rtpSender}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get maxSpatialLayer(){return this._maxSpatialLayer}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Ad.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Ad.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Od.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Ad.debug("pause()"),this._closed?Ad.error("pause() | Producer closed"):(this._paused=!0,this._track&&this._disableTrackOnPause&&(this._track.enabled=!1),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@pause",e,t)})).catch((()=>{})),this._observer.safeEmit("pause"))}resume(){Ad.debug("resume()"),this._closed?Ad.error("resume() | Producer closed"):(this._paused=!1,this._track&&this._disableTrackOnPause&&(this._track.enabled=!0),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@resume",e,t)})).catch((()=>{})),this._observer.safeEmit("resume"))}async replaceTrack({track:e}){if(Ad.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new Od.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new Od.InvalidStateError("track ended");e!==this._track?(await new Promise(((t,r)=>{this.safeEmit("@replacetrack",e,t,r)})),this.destroyTrack(),this._track=e,this._track&&this._disableTrackOnPause&&(this._paused?this._paused&&(this._track.enabled=!1):this._track.enabled=!0),this.handleTrack()):Ad.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new Od.InvalidStateError("closed");if("video"!==this._kind)throw new Od.UnsupportedError("not a video Producer");if("number"!=typeof e)throw new TypeError("invalid spatialLayer");e!==this._maxSpatialLayer&&(await new Promise(((t,r)=>{this.safeEmit("@setmaxspatiallayer",e,t,r)})).catch((()=>{})),this._maxSpatialLayer=e)}async setRtpEncodingParameters(e){if(this._closed)throw new Od.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){Ad.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track&&this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){if(this._track)try{this._track.removeEventListener("ended",this.onTrackEnded),this._stopTracks&&this._track.stop()}catch(e){}}}Dd.Producer=Ld;var Md={};Object.defineProperty(Md,"__esModule",{value:!0}),Md.Consumer=void 0;const Nd=pc,xd=Oc,Fd=new cc.Logger("Consumer");class jd extends Nd.EnhancedEventEmitter{_id;_localId;_producerId;_closed=!1;_rtpReceiver;_track;_rtpParameters;_paused;_appData;_observer=new Nd.EnhancedEventEmitter;constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),Fd.debug("constructor()"),this._id=e,this._localId=t,this._producerId=r,this._rtpReceiver=n,this._track=i,this._rtpParameters=s,this._paused=!i.enabled,this._appData=o??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get producerId(){return this._producerId}get closed(){return this._closed}get kind(){return this._track.kind}get rtpReceiver(){return this._rtpReceiver}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Fd.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Fd.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new xd.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Fd.debug("pause()"),this._closed?Fd.error("pause() | Consumer closed"):this._paused?Fd.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){Fd.debug("resume()"),this._closed?Fd.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):Fd.debug("resume() | Consumer is already resumed")}onTrackEnded(){Fd.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){try{this._track.removeEventListener("ended",this.onTrackEnded),this._track.stop()}catch(e){}}}Md.Consumer=jd;var Ud={};Object.defineProperty(Ud,"__esModule",{value:!0}),Ud.DataProducer=void 0;const Bd=pc,Vd=Oc,Hd=new cc.Logger("DataProducer");class Wd extends Bd.EnhancedEventEmitter{_id;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new Bd.EnhancedEventEmitter;constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),Hd.debug("constructor()"),this._id=e,this._dataChannel=t,this._sctpStreamParameters=r,this._appData=n??{},this.handleDataChannel()}get id(){return this._id}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get bufferedAmount(){return this._dataChannel.bufferedAmount}get bufferedAmountLowThreshold(){return this._dataChannel.bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._dataChannel.bufferedAmountLowThreshold=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Hd.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Hd.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(Hd.debug("send()"),this._closed)throw new Vd.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(Hd.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?Hd.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):Hd.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(Hd.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||Hd.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}Ud.DataProducer=Wd;var qd={};Object.defineProperty(qd,"__esModule",{value:!0}),qd.DataConsumer=void 0;const zd=pc,Gd=new cc.Logger("DataConsumer");class Yd extends zd.EnhancedEventEmitter{_id;_dataProducerId;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new zd.EnhancedEventEmitter;constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),Gd.debug("constructor()"),this._id=e,this._dataProducerId=t,this._dataChannel=r,this._sctpStreamParameters=n,this._appData=i??{},this.handleDataChannel()}get id(){return this._id}get dataProducerId(){return this._dataProducerId}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get binaryType(){return this._dataChannel.binaryType}set binaryType(e){this._dataChannel.binaryType=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Gd.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Gd.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(Gd.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?Gd.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):Gd.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(Gd.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(e=>{this._closed||this.safeEmit("message",e.data)}))}}qd.DataConsumer=Yd,Object.defineProperty(gd,"__esModule",{value:!0}),gd.Transport=void 0;const $d=vd,Kd=pc,Jd=Oc,Qd=Mc,Zd=Nc,Xd=Dd,eu=Md,tu=Ud,ru=qd,nu=new cc.Logger("Transport");class iu{consumerOptions;promise;resolve;reject;constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class su extends Kd.EnhancedEventEmitter{_id;_closed=!1;_direction;_extendedRtpCapabilities;_canProduceByKind;_maxSctpMessageSize;_handler;_iceGatheringState="new";_connectionState="new";_appData;_producers=new Map;_consumers=new Map;_dataProducers=new Map;_dataConsumers=new Map;_probatorConsumerCreated=!1;_awaitQueue=new $d.AwaitQueue;_pendingConsumerTasks=[];_consumerCreationInProgress=!1;_pendingPauseConsumers=new Map;_consumerPauseInProgress=!1;_pendingResumeConsumers=new Map;_consumerResumeInProgress=!1;_pendingCloseConsumers=new Map;_consumerCloseInProgress=!1;_observer=new Kd.EnhancedEventEmitter;constructor({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u,handlerFactory:l,extendedRtpCapabilities:p,canProduceByKind:h}){super(),nu.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._extendedRtpCapabilities=p,this._canProduceByKind=h,this._maxSctpMessageSize=s?s.maxMessageSize:null;const f=Qd.clone(c)??{};delete f.iceServers,delete f.iceTransportPolicy,delete f.bundlePolicy,delete f.rtcpMuxPolicy,delete f.sdpSemantics,this._handler=l(),this._handler.run({direction:e,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:f,proprietaryConstraints:d,extendedRtpCapabilities:p}),this._appData=u??{},this.handleHandler()}get id(){return this._id}get closed(){return this._closed}get direction(){return this._direction}get handler(){return this._handler}get iceGatheringState(){return this._iceGatheringState}get connectionState(){return this._connectionState}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){if(!this._closed){nu.debug("close()"),this._closed=!0,this._awaitQueue.stop(),this._handler.close(),this._connectionState="closed";for(const e of this._producers.values())e.transportClosed();this._producers.clear();for(const e of this._consumers.values())e.transportClosed();this._consumers.clear();for(const e of this._dataProducers.values())e.transportClosed();this._dataProducers.clear();for(const e of this._dataConsumers.values())e.transportClosed();this._dataConsumers.clear(),this._observer.safeEmit("close")}}async getStats(){if(this._closed)throw new Jd.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(nu.debug("restartIce()"),this._closed)throw new Jd.InvalidStateError("closed");if(!e)throw new TypeError("missing iceParameters");return this._awaitQueue.push((async()=>await this._handler.restartIce(e)),"transport.restartIce()")}async updateIceServers({iceServers:e}={}){if(nu.debug("updateIceServers()"),this._closed)throw new Jd.InvalidStateError("closed");if(!Array.isArray(e))throw new TypeError("missing iceServers");return this._awaitQueue.push((async()=>this._handler.updateIceServers(e)),"transport.updateIceServers()")}async produce({track:e,encodings:t,codecOptions:r,codec:n,stopTracks:i=!0,disableTrackOnPause:s=!0,zeroRtpOnPause:o=!1,onRtpSender:a,appData:c={}}={}){if(nu.debug("produce() [track:%o]",e),this._closed)throw new Jd.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new Jd.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new Jd.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new Jd.InvalidStateError("track ended");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("produce"))throw new TypeError('no "produce" listener set into this transport');if(c&&"object"!=typeof c)throw new TypeError("if given, appData must be an object");return this._awaitQueue.push((async()=>{let d;if(t&&!Array.isArray(t))throw TypeError("encodings must be an array");t&&0===t.length?d=void 0:t&&(d=t.map((e=>{const t={active:!0};return!1===e.active&&(t.active=!1),"boolean"==typeof e.dtx&&(t.dtx=e.dtx),"string"==typeof e.scalabilityMode&&(t.scalabilityMode=e.scalabilityMode),"number"==typeof e.scaleResolutionDownBy&&(t.scaleResolutionDownBy=e.scaleResolutionDownBy),"number"==typeof e.maxBitrate&&(t.maxBitrate=e.maxBitrate),"number"==typeof e.maxFramerate&&(t.maxFramerate=e.maxFramerate),"boolean"==typeof e.adaptivePtime&&(t.adaptivePtime=e.adaptivePtime),"string"==typeof e.priority&&(t.priority=e.priority),"string"==typeof e.networkPriority&&(t.networkPriority=e.networkPriority),t})));const{localId:u,rtpParameters:l,rtpSender:p}=await this._handler.send({track:e,encodings:d,codecOptions:r,codec:n,onRtpSender:a});try{Zd.validateRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new Xd.Producer({id:t,localId:u,rtpSender:p,track:e,rtpParameters:l,stopTracks:i,disableTrackOnPause:s,zeroRtpOnPause:o,appData:c});return this._producers.set(r.id,r),this.handleProducer(r),this._observer.safeEmit("newproducer",r),r}catch(e){throw this._handler.stopSending(u).catch((()=>{})),e}}),"transport.produce()").catch((t=>{if(i)try{e.stop()}catch(e){}throw t}))}async consume({id:e,producerId:t,kind:r,rtpParameters:n,streamId:i,onRtpReceiver:s,appData:o={}}){if(nu.debug("consume()"),this._closed)throw new Jd.InvalidStateError("closed");if("recv"!==this._direction)throw new Jd.UnsupportedError("not a receiving Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing producerId");if("audio"!==r&&"video"!==r)throw new TypeError(`invalid kind '${r}'`);if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(o&&"object"!=typeof o)throw new TypeError("if given, appData must be an object");const a=Qd.clone(n);if(!Zd.canReceive(a,this._extendedRtpCapabilities))throw new Jd.UnsupportedError("cannot consume this Producer");const c=new iu({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),queueMicrotask((()=>{this._closed||!1===this._consumerCreationInProgress&&this.createPendingConsumers()})),c.promise}async produceData({ordered:e=!0,maxPacketLifeTime:t,maxRetransmits:r,label:n="",protocol:i="",appData:s={}}={}){if(nu.debug("produceData()"),this._closed)throw new Jd.InvalidStateError("closed");if("send"!==this._direction)throw new Jd.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new Jd.UnsupportedError("SCTP not enabled by remote Transport");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("producedata"))throw new TypeError('no "producedata" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");return(t||r)&&(e=!1),this._awaitQueue.push((async()=>{const{dataChannel:o,sctpStreamParameters:a}=await this._handler.sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i});Zd.validateSctpStreamParameters(a);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:a,label:n,protocol:i,appData:s},e,t)})),d=new tu.DataProducer({id:c,dataChannel:o,sctpStreamParameters:a,appData:s});return this._dataProducers.set(d.id,d),this.handleDataProducer(d),this._observer.safeEmit("newdataproducer",d),d}),"transport.produceData()")}async consumeData({id:e,dataProducerId:t,sctpStreamParameters:r,label:n="",protocol:i="",appData:s={}}){if(nu.debug("consumeData()"),this._closed)throw new Jd.InvalidStateError("closed");if("recv"!==this._direction)throw new Jd.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new Jd.UnsupportedError("SCTP not enabled by remote Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing dataProducerId");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");const o=Qd.clone(r);return Zd.validateSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new ru.DataConsumer({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:o,appData:s});return this._dataConsumers.set(a.id,a),this.handleDataConsumer(a),this._observer.safeEmit("newdataconsumer",a),a}),"transport.consumeData()")}createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void nu.debug("createPendingConsumers() | there is no Consumer to be created");const e=[...this._pendingConsumerTasks];let t;this._pendingConsumerTasks=[];const r=[];for(const t of e){const{id:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o}=t.consumerOptions;r.push({trackId:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o})}try{const n=await this._handler.receive(r);for(let r=0;r<n.length;++r){const i=e[r],s=n[r],{id:o,producerId:a,kind:c,rtpParameters:d,appData:u}=i.consumerOptions,{localId:l,rtpReceiver:p,track:h}=s,f=new eu.Consumer({id:o,localId:l,producerId:a,rtpReceiver:p,track:h,rtpParameters:d,appData:u});this._consumers.set(f.id,f),this.handleConsumer(f),this._probatorConsumerCreated||t||"video"!==c||(t=f),this._observer.safeEmit("newconsumer",f),i.resolve(f)}}catch(t){for(const r of e)r.reject(t)}if(t)try{const e=Zd.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),nu.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){nu.error("createPendingConsumers() | failed to create Consumer for RTP probation:%o",e)}}),"transport.createPendingConsumers()").then((()=>{this._consumerCreationInProgress=!1,this._pendingConsumerTasks.length>0&&this.createPendingConsumers()})).catch((()=>{}))}pausePendingConsumers(){this._consumerPauseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingPauseConsumers.size)return void nu.debug("pausePendingConsumers() | there is no Consumer to be paused");const e=Array.from(this._pendingPauseConsumers.values());this._pendingPauseConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.pauseReceiving(t)}catch(e){nu.error("pausePendingConsumers() | failed to pause Consumers:",e)}}),"transport.pausePendingConsumers").then((()=>{this._consumerPauseInProgress=!1,this._pendingPauseConsumers.size>0&&this.pausePendingConsumers()})).catch((()=>{}))}resumePendingConsumers(){this._consumerResumeInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingResumeConsumers.size)return void nu.debug("resumePendingConsumers() | there is no Consumer to be resumed");const e=Array.from(this._pendingResumeConsumers.values());this._pendingResumeConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.resumeReceiving(t)}catch(e){nu.error("resumePendingConsumers() | failed to resume Consumers:",e)}}),"transport.resumePendingConsumers").then((()=>{this._consumerResumeInProgress=!1,this._pendingResumeConsumers.size>0&&this.resumePendingConsumers()})).catch((()=>{}))}closePendingConsumers(){this._consumerCloseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingCloseConsumers.size)return void nu.debug("closePendingConsumers() | there is no Consumer to be closed");const e=Array.from(this._pendingCloseConsumers.values());this._pendingCloseConsumers.clear();try{await this._handler.stopReceiving(e.map((e=>e.localId)))}catch(e){nu.error("closePendingConsumers() | failed to close Consumers:",e)}}),"transport.closePendingConsumers").then((()=>{this._consumerCloseInProgress=!1,this._pendingCloseConsumers.size>0&&this.closePendingConsumers()})).catch((()=>{}))}handleHandler(){const e=this._handler;e.on("@connect",(({dtlsParameters:e},t,r)=>{this._closed?r(new Jd.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(nu.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@icecandidateerror",(e=>{nu.warn(`ICE candidate error [url:${e.url}, localAddress:${e.address}, localPort:${e.port}]: ${e.errorCode} "${e.errorText}"`),this.safeEmit("icecandidateerror",e)})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(nu.debug("connection state changed to %s",e),this._connectionState=e,this._closed||this.safeEmit("connectionstatechange",e))}))}handleProducer(e){e.on("@close",(()=>{this._producers.delete(e.id),this._closed||this._awaitQueue.push((async()=>await this._handler.stopSending(e.localId)),"producer @close event").catch((e=>nu.warn("producer.close() failed:%o",e)))})),e.on("@pause",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.pauseSending(e.localId)),"producer @pause event").then(t).catch(r)})),e.on("@resume",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.resumeSending(e.localId)),"producer @resume event").then(t).catch(r)})),e.on("@replacetrack",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.replaceTrack(e.localId,t)),"producer @replacetrack event").then(r).catch(n)})),e.on("@setmaxspatiallayer",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setMaxSpatialLayer(e.localId,t)),"producer @setmaxspatiallayer event").then(r).catch(n)})),e.on("@setrtpencodingparameters",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setRtpEncodingParameters(e.localId,t)),"producer @setrtpencodingparameters event").then(r).catch(n)})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new Jd.InvalidStateError("closed"));this._handler.getSenderStats(e.localId).then(t).catch(r)}))}handleConsumer(e){e.on("@close",(()=>{this._consumers.delete(e.id),this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.delete(e.id),this._closed||(this._pendingCloseConsumers.set(e.id,e),!1===this._consumerCloseInProgress&&this.closePendingConsumers())})),e.on("@pause",(()=>{this._pendingResumeConsumers.has(e.id)&&this._pendingResumeConsumers.delete(e.id),this._pendingPauseConsumers.set(e.id,e),queueMicrotask((()=>{this._closed||!1===this._consumerPauseInProgress&&this.pausePendingConsumers()}))})),e.on("@resume",(()=>{this._pendingPauseConsumers.has(e.id)&&this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.set(e.id,e),queueMicrotask((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new Jd.InvalidStateError("closed"));this._handler.getReceiverStats(e.localId).then(t).catch(r)}))}handleDataProducer(e){e.on("@close",(()=>{this._dataProducers.delete(e.id)}))}handleDataConsumer(e){e.on("@close",(()=>{this._dataConsumers.delete(e.id)}))}}gd.Transport=su;var ou={},au={},cu={},du={exports:{}},uu=du.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(uu).forEach((function(e){uu[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var s=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(r[n[s]]=t(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&r[e.push].push(s)},n=du.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},s=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),o=s[s.length-1]);for(var a=0;a<(n[t]||[]).length;a+=1){var c=n[t][a];if(c.reg.test(i))return r(c,o,i)}})),t.media=s,t};var s=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(s,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(cu);var lu=du.exports,pu=/%[sdv%]/g,hu=function(e){var t=1,r=arguments,n=r.length;return e.replace(pu,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},fu=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var s=t.names[i];t.name?n.push(r[t.name][s]):n.push(r[t.names[i]])}else n.push(r[t.name]);return hu.apply(null,n)},mu=["v","o","s","i","u","e","p","c","b","t","r","z","a"],gu=["i","c","b","a"],vu=cu,yu=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||mu,n=t.innerOrder||gu,i=[];return r.forEach((function(t){lu[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(fu(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(fu(t,r,e))}))}))})),e.media.forEach((function(e){i.push(fu("m",lu.m[0],e)),n.forEach((function(t){lu[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(fu(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(fu(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},_u=du.exports;au.grammar=_u,au.write=yu,au.parse=vu.parse,au.parseParams=vu.parseParams,au.parseFmtpConfig=vu.parseFmtpConfig,au.parsePayloads=vu.parsePayloads,au.parseRemoteCandidates=vu.parseRemoteCandidates,au.parseImageAttributes=vu.parseImageAttributes,au.parseSimulcastStreamList=vu.parseSimulcastStreamList;var bu={};Object.defineProperty(bu,"__esModule",{value:!0}),bu.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=[];let n=!1,i=!1;for(const s of e.media){const e=s.type;switch(e){case"audio":if(n)continue;n=!0;break;case"video":if(i)continue;i=!0;break;default:continue}for(const r of s.rtp){const n={kind:e,mimeType:`${e}/${r.codec}`,preferredPayloadType:r.payload,clockRate:r.rate,channels:r.encoding,parameters:{},rtcpFeedback:[]};t.set(n.preferredPayloadType,n)}for(const e of s.fmtp??[]){const r=wu.parseParams(e.config),n=t.get(e.payload);n&&(r?.hasOwnProperty("profile-level-id")&&(r["profile-level-id"]=String(r["profile-level-id"])),n.parameters=r)}for(const r of s.rtcpFb??[]){const n={type:r.type,parameter:r.subtype};if(n.parameter||delete n.parameter,"*"!==r.payload){const e=t.get(r.payload);if(!e)continue;e.rtcpFeedback.push(n)}else for(const r of t.values())r.kind!==e||/.+\/rtx$/i.test(r.mimeType)||r.rtcpFeedback.push(n)}for(const t of s.ext??[]){if(t["encrypt-uri"])continue;const n={kind:e,uri:t.uri,preferredId:t.value};r.push(n)}}return{codecs:Array.from(t.values()),headerExtensions:r}},bu.extractDtlsParameters=function({sdpObject:e}){let t,r=e.setup,n=e.fingerprint;if(!r||!n){const t=(e.media??[]).find((e=>0!==e.port));t&&(r??=t.setup,n??=t.fingerprint)}if(!r)throw new Error("no a=setup found at SDP session or media level");if(!n)throw new Error("no a=fingerprint found at SDP session or media level");switch(r){case"active":t="client";break;case"passive":t="server";break;case"actpass":t="auto"}return{role:t,fingerprints:[{algorithm:n.type,value:n.hash}]}},bu.getCname=function({offerMediaObject:e}){const t=(e.ssrcs??[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},bu.applyCodecParameters=function({offerRtpParameters:e,answerMediaObject:t}){for(const r of e.codecs){const e=r.mimeType.toLowerCase();if("audio/opus"!==e)continue;const n=(t.rtp??[]).find((e=>e.payload===r.payloadType));if(!n)continue;t.fmtp=t.fmtp??[];let i=t.fmtp.find((e=>e.payload===r.payloadType));i||(i={payload:r.payloadType,config:""},t.fmtp.push(i));const s=wu.parseParams(i.config);switch(e){case"audio/opus":{const e=r.parameters["sprop-stereo"];void 0!==e&&(s.stereo=Number(e)?1:0);break}}i.config="";for(const e of Object.keys(s))i.config&&(i.config+=";"),i.config+=`${e}=${s[e]}`}};const wu=au;var Su={};Object.defineProperty(Su,"__esModule",{value:!0}),Su.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs??[]){const e=r.id;t.add(e)}if(0===t.size)throw new Error("no a=ssrc lines found");const r=new Map;for(const n of e.ssrcGroups??[]){if("FID"!==n.semantics)continue;let[e,i]=n.ssrcs.split(/\s+/);e=Number(e),i=Number(i),t.has(e)&&(t.delete(e),t.delete(i),r.set(e,i))}for(const e of t)r.set(e,null);const n=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),n.push(r)}return n},Su.addLegacySimulcast=function({offerMediaObject:e,numStreams:t}){if(t<=1)throw new TypeError("numStreams must be greater than 1");const r=(e.ssrcs??[]).find((e=>"msid"===e.attribute));if(!r)throw new Error("a=ssrc line with msid information not found");const[n,i]=r.value.split(" "),s=Number(r.id);let o;(e.ssrcGroups??[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===s&&(o=Number(t[1]),!0)}));const a=e.ssrcs.find((e=>"cname"===e.attribute));if(!a)throw new Error("a=ssrc line with cname information not found");const c=a.value,d=[],u=[];for(let e=0;e<t;++e)d.push(s+e),o&&u.push(o+e);e.ssrcGroups=[],e.ssrcs=[],e.ssrcGroups.push({semantics:"SIM",ssrcs:d.join(" ")});for(const t of d)e.ssrcs.push({id:t,attribute:"cname",value:c}),e.ssrcs.push({id:t,attribute:"msid",value:`${n} ${i}`});for(let t=0;t<u.length;++t){const r=d[t],s=u[t];e.ssrcs.push({id:s,attribute:"cname",value:c}),e.ssrcs.push({id:s,attribute:"msid",value:`${n} ${i}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${r} ${s}`})}};var Eu={};Object.defineProperty(Eu,"__esModule",{value:!0}),Eu.addNackSupportForOpus=function(e){for(const t of e.codecs??[])"audio/opus"!==t.mimeType.toLowerCase()&&"audio/multiopus"!==t.mimeType.toLowerCase()||t.rtcpFeedback?.some((e=>"nack"===e.type&&!e.parameter))||(t.rtcpFeedback||(t.rtcpFeedback=[]),t.rtcpFeedback.push({type:"nack"}))};var Cu={};Object.defineProperty(Cu,"__esModule",{value:!0}),Cu.HandlerInterface=void 0;const Ru=pc;class Pu extends Ru.EnhancedEventEmitter{constructor(){super()}}Cu.HandlerInterface=Pu;var Tu={},ku={};Object.defineProperty(ku,"__esModule",{value:!0}),ku.OfferMediaSection=ku.AnswerMediaSection=ku.MediaSection=void 0;const Du=au,Iu=Mc;class Ou{_mediaObject;_planB;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:n=!1}){if(this._mediaObject={},this._planB=n,e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={component:1};t.foundation=e.foundation,t.ip=e.address??e.ip,t.port=e.port,t.priority=e.priority,t.transport=e.protocol,t.type=e.type,e.tcpType&&(t.tcptype=e.tcpType),this._mediaObject.candidates.push(t)}this._mediaObject.endOfCandidates="end-of-candidates",this._mediaObject.iceOptions="renomination"}r&&this.setDtlsRole(r.role)}get mid(){return String(this._mediaObject.mid)}get closed(){return 0===this._mediaObject.port}getObject(){return this._mediaObject}setIceParameters(e){this._mediaObject.iceUfrag=e.usernameFragment,this._mediaObject.icePwd=e.password}pause(){this._mediaObject.direction="inactive"}disable(){this.pause(),delete this._mediaObject.ext,delete this._mediaObject.ssrcs,delete this._mediaObject.ssrcGroups,delete this._mediaObject.simulcast,delete this._mediaObject.simulcast_03,delete this._mediaObject.rids,delete this._mediaObject.extmapAllowMixed}close(){this.disable(),this._mediaObject.port=0}}ku.MediaSection=Ou;ku.AnswerMediaSection=class extends Ou{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1,offerMediaObject:o,offerRtpParameters:a,answerRtpParameters:c,codecOptions:d}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s}),this._mediaObject.mid=String(o.mid),this._mediaObject.type=o.type,this._mediaObject.protocol=o.protocol,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.port=7),o.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of c.codecs){const t={payload:e.payloadType,codec:Au(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=Iu.clone(e.parameters)??{};let n=Iu.clone(e.rtcpFeedback)??[];if(d){const{opusStereo:t,opusFec:i,opusDtx:s,opusMaxPlaybackRate:o,opusMaxAverageBitrate:c,opusPtime:u,opusNack:l,videoGoogleStartBitrate:p,videoGoogleMaxBitrate:h,videoGoogleMinBitrate:f}=d,m=a.codecs.find((t=>t.payloadType===e.payloadType));switch(e.mimeType.toLowerCase()){case"audio/opus":case"audio/multiopus":void 0!==t&&(m.parameters["sprop-stereo"]=t?1:0,r.stereo=t?1:0),void 0!==i&&(m.parameters.useinbandfec=i?1:0,r.useinbandfec=i?1:0),void 0!==s&&(m.parameters.usedtx=s?1:0,r.usedtx=s?1:0),void 0!==o&&(r.maxplaybackrate=o),void 0!==c&&(r.maxaveragebitrate=c),void 0!==u&&(m.parameters.ptime=u,r.ptime=u),l||(m.rtcpFeedback=m.rtcpFeedback.filter((e=>"nack"!==e.type||e.parameter)),n=n.filter((e=>"nack"!==e.type||e.parameter)));break;case"video/vp8":case"video/vp9":case"video/h264":case"video/h265":void 0!==p&&(r["x-google-start-bitrate"]=p),void 0!==h&&(r["x-google-max-bitrate"]=h),void 0!==f&&(r["x-google-min-bitrate"]=f)}}const i={payload:e.payloadType,config:""};for(const e of Object.keys(r))i.config&&(i.config+=";"),i.config+=`${e}=${r[e]}`;i.config&&this._mediaObject.fmtp.push(i);for(const t of n)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions){(o.ext??[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if("extmap-allow-mixed"===o.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),o.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:o.simulcast.list1},this._mediaObject.rids=[];for(const e of o.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(o.simulcast_03){this._mediaObject.simulcast_03={value:o.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of o.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize",this._planB&&"video"===this._mediaObject.type&&(this._mediaObject.xGoogleFlag="conference");break;case"application":"number"==typeof o.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize):o.sctpmap&&(this._mediaObject.payloads=n.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize})}}setDtlsRole(e){switch(e){case"client":this._mediaObject.setup="active";break;case"server":this._mediaObject.setup="passive";break;case"auto":this._mediaObject.setup="actpass"}}resume(){this._mediaObject.direction="recvonly"}muxSimulcastStreams(e){if(!this._mediaObject.simulcast?.list1)return;const t={};for(const r of e)r.rid&&(t[r.rid]=r);const r=this._mediaObject.simulcast.list1,n=Du.parseSimulcastStreamList(r);for(const e of n)for(const r of e)r.paused=!t[r.scid]?.active;this._mediaObject.simulcast.list1=n.map((e=>e.map((e=>`${e.paused?"~":""}${e.scid}`)).join(","))).join(";")}};function Au(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}ku.OfferMediaSection=class extends Ou{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1,mid:o,kind:a,offerRtpParameters:c,streamId:d,trackId:u,oldDataChannelSpec:l=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s}),this._mediaObject.mid=String(o),this._mediaObject.type=a,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.protocol="RTP/AVP",this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.protocol=n?"UDP/DTLS/SCTP":"UDP/TLS/RTP/SAVPF",this._mediaObject.port=7),this._mediaObject.extmapAllowMixed="extmap-allow-mixed",a){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._planB||(this._mediaObject.msid=`${d??"-"} ${u}`);for(const e of c.codecs){const t={payload:e.payloadType,codec:Au(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r={payload:e.payloadType,config:""};for(const t of Object.keys(e.parameters))r.config&&(r.config+=";"),r.config+=`${t}=${e.parameters[t]}`;r.config&&this._mediaObject.fmtp.push(r);for(const t of e.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=c.encodings[0],t=e.ssrc,r=e.rtx?.ssrc;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],c.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:t,attribute:"msid",value:`${d??"-"} ${u}`}),r&&(c.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:r,attribute:"msid",value:`${d??"-"} ${u}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":l?(this._mediaObject.payloads=n.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize}):(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize)}}setDtlsRole(e){this._mediaObject.setup="actpass"}resume(){this._mediaObject.direction="sendonly"}planBReceive({offerRtpParameters:e,streamId:t,trackId:r}){const n=e.encodings[0],i=n.ssrc,s=n.rtx?.ssrc,o=this._mediaObject.payloads.split(" ");for(const t of e.codecs){if(o.includes(String(t.payloadType)))continue;const e={payload:t.payloadType,codec:Au(t),rate:t.clockRate};t.channels>1&&(e.encoding=t.channels),this._mediaObject.rtp.push(e);const r={payload:t.payloadType,config:""};for(const e of Object.keys(t.parameters))r.config&&(r.config+=";"),r.config+=`${e}=${t.parameters[e]}`;r.config&&this._mediaObject.fmtp.push(r);for(const e of t.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:t.payloadType,type:e.type,subtype:e.parameter})}this._mediaObject.payloads+=` ${e.codecs.filter((e=>!this._mediaObject.payloads.includes(e.payloadType))).map((e=>e.payloadType)).join(" ")}`,this._mediaObject.payloads=this._mediaObject.payloads.trim(),e.rtcp.cname&&this._mediaObject.ssrcs.push({id:i,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:i,attribute:"msid",value:`${t??"-"} ${r}`}),s&&(e.rtcp.cname&&this._mediaObject.ssrcs.push({id:s,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:s,attribute:"msid",value:`${t??"-"} ${r}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${i} ${s}`}))}planBStopReceiving({offerRtpParameters:e}){const t=e.encodings[0],r=t.ssrc,n=t.rtx?.ssrc;this._mediaObject.ssrcs=this._mediaObject.ssrcs.filter((e=>e.id!==r&&e.id!==n)),n&&(this._mediaObject.ssrcGroups=this._mediaObject.ssrcGroups.filter((e=>e.ssrcs!==`${r} ${n}`)))}},Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.RemoteSdp=void 0;const Lu=au,Mu=ku,Nu=new cc.Logger("RemoteSdp");Tu.RemoteSdp=class{_iceParameters;_iceCandidates;_dtlsParameters;_sctpParameters;_plainRtpParameters;_planB;_mediaSections=[];_midToIndex=new Map;_firstMid;_sdpObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1}){if(this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=n,this._plainRtpParameters=i,this._planB=s,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:1e4,sessionVersion:0,username:"mediasoup-client"},name:"-",timing:{start:0,stop:0},media:[]},e?.iceLite&&(this._sdpObject.icelite="ice-lite"),r){this._sdpObject.msidSemantic={semantic:"WMS",token:"*"};const e=this._dtlsParameters.fingerprints.length;this._sdpObject.fingerprint={type:r.fingerprints[e-1].algorithm,hash:r.fingerprints[e-1].value},this._sdpObject.groups=[{type:"BUNDLE",mids:""}]}i&&(this._sdpObject.origin.address=i.ip,this._sdpObject.origin.ipVer=i.ipVersion)}updateIceParameters(e){Nu.debug("updateIceParameters() [iceParameters:%o]",e),this._iceParameters=e,this._sdpObject.icelite=e.iceLite?"ice-lite":void 0;for(const t of this._mediaSections)t.setIceParameters(e)}updateDtlsRole(e){Nu.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}setSessionExtmapAllowMixed(){Nu.debug("setSessionExtmapAllowMixed()"),this._sdpObject.extmapAllowMixed="extmap-allow-mixed"}getNextMediaSectionIdx(){for(let e=0;e<this._mediaSections.length;++e){const t=this._mediaSections[e];if(t.closed)return{idx:e,reuseMid:t.mid}}return{idx:this._mediaSections.length}}send({offerMediaObject:e,reuseMid:t,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i}){const s=new Mu.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i});t?this._replaceMediaSection(s,t):this._midToIndex.has(s.mid)?this._replaceMediaSection(s):this._addMediaSection(s)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}){const s=this._midToIndex.get(e);let o;if(void 0!==s&&(o=this._mediaSections[s]),this.setSessionExtmapAllowMixed(),o)o.planBReceive({offerRtpParameters:r,streamId:n,trackId:i}),this._replaceMediaSection(o);else{o=new Mu.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i});const s=this._mediaSections.find((e=>e.closed));s?this._replaceMediaSection(o,s.mid):this._addMediaSection(o)}}pauseMediaSection(e){this._findMediaSection(e).pause()}resumeSendingMediaSection(e){this._findMediaSection(e).resume()}resumeReceivingMediaSection(e){this._findMediaSection(e).resume()}disableMediaSection(e){this._findMediaSection(e).disable()}closeMediaSection(e){const t=this._findMediaSection(e);return e===this._firstMid?(Nu.debug("closeMediaSection() | cannot close first media section, disabling it instead [mid:%s]",e),this.disableMediaSection(e),!1):(t.close(),this._regenerateBundleMids(),!0)}muxMediaSectionSimulcast(e,t){const r=this._findMediaSection(e);r.muxSimulcastStreams(t),this._replaceMediaSection(r)}planBStopReceiving({mid:e,offerRtpParameters:t}){const r=this._findMediaSection(e);r.planBStopReceiving({offerRtpParameters:t}),this._replaceMediaSection(r)}sendSctpAssociation({offerMediaObject:e}){const t=new Mu.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation({oldDataChannelSpec:e=!1}={}){const t=new Mu.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application",oldDataChannelSpec:e});this._addMediaSection(t)}getSdp(){return this._sdpObject.origin.sessionVersion++,Lu.write(this._sdpObject)}_addMediaSection(e){this._firstMid||(this._firstMid=e.mid),this._mediaSections.push(e),this._midToIndex.set(e.mid,this._mediaSections.length-1),this._sdpObject.media.push(e.getObject()),this._regenerateBundleMids()}_replaceMediaSection(e,t){if("string"==typeof t){const r=this._midToIndex.get(t);if(void 0===r)throw new Error(`no media section found for reuseMid '${t}'`);const n=this._mediaSections[r];this._mediaSections[r]=e,this._midToIndex.delete(n.mid),this._midToIndex.set(e.mid,r),this._sdpObject.media[r]=e.getObject(),this._regenerateBundleMids()}else{const t=this._midToIndex.get(e.mid);if(void 0===t)throw new Error(`no media section found with mid '${e.mid}'`);this._mediaSections[t]=e,this._sdpObject.media[t]=e.getObject()}}_findMediaSection(e){const t=this._midToIndex.get(e);if(void 0===t)throw new Error(`no media section found with mid '${e}'`);return this._mediaSections[t]}_regenerateBundleMids(){this._dtlsParameters&&(this._sdpObject.groups[0].mids=this._mediaSections.filter((e=>!e.closed)).map((e=>e.mid)).join(" "))}};var xu={};Object.defineProperty(xu,"__esModule",{value:!0}),xu.parse=function(e){const t=Fu.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const Fu=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");Object.defineProperty(ou,"__esModule",{value:!0}),ou.Chrome111=void 0;const ju=au,Uu=Mc,Bu=Nc,Vu=bu,Hu=Su,Wu=Eu,qu=Oc,zu=Cu,Gu=Tu,Yu=xu,$u=new cc.Logger("Chrome111"),Ku={OS:1024,MIS:1024};class Ju extends zu.HandlerInterface{_closed=!1;_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Ju}constructor(){super()}get name(){return"Chrome111"}close(){if($u.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){$u.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=ju.parse(t.sdp),n=Vu.extractRtpCapabilities({sdpObject:r});return Wu.addNackSupportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return $u.debug("getNativeSctpCapabilities()"),{numStreams:Ku}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),$u.debug("run()"),this._direction=e,this._remoteSdp=new Gu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Bu.getSendingRtpParameters("audio",d),video:Bu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Bu.getSendingRemoteRtpParameters("audio",d),video:Bu.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):($u.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),$u.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),$u.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});$u.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};$u.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();$u.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){if(this.assertNotClosed(),this.assertSendDirection(),$u.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1){let e=1;for(const r of t){const t=r.scalabilityMode?(0,Yu.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=Uu.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Bu.reduceCodecs(s.codecs,n);const o=Uu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Bu.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(c.sender);const d=await this._pc.createOffer();let u=ju.parse(d.sdp);u.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),$u.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const l=c.mid;s.mid=l,u=ju.parse(this._pc.localDescription.sdp);const p=u.media[a.idx];if(s.rtcp.cname=Vu.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Hu.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Hu.getRtpEncodings({offerMediaObject:p});this._remoteSdp.send({offerMediaObject:p,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r});const h={type:"answer",sdp:this._remoteSdp.getSdp()};return $u.debug("send() | calling pc.setRemoteDescription() [answer:%o]",h),await this._pc.setRemoteDescription(h),this._mapMidTransceiver.set(l,c),{localId:l,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),$u.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();$u.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),$u.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();$u.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),$u.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();$u.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?$u.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):$u.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),$u.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();$u.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),$u.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();$u.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};$u.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ku.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ju.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),$u.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};$u.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;$u.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};$u.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=ju.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Vu.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ju.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),$u.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){$u.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$u.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$u.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){$u.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$u.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$u.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){$u.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$u.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$u.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};$u.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};$u.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ju.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}$u.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=ju.parse(this._pc.localDescription.sdp));const r=Vu.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new qu.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}ou.Chrome111=Ju;var Qu={};Object.defineProperty(Qu,"__esModule",{value:!0}),Qu.Chrome74=void 0;const Zu=au,Xu=Mc,el=Nc,tl=bu,rl=Su,nl=Eu,il=Oc,sl=Cu,ol=Tu,al=xu,cl=new cc.Logger("Chrome74"),dl={OS:1024,MIS:1024};class ul extends sl.HandlerInterface{_closed=!1;_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new ul}constructor(){super()}get name(){return"Chrome74"}close(){if(cl.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){cl.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=Zu.parse(t.sdp),n=tl.extractRtpCapabilities({sdpObject:r});return nl.addNackSupportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return cl.debug("getNativeSctpCapabilities()"),{numStreams:dl}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){cl.debug("run()"),this._direction=e,this._remoteSdp=new ol.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:el.getSendingRtpParameters("audio",d),video:el.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:el.getSendingRemoteRtpParameters("audio",d),video:el.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(cl.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),cl.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),cl.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});cl.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};cl.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();cl.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),cl.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const i=Xu.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=el.reduceCodecs(i.codecs,n);const s=Xu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=el.reduceCodecs(s.codecs,n);const o=this._remoteSdp.getNextMediaSectionIdx(),a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let c,d=await this._pc.createOffer(),u=Zu.parse(d.sdp);u.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u});let l=!1;const p=(0,al.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(cl.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=Zu.parse(d.sdp),c=u.media[o.idx],rl.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:Zu.write(u)}),cl.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const h=a.mid;if(i.mid=h,u=Zu.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=tl.getCname({offerMediaObject:c}),t)if(1===t.length){let e=rl.getRtpEncodings({offerMediaObject:c});Object.assign(e[0],t[0]),l&&(e=[e[0]]),i.encodings=e}else i.encodings=t;else i.encodings=rl.getRtpEncodings({offerMediaObject:c});if(i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:c,reuseMid:o.reuseMid,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return cl.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,a),{localId:h,rtpParameters:i,rtpSender:a.sender}}async stopSending(e){if(this.assertSendDirection(),cl.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();cl.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),cl.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();cl.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),cl.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();cl.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?cl.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):cl.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),cl.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();cl.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),cl.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();cl.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};cl.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%dl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Zu.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),cl.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};cl.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;cl.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};cl.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=Zu.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));tl.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Zu.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),cl.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){cl.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};cl.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();cl.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){cl.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};cl.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();cl.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){cl.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};cl.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();cl.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};cl.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};cl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Zu.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}cl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Zu.parse(this._pc.localDescription.sdp));const r=tl.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new il.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Qu.Chrome74=ul;var ll={};Object.defineProperty(ll,"__esModule",{value:!0}),ll.Chrome70=void 0;const pl=au,hl=Mc,fl=Nc,ml=bu,gl=Su,vl=Cu,yl=Tu,_l=xu,bl=new cc.Logger("Chrome70"),wl={OS:1024,MIS:1024};class Sl extends vl.HandlerInterface{_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Sl}constructor(){super()}get name(){return"Chrome70"}close(){if(bl.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){bl.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=pl.parse(t.sdp);return ml.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return bl.debug("getNativeSctpCapabilities()"),{numStreams:wl}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){bl.debug("run()"),this._direction=e,this._remoteSdp=new yl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:fl.getSendingRtpParameters("audio",d),video:fl.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:fl.getSendingRemoteRtpParameters("audio",d),video:fl.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(bl.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){bl.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(bl.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});bl.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};bl.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};bl.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();bl.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),bl.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const i=hl.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=fl.reduceCodecs(i.codecs,n);const s=hl.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=fl.reduceCodecs(s.codecs,n);const o=this._remoteSdp.getNextMediaSectionIdx(),a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});let c,d=await this._pc.createOffer(),u=pl.parse(d.sdp);u.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),t&&t.length>1&&(bl.debug("send() | enabling legacy simulcast"),u=pl.parse(d.sdp),c=u.media[o.idx],gl.addLegacySimulcast({offerMediaObject:c,numStreams:t.length}),d={type:"offer",sdp:pl.write(u)});let l=!1;const p=(0,_l.parse)((t??[{}])[0].scalabilityMode);if(t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(bl.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=pl.parse(d.sdp),c=u.media[o.idx],gl.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:pl.write(u)}),bl.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d),t){bl.debug("send() | applying given encodings");const e=a.sender.getParameters();for(let r=0;r<(e.encodings??[]).length;++r){const n=e.encodings[r],i=t[r];if(!i)break;e.encodings[r]=Object.assign(n,i)}await a.sender.setParameters(e)}const h=a.mid;if(i.mid=h,u=pl.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=ml.getCname({offerMediaObject:c}),i.encodings=gl.getRtpEncodings({offerMediaObject:c}),t)for(let e=0;e<i.encodings.length;++e)t[e]&&Object.assign(i.encodings[e],t[e]);if(l&&(i.encodings=[i.encodings[0]]),i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:c,reuseMid:o.reuseMid,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return bl.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,a),{localId:h,rtpParameters:i,rtpSender:a.sender}}async stopSending(e){this.assertSendDirection(),bl.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();bl.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};bl.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?bl.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):bl.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),bl.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();bl.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};bl.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),bl.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();bl.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};bl.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};bl.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%wl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=pl.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),bl.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};bl.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;bl.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};bl.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=pl.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));ml.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:pl.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),bl.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){bl.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};bl.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();bl.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};bl.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};bl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=pl.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}bl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=pl.parse(this._pc.localDescription.sdp));const r=ml.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}ll.Chrome70=Sl;var El={},Cl={};Object.defineProperty(Cl,"__esModule",{value:!0}),Cl.getRtpEncodings=function({offerMediaObject:e,track:t}){const r=new Set;for(const n of e.ssrcs??[]){if("msid"!==n.attribute)continue;if(n.value.split(" ")[1]===t.id){const e=n.id;r.add(e)}}if(0===r.size)throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);const n=new Map;for(const t of e.ssrcGroups??[]){if("FID"!==t.semantics)continue;let[e,i]=t.ssrcs.split(/\s+/);e=Number(e),i=Number(i),r.has(e)&&(r.delete(e),r.delete(i),n.set(e,i))}for(const e of r)n.set(e,null);const i=[];for(const[e,t]of n){const r={ssrc:e};t&&(r.rtx={ssrc:t}),i.push(r)}return i},Cl.addLegacySimulcast=function({offerMediaObject:e,track:t,numStreams:r}){if(r<=1)throw new TypeError("numStreams must be greater than 1");let n,i,s;if(!(e.ssrcs??[]).find((e=>{if("msid"!==e.attribute)return!1;return e.value.split(" ")[1]===t.id&&(n=e.id,s=e.value.split(" ")[0],!0)})))throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);(e.ssrcGroups??[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===n&&(i=Number(t[1]),!0)}));const o=e.ssrcs.find((e=>"cname"===e.attribute&&e.id===n));if(!o)throw new Error(`a=ssrc line with cname information not found [track.id:${t.id}]`);const a=o.value,c=[],d=[];for(let e=0;e<r;++e)c.push(n+e),i&&d.push(i+e);e.ssrcGroups=e.ssrcGroups??[],e.ssrcs=e.ssrcs??[],e.ssrcGroups.push({semantics:"SIM",ssrcs:c.join(" ")});for(const r of c)e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:`${s} ${t.id}`});for(let r=0;r<d.length;++r){const n=c[r],i=d[r];e.ssrcs.push({id:i,attribute:"cname",value:a}),e.ssrcs.push({id:i,attribute:"msid",value:`${s} ${t.id}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${n} ${i}`})}},Object.defineProperty(El,"__esModule",{value:!0}),El.Chrome67=void 0;const Rl=au,Pl=Mc,Tl=Nc,kl=bu,Dl=Cl,Il=Cu,Ol=Tu,Al=new cc.Logger("Chrome67"),Ll={OS:1024,MIS:1024};class Ml extends Il.HandlerInterface{_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_sendStream=new MediaStream;_mapSendLocalIdRtpSender=new Map;_nextSendLocalId=0;_mapRecvLocalIdInfo=new Map;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Ml}constructor(){super()}get name(){return"Chrome67"}close(){if(Al.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Al.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Rl.parse(t.sdp);return kl.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Al.debug("getNativeSctpCapabilities()"),{numStreams:Ll}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Al.debug("run()"),this._direction=e,this._remoteSdp=new Ol.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Tl.getSendingRtpParameters("audio",d),video:Tl.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Tl.getSendingRemoteRtpParameters("audio",d),video:Tl.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Al.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){Al.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Al.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Al.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Al.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Al.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Al.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),Al.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Al.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let i,s=await this._pc.createOffer(),o=Rl.parse(s.sdp);o.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const a=Pl.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Tl.reduceCodecs(a.codecs);const c=Pl.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Tl.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Al.debug("send() | enabling simulcast"),o=Rl.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Dl.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Rl.write(o)}),Al.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Rl.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=kl.getCname({offerMediaObject:i}),a.encodings=Dl.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};Al.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);this._nextSendLocalId++;const l=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(u,l),{localId:u,rtpParameters:a,rtpSender:l}}async stopSending(e){this.assertSendDirection(),Al.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");this._pc.removeTrack(t),t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();Al.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Al.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};Al.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?Al.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Al.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.track;await r.replaceTrack(t),n&&this._sendStream.removeTrack(n),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),Al.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),Al.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};Al.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ll.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Rl.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Al.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Al.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;Al.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};Al.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Rl.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));kl.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Rl.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Al.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=n,o=e,a=this._pc.getReceivers().find((e=>e.track&&e.track.id===s));if(!a)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(s,{mid:o,rtpParameters:i,rtpReceiver:a}),t.push({localId:s,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){Al.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Al.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Al.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)??{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};Al.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};Al.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Rl.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Al.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Rl.parse(this._pc.localDescription.sdp));const r=kl.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}El.Chrome67=Ml;var Nl={};Object.defineProperty(Nl,"__esModule",{value:!0}),Nl.Chrome55=void 0;const xl=au,Fl=Oc,jl=Mc,Ul=Nc,Bl=bu,Vl=Cl,Hl=Cu,Wl=Tu,ql=new cc.Logger("Chrome55"),zl={OS:1024,MIS:1024};class Gl extends Hl.HandlerInterface{_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_sendStream=new MediaStream;_mapSendLocalIdTrack=new Map;_nextSendLocalId=0;_mapRecvLocalIdInfo=new Map;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Gl}constructor(){super()}get name(){return"Chrome55"}close(){if(ql.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){ql.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=xl.parse(t.sdp);return Bl.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return ql.debug("getNativeSctpCapabilities()"),{numStreams:zl}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){ql.debug("run()"),this._direction=e,this._remoteSdp=new Wl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Ul.getSendingRtpParameters("audio",d),video:Ul.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Ul.getSendingRemoteRtpParameters("audio",d),video:Ul.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(ql.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){ql.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(ql.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});ql.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};ql.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};ql.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();ql.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),ql.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&ql.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let i,s=await this._pc.createOffer(),o=xl.parse(s.sdp);o.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const a=jl.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Ul.reduceCodecs(a.codecs);const c=jl.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Ul.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(ql.debug("send() | enabling simulcast"),o=xl.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Vl.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:xl.write(o)}),ql.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=xl.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Bl.getCname({offerMediaObject:i}),a.encodings=Vl.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};ql.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(u,e),{localId:u,rtpParameters:a}}async stopSending(e){this.assertSendDirection(),ql.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();ql.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void ql.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};ql.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new Fl.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new Fl.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new Fl.UnsupportedError("not supported")}async getSenderStats(e){throw new Fl.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};ql.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%zl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=xl.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),ql.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};ql.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;ql.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};ql.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=xl.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));Bl.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:xl.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),ql.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=e,o=n,a=r.streamId??i.rtcp.cname,c=this._pc.getRemoteStreams().find((e=>e.id===a)),d=c.getTrackById(o);if(!d)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(o,{mid:s,rtpParameters:i}),t.push({localId:o,track:d})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){ql.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ql.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ql.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new Fl.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};ql.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};ql.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=xl.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}ql.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=xl.parse(this._pc.localDescription.sdp));const r=Bl.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Nl.Chrome55=Gl;var Yl={};Object.defineProperty(Yl,"__esModule",{value:!0}),Yl.Firefox120=void 0;const $l=au,Kl=Oc,Jl=Mc,Ql=Nc,Zl=bu,Xl=Su,ep=Cu,tp=Tu,rp=xu,np=new cc.Logger("Firefox120"),ip={OS:16,MIS:2048};class sp extends ep.HandlerInterface{_closed=!1;_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new sp}constructor(){super()}get name(){return"Firefox120"}close(){if(np.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){np.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"}),e.addTransceiver(r,{direction:"sendrecv",sendEncodings:[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}]});const n=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const i=$l.parse(n.sdp);return Zl.extractRtpCapabilities({sdpObject:i})}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw n}}async getNativeSctpCapabilities(){return np.debug("getNativeSctpCapabilities()"),{numStreams:ip}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),np.debug("run()"),this._direction=e,this._remoteSdp=new tp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Ql.getSendingRtpParameters("audio",d),video:Ql.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Ql.getSendingRemoteRtpParameters("audio",d),video:Ql.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(np.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new Kl.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),np.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});np.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};np.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();np.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),np.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=Jl.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Ql.reduceCodecs(s.codecs,n);const o=Jl.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Ql.reduceCodecs(o.codecs,n);const a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(a.sender);const c=await this._pc.createOffer();let d=$l.parse(c.sdp);d.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:d});const u=(0,rp.parse)((t??[{}])[0].scalabilityMode);np.debug("send() | calling pc.setLocalDescription() [offer:%o]",c),await this._pc.setLocalDescription(c);const l=a.mid;s.mid=l,d=$l.parse(this._pc.localDescription.sdp);const p=d.media[d.media.length-1];if(s.rtcp.cname=Zl.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Xl.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Xl.getRtpEncodings({offerMediaObject:p});if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${u.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:p,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r});const h={type:"answer",sdp:this._remoteSdp.getSdp()};return np.debug("send() | calling pc.setRemoteDescription() [answer:%o]",h),await this._pc.setRemoteDescription(h),this._mapMidTransceiver.set(l,a),{localId:l,rtpParameters:s,rtpSender:a.sender}}async stopSending(e){if(this.assertSendDirection(),np.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();np.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),np.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();np.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),np.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();np.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?np.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):np.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),np.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();np.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),np.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();np.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};np.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%ip.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=$l.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),np.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};np.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;np.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};np.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=$l.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));Zl.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:$l.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),np.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){np.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};np.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();np.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){np.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};np.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();np.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){np.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};np.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();np.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};np.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};np.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=$l.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}np.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=$l.parse(this._pc.localDescription.sdp));const r=Zl.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Kl.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Yl.Firefox120=sp;var op={};Object.defineProperty(op,"__esModule",{value:!0}),op.Firefox60=void 0;const ap=au,cp=Oc,dp=Mc,up=Nc,lp=bu,pp=Su,hp=Cu,fp=Tu,mp=xu,gp=new cc.Logger("Firefox60"),vp={OS:16,MIS:2048};class yp extends hp.HandlerInterface{_closed=!1;_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new yp}constructor(){super()}get name(){return"Firefox60"}close(){if(gp.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){gp.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"});const n=e.addTransceiver(r,{direction:"sendrecv"}),i=n.sender.getParameters(),s=[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}];i.encodings=s,await n.sender.setParameters(i);const o=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const a=ap.parse(o.sdp);return lp.extractRtpCapabilities({sdpObject:a})}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw n}}async getNativeSctpCapabilities(){return gp.debug("getNativeSctpCapabilities()"),{numStreams:vp}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),gp.debug("run()"),this._direction=e,this._remoteSdp=new fp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:up.getSendingRtpParameters("audio",d),video:up.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:up.getSendingRemoteRtpParameters("audio",d),video:up.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(gp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new cp.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),gp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});gp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();gp.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),gp.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&((t=dp.clone(t)).forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const i=dp.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=up.reduceCodecs(i.codecs,n);const s=dp.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=up.reduceCodecs(s.codecs,n);const o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});if(t){const e=o.sender.getParameters();e.encodings=t,await o.sender.setParameters(e)}const a=await this._pc.createOffer();let c=ap.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:c});const d=(0,mp.parse)((t??[{}])[0].scalabilityMode);gp.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const u=o.mid;i.mid=u,c=ap.parse(this._pc.localDescription.sdp);const l=c.media[c.media.length-1];if(i.rtcp.cname=lp.getCname({offerMediaObject:l}),t)if(1===t.length){const e=pp.getRtpEncodings({offerMediaObject:l});Object.assign(e[0],t[0]),i.encodings=e}else i.encodings=t.reverse();else i.encodings=pp.getRtpEncodings({offerMediaObject:l});if(i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${d.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:l,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r});const p={type:"answer",sdp:this._remoteSdp.getSdp()};return gp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",p),await this._pc.setRemoteDescription(p),this._mapMidTransceiver.set(u,o),{localId:u,rtpParameters:i,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),gp.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();gp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),gp.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();gp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),gp.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();gp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?gp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):gp.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),gp.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();t=n.encodings.length-1-t,n.encodings.forEach(((e,r)=>{e.active=r>=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();gp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),gp.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();gp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};gp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%vp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ap.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),gp.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;gp.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=ap.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));lp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:ap.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),gp.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){gp.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gp.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){gp.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gp.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){gp.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gp.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};gp.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ap.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}gp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=ap.parse(this._pc.localDescription.sdp));const r=lp.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new cp.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}op.Firefox60=yp;var _p={};Object.defineProperty(_p,"__esModule",{value:!0}),_p.Safari12=void 0;const bp=au,wp=Mc,Sp=Nc,Ep=bu,Cp=Su,Rp=Eu,Pp=Oc,Tp=Cu,kp=Tu,Dp=xu,Ip=new cc.Logger("Safari12"),Op={OS:1024,MIS:1024};class Ap extends Tp.HandlerInterface{_closed=!1;_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Ap}constructor(){super()}get name(){return"Safari12"}close(){if(Ip.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Ip.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=bp.parse(t.sdp),n=Ep.extractRtpCapabilities({sdpObject:r});return Rp.addNackSupportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ip.debug("getNativeSctpCapabilities()"),{numStreams:Op}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Ip.debug("run()"),this._direction=e,this._remoteSdp=new kp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Sp.getSendingRtpParameters("audio",d),video:Sp.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Sp.getSendingRemoteRtpParameters("audio",d),video:Sp.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Ip.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),Ip.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Ip.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ip.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ip.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ip.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),Ip.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=wp.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Sp.reduceCodecs(s.codecs,n);const o=wp.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Sp.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});i&&i(c.sender);let d,u=await this._pc.createOffer(),l=bp.parse(u.sdp);l.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});const p=(0,Dp.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(Ip.debug("send() | enabling legacy simulcast"),l=bp.parse(u.sdp),d=l.media[a.idx],Cp.addLegacySimulcast({offerMediaObject:d,numStreams:t.length}),u={type:"offer",sdp:bp.write(l)}),Ip.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);const h=c.mid;if(s.mid=h,l=bp.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Ep.getCname({offerMediaObject:d}),s.encodings=Cp.getRtpEncodings({offerMediaObject:d}),t)for(let e=0;e<s.encodings.length;++e)t[e]&&Object.assign(s.encodings[e],t[e]);if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return Ip.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,c),{localId:h,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;Ip.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();Ip.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ip.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Ip.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ip.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();Ip.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ip.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ip.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Ip.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Ip.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ip.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Ip.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Ip.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Op.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=bp.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ip.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ip.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Ip.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Ip.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=bp.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ep.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:bp.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ip.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Ip.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ip.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ip.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Ip.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ip.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ip.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Ip.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ip.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ip.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Ip.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ip.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=bp.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ip.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=bp.parse(this._pc.localDescription.sdp));const r=Ep.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Pp.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}_p.Safari12=Ap;var Lp={};Object.defineProperty(Lp,"__esModule",{value:!0}),Lp.Safari11=void 0;const Mp=au,Np=Mc,xp=Nc,Fp=bu,jp=Cl,Up=Cu,Bp=Tu,Vp=new cc.Logger("Safari11"),Hp={OS:1024,MIS:1024};class Wp extends Up.HandlerInterface{_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_sendStream=new MediaStream;_mapSendLocalIdRtpSender=new Map;_nextSendLocalId=0;_mapRecvLocalIdInfo=new Map;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Wp}constructor(){super()}get name(){return"Safari11"}close(){if(Vp.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Vp.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Mp.parse(t.sdp);return Fp.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Vp.debug("getNativeSctpCapabilities()"),{numStreams:Hp}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Vp.debug("run()"),this._direction=e,this._remoteSdp=new Bp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:xp.getSendingRtpParameters("audio",d),video:xp.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:xp.getSendingRemoteRtpParameters("audio",d),video:xp.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Vp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){Vp.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Vp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Vp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Vp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Vp.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),Vp.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Vp.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let i,s=await this._pc.createOffer(),o=Mp.parse(s.sdp);o.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const a=Np.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=xp.reduceCodecs(a.codecs);const c=Np.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=xp.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Vp.debug("send() | enabling simulcast"),o=Mp.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),jp.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Mp.write(o)}),Vp.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Mp.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Fp.getCname({offerMediaObject:i}),a.encodings=jp.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);this._nextSendLocalId++;const l=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(u,l),{localId:u,rtpParameters:a,rtpSender:l}}async stopSending(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();Vp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Vp.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?Vp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Vp.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.track;await r.replaceTrack(t),n&&this._sendStream.removeTrack(n),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),Vp.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),Vp.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Vp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Hp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Mp.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Vp.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;Vp.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};Vp.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Mp.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));Fp.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Mp.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Vp.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=e,o=n,a=this._pc.getReceivers().find((e=>e.track&&e.track.id===o));if(!a)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(o,{mid:s,rtpParameters:i,rtpReceiver:a}),t.push({localId:o,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){Vp.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Vp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vp.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)??{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async pauseReceiving(e){}async resumeReceiving(e){}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Vp.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};Vp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Mp.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Vp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Mp.parse(this._pc.localDescription.sdp));const r=Fp.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Lp.Safari11=Wp;var qp={},zp={};Object.defineProperty(zp,"__esModule",{value:!0}),zp.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=Gp.clone(e);for(const e of t.codecs??[]){if(e.channels=e.numChannels,delete e.numChannels,e.mimeType=e.mimeType??`${e.kind}/${e.name}`,e.parameters){const t=e.parameters;t.apt&&(t.apt=Number(t.apt)),t["packetization-mode"]&&(t["packetization-mode"]=Number(t["packetization-mode"]))}for(const t of e.rtcpFeedback??[])t.parameter||(t.parameter="")}return t},zp.mangleRtpParameters=function(e){const t=Gp.clone(e);t.mid&&(t.muxId=t.mid,delete t.mid);for(const e of t.codecs)e.channels&&(e.numChannels=e.channels,delete e.channels),e.mimeType&&!e.name&&(e.name=e.mimeType.split("/")[1]),delete e.mimeType;return t};const Gp=Mc;Object.defineProperty(qp,"__esModule",{value:!0}),qp.Edge11=void 0;const Yp=Oc,$p=Mc,Kp=Nc,Jp=zp,Qp=Cu,Zp=new cc.Logger("Edge11");class Xp extends Qp.HandlerInterface{_sendingRtpParametersByKind;_remoteIceParameters;_remoteIceCandidates;_remoteDtlsParameters;_iceGatherer;_iceTransport;_dtlsTransport;_rtpSenders=new Map;_rtpReceivers=new Map;_nextSendLocalId=0;_cname;_transportReady=!1;static createFactory(){return()=>new Xp}constructor(){super()}get name(){return"Edge11"}close(){Zp.debug("close()");try{this._iceGatherer.close()}catch(e){}try{this._iceTransport.stop()}catch(e){}try{this._dtlsTransport.stop()}catch(e){}for(const e of this._rtpSenders.values())try{e.stop()}catch(e){}for(const e of this._rtpReceivers.values())try{e.stop()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){return Zp.debug("getNativeRtpCapabilities()"),Jp.getCapabilities()}async getNativeSctpCapabilities(){return Zp.debug("getNativeSctpCapabilities()"),{numStreams:{OS:0,MIS:0}}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Zp.debug("run()"),this._sendingRtpParametersByKind={audio:Kp.getSendingRtpParameters("audio",d),video:Kp.getSendingRtpParameters("video",d)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=n,this._cname=`CNAME-${$p.generateRandomNumber()}`,this.setIceGatherer({iceServers:s,iceTransportPolicy:o}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new Yp.UnsupportedError("not supported")}async restartIce(e){if(Zp.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){Zp.debug("restartIce() | calling iceTransport.start()"),this._iceTransport.start(this._iceGatherer,e,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({})}}async getTransportStats(){return this._iceTransport.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){Zp.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),Zp.debug("send() | calling new RTCRtpSender()");const i=new RTCRtpSender(e,this._dtlsTransport),s=$p.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Kp.reduceCodecs(s.codecs,n);const o=s.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const e of t)e.ssrc=$p.generateRandomNumber(),o&&(e.rtx={ssrc:$p.generateRandomNumber()});s.encodings=t,s.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const a=Jp.mangleRtpParameters(s);Zp.debug("send() | calling rtpSender.send() [params:%o]",a),await i.send(a);const c=String(this._nextSendLocalId);return this._nextSendLocalId++,this._rtpSenders.set(c,i),{localId:c,rtpParameters:s,rtpSender:i}}async stopSending(e){Zp.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{Zp.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(e){throw Zp.warn("stopSending() | rtpSender.stop() failed:%o",e),e}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?Zp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Zp.debug("replaceTrack() [localId:%s, no track]",e);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");r.setTrack(t)}async setMaxSpatialLayer(e,t){Zp.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){Zp.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");return t.getStats()}async sendDataChannel(e){throw new Yp.UnsupportedError("not implemented")}async receive(e){const t=[];for(const t of e){const{trackId:e,kind:r}=t;Zp.debug("receive() [trackId:%s, kind:%s]",e,r)}this._transportReady||await this.setupTransport({localDtlsRole:"server"});for(const r of e){const{trackId:e,kind:n,rtpParameters:i}=r;Zp.debug("receive() | calling new RTCRtpReceiver()");const s=new RTCRtpReceiver(this._dtlsTransport,n);s.addEventListener("error",(e=>{Zp.error('rtpReceiver "error" event [event:%o]',e)}));const o=Jp.mangleRtpParameters(i);Zp.debug("receive() | calling rtpReceiver.receive() [params:%o]",o),await s.receive(o);const a=e;this._rtpReceivers.set(a,s),t.push({localId:a,track:s.track,rtpReceiver:s})}return t}async stopReceiving(e){for(const t of e){Zp.debug("stopReceiving() [localId:%s]",t);const e=this._rtpReceivers.get(t);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(t);try{Zp.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(e){Zp.warn("stopReceiving() | rtpReceiver.stop() failed:%o",e)}}}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){const t=this._rtpReceivers.get(e);if(!t)throw new Error("RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel(e){throw new Yp.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e??[],gatherPolicy:t??"all"});r.addEventListener("error",(e=>{Zp.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(e){Zp.debug("setIceGatherer() | iceGatherer.gather() failed: %s",e.toString())}this._iceGatherer=r}setIceTransport(){const e=new RTCIceTransport(this._iceGatherer);e.addEventListener("statechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("icestatechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("candidatepairchange",(e=>{Zp.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{Zp.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{Zp.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{Zp.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){Zp.debug("setupTransport()");const t=this._dtlsTransport.getLocalParameters();t.role=e,await new Promise(((e,r)=>{this.safeEmit("@connect",{dtlsParameters:t},e,r)})),this._iceTransport.start(this._iceGatherer,this._remoteIceParameters,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({}),this._remoteDtlsParameters.fingerprints=this._remoteDtlsParameters.fingerprints.filter((e=>"sha-256"===e.algorithm||"sha-384"===e.algorithm||"sha-512"===e.algorithm)),this._dtlsTransport.start(this._remoteDtlsParameters),this._transportReady=!0}}qp.Edge11=Xp;var eh={};Object.defineProperty(eh,"__esModule",{value:!0}),eh.ReactNativeUnifiedPlan=void 0;const th=au,rh=Mc,nh=Nc,ih=bu,sh=Su,oh=Eu,ah=Oc,ch=Cu,dh=Tu,uh=xu,lh=new cc.Logger("ReactNativeUnifiedPlan"),ph={OS:1024,MIS:1024};class hh extends ch.HandlerInterface{_closed=!1;_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new hh}constructor(){super()}get name(){return"ReactNativeUnifiedPlan"}close(){if(lh.debug("close()"),!this._closed){if(this._closed=!0,this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){lh.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=th.parse(t.sdp),n=ih.extractRtpCapabilities({sdpObject:r});return oh.addNackSupportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return lh.debug("getNativeSctpCapabilities()"),{numStreams:ph}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),lh.debug("run()"),this._direction=e,this._remoteSdp=new dh.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:nh.getSendingRtpParameters("audio",d),video:nh.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:nh.getSendingRemoteRtpParameters("audio",d),video:nh.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(lh.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),lh.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),lh.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});lh.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};lh.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();lh.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),lh.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=rh.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=nh.reduceCodecs(s.codecs,n);const o=rh.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=nh.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(c.sender);let d,u=await this._pc.createOffer(),l=th.parse(u.sdp);l.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed(),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});let p=!1;const h=(0,uh.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===s.codecs[0].mimeType.toLowerCase()&&(lh.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,l=th.parse(u.sdp),d=l.media[a.idx],sh.addLegacySimulcast({offerMediaObject:d,numStreams:h.spatialLayers}),u={type:"offer",sdp:th.write(l)}),lh.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);let f=c.mid??void 0;if(f||lh.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),s.mid=f,l=th.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=ih.getCname({offerMediaObject:d}),t)if(1===t.length){let e=sh.getRtpEncodings({offerMediaObject:d});Object.assign(e[0],t[0]),p&&(e=[e[0]]),s.encodings=e}else s.encodings=t;else s.encodings=sh.getRtpEncodings({offerMediaObject:d});if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${h.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return lh.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),f||(f=c.mid,s.mid=f),this._mapMidTransceiver.set(f,c),{localId:f,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;lh.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();lh.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),lh.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();lh.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),lh.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();lh.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?lh.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):lh.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),lh.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();lh.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),lh.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();lh.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};lh.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%ph.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=th.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),lh.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};lh.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;lh.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};lh.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=th.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));ih.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:th.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),lh.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){lh.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};lh.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();lh.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){lh.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};lh.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();lh.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){lh.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};lh.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();lh.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};lh.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};lh.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=th.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}lh.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=th.parse(this._pc.localDescription.sdp));const r=ih.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new ah.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}eh.ReactNativeUnifiedPlan=hh;var fh={};Object.defineProperty(fh,"__esModule",{value:!0}),fh.ReactNative=void 0;const mh=au,gh=Oc,vh=Mc,yh=Nc,_h=bu,bh=Cl,wh=Cu,Sh=Tu,Eh=new cc.Logger("ReactNative"),Ch={OS:1024,MIS:1024};class Rh extends wh.HandlerInterface{_direction;_remoteSdp;_sendingRtpParametersByKind;_sendingRemoteRtpParametersByKind;_forcedLocalDtlsRole;_pc;_sendStream=new MediaStream;_mapSendLocalIdTrack=new Map;_nextSendLocalId=0;_mapRecvLocalIdInfo=new Map;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return()=>new Rh}constructor(){super()}get name(){return"ReactNative"}close(){if(Eh.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Eh.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=mh.parse(t.sdp);return _h.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Eh.debug("getNativeSctpCapabilities()"),{numStreams:Ch}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Eh.debug("run()"),this._direction=e,this._remoteSdp=new Sh.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:yh.getSendingRtpParameters("audio",d),video:yh.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:yh.getSendingRemoteRtpParameters("audio",d),video:yh.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Eh.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){Eh.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Eh.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Eh.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Eh.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Eh.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Eh.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),Eh.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Eh.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let i,s=await this._pc.createOffer(),o=mh.parse(s.sdp);o.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const a=vh.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=yh.reduceCodecs(a.codecs);const c=vh.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=yh.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Eh.debug("send() | enabling simulcast"),o=mh.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),bh.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:mh.write(o)}),Eh.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=mh.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=_h.getCname({offerMediaObject:i}),a.encodings=bh.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};Eh.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(u,e),{localId:u,rtpParameters:a}}async stopSending(e){this.assertSendDirection(),Eh.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();Eh.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Eh.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};Eh.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new gh.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new gh.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new gh.UnsupportedError("not implemented")}async getSenderStats(e){throw new gh.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};Eh.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ch.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=mh.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Eh.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Eh.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i}=t;Eh.debug("receive() [trackId:%s, kind:%s]",e,n);const s=n;let o=t.streamId??i.rtcp.cname;Eh.debug("receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc"),o+=`-hack-${vh.generateRandomNumber()}`,r.set(e,o),this._remoteSdp.receive({mid:s,kind:n,offerRtpParameters:i,streamId:o,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Eh.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=mh.parse(i.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,i=s.media.find((e=>String(e.mid)===n));_h.applyCodecParameters({offerRtpParameters:r,answerMediaObject:i})}i={type:"answer",sdp:mh.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Eh.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{kind:e,trackId:i,rtpParameters:s}=n,o=i,a=e,c=r.get(i),d=this._pc.getRemoteStreams().find((e=>e.id===c)),u=d.getTrackById(o);if(!u)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(o,{mid:a,rtpParameters:s}),t.push({localId:o,track:u})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){Eh.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Eh.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Eh.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new gh.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};Eh.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};Eh.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=mh.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Eh.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=mh.parse(this._pc.localDescription.sdp));const r=_h.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}fh.ReactNative=Rh,Object.defineProperty(oc,"__esModule",{value:!0}),oc.Device=void 0,oc.detectDeviceAsync=zh,oc.detectDevice=Gh;const Ph=ac.exports,Th=pc,kh=Oc,Dh=Mc,Ih=Nc,Oh=gd,Ah=ou,Lh=Qu,Mh=ll,Nh=El,xh=Nl,Fh=Yl,jh=op,Uh=_p,Bh=Lp,Vh=qp,Hh=eh,Wh=fh,qh=new cc.Logger("Device");async function zh(e){qh.debug("detectDeviceAsync() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return $h(await(0,Ph.UAParser)(e).withFeatureCheck())}function Gh(e){qh.debug("detectDevice() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return $h((0,Ph.UAParser)(e))}class Yh{_handlerFactory;_handlerName;_loaded=!1;_extendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind;_sctpCapabilities;_observer=new Th.EnhancedEventEmitter;static async factory({handlerName:e,handlerFactory:t}={}){if(qh.debug("factory()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(!e&&!t&&!(e=await zh()))throw new kh.UnsupportedError("device not supported");return new Yh({handlerName:e,handlerFactory:t})}constructor({handlerName:e,handlerFactory:t}={}){if(qh.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)qh.debug("constructor() | handler given: %s",e);else{if(!(e=Gh()))throw new kh.UnsupportedError("device not supported");qh.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=Ah.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=Lh.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=Mh.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=Nh.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=xh.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=Fh.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=jh.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=Uh.Safari12.createFactory();break;case"Safari11":this._handlerFactory=Bh.Safari11.createFactory();break;case"Edge11":this._handlerFactory=Vh.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=Hh.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=Wh.ReactNative.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}const r=this._handlerFactory();this._handlerName=r.name,r.close(),this._extendedRtpCapabilities=void 0,this._recvRtpCapabilities=void 0,this._canProduceByKind={audio:!1,video:!1},this._sctpCapabilities=void 0}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new kh.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new kh.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e,preferLocalCodecsOrder:t=!1}){let r;qh.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new kh.InvalidStateError("already loaded");const n=Dh.clone(e);Ih.validateRtpCapabilities(n),r=this._handlerFactory();const i=await r.getNativeRtpCapabilities();qh.debug("load() | got native RTP capabilities:%o",i);const s=Dh.clone(i);Ih.validateRtpCapabilities(s),this._extendedRtpCapabilities=Ih.getExtendedRtpCapabilities(s,n,t),qh.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=Ih.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=Ih.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=Ih.getRecvRtpCapabilities(this._extendedRtpCapabilities),Ih.validateRtpCapabilities(this._recvRtpCapabilities),qh.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await r.getNativeSctpCapabilities(),qh.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),Ih.validateSctpCapabilities(this._sctpCapabilities),qh.debug("load() succeeded"),this._loaded=!0,r.close()}catch(e){throw r&&r.close(),e}}canProduce(e){if(!this._loaded)throw new kh.InvalidStateError("not loaded");if("audio"!==e&&"video"!==e)throw new TypeError(`invalid kind "${e}"`);return this._canProduceByKind[e]}createSendTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d}){return qh.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d}){return qh.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u}){if(!this._loaded)throw new kh.InvalidStateError("not loaded");if("string"!=typeof t)throw new TypeError("missing id");if("object"!=typeof r)throw new TypeError("missing iceParameters");if(!Array.isArray(n))throw new TypeError("missing iceCandidates");if("object"!=typeof i)throw new TypeError("missing dtlsParameters");if(s&&"object"!=typeof s)throw new TypeError("wrong sctpParameters");if(u&&"object"!=typeof u)throw new TypeError("if given, appData must be an object");const l=new Oh.Transport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u,handlerFactory:this._handlerFactory,extendedRtpCapabilities:this._extendedRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",l),l}}function $h(e){if("object"==typeof navigator&&"ReactNative"===navigator.product)return qh.debug("detectDeviceImpl() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void qh.warn("detectDeviceImpl() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(qh.debug("detectDeviceImpl() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(qh.debug("detectDeviceImpl() | ReactNative PlanB handler chosen"),"ReactNative");{qh.debug("detectDeviceImpl() | browser detected [userAgent:%s, parsed:%o]",e.ua,e);const t=e.browser,r=t.name?.toLowerCase(),n=parseInt(t.major??"0"),i=e.engine.name?.toLowerCase(),s=e.os,o=s.name?.toLowerCase(),a=parseFloat(s.version??"0"),c=e.device.model?.toLowerCase(),d="ios"===o||"ipad"===c,u=r&&["chrome","chromium","mobile chrome","chrome webview","chrome headless"].includes(r),l=r&&["firefox","mobile firefox","mobile focus"].includes(r),p=r&&["safari","mobile safari"].includes(r),h=r&&["edge"].includes(r);if((u||h)&&!d&&n>=111)return"Chrome111";if(u&&!d&&n>=74||h&&!d&&n>=88)return"Chrome74";if(u&&!d&&n>=70)return"Chrome70";if(u&&!d&&n>=67)return"Chrome67";if(u&&!d&&n>=55)return"Chrome55";if(l&&!d&&n>=120)return"Firefox120";if(l&&!d&&n>=60)return"Firefox60";if(l&&d&&a>=14.3)return"Safari12";if(p&&n>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(p&&n>=11)return"Safari11";if(h&&!d&&n>=11&&n<=18)return"Edge11";if("webkit"===i&&d&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if("blink"===i){const t=e.ua.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){const e=Number(t[1]);return e>=111?"Chrome111":e>=74?"Chrome74":e>=70?"Chrome70":e>=67?"Chrome67":"Chrome55"}return"Chrome111"}return void qh.warn("detectDeviceImpl() | browser not supported [name:%s, version:%s]",r,n)}}oc.Device=Yh;var Kh={};Object.defineProperty(Kh,"__esModule",{value:!0});var Jh,Qh,Zh,Xh={};Object.defineProperty(Xh,"__esModule",{value:!0}),Jh=sc,Qh=f&&f.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Zh=f&&f.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||Qh(t,e,r)},Object.defineProperty(Jh,"__esModule",{value:!0}),Zh(oc,Jh),Zh(gd,Jh),Zh(Dd,Jh),Zh(Md,Jh),Zh(Ud,Jh),Zh(qd,Jh),Zh(Kh,Jh),Zh(Xh,Jh),Zh(Cu,Jh),Zh(Oc,Jh);var ef={},tf={},rf={},nf={};Object.defineProperty(nf,"__esModule",{value:!0}),nf.default="ffffffff-ffff-ffff-ffff-ffffffffffff";var sf={};Object.defineProperty(sf,"__esModule",{value:!0}),sf.default="00000000-0000-0000-0000-000000000000";var of={},af={},cf={};Object.defineProperty(cf,"__esModule",{value:!0}),cf.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i,Object.defineProperty(af,"__esModule",{value:!0});const df=cf;af.default=function(e){return"string"==typeof e&&df.default.test(e)},Object.defineProperty(of,"__esModule",{value:!0});const uf=af;of.default=function(e){if(!(0,uf.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)};var lf={};Object.defineProperty(lf,"__esModule",{value:!0}),lf.unsafeStringify=void 0;const pf=af,hf=[];for(let e=0;e<256;++e)hf.push((e+256).toString(16).slice(1));function ff(e,t=0){return(hf[e[t+0]]+hf[e[t+1]]+hf[e[t+2]]+hf[e[t+3]]+"-"+hf[e[t+4]]+hf[e[t+5]]+"-"+hf[e[t+6]]+hf[e[t+7]]+"-"+hf[e[t+8]]+hf[e[t+9]]+"-"+hf[e[t+10]]+hf[e[t+11]]+hf[e[t+12]]+hf[e[t+13]]+hf[e[t+14]]+hf[e[t+15]]).toLowerCase()}lf.unsafeStringify=ff,lf.default=function(e,t=0){const r=ff(e,t);if(!(0,pf.default)(r))throw TypeError("Stringified UUID is invalid");return r};var mf={},gf={};let vf;Object.defineProperty(gf,"__esModule",{value:!0});const yf=new Uint8Array(16);gf.default=function(){if(!vf){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");vf=crypto.getRandomValues.bind(crypto)}return vf(yf)},Object.defineProperty(mf,"__esModule",{value:!0}),mf.updateV1State=void 0;const _f=gf,bf=lf,wf={};function Sf(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function Ef(e,t,r,n,i,s,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(o<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else s=new Uint8Array(16),o=0;t??=Date.now(),r??=0,n??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;s[o++]=a>>>24&255,s[o++]=a>>>16&255,s[o++]=a>>>8&255,s[o++]=255&a;const c=t/4294967296*1e4&268435455;s[o++]=c>>>8&255,s[o++]=255&c,s[o++]=c>>>24&15|16,s[o++]=c>>>16&255,s[o++]=n>>>8|128,s[o++]=255&n;for(let e=0;e<6;++e)s[o++]=i[e];return s}mf.updateV1State=Sf,mf.default=function(e,t,r){let n;const i=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)n=Ef(e.random??e.rng?.()??(0,_f.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),s=(0,_f.default)();Sf(wf,e,s),n=Ef(s,wf.msecs,wf.nsecs,i?void 0:wf.clockseq,i?void 0:wf.node,t,r)}return t??(0,bf.unsafeStringify)(n)};var Cf={};Object.defineProperty(Cf,"__esModule",{value:!0});const Rf=of,Pf=lf;Cf.default=function(e){const t=function(e){return Uint8Array.of((15&e[6])<<4|e[7]>>4&15,(15&e[7])<<4|(240&e[4])>>4,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,(15&e[1])<<4|(240&e[2])>>4,96|15&e[2],e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,Rf.default)(e):e);return"string"==typeof e?(0,Pf.unsafeStringify)(t):t};var Tf={},kf={};function Df(e){return 14+(e+64>>>9<<4)+1}function If(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function Of(e,t,r,n,i,s){return If((o=If(If(t,e),If(n,s)))<<(a=i)|o>>>32-a,r);var o,a}function Af(e,t,r,n,i,s,o){return Of(t&r|~t&n,e,t,i,s,o)}function Lf(e,t,r,n,i,s,o){return Of(t&n|r&~n,e,t,i,s,o)}function Mf(e,t,r,n,i,s,o){return Of(t^r^n,e,t,i,s,o)}function Nf(e,t,r,n,i,s,o){return Of(r^(t|~n),e,t,i,s,o)}Object.defineProperty(kf,"__esModule",{value:!0}),kf.default=function(e){const t=function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(Df(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),r=function(e,t){const r=new Uint32Array(Df(t)).fill(0);r.set(e),r[t>>5]|=128<<t%32,r[r.length-1]=t,e=r;let n=1732584193,i=-271733879,s=-1732584194,o=271733878;for(let t=0;t<e.length;t+=16){const r=n,a=i,c=s,d=o;n=Af(n,i,s,o,e[t],7,-680876936),o=Af(o,n,i,s,e[t+1],12,-389564586),s=Af(s,o,n,i,e[t+2],17,606105819),i=Af(i,s,o,n,e[t+3],22,-1044525330),n=Af(n,i,s,o,e[t+4],7,-176418897),o=Af(o,n,i,s,e[t+5],12,1200080426),s=Af(s,o,n,i,e[t+6],17,-1473231341),i=Af(i,s,o,n,e[t+7],22,-45705983),n=Af(n,i,s,o,e[t+8],7,1770035416),o=Af(o,n,i,s,e[t+9],12,-1958414417),s=Af(s,o,n,i,e[t+10],17,-42063),i=Af(i,s,o,n,e[t+11],22,-1990404162),n=Af(n,i,s,o,e[t+12],7,1804603682),o=Af(o,n,i,s,e[t+13],12,-40341101),s=Af(s,o,n,i,e[t+14],17,-1502002290),i=Af(i,s,o,n,e[t+15],22,1236535329),n=Lf(n,i,s,o,e[t+1],5,-165796510),o=Lf(o,n,i,s,e[t+6],9,-1069501632),s=Lf(s,o,n,i,e[t+11],14,643717713),i=Lf(i,s,o,n,e[t],20,-373897302),n=Lf(n,i,s,o,e[t+5],5,-701558691),o=Lf(o,n,i,s,e[t+10],9,38016083),s=Lf(s,o,n,i,e[t+15],14,-660478335),i=Lf(i,s,o,n,e[t+4],20,-405537848),n=Lf(n,i,s,o,e[t+9],5,568446438),o=Lf(o,n,i,s,e[t+14],9,-1019803690),s=Lf(s,o,n,i,e[t+3],14,-187363961),i=Lf(i,s,o,n,e[t+8],20,1163531501),n=Lf(n,i,s,o,e[t+13],5,-1444681467),o=Lf(o,n,i,s,e[t+2],9,-51403784),s=Lf(s,o,n,i,e[t+7],14,1735328473),i=Lf(i,s,o,n,e[t+12],20,-1926607734),n=Mf(n,i,s,o,e[t+5],4,-378558),o=Mf(o,n,i,s,e[t+8],11,-2022574463),s=Mf(s,o,n,i,e[t+11],16,1839030562),i=Mf(i,s,o,n,e[t+14],23,-35309556),n=Mf(n,i,s,o,e[t+1],4,-1530992060),o=Mf(o,n,i,s,e[t+4],11,1272893353),s=Mf(s,o,n,i,e[t+7],16,-155497632),i=Mf(i,s,o,n,e[t+10],23,-1094730640),n=Mf(n,i,s,o,e[t+13],4,681279174),o=Mf(o,n,i,s,e[t],11,-358537222),s=Mf(s,o,n,i,e[t+3],16,-722521979),i=Mf(i,s,o,n,e[t+6],23,76029189),n=Mf(n,i,s,o,e[t+9],4,-640364487),o=Mf(o,n,i,s,e[t+12],11,-421815835),s=Mf(s,o,n,i,e[t+15],16,530742520),i=Mf(i,s,o,n,e[t+2],23,-995338651),n=Nf(n,i,s,o,e[t],6,-198630844),o=Nf(o,n,i,s,e[t+7],10,1126891415),s=Nf(s,o,n,i,e[t+14],15,-1416354905),i=Nf(i,s,o,n,e[t+5],21,-57434055),n=Nf(n,i,s,o,e[t+12],6,1700485571),o=Nf(o,n,i,s,e[t+3],10,-1894986606),s=Nf(s,o,n,i,e[t+10],15,-1051523),i=Nf(i,s,o,n,e[t+1],21,-2054922799),n=Nf(n,i,s,o,e[t+8],6,1873313359),o=Nf(o,n,i,s,e[t+15],10,-30611744),s=Nf(s,o,n,i,e[t+6],15,-1560198380),i=Nf(i,s,o,n,e[t+13],21,1309151649),n=Nf(n,i,s,o,e[t+4],6,-145523070),o=Nf(o,n,i,s,e[t+11],10,-1120210379),s=Nf(s,o,n,i,e[t+2],15,718787259),i=Nf(i,s,o,n,e[t+9],21,-343485551),n=If(n,r),i=If(i,a),s=If(s,c),o=If(o,d)}return Uint32Array.of(n,i,s,o)}(t,8*e.length);return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(r)};var xf={};Object.defineProperty(xf,"__esModule",{value:!0}),xf.URL=xf.DNS=xf.stringToBytes=void 0;const Ff=of,jf=lf;function Uf(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}xf.stringToBytes=Uf,xf.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",xf.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",xf.default=function(e,t,r,n,i,s){const o="string"==typeof r?Uf(r):r,a="string"==typeof n?(0,Ff.default)(n):n;if("string"==typeof n&&(n=(0,Ff.default)(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(a),c.set(o,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){s=s||0;for(let e=0;e<16;++e)i[s+e]=c[e];return i}return(0,jf.unsafeStringify)(c)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=kf,r=xf;var n=xf;function i(e,n,i,s){return(0,r.default)(48,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(Tf);var Bf={},Vf={};Object.defineProperty(Vf,"__esModule",{value:!0});const Hf="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);Vf.default={randomUUID:Hf},Object.defineProperty(Bf,"__esModule",{value:!0});const Wf=Vf,qf=gf,zf=lf;Bf.default=function(e,t,r){if(Wf.default.randomUUID&&!t&&!e)return Wf.default.randomUUID();const n=(e=e||{}).random??e.rng?.()??(0,qf.default)();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return(0,zf.unsafeStringify)(n)};var Gf={},Yf={};function $f(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Kf(e,t){return e<<t|e>>>32-t}Object.defineProperty(Yf,"__esModule",{value:!0}),Yf.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,s=Math.ceil(i/16),o=new Array(s);for(let t=0;t<s;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];o[t]=r}o[s-1][14]=8*(e.length-1)/Math.pow(2,32),o[s-1][14]=Math.floor(o[s-1][14]),o[s-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<s;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=o[e][t];for(let e=16;e<80;++e)n[e]=Kf(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],s=r[1],a=r[2],c=r[3],d=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),o=Kf(i,5)+$f(r,s,a,c)+d+t[r]+n[e]>>>0;d=c,c=a,a=Kf(s,30)>>>0,s=i,i=o}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+d>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=Yf,r=xf;var n=xf;function i(e,n,i,s){return(0,r.default)(80,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(Gf);var Jf={};Object.defineProperty(Jf,"__esModule",{value:!0});const Qf=lf,Zf=mf,Xf=Cf;Jf.default=function(e,t,r){e??={},r??=0;let n=(0,Zf.default)({...e,_v6:!0},new Uint8Array(16));if(n=(0,Xf.default)(n),t){for(let e=0;e<16;e++)t[r+e]=n[e];return t}return(0,Qf.unsafeStringify)(n)};var em={};Object.defineProperty(em,"__esModule",{value:!0});const tm=of,rm=lf;em.default=function(e){const t=function(e){return Uint8Array.of((15&e[3])<<4|e[4]>>4&15,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|15&e[6],e[7],(15&e[1])<<4|(240&e[2])>>4,(15&e[2])<<4|(240&e[3])>>4,16|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,tm.default)(e):e);return"string"==typeof e?(0,rm.unsafeStringify)(t):t};var nm={};Object.defineProperty(nm,"__esModule",{value:!0}),nm.updateV7State=void 0;const im=gf,sm=lf,om={};function am(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function cm(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else n=new Uint8Array(16),i=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=255&t,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|3&e[10],n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}nm.updateV7State=am,nm.default=function(e,t,r){let n;if(e)n=cm(e.random??e.rng?.()??(0,im.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),i=(0,im.default)();am(om,e,i),n=cm(i,om.msecs,om.seq,t,r)}return t??(0,sm.unsafeStringify)(n)};var dm={};Object.defineProperty(dm,"__esModule",{value:!0});const um=af;dm.default=function(e){if(!(0,um.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.validate=e.v7=e.v6ToV1=e.v6=e.v5=e.v4=e.v3=e.v1ToV6=e.v1=e.stringify=e.parse=e.NIL=e.MAX=void 0;var t=nf;Object.defineProperty(e,"MAX",{enumerable:!0,get:function(){return t.default}});var r=sf;Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return r.default}});var n=of;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return n.default}});var i=lf;Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return i.default}});var s=mf;Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return s.default}});var o=Cf;Object.defineProperty(e,"v1ToV6",{enumerable:!0,get:function(){return o.default}});var a=Tf;Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return a.default}});var c=Bf;Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return c.default}});var d=Gf;Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return d.default}});var u=Jf;Object.defineProperty(e,"v6",{enumerable:!0,get:function(){return u.default}});var l=em;Object.defineProperty(e,"v6ToV1",{enumerable:!0,get:function(){return l.default}});var p=nm;Object.defineProperty(e,"v7",{enumerable:!0,get:function(){return p.default}});var h=af;Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return h.default}});var f=dm;Object.defineProperty(e,"version",{enumerable:!0,get:function(){return f.default}})}(rf);var lm={};Object.defineProperty(lm,"__esModule",{value:!0}),lm.FakeEventTarget=void 0;lm.FakeEventTarget=class{listeners={};addEventListener(e,t,r={}){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:t,once:!0===r.once}))}removeEventListener(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==t)))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}};var pm={};Object.defineProperty(pm,"__esModule",{value:!0}),pm.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Object.defineProperty(tf,"__esModule",{value:!0}),tf.FakeMediaStreamTrack=void 0;const hm=rf,fm=lm,mm=pm;class gm extends fm.FakeEventTarget{#b;#w;#S;#E;#C;#R;#P;#T;#k;#D;#I;#O=null;#A=null;#L=null;#M=null;#N=null;constructor({kind:e,id:t,label:r,contentHint:n,enabled:i,muted:s,readyState:o,capabilities:a,constraints:c,settings:d,data:u}){super(),this.#b=t??(0,hm.v4)(),this.#w=e,this.#S=r??"",this.#P=n??"",this.#C=i??!0,this.#R=s??!1,this.#E=o??"live",this.#T=a??{},this.#k=c??{},this.#D=d??{},this.#I=u??{}}get id(){return this.#b}get kind(){return this.#w}get label(){return this.#S}get contentHint(){return this.#P}set contentHint(e){this.#P=e}get enabled(){return this.#C}set enabled(e){const t=this.#C!==e;this.#C=e,t&&this.dispatchEvent(new Event("enabledchange"))}get muted(){return this.#R}get readyState(){return this.#E}get data(){return this.#I}set data(e){this.#I=e}get onmute(){return this.#O}set onmute(e){this.#O&&this.removeEventListener("mute",this.#O),this.#O=e,e&&this.addEventListener("mute",e)}get onunmute(){return this.#A}set onunmute(e){this.#A&&this.removeEventListener("unmute",this.#A),this.#A=e,e&&this.addEventListener("unmute",e)}get onended(){return this.#L}set onended(e){this.#L&&this.removeEventListener("ended",this.#L),this.#L=e,e&&this.addEventListener("ended",e)}get onenabledchange(){return this.#M}set onenabledchange(e){this.#M&&this.removeEventListener("enabledchange",this.#M),this.#M=e,e&&this.addEventListener("enabledchange",e)}get onstopped(){return this.#N}set onstopped(e){this.#N&&this.removeEventListener("stopped",this.#N),this.#N=e,e&&this.addEventListener("stopped",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t){super.removeEventListener(e,t)}stop(){"ended"!==this.#E&&(this.#E="ended",this.dispatchEvent(new Event("stopped")))}clone({id:e,data:t}={}){return new gm({id:e??(0,hm.v4)(),kind:this.#w,label:this.#S,contentHint:this.#P,enabled:this.#C,muted:this.#R,readyState:this.#E,capabilities:(0,mm.clone)(this.#T),constraints:(0,mm.clone)(this.#k),settings:(0,mm.clone)(this.#D),data:t??(0,mm.clone)(this.#I)})}getCapabilities(){return this.#T}getConstraints(){return this.#k}async applyConstraints(e={}){return this.#k=e,Promise.resolve()}getSettings(){return this.#D}remoteStop(){"ended"!==this.#E&&(this.#E="ended",this.dispatchEvent(new Event("stopped")),this.dispatchEvent(new Event("ended")))}remoteMute(){this.#R||(this.#R=!0,this.dispatchEvent(new Event("mute")))}remoteUnmute(){this.#R&&(this.#R=!1,this.dispatchEvent(new Event("unmute")))}}tf.FakeMediaStreamTrack=gm,Object.defineProperty(ef,"__esModule",{value:!0}),ef.FakeHandler=void 0;const vm=tf,ym=pc,_m=Mc,bm=Nc,wm=Oc,Sm=Cu,Em=new cc.Logger("FakeHandler");class Cm extends ym.EnhancedEventEmitter{id;ordered;maxPacketLifeTime;maxRetransmits;label;protocol;constructor({id:e,ordered:t,maxPacketLifeTime:r,maxRetransmits:n,label:i,protocol:s}){super(),this.id=e,this.ordered=t,this.maxPacketLifeTime=r,this.maxRetransmits=n,this.label=i,this.protocol=s}close(){this.safeEmit("close"),this.emit("@close")}send(e){this.safeEmit("message",e)}addEventListener(e,t){this.on(e,t)}}class Rm extends Sm.HandlerInterface{_closed=!1;fakeParameters;_rtpParametersByKind;_cname=`CNAME-${_m.generateRandomNumber()}`;_transportReady=!1;_nextLocalId=1;_tracks=new Map;_nextSctpStreamId=0;static createFactory(e){return()=>new Rm(e)}constructor(e){super(),this.fakeParameters=e}get name(){return"FakeHandler"}close(){Em.debug("close()"),this._closed||(this._closed=!0)}setIceGatheringState(e){this.emit("@icegatheringstatechange",e)}setConnectionState(e){this.emit("@connectionstatechange",e)}async getNativeRtpCapabilities(){return Em.debug("getNativeRtpCapabilities()"),this.fakeParameters.generateNativeRtpCapabilities()}async getNativeSctpCapabilities(){return Em.debug("getNativeSctpCapabilities()"),this.fakeParameters.generateNativeSctpCapabilities()}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,proprietaryConstraints:a,extendedRtpCapabilities:c}){this.assertNotClosed(),Em.debug("run()"),this._rtpParametersByKind={audio:bm.getSendingRtpParameters("audio",c),video:bm.getSendingRtpParameters("video",c)}}async updateIceServers(e){this.assertNotClosed(),Em.debug("updateIceServers()")}async restartIce(e){this.assertNotClosed(),Em.debug("restartIce()")}async getTransportStats(){return this.assertNotClosed(),new Map}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),Em.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"});const i=_m.clone(this._rtpParametersByKind[e.kind]),s=i.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));i.mid=`mid-${_m.generateRandomNumber()}`,t||(t=[{}]);for(const e of t)e.ssrc=_m.generateRandomNumber(),s&&(e.rtx={ssrc:_m.generateRandomNumber()});i.encodings=t,i.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const o=this._nextLocalId++;return this._tracks.set(o,e),{localId:String(o),rtpParameters:i}}async stopSending(e){if(Em.debug("stopSending() [localId:%s]",e),!this._closed){if(!this._tracks.has(Number(e)))throw new Error("local track not found");this._tracks.delete(Number(e))}}async pauseSending(e){this.assertNotClosed()}async resumeSending(e){this.assertNotClosed()}async replaceTrack(e,t){this.assertNotClosed(),t?Em.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Em.debug("replaceTrack() [localId:%s, no track]",e),this._tracks.delete(Number(e)),this._tracks.set(Number(e),t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),Em.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),Em.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t)}async getSenderStats(e){return this.assertNotClosed(),new Map}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),Em.debug("sendDataChannel()");return{dataChannel:new Cm({id:this._nextSctpStreamId++,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}),sctpStreamParameters:{streamId:this._nextSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r}}}async receive(e){this.assertNotClosed();const t=[];for(const r of e){const{trackId:e,kind:n}=r;this._transportReady||await this.setupTransport({localDtlsRole:"client"}),Em.debug("receive() [trackId:%s, kind:%s]",e,n);const i=this._nextLocalId++,s=new vm.FakeMediaStreamTrack({kind:n});this._tracks.set(i,s),t.push({localId:String(i),track:s})}return t}async stopReceiving(e){if(!this._closed)for(const t of e)Em.debug("stopReceiving() [localId:%s]",t),this._tracks.delete(Number(t))}async pauseReceiving(e){this.assertNotClosed()}async resumeReceiving(e){this.assertNotClosed()}async getReceiverStats(e){return this.assertNotClosed(),new Map}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"client"}),Em.debug("receiveDataChannel()");return{dataChannel:new Cm({id:e.streamId,ordered:e.ordered,maxPacketLifeTime:e.maxPacketLifeTime,maxRetransmits:e.maxRetransmits,label:t,protocol:r})}}async setupTransport({localDtlsRole:e,localSdpObject:t}){const r=_m.clone(this.fakeParameters.generateLocalDtlsParameters());e&&(r.role=e),this.emit("@connectionstatechange","connecting"),await new Promise(((e,t)=>this.emit("@connect",{dtlsParameters:r},e,t))),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new wm.InvalidStateError("method called in a closed handler")}}ef.FakeHandler=Rm;var Pm={};Object.defineProperty(Pm,"__esModule",{value:!0}),Pm.generateRouterRtpCapabilities=function(){return Tm.deepFreeze({codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}},{mimeType:"video/H264",kind:"video",preferredPayloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:105,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"profile-id":0,"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:106,clockRate:9e4,rtcpFeedback:[],parameters:{apt:105}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",preferredId:2,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",preferredId:3,preferredEncrypt:!1,direction:"recvonly"},{kind:"audio",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07",preferredId:6,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:framemarking",preferredId:7,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:11,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:12,preferredEncrypt:!1,direction:"sendrecv"}]})},Pm.generateNativeRtpCapabilities=function(){return Tm.deepFreeze({codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:111,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{minptime:10,useinbandfec:1}},{mimeType:"audio/ISAC",kind:"audio",preferredPayloadType:103,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/CN",kind:"audio",preferredPayloadType:106,clockRate:32e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:96,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:97,clockRate:9e4,rtcpFeedback:[],parameters:{apt:96}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:98,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{"profile-id":0}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:99,clockRate:9e4,rtcpFeedback:[],parameters:{apt:98}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:2},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:3},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:4},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",preferredId:6},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-content-type",preferredId:7},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-timing",preferredId:8},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10}]})},Pm.generateNativeSctpCapabilities=function(){return Tm.deepFreeze({numStreams:{OS:2048,MIS:2048}})},Pm.generateLocalDtlsParameters=function(){return Tm.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"82:5A:68:3D:36:C3:0A:DE:AF:E7:32:43:D2:88:83:57:AC:2D:65:E5:80:C4:B6:FB:AF:1A:A0:21:9F:6D:0C:AD"}],role:"auto"})},Pm.generateTransportRemoteParameters=function(){return{id:km(),iceParameters:Tm.deepFreeze({iceLite:!0,password:"yku5ej8nvfaor28lvtrabcx0wkrpkztz",usernameFragment:"h3hk1iz6qqlnqlne"}),iceCandidates:Tm.deepFreeze([{foundation:"udpcandidate",address:"9.9.9.9",ip:"9.9.9.9",port:40533,priority:1078862079,protocol:"udp",type:"host",tcpType:"passive"},{foundation:"udpcandidate",address:"9.9.9.9",ip:"9:9:9:9:9:9",port:41333,priority:1078862089,protocol:"udp",type:"host",tcpType:"passive"}]),dtlsParameters:Tm.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"A9:F4:E0:D2:74:D3:0F:D9:CA:A5:2F:9F:7F:47:FA:F0:C4:72:DD:73:49:D0:3B:14:90:20:51:30:1B:90:8E:71"},{algorithm:"sha-384",value:"03:D9:0B:87:13:98:F6:6D:BC:FC:92:2E:39:D4:E1:97:32:61:30:56:84:70:81:6E:D1:82:97:EA:D9:C1:21:0F:6B:C5:E7:7F:E1:97:0C:17:97:6E:CF:B3:EF:2E:74:B0"},{algorithm:"sha-512",value:"84:27:A4:28:A4:73:AF:43:02:2A:44:68:FF:2F:29:5C:3B:11:9A:60:F4:A8:F0:F5:AC:A0:E3:49:3E:B1:34:53:A9:85:CE:51:9B:ED:87:5E:B8:F4:8E:3D:FA:20:51:B8:96:EE:DA:56:DC:2F:5C:62:79:15:23:E0:21:82:2B:2C"}],role:"auto"}),sctpParameters:Tm.deepFreeze({port:5e3,OS:2048,MIS:2048,maxMessageSize:2e6})}},Pm.generateProducerRemoteParameters=function(){return Tm.deepFreeze({id:km()})},Pm.generateConsumerRemoteParameters=function({id:e,codecMimeType:t}={}){switch(t){case"audio/opus":return{id:e??km(),producerId:km(),kind:"audio",rtpParameters:Tm.deepFreeze({codecs:[{mimeType:"audio/opus",payloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}}],encodings:[{ssrc:46687003}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",id:10}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"audio/ISAC":return{id:e??km(),producerId:km(),kind:"audio",rtpParameters:Tm.deepFreeze({codecs:[{mimeType:"audio/ISAC",payloadType:111,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}}],encodings:[{ssrc:46687004}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/VP8":return{id:e??km(),producerId:km(),kind:"video",rtpParameters:Tm.deepFreeze({codecs:[{mimeType:"video/VP8",payloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",payloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}}],encodings:[{ssrc:99991111,rtx:{ssrc:99991112}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/H264":return{id:e??km(),producerId:km(),kind:"video",rtpParameters:Tm.deepFreeze({codecs:[{mimeType:"video/H264",payloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",payloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}}],encodings:[{ssrc:99991113,rtx:{ssrc:99991114}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};default:throw new TypeError(`unknown codecMimeType '${t}'`)}},Pm.generateDataProducerRemoteParameters=function(){return Tm.deepFreeze({id:km()})},Pm.generateDataConsumerRemoteParameters=function({id:e}={}){return{id:e??km(),dataProducerId:km(),sctpStreamParameters:Tm.deepFreeze({streamId:666,maxPacketLifeTime:5e3,maxRetransmits:void 0})}};const Tm=Mc;function km(){return String(Tm.generateRandomNumber())}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.testFakeParameters=e.FakeHandler=e.ortc=e.parseScalabilityMode=e.detectDeviceAsync=e.detectDevice=e.Device=e.version=e.types=void 0;const t=Qa.exports;e.debug=t.default,e.types=sc,e.version="3.11.0";var r=oc;Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return r.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return r.detectDevice}}),Object.defineProperty(e,"detectDeviceAsync",{enumerable:!0,get:function(){return r.detectDeviceAsync}});var n=xu;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return n.parse}}),e.ortc=Nc;var i=ef;Object.defineProperty(e,"FakeHandler",{enumerable:!0,get:function(){return i.FakeHandler}}),e.testFakeParameters=Pm}(Ja);const Dm=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Im=[{maxBitrate:1e6,dtx:!0}],Om=[{maxBitrate:4e4,dtx:!0}],Am={width:1280,height:720},Lm=0,Mm=2,Nm=0;function xm(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function Fm(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}const jm=new Wn,Um=e=>u(void 0,void 0,void 0,(function*(){return yield new Promise(((t,r)=>{!function(e,t,r){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");"function"==typeof t&&(r=t,t={}),t=t||{},r=r||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async=!("async"in t)||!!t.async,i.src=e,t.attrs&&function(e,t){for(var r in t)e.setAttribute(r,t[r])}(i,t.attrs),t.text&&(i.text=""+t.text),("onload"in i?xm:Fm)(i,r),i.onload||xm(i,r),n.appendChild(i)}(e,((e,n)=>{e?r(e):t(n)}))}))})),Bm=(e,...t)=>u(void 0,[e,...t],void 0,(function*(e,t=3,r=500){let n=0;for(;n<t;)try{return void(yield Um(e))}catch(e){if(n+=1,!(n<t))throw e;yield jm.sleepMs(r)}}));var Vm;let Hm=class{constructor(){Vm.set(this,new Map)}add(e,t,r){const n=this.getKey(e,t);if(l(this,Vm,"f").has(n))throw new Error("Attempt to rewrite cached track processor");l(this,Vm,"f").set(n,r)}get(e,t){return l(this,Vm,"f").get(this.getKey(e,t))}has(e,t){return l(this,Vm,"f").has(this.getKey(e,t))}getKey(e,t){return`${e}:${t}`}reset(){for(const e of l(this,Vm,"f").values())e.stopProcessing();l(this,Vm,"f").clear()}};var Wm,qm;Vm=new WeakMap,Hm=a([ut()],Hm);let zm=class{constructor(e,t,r,n){this.config=e,this.processorsCache=t,this.audioTrackProcessorFactory=r,Wm.set(this,new Map),qm.set(this,void 0),p(this,qm,n("IntegrationsService"),"f")}init(){const e=this.config.get("denoiser");if("asdk"===e){l(this,qm,"f").info("Start integration of ASDK",{denoiser:e});const t={integrated:!1,initPromise:this.integrateASDK()};l(this,Wm,"f").set("asdk",t)}else{l(this,qm,"f").info("Start integration of RNNoise",{denoiser:e});const t={integrated:!1,initPromise:this.integrateRNNoise()};l(this,Wm,"f").set("rnnoise",t)}}integrateASDK(){return u(this,void 0,void 0,(function*(){const e=this.config.get("asdk"),t=this.config.get("staticFilesPath");if(!window.atsvb){const s=`https://effectssdk.ai/sdk/audio/dev/${e.version}/atsvb-web.js`;let o=s;if(e.localDir){const n=`${e.localDir}/${e.version}/atsvb-web.js`;o=new r.URL(n,t).href}yield(n=o,i=s,u(void 0,void 0,void 0,(function*(){try{yield Bm(n)}catch(e){if(!i)throw e;yield Bm(i)}})))}var n,i;if(!window.atsvb)throw l(this,qm,"f").info("Audio Effects SDK is not loaded, skipping initialization",{case:"initAudioSDK"}),new Error("windows.atsvb is still missing");const s=this.audioTrackProcessorFactory({trackLabel:$n.Microphone});yield s.init(),this.processorsCache.add("asdk",$n.Microphone,s);const o=l(this,Wm,"f").get("asdk");if(!o)throw Error("IntegrationContext is missing for ASDK");o.integrated=!0}))}get audio(){return"asdk"===this.config.get("denoiser")?this.getASDKState():this.getRNNoiseState()}getASDKState(){var e,t;const r=l(this,Wm,"f").get("asdk");return{type:"asdk",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}getRNNoiseState(){var e,t;const r=l(this,Wm,"f").get("rnnoise");return{type:"rnnoise",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}integrateRNNoise(){return u(this,void 0,void 0,(function*(){const e=yield function(e){return u(this,void 0,void 0,(function*(){if(!window.WebAssembly)throw new Error("Webassembly not supported");const t=yield fetch(`${e}/rnnoise-processor.wasm`);return yield WebAssembly.instantiate(yield t.arrayBuffer())}))}(this.config.get("staticFilesPath")),t=this.audioTrackProcessorFactory({trackLabel:$n.Microphone,noiseSuppressor:e});this.processorsCache.add("rnnoise",$n.Microphone,t);const r=l(this,Wm,"f").get("rnnoise");if(!r)throw Error("IntegrationContext is missing for RNNoise");r.integrated=!0}))}reset(){l(this,Wm,"f").clear()}};var Gm,Ym,$m,Km,Jm,Qm,Zm,Xm,eg;Wm=new WeakMap,qm=new WeakMap,zm=a([ut(),c(0,pt(Gn.Config)),c(1,pt(Gn.ProcessorsCache)),c(2,pt(Gn.AudioTrackProcessorFactory)),c(3,pt(Gn.LoggerFactory)),d("design:paramtypes",[kt,Hm,Function,Function])],zm),function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(Xm||(Xm={})),function(e){e.TSVB="tsvb",e.COMPONENTS_SYSTEM="components_system",e.SRTEAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.PRESET_INIT="preset_init",e.RENDERER="renderer",e.RECORDER="recorder",e.EFFECT_VIRTUAL_BACKGROUND="effect_virtual_background",e.EFFECT_COLOR_CORRECTION="effect_color_correction",e.EFFECT_COLOR_FILTER="effect_color_filter",e.EFFECT_SMART_ZOOM="effect_smart_zoom",e.EFFECT_LOW_LIGHT="effect_low_light"}(eg||(eg={}));class tg{constructor(e){Gm.set(this,void 0),Ym.set(this,void 0),$m.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),Km.set(this,null),Jm.set(this,void 0),Qm.set(this,!1),Zm.set(this,void 0);const{loggerFactory:t}=e;if(p(this,Ym,t("EffectsSDKTrackProcessor"),"f"),p(this,Zm,e.onModelsLoaded,"f"),!e.customerId)throw new Error("Customer ID must be provided");p(this,Gm,new window.tsvb(e.customerId),"f"),l(this,Gm,"f").onError(this.tsvbErrorHandler.bind(this)),l(this,Gm,"f").onReady=this.onReady.bind(this);const r=e.config.get("staticFilesPath"),{localDir:n,version:i}=e.config.get("effectsSDKParams"),s=n&&i?`${r}/esdk/${null!=i?i:"3.5.5"}`:`https://effectssdk.ai/sdk/web/${null!=i?i:"3.5.5"}`,o={preset:"balanced",provider:"webgpu",sdk_url:e.sdk_url,api_url:e.api_url,wasmPaths:{"ort-wasm.wasm":`${s}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${s}/ort-wasm-simd.wasm`,"ort-wasm-simd.jsep.wasm":`${s}/ort-wasm-simd.jsep.wasm`}};l(this,Gm,"f").config(o)}init(){return u(this,void 0,void 0,(function*(){yield l(this,Gm,"f").preload(),yield l(this,Gm,"f").cache(),p(this,Qm,!0,"f")}))}awaitReady(){return u(this,void 0,void 0,(function*(){yield new Promise(((e,t)=>{const r=Date.now(),n=setInterval((()=>{if(this.isModelsLoaded)return clearInterval(n),void e();Date.now()-r>6e4&&(clearInterval(n),t(new Error("ESDK init timeout")))}),100)}))}))}tsvbErrorHandler(e){var t;const{emitter:r,type:n}=e,i=o(e,["emitter","type"]),s=null!=r?r:"N/A emitter";n===Xm.ERROR&&l(this,Ym,"f").error(s,Object.assign({error:mr(e)},i)),n===Xm.WARNING&&l(this,Ym,"f").warn(s,Object.assign({},i)),n===Xm.INFO&&l(this,Ym,"f").info(s,Object.assign({},i)),r===eg.ML_INFERENCE&&(i.message.toLocaleLowerCase().includes("init lowlighter")&&(l(this,$m,"f").lowLighter=!0),i.message.toLocaleLowerCase().includes("init colorcorrector")&&(l(this,$m,"f").colorCorrector=!0),i.message.toLocaleLowerCase().includes("init facedetector")&&(l(this,$m,"f").faceDetector=!0),i.message.toLocaleLowerCase().includes("init segmentation")&&(l(this,$m,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=l(this,Zm,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return l(this,$m,"f").colorCorrector&&l(this,$m,"f").faceDetector&&l(this,$m,"f").lowLighter&&l(this,$m,"f").segmentation}get modelsLoadProgress(){return Object.values(l(this,$m,"f")).filter(Boolean).length/Object.keys(l(this,$m,"f")).length}get isReady(){return l(this,Qm,"f")}setOnLoadModels(e){p(this,Zm,e,"f"),this.isModelsLoaded&&l(this,Zm,"f").call(this)}onReady(){p(this,Qm,!0,"f"),l(this,Ym,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(l(this,Jm,"f"))}processTrack(e){var t,r,n;if(l(this,Km,"f")===e||"ended"===e.readyState)return null!==(r=null===(t=l(this,Gm,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])&&void 0!==r?r:e;this.stopProcessing();try{l(this,Gm,"f").useStream(new MediaStream([e]));const t=null===(n=l(this,Gm,"f").getStream())||void 0===n?void 0:n.getVideoTracks()[0];return t?(p(this,Km,e,"f"),t):e}catch(t){throw l(this,Ym,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}stopProcessing(){try{l(this,Gm,"f").clear(),l(this,Gm,"f").stop()}catch(e){l(this,Ym,"f").error("stopProcessing()",{error:e})}finally{p(this,Km,null,"f")}}updateEffects(e){var t,r,n,i,s,o,a,c,d,u,h,f,m,g,v,y,_,b,w,S,E,C;if(p(this,Jm,e,"f"),!l(this,Qm,"f"))return void l(this,Ym,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!l(this,Jm,"f")||0===Object.keys(l(this,Jm,"f")).length)return void l(this,Gm,"f").stop();let R=0;if((null===(t=l(this,Jm,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=l(this,Jm,"f"))||void 0===r?void 0:r.backgroundColor)?(l(this,Gm,"f").setBlur(l(this,Jm,"f").blur),R+=1):l(this,Gm,"f").clearBlur(),void 0!==(null===(n=l(this,Jm,"f"))||void 0===n?void 0:n.background)?(l(this,Gm,"f").setBackground(l(this,Jm,"f").background),R+=1):void 0!==(null===(i=l(this,Jm,"f"))||void 0===i?void 0:i.backgroundColor)?(l(this,Gm,"f").setBackgroundColor(null===(s=l(this,Jm,"f"))||void 0===s?void 0:s.backgroundColor),l(this,Gm,"f").setBackground("color"),R+=1):l(this,Gm,"f").clearBackground(),(null===(o=l(this,Jm,"f"))||void 0===o?void 0:o.beautification)?(l(this,Gm,"f").enableBeautification(),l(this,Gm,"f").setBeautificationLevel(l(this,Jm,"f").beautification),R+=1):l(this,Gm,"f").disableBeautification(),(null===(a=l(this,Jm,"f"))||void 0===a?void 0:a.lowLightEffect)?(l(this,Gm,"f").enableLowLightEffect(),l(this,Gm,"f").setLowLightEffectPower(l(this,Jm,"f").lowLightEffect),R+=1):l(this,Gm,"f").disableLowLightEffect(),(null===(c=l(this,Jm,"f"))||void 0===c?void 0:c.colorCorrector)?(l(this,Gm,"f").enableColorCorrector(),l(this,Gm,"f").setColorCorrectorPower(l(this,Jm,"f").colorCorrector),R+=1):l(this,Gm,"f").disableColorCorrector(),(null===(d=l(this,Jm,"f"))||void 0===d?void 0:d.smartZoom)?(l(this,Gm,"f").enableSmartZoom(),l(this,Gm,"f").setFaceArea(l(this,Jm,"f").smartZoom),R+=1):l(this,Gm,"f").disableSmartZoom(),(null===(u=l(this,Jm,"f"))||void 0===u?void 0:u.layout)?(l(this,Gm,"f").setLayout(l(this,Jm,"f").layout),R+=1):l(this,Gm,"f").setLayout("center"),(null===(h=l(this,Jm,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=l(this,Jm,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=l(this,Jm,"f"))||void 0===m?void 0:m.colorFilter.url)?(l(this,Gm,"f").setColorFilterConfig({lut:l(this,Jm,"f").colorFilter.url,power:l(this,Jm,"f").colorFilter.power}),l(this,Gm,"f").enableColorFilter(),R+=1):l(this,Gm,"f").disableColorFilter(),null===(g=l(this,Jm,"f"))||void 0===g?void 0:g.lowerThird){const e=l(this,Gm,"f").createComponent({component:l(this,Jm,"f").lowerThird.type,options:null!==(v=l(this,Jm,"f").lowerThird.options)&&void 0!==v?v:{}});null===(b=null===(_=null===(y=l(this,Gm,"f").components)||void 0===y?void 0:y.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===b||b.call(_),l(this,Gm,"f").addComponent(e,"lowerThird"),l(this,Gm,"f").components.lowerThird.showLowerThird(),R+=1}else null===(E=null===(S=null===(w=l(this,Gm,"f").components)||void 0===w?void 0:w.lowerThird)||void 0===S?void 0:S.hideLowerThird)||void 0===E||E.call(S);(null===(C=l(this,Jm,"f"))||void 0===C?void 0:C.sharpness)?(l(this,Gm,"f").setSharpnessEffectConfig(l(this,Jm,"f").sharpness),R+=1):l(this,Gm,"f").disableSharpnessEffect(),R>2?l(this,Gm,"f").enableFrameSkipping():l(this,Gm,"f").disableFrameSkipping(),l(this,Gm,"f").run()}}Gm=new WeakMap,Ym=new WeakMap,$m=new WeakMap,Km=new WeakMap,Jm=new WeakMap,Qm=new WeakMap,Zm=new WeakMap;const rg=e=>"rtx"!==e.mimeType;var ng,ig,sg,og,ag,cg,dg,ug,lg,pg,hg,fg,mg,gg,vg,yg,_g;class bg{constructor({track:e,statsHandler:t}){ng.set(this,void 0),ig.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return l(this,ng,"f")}get audioWebRTCStats(){return l(this,ig,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addOutboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addOutboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){p(this,ng,e,"f")}setAudioWebRTCStats(e){p(this,ig,e,"f")}}ng=new WeakMap,ig=new WeakMap,function(e){e.CloseProducer="CloseProducer",e.Mute="Mute",e.Resume="Resume"}(sg||(sg={}));class wg{constructor(e){og.set(this,void 0),ag.set(this,void 0),this.encoderConfig={},this.label=$n.Unknown,cg.set(this,void 0),dg.set(this,void 0),ug.set(this,void 0),lg.set(this,void 0),pg.set(this,void 0),hg.set(this,void 0),fg.set(this,void 0),mg.set(this,void 0),gg.set(this,!0),vg.set(this,void 0),yg.set(this,void 0),_g.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,socket:c,mutex:d,loggerFactory:u,loggerNamespace:l,statsHandler:h}=e;p(this,og,t,"f"),p(this,pg,r,"f"),p(this,hg,n,"f"),p(this,fg,i,"f"),p(this,mg,new Dt,"f"),this.logger=u(l),p(this,vg,d,"f"),p(this,dg,s,"f"),p(this,cg,o,"f"),p(this,ug,a,"f"),p(this,lg,c,"f"),p(this,_g,h,"f"),p(this,yg,new bg({track:t,statsHandler:h}),"f")}get videoWebRTCStats(){return l(this,yg,"f").videoWebRTCStats}get audioWebRTCStats(){return l(this,yg,"f").audioWebRTCStats}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished}}get observer(){return l(this,mg,"f")}get mediaStreamTrack(){return l(this,og,"f")}get originalTrack(){return l(this,ag,"f")}get id(){return this.mediaStreamTrack.id}get kind(){return this.mediaStreamTrack.kind}get producerId(){var e;return null===(e=this.producer)||void 0===e?void 0:e.id}get isPublished(){return!!this.producer&&!this.producer.closed}get isPaused(){var e,t;return null!==(t=null===(e=this.producer)||void 0===e?void 0:e.paused)&&void 0!==t&&t}get internalEventEmitter(){return l(this,pg,"f")}getLabel(){return this.label}setLabel(e){this.label=e}setEncoderConfig(e){this.encoderConfig=e}getEncoderConfig(){return this.encoderConfig}setProducer(e){this.producer=e}setStopTrackOnPause(e){this.isPublished||p(this,gg,e,"f")}getProducer(){return this.producer}setOriginalTrack(){p(this,ag,this.mediaStreamTrack,"f")}closeProducer(){return u(this,arguments,void 0,(function*(e=!0){const t=yield l(this,vg,"f").lock(sg.CloseProducer);if(!this.producer)return void t();const{producerId:r}=this;try{r&&(yield l(this,ug,"f").closeRemoteProducer(r),this.logger.info("Remote producer closed",{producerId:r}))}catch(e){this.logger.warn("closeProducer()",{label:this.getLabel(),error:mr(e),producerId:r})}this.producer.close(),this.producer=void 0,e&&this.stopMediaStreamTrack(),t()}))}setPriority(e){return u(this,void 0,void 0,(function*(){this.producer?(yield this.producer.setRtpEncodingParameters({priority:e}),this.logger.debug("setPriority()",{label:this.getLabel(),priority:e})):this.logger.warn("setPriority()",{priority:e,reason:"Not published yet"})}))}stopMediaStreamTrack(){this.mediaStreamTrack.stop(),this.mediaStreamTrack.dispatchEvent(new Event("ended")),this.stopOriginalTrack()}stopOriginalTrack(){l(this,ag,"f")&&(l(this,ag,"f").stop(),p(this,ag,void 0,"f"))}produce(e){return u(this,arguments,void 0,(function*({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s,o,a,c,d;if(!l(this,cg,"f").canPublish)throw this.logger.error("produce()",{message:"Not enough access to produce"}),new Error("Not enough access to produce");if(this.producer)throw new Error("Track already produced");try{yield l(this,lg,"f").request(Pr);const{rtpCapabilities:{codecs:u}}=l(this,dg,"f").mediasoupDevice,p=null==u?void 0:u.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),h=0,f=this.prepareProducerEncodings({codec:p,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),m={trackTransformParams:n,peerId:String(l(this,cg,"f").id),label:this.getLabel(),maxSpatialLayer:h,encodings:f,codecOptions:t,preferredCodec:r,codec:p,keyFrameRequestDelay:i},g=yield null===(s=l(this,ug,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:f,codecOptions:t,codec:p,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:m});if(!g)return;const v=g.rtpSender,y=()=>/Safari/i.test(navigator.userAgent);if(e&&v&&y()){const t=v.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield v.setParameters(t)}this.setProducer(g),(null===(a=null===(o=this.producer)||void 0===o?void 0:o.track)||void 0===a?void 0:a.id)!==l(this,og,"f").id&&(this.logger.info("Producer initialized with old track, updating",{oldTrackId:null===(d=null===(c=this.producer)||void 0===c?void 0:c.track)||void 0===d?void 0:d.id,newTrackId:l(this,og,"f").id}),yield this.replaceTrack(l(this,og,"f"))),"video"===this.kind&&(e&&v&&p&&Hn(p.mimeType)&&!y()?yield v.setParameters(Object.assign(Object.assign({},v.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:p,maxSpatialLayer:h})})):yield g.setMaxSpatialLayer(h),yield l(this,lg,"f").request(mn,{producerId:g.id,maxSpatialLayer:h})),"audio"===this.kind&&(yield this.setPriority("high")),this.logger.debug("produce()",{track:this.logCtx,encodings:e,codecOptions:t})}catch(e){throw this.logger.error("produce()",{error:e,track:this.logCtx}),new Error("Publish track failed")}}))}publish(){return u(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(Qr.trackProduced,this)}))}unpublish(){return u(this,arguments,void 0,(function*(e=!0){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Qr.trackUnproduced,this),this.producer&&(yield this.closeProducer()),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return u(this,void 0,void 0,(function*(){return yield l(this,lg,"f").request(hn,{producerId:e})}))}resumeRemoteProducer(e){return u(this,void 0,void 0,(function*(){return yield l(this,lg,"f").request(fn,{producerId:e})}))}mute(e){return u(this,void 0,void 0,(function*(){const t=yield l(this,vg,"f").lock(sg.Mute);if(!this.producer)return this.logger.warn("pause()",{message:"Track is not published",track:this.logCtx}),void t();try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),l(this,gg,"f"))return null==e||e(),l(this,og,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Qr.trackClosed,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Qr.trackPaused,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield l(this,dg,"f").deleteTrack(this),this.internalEventEmitter.emit(Qr.trackFailed,this),new Error("Can`t pause track, removing")}finally{t()}}))}resume(){return u(this,void 0,void 0,(function*(){const e=yield l(this,vg,"f").lock(sg.Resume);if(!this.producer)return this.logger.warn("resume()",{message:"Track is not published",track:this.logCtx}),void e();try{if(this.logger.debug("resume()",{track:this.logCtx}),l(this,gg,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Qr.trackReopened,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Qr.trackResumed,this)}catch(e){throw this.logger.error("resume()",{error:e,track:this.logCtx}),new Error("Can`t resume track")}finally{e()}}))}getInfo(){return u(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=l(this,og,"f").getSettings();return{trackId:l(this,og,"f").id,readyState:l(this,og,"f").readyState,kind:this.kind,label:this.label,width:e,height:t,frameRate:r,aspectRatio:n,paused:this.isPaused,trackOutboundStats:yield this.getStats()}}))}getStats(){return u(this,void 0,void 0,(function*(){var e,t,r,n,i;try{return{producerId:null===(e=this.producer)||void 0===e?void 0:e.id,codec:null===(t=this.producer)||void 0===t?void 0:t.rtpParameters.codecs.find((e=>rg(e))),dtlsState:null===(i=null===(n=null===(r=this.producer)||void 0===r?void 0:r.rtpSender)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.state,rtcStats:yield this.getOutboundRTPStreamStats()}}catch(e){return void this.logger.debug("getStats()",{error:e})}}))}replaceTrack(e){return u(this,void 0,void 0,(function*(){var t;try{p(this,og,e,"f"),this.internalEventEmitter.emit(Qr.trackReopened,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),p(this,yg,new bg({track:e,statsHandler:l(this,_g,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return u(this,void 0,void 0,(function*(){this.producer?(yield this.resumeRemoteProducer(this.producer.id),this.producer.resume()):this.logger.debug("resumeProducer()",{message:"Track not produced yet",track:this.logCtx})}))}reopenMediaStreamTrack(){return u(this,void 0,void 0,(function*(){var e;const t=yield l(this,fg,"f").createMediaStreamTrack({label:this.label,constraints:l(this,hg,"f")});p(this,og,t,"f"),yield null===(e=this.producer)||void 0===e?void 0:e.replaceTrack({track:t})}))}prepareProducerEncodings(e){const{encodings:t,codec:r,maxSpatialLayer:n}=e;return t&&t.length>1&&r&&Hn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>u(this,[...n],void 0,(function*(n=0){if(!this.producer)throw new Error("Producer is missed");try{const i=yield this.producer.getStats(),s=Array.from(i.values()).find((e=>"outbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>u(this,void 0,void 0,(function*(){return yield r(n+1)}))),150);n>=5&&!s&&t(new Error("OutboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),this.logger.debug("getOutboundRTPStreamStats()",{error:e})}}));r().catch((e=>{this.logger.debug("Error executing getRTCStatsReport",{case:"DefaultBaseTrack",error:mr(e)})}))}))}))}}var Sg,Eg,Cg,Rg;og=new WeakMap,ag=new WeakMap,cg=new WeakMap,dg=new WeakMap,ug=new WeakMap,lg=new WeakMap,pg=new WeakMap,hg=new WeakMap,fg=new WeakMap,mg=new WeakMap,gg=new WeakMap,vg=new WeakMap,yg=new WeakMap,_g=new WeakMap;class Pg extends wg{constructor(e){super(e),this.transformParams={},Sg.set(this,void 0),Eg.set(this,void 0),Cg.set(this,!1),Rg.set(this,(()=>{})),p(this,Eg,e,"f")}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished,isEffectsProcessing:this.isEffectsProcessing}}get isEffectsProcessing(){return Boolean(l(this,Sg,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){var e;return{videoGoogleStartBitrate:null!==(e=this.getEncoderConfig().videoGoogleStartBitrate)&&void 0!==e?e:1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===$n.ScreenVideo?"vp8":"h264")}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Dm}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return u(this,void 0,void 0,(function*(){const t=this.getProducer();t?(yield t.setMaxSpatialLayer(e),this.logger.debug("setMaxSpatialLayer()",{label:this.getLabel(),spatialLayer:e})):this.logger.warn("setMaxSpatialLayer()",{message:"Not produced yet"})}))}getMaxSpatialLayer(){const e=this.getProducer();if(e)return e.maxSpatialLayer;this.logger.warn("getMaxSpatialLayer()",{message:"Not produced yet"})}enableEffects(){return u(this,void 0,void 0,(function*(){if(!l(this,Cg,"f")){p(this,Cg,!0,"f");try{if(l(this,Sg,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void p(this,Cg,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=l(this,Eg,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();p(this,Sg,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=l(this,Sg,"f").processTrack(this.mediaStreamTrack),n=Date.now();this.logger.info("enableEffects() time",{time:(n-t)/1e3}),yield this.replaceTrack(r),this.logger.info("enableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("enableEffects()",{track:this.logCtx,error:mr(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:mr(e)})})),l(this,Rg,"f").call(this,e)}finally{p(this,Cg,!1,"f")}}}))}disableEffects(){return u(this,void 0,void 0,(function*(){var e;try{if(!l(this,Sg,"f"))return void this.logger.debug("disableEffects()",{description:"Track is not processed"});this.originalTrack?yield this.replaceTrack(this.originalTrack):this.logger.warn("disableEffects()",{description:"Original track missing"}),null===(e=l(this,Sg,"f"))||void 0===e||e.stopProcessing(),p(this,Sg,void 0,"f"),this.logger.info("disableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("disableEffects()",{track:this.logCtx,error:e})}}))}publish(){return u(this,arguments,void 0,(function*(e={}){var t;yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),transformParams:this.transformParams,codecOptions:this.getCodecOptions(),keyFrameRequestDelay:null!==(t=e.keyFrameRequestDelay)&&void 0!==t?t:0}),this.internalEventEmitter.emit(Qr.trackProduced,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return u(this,void 0,void 0,(function*(){var t;if(!Hn(this.getPreferredCodec()))return;const{rtpSender:r}=null!==(t=this.getProducer())&&void 0!==t?t:{};if(!r)return void this.logger.warn("No rtpSender found in producer to change encodings",{maxSpatialLayer:e,trackId:this.id,producerId:this.producerId});const{encodings:n=[]}=this.getEncoderConfig(),i=n[e];if(!i)return void this.logger.warn("Skipping RTPSender params update. No target encoding found",{initialEncodings:n});this.logger.debug("Adjusting encoding parameters to max spatial layer",{targetEncoding:i,maxSpatialLayer:e});const s=r.getParameters();yield r.setParameters(Object.assign(Object.assign({},s),{encodings:[Object.assign(Object.assign({},s.encodings[0]),i)]}))}))}applyEffects(e){return u(this,void 0,void 0,(function*(){var t;try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=l(this,Sg,"f"))||void 0===t||t.updateEffects(e)}catch(e){l(this,Rg,"f").call(this,e)}}))}resetEffects(){var e;null===(e=l(this,Sg,"f"))||void 0===e||e.updateEffects({})}setOnLoadModels(e){var t;null===(t=l(this,Sg,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e,t;return null!==(t=null===(e=l(this,Sg,"f"))||void 0===e?void 0:e.modelsLoadProgress)&&void 0!==t?t:0}pause(){return u(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;l(this,Sg,"f")&&(null===(e=l(this,Sg,"f"))||void 0===e||e.stopProcessing(),p(this,Sg,void 0,"f"))}))}))}setOnEffectError(e){p(this,Rg,e,"f")}}var Tg,kg;Sg=new WeakMap,Eg=new WeakMap,Cg=new WeakMap,Rg=new WeakMap;let Dg=kg=class{constructor(e){Tg.set(this,void 0),p(this,Tg,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack(e){return u(this,arguments,void 0,(function*({label:e,constraints:t}){if(kg.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[$n.ScreenVideo,$n.ScreenAudio].includes(e)}createUserMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return l(this,Tg,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return l(this,Tg,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};Tg=new WeakMap,Dg=kg=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],Dg);var Ig,Og,Ag,Lg,Mg,Ng,xg,Fg=Dg;let jg=class{constructor(e,t,r,n,i,s,o,a,c){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.clientEventEmitter=n,this.integrationsService=i,this.processorsCache=s,this.videoTrackFactory=o,this.mediaStreamTrackManager=a,this.socket=c,this.isDeviceLoaded=!1,this.tracks=new Map,Ig.set(this,void 0),Og.set(this,null),Ag.set(this,!1),Lg.set(this,new Map),Mg.set(this,!1),Ng.set(this,!1),xg.set(this,void 0);const d=this.config.get("effectsSDKParams");p(this,xg,this.config.get("denoiser"),"f"),p(this,Ig,this.loggerFactory("Media"),"f"),p(this,Og,null!=d?d:null,"f")}get mediasoupDevice(){var e;return null!==(e=this.device)&&void 0!==e||(this.device=this.createDevice()),this.device}get effectsSDKInitialized(){return l(this,Ag,"f")}get effectsSDKParams(){return l(this,Og,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return u(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));l(this,Ig,"f").error("getTrackCodec()",{label:e.getLabel,rtpCapabilities:t})}createTracks({constraints:e,mediaStreamTracks:t}){return t.map((t=>{const r={mediaStreamTrack:t,constraints:e};let n;return n="audio"===t.kind?this.audioTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),l(this,Ig,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createCustomMediaTrack(e,t){return this.createTracks({constraints:t,mediaStreamTracks:[e]})[0]}deleteTrack(e){return u(this,void 0,void 0,(function*(){const t={trackId:e.id,label:e.getLabel(),producerId:e.producerId};try{"disableNoiseSuppression"in e&&(yield e.disableNoiseSuppression()),"disableEffects"in e&&(yield e.disableEffects())}catch(e){l(this,Ig,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){l(this,Ig,"f").error("deleteTrack()",{error:e})}finally{l(this,Ig,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){try{this.getAllTracks().forEach((e=>e.stopMediaStreamTrack()))}catch(e){l(this,Ig,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}unpublishTracks(){return u(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>u(this,void 0,void 0,(function*(){return yield e.unpublish(!1)})))))}catch(e){l(this,Ig,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){return u(this,void 0,void 0,(function*(){if(l(this,Ag,"f"))return!0;if(!l(this,Og,"f"))throw l(this,Ig,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const e=(e,t)=>u(this,void 0,void 0,(function*(){if(!window.tsvb)return l(this,Ig,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);l(this,Ig,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{l(this,Lg,"f").set($n.Camera,yield this.createEffectsSDKTrackProcessor($n.Camera)),l(this,Lg,"f").set($n.CameraPreview,yield this.createEffectsSDKTrackProcessor($n.CameraPreview)),p(this,Ag,!0,"f"),l(this,Ig,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){l(this,Ig,"f").error("Failed to initialize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return yield new Promise(((t,r)=>{if(!window.tsvb)return l(this,Ig,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>u(this,void 0,void 0,(function*(){return yield e(t,r)}))));e(t,r).catch((e=>{l(this,Ig,"f").error("Failed to execute init() in initEffectsSDK",{error:mr(e)})}))}))}))}initDenoiser(e,t){return u(this,void 0,void 0,(function*(){if(!l(this,Mg,"f"))try{p(this,Mg,!0,"f"),this.clientEventEmitter.emit(qr,!0);try{yield this.integrationsService.audio.waitForInitialization}catch(e){"asdk"===l(this,xg,"f")&&(p(this,Ng,!0,"f"),p(this,xg,"rnnoise","f"),this.config.set("denoiser",l(this,xg,"f")),l(this,Ig,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",error:mr(e),type:this.config.get("denoiser")}),this.clientEventEmitter.emit($r),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization)}l(this,Ig,"f").debug("Denoiser initialized, activating",{case:"Denoiser",type:this.integrationsService.audio.type,trackLabel:e.getLabel()});const r=e,n=this.processorsCache.get(l(this,xg,"f"),$n.Microphone);if(!n)return void l(this,Ig,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type});"asdk"===n.type&&n.setOnError(((r,n)=>{this.clientEventEmitter.emit(qr,!0),this.fallbackToRNoise(e,{reason:r,options:t,error:n}).catch((t=>{l(this,Ig,"f").error("Failed to fallback to RNNoise through onError",{case:"Denoiser",type:l(this,xg,"f"),error:mr(t),label:e.getLabel()})})).then((()=>{this.clientEventEmitter.emit(qr,!1)})).catch((()=>{}))})),r.setTrackProcessor(n),l(this,Ig,"f").debug("Denoiser trackProcessor set, check if activation is needed",{case:"Denoiser",type:l(this,xg,"f"),shouldEnableDenoiser:null==t?void 0:t.noiseSuppression,trackLabel:e.getLabel()}),(null==t?void 0:t.noiseSuppression)&&(yield e.enableNoiseSuppression())}catch(r){if(l(this,Ig,"f").warn("Failed to start noise suppression, featured original track",{case:"Denoiser",type:l(this,xg,"f"),error:mr(r),label:e.getLabel()}),"asdk"===l(this,xg,"f"))try{l(this,Ig,"f").warn("Fallback to RNNoise",{error:mr(r)}),yield this.fallbackToRNoise(e,{options:t,reason:"ASDK init error",error:r})}catch(t){l(this,Ig,"f").error("Failed to fallback to RNNoise through catch",{case:"Denoiser",type:l(this,xg,"f"),error:mr(t),label:e.getLabel()})}}finally{this.clientEventEmitter.emit(qr,!1),p(this,Mg,!1,"f")}}))}fallbackToRNoise(e,t){return u(this,void 0,void 0,(function*(){var r;if(l(this,Ng,"f"))return;if(p(this,Ng,!0,"f"),"rnnoise"===l(this,xg,"f"))return;this.clientEventEmitter.emit($r),l(this,Ig,"f").info("Fallback to RNNoise",{reason:null==t?void 0:t.reason,error:mr(null==t?void 0:t.error),case:"Denoiser"});const n=e;yield n.disableNoiseSuppression(),n.unsetTrackProcessor(),p(this,xg,"rnnoise","f"),this.config.set("denoiser",l(this,xg,"f")),l(this,Ig,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",type:this.config.get("denoiser")}),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization;const i=this.processorsCache.get(l(this,xg,"f"),$n.Microphone);i?(n.setTrackProcessor(i),(null===(r=null==t?void 0:t.options)||void 0===r?void 0:r.noiseSuppression)&&(yield n.enableNoiseSuppression())):l(this,Ig,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type})}))}createEffectsSDKTrackProcessor(e){return u(this,void 0,void 0,(function*(){var t,r,n;if(e){const t=l(this,Lg,"f").get(e);if(t)return t}if(!l(this,Og,"f"))throw l(this,Ig,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const i=new tg({loggerFactory:this.loggerFactory,customerId:null===(t=this.config.get("effectsSDKParams"))||void 0===t?void 0:t.customerId,sdk_url:null===(r=this.config.get("effectsSDKParams"))||void 0===r?void 0:r.sdk_url,api_url:null===(n=this.config.get("effectsSDKParams"))||void 0===n?void 0:n.api_url,config:this.config});return yield i.init(),l(this,Ig,"f").info("Track effects processor initialized",{trackLabel:e}),i}))}handleProducerSetMaxSpatialLayer(e){return u(this,arguments,void 0,(function*({producerId:e,spatialLayer:t}){const r=this.getAllTracks().find((t=>{var r;return(null===(r=t.getProducer())||void 0===r?void 0:r.id)===e}));if(!r)return void l(this,Ig,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof Pg))return void l(this,Ig,"f").warn("producerRequestMaxSpatialLayer()",{message:"Wrong producer kind"});const n=null!=t?t:Lm,i=r.getMaxSpatialLayer();i!==n?(r.getEncodings().length>1&&(yield r.setMaxSpatialLayer(n)),yield this.socket.request(mn,{producerId:e,maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):l(this,Ig,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}static getVideoTrackTransformParams(e){var t,r;const n=e.getSettings();return{width:null!==(t=n.width)&&void 0!==t?t:Am.width,height:null!==(r=n.height)&&void 0!==r?r:Am.height}}static getScreenVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:20},width:{max:Am.width},height:{max:Am.height}},encoderConfig:null!==(r=null==e?void 0:e.videoEncoderConfig)&&void 0!==r?r:{encodings:Im}}}static getCameraVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:Am.width},height:{max:Am.height}},encoderConfig:null!==(r=null==e?void 0:e.encoderConfig)&&void 0!==r?r:{encodings:Dm}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=Bn.getParser(t);return r.satisfies({"yandex browser":">=25"})&&"iOS"===r.getOSName()?void 0:r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":void 0})();return l(this,Ig,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new Ja.Device({handlerName:e})}};Ig=new WeakMap,Og=new WeakMap,Ag=new WeakMap,Lg=new WeakMap,Mg=new WeakMap,Ng=new WeakMap,xg=new WeakMap,jg=a([ut(),c(0,pt(Gn.Config)),c(1,pt(Gn.LoggerFactory)),c(2,pt(Gn.AudioTrackFactory)),c(3,pt(Gn.ClientEventEmitter)),c(4,pt(Gn.IntegrationsService)),c(5,pt(Gn.ProcessorsCache)),c(6,pt(Gn.VideoTrackFactory)),c(7,pt(Gn.MediaStreamTrackManager)),c(8,pt(Gn.SocketIO)),d("design:paramtypes",[kt,Function,Function,Dt,zm,Hm,Function,Fg,fa])],jg);var Ug=jg;const Bg={[zi.PRODUCER_KIND_VIDEO]:"video",[zi.PRODUCER_KIND_AUDIO]:"audio"},Vg={[Ki.PEER_ROLE_HOST]:"host",[Ki.PEER_ROLE_AUDIENCE]:"audience"},Hg={[xi.PRODUCER_LABEL_CAMERA]:$n.Camera,[xi.PRODUCER_LABEL_MICROPHONE]:$n.Microphone,[xi.PRODUCER_LABEL_SCREEN_VIDEO]:$n.ScreenVideo,[xi.PRODUCER_LABEL_SCREEN_AUDIO]:$n.ScreenAudio,[xi.PRODUCER_LABEL_CUSTOM_VIDEO]:$n.CustomVideo,[xi.PRODUCER_LABEL_CUSTOM_AUDIO]:$n.CustomAudio,[xi.PRODUCER_LABEL_UNKNOWN]:$n.Unknown,[xi.PRODUCER_LABEL_UNSPECIFIED]:$n.Unknown},Wg={[Ni.PEER_GROUP_MODERATOR]:"moderator",[Ni.PEER_GROUP_USER]:"user"},qg=e=>{const t=Bg[e];if(!t)throw new Error(`Unknown producer kind: ${e}`);return t},zg=e=>{const t=Wg[e];if(!t)throw new Error(`Unknown peer group: ${e}`);return t},Gg=e=>{const t=Hg[e];if(!t)throw new Error(`Unknown producer label: ${e}`);return t},Yg=e=>{const t=Vg[e];if(!t)throw new Error(`Unknown peer role: ${e}`);return t},$g=e=>({id:e.id,channelIds:e.channelIds,groups:e.groups.map(zg),producePermissions:e.producePermissions.map(Gg),appId:e.appId,producers:e.producers.map(Kg),uid:e.uid,appData:e.appData,role:Yg(e.role),loginDate:e.loginDate}),Kg=e=>{var t;return{id:e.id,kind:qg(e.kind),label:Gg(e.label),peerId:e.peerId,paused:e.paused,encodings:e.encodings,maxSpatialLayer:null!==(t=e.maxSpatialLayer)&&void 0!==t?t:0}},Jg=e=>{switch(e){case"moderator":return Ni.PEER_GROUP_MODERATOR;case"user":return Ni.PEER_GROUP_USER;default:return Ni.PEER_GROUP_UNSPECIFIED}};var Qg;let Zg=class{constructor(e,t,r,n,i,s,o){this.network=e,this.media=t,this.myPeer=r,this.eventsQueue=n,this.clientEventEmitter=i,this.peers=s,Qg.set(this,void 0),p(this,Qg,o("ChannelStateSyncEventHandler"),"f"),this.debouncedTriggerChannelStateEvent=jn(this.triggerChannelStateEvent.bind(this),3e3),this.watchNetworkState()}handleChannelStateEvent(e){return u(this,void 0,void 0,(function*(){this.network.peersLoaded?yield this.restoreState(e):this.loadChannelState(e),this.clientEventEmitter.emit(zr)}))}watchNetworkState(){this.clientEventEmitter.on(Vr,(()=>{this.debouncedTriggerChannelStateEvent()}))}triggerChannelStateEvent(){return u(this,void 0,void 0,(function*(){const e=()=>u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>u(this,void 0,void 0,(function*(){const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(l(this,Qg,"f").info("Channel state event received",{case:"ChannelStateSynchronizer.triggerChannelStateEvent"}),e()):t(new Error("Channel state event not received"))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Br,i),e()};this.clientEventEmitter.on(Br,i)}))))}));try{yield zn(e,{maxRetries:5,actionName:"triggerChannelStateEventWithRetry",logger:l(this,Qg,"f")})}catch(e){l(this,Qg,"f").warn("Failed to trigger channel state event",{case:"ChannelStateSynchronizer.triggerChannelStateEvent",error:mr(e)})}}))}loadChannelState(e){l(this,Qg,"f").info("Loading channel state",{case:"loadChannelState"});try{const t=this.peers.hosts().map((e=>e.shortData)),r=e.peers.filter((e=>e.role===Ki.PEER_ROLE_HOST));this.setMissingPeers(t,r),this.restoreLocalPeersState(r),this.network.peersLoaded=!0}catch(e){l(this,Qg,"f").error("Failed to load channel state",{case:"loadState",error:mr(e)})}}restoreState(e){return u(this,void 0,void 0,(function*(){const{peers:t}=e,r={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isSocketConnectionActive)return l(this,Qg,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),r;l(this,Qg,"f").info("Restoring local state",{case:"restoreLocalState"});const e=this.peers.hosts().map((e=>e.shortData)),n=t.filter((e=>e.role===Ki.PEER_ROLE_HOST)),{removedProducers:i,fixedProducersState:s}=yield this.restoreRemoteProducersState(n);r.removedProducers.push(...s),r.removedProducers.push(...i),r.removedPeers.push(...this.removeUnnecessaryPeers(e,n)),r.missingPeers.push(...this.setMissingPeers(e,n));const o=this.restoreLocalPeersState(n);return r.missingProducers.push(...o.missingProducers),r.removedProducers.push(...o.removedProducers),r.restoredAppDataPeers.push(...o.restoredAppDataPeers),r.fixedProducersState.push(...o.fixedProducersState),r.fixedConsumersState.push(...o.fixedConsumersState),r}catch(e){return l(this,Qg,"f").info("Failed to restore local state",{case:"restoreLocalState",error:mr(e)}),r}}))}restoreRemoteProducersState(e){return u(this,void 0,void 0,(function*(){const t={removedProducers:[],fixedProducersState:[]},r=this.myPeer.get(),n=e.find((e=>e.id===this.myPeer.id));if(!r||!n)return t;const i=this.media.getAllTracks(),s=n.producers.filter((e=>!i.map((e=>e.producerId)).some((t=>e.id===t))));yield Promise.all(s.map((e=>u(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),l(this,Qg,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const o=n.producers.filter((e=>!!i.find((t=>t.isPaused&&t.isPaused!==e.paused))));return yield Promise.all(o.map((e=>u(this,void 0,void 0,(function*(){yield this.network.pauseRemoteProducer(e.id),t.fixedProducersState.push(e.id),l(this,Qg,"f").info("Remote producer state repaired",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})}))))),t}))}removeUnnecessaryPeers(e,t){const r=[];return e.filter((e=>!t.find((t=>t.id===e.id)))).forEach((e=>{this.peers.remove(e.id).catch((e=>{l(this,Qg,"f").error("Failed to remove peer",{error:mr(e)})})),r.push(e.id),l(this,Qg,"f").info("Unnecessary peer removed",{case:"restoreLocalState",removedPeerId:e.id})})),r}setMissingPeers(e,t){const r=[];return t.forEach((t=>{if(e.find((e=>e.id===t.id)))return;const n=this.peers.add($g(t));r.push(n.id),l(this,Qg,"f").info("Missing peer added to storage",{case:"restoreLocalState",peerId:t.id})})),r}restoreLocalPeersState(e){const t=new Map(e.map((e=>[e.id,e]))),r=this.peers.hosts(),n={removedProducers:[],missingProducers:[],restoredAppDataPeers:[],fixedConsumersState:[],fixedProducersState:[]};return r.forEach((e=>{const r=t.get(e.id);if(!r)return void l(this,Qg,"f").warn("Found new local peer, skip restoring state",{case:"restoreLocalState",newPeerId:e.id});n.removedProducers.push(...this.removeUnnecessaryProducers(e,r));this.restoreAppData(e,r)&&n.restoredAppDataPeers.push(e.id);const{fixedProducersState:i,fixedConsumersState:s,missingProducers:o}=this.restoreTracksState(e,r);n.fixedProducersState.push(...i),n.fixedConsumersState.push(...s),n.missingProducers.push(...o)})),l(this,Qg,"f").info("Peers state restored",{case:"restoreLocalState"}),n}removeUnnecessaryProducers(e,t){const r=[];return e.getProducers().filter((e=>!t.producers.find((t=>t.id===e.id)))).forEach((t=>{e.observer.safeEmit(pn,t),r.push(t.id),l(this,Qg,"f").info("Unnecessary producer removed",{case:"restoreLocalState",removedProducerId:t.id,removedProducerPeerId:t.peerId})})),r}restoreTracksState(e,t){const r={missingProducers:[],fixedProducersState:[],fixedConsumersState:[]};return t.producers.forEach((t=>{var n;const i=e.producers.get(t.id);if(!i)return e.observer.safeEmit(ln,Kg(t)),r.missingProducers.push(t.id),void l(this,Qg,"f").info("Missing producer added to storage",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId});const{paused:s}=t;if(i.paused!==s){i.setPaused(s);const n=i.paused?en:tn;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),l(this,Qg,"f").info("Producer state fixed",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId})}const o=e.tracks.get(i.label);if((null==o?void 0:o.consumerId)&&(null===(n=o.consumer)||void 0===n?void 0:n.paused)!==t.paused){const{consumerId:n}=o,s=i.paused?bn:wn;e.observer.safeEmit(s,n),r.fixedConsumersState.push(n),l(this,Qg,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!Fn(e.appData,t.appData)&&(e.observer.emit(br,t.appData),l(this,Qg,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};Qg=new WeakMap,Zg=a([ut(),c(0,pt(Gn.Network)),c(1,pt(Gn.Media)),c(2,pt(Gn.MyPeer)),c(3,pt(Gn.EventsQueue)),c(4,pt(Gn.ClientEventEmitter)),c(5,pt(Gn.Peers)),c(6,pt(Gn.LoggerFactory)),d("design:paramtypes",[Ma,Ug,Vs,Us,Dt,Na,Function])],Zg);var Xg,ev=Zg;let tv=class{constructor(e,t,r,n,i){this.peers=e,this.clientEventEmitter=t,this.channelStateSyncEventHandler=n,this.channelStateSynchronizer=i,Xg.set(this,void 0),p(this,Xg,r("ChannelEvents"),"f")}handleChannelEvent(e){return u(this,void 0,void 0,(function*(){switch(e.eventType){case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE:yield this.handleChannelState(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:this.handleChannelStateShort(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:this.handleChannelManagementEvent(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_JOINED:this.handlePeerJoined(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_LEFT:this.handlePeerLeft(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:this.handlePeerAppDataChanged(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:this.handlePeerGroupsChanged(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:this.handleChannelActivityConfirmationAcquired();break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:this.handleChannelActivityConfirmationExpired();break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:this.handleChannelActivityConfirmationRequired(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:this.handleChannelProducePermissionsChanged(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:this.handlePeerProducePermissionsChanged(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:this.handleChannelProducePermissionsDeleted(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}))}handleChannelManagementEvent(e){if(!e.channelManagementEvent)throw new Error("Missing channelManagementEvent in CHANNEL_MANAGEMENT_EVENT");const t=e.channelManagementEvent.event;this.clientEventEmitter.safeEmit(Tr,t),l(this,Xg,"f").debug("New channel event",{event:t})}handlePeerJoined(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.add($g(e.peer));l(this,Xg,"f").debug("Peer joined to the channel",{peer:Bs(t)})}handlePeerLeft(e){if(!e.peer)throw new Error("Missing peer in PEER_LEFT event");this.peers.remove(e.peer.id).catch((e=>{l(this,Xg,"f").debug("Failed to remove peer",{error:mr(e)})})),l(this,Xg,"f").debug("Peer left the channel",{peerId:e.peer.id})}handleChannelState(e){return u(this,void 0,void 0,(function*(){if(!e.channelState)throw new Error("Missing channelState in CHANNEL_STATE event");try{yield this.channelStateSynchronizer.handleChannelStateEvent(e.channelState)}catch(e){l(this,Xg,"f").error("Failed to restore channel state",{case:"restoreLocalState",error:mr(e)})}}))}handleChannelStateShort(e){if(!e.channelStateShort)throw new Error("Missing channelStateShort in CHANNEL_STATE_SHORT event");this.channelStateSyncEventHandler.handleChannelStateShort(e.channelStateShort).catch((e=>{l(this,Xg,"f").error("Failed to handle channel state short event",{error:mr(e)})}))}handlePeerAppDataChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.get(e.peer.id);t&&t.observer.emit(br,e.peer.appData)}handlePeerGroupsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_GROUP_CHANGED event");const t=this.peers.get(e.peer.id);null==t||t.handleGroupsChange(e.peer.groups.map(zg))}handleChannelActivityConfirmationExpired(){this.clientEventEmitter.safeEmit(Ar),l(this,Xg,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",{})}handleChannelActivityConfirmationAcquired(){this.clientEventEmitter.safeEmit(Or),l(this,Xg,"f").info("Notify the channel that the activity has been acquired.",{})}handleChannelActivityConfirmationRequired(e){if(!e.channelActivityConfirmationTime)throw new Error("Missing channelActivityConfirmationTime in CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED event");const t=e.channelActivityConfirmationTime;this.clientEventEmitter.safeEmit(Ir,t),l(this,Xg,"f").info("Notify the channel that activity confirmation is required",{event:e.channelActivityConfirmationTime})}handleChannelProducePermissionsChanged(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_CHANGED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(Jg(e)))))),n=e.channelProducePermissions.producePermissions.map(Gg),i=e.channelProducePermissions.changedProducePermissions.map(Gg);r.forEach((e=>{const t=Array.from(new Set([...e.producePermissions,...i])).filter((e=>!i.includes(e)||n.includes(e)));e.handleProducePermissionsChange(t)})),l(this,Xg,"f").info("Peers changed produce permissions",{groups:t,producePermissions:n})}handlePeerProducePermissionsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_PRODUCE_PERMISSIONS_CHANGED event");const t=this.peers.get(e.peer.id);if(!t)return;const r=e.peer.producePermissions.map(Gg);t.handleProducePermissionsChange(r)}handleChannelProducePermissionsDeleted(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_DELETED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(Jg(e)))))),n=e.channelProducePermissions.producePermissions.map(Gg);r.forEach((e=>{const t=e.producePermissions.filter((e=>!n.includes(e)));e.handleProducePermissionsChange(t)})),l(this,Xg,"f").info("Peers deleted produce permissions",{groups:t,producePermissions:n})}};Xg=new WeakMap,tv=a([ut(),c(0,pt(Gn.Peers)),c(1,pt(Gn.ClientEventEmitter)),c(2,pt(Gn.LoggerFactory)),c(3,pt(Gn.ChannelStateSyncEventHandler)),c(4,pt(Gn.ChannelStateSynchronizer)),d("design:paramtypes",[Na,Dt,Function,Ka,ev])],tv);var rv=tv,nv={},iv=f&&f.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(nv,"__esModule",{value:!0});var sv,ov,av=nv.AwaitQueue=class{constructor({ClosedErrorClass:e=Error,StoppedErrorClass:t=Error,RemovedTaskErrorClass:r=Error}={ClosedErrorClass:Error,StoppedErrorClass:Error,RemovedTaskErrorClass:Error}){this.closed=!1,this.pendingTasks=[],this.ClosedErrorClass=Error,this.StoppedErrorClass=Error,this.RemovedTaskErrorClass=Error,this.ClosedErrorClass=e,this.StoppedErrorClass=t,this.RemovedTaskErrorClass=r}get size(){return this.pendingTasks.length}close(){if(!this.closed){this.closed=!0;for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.ClosedErrorClass("AwaitQueue closed"));this.pendingTasks.length=0}}push(e,t){return iv(this,void 0,void 0,(function*(){if(this.closed)throw new this.ClosedErrorClass("AwaitQueue closed");if("function"!=typeof e)throw new TypeError("given task is not a function");if(!e.name&&t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={task:e,name:t,resolve:r,reject:n,stopped:!1,enqueuedAt:new Date,executedAt:void 0};this.pendingTasks.push(i),1===this.pendingTasks.length&&this.next()}))}))}removeTask(e){if(0===e)throw new TypeError("cannot remove task with index 0");const t=this.pendingTasks[e];t&&(this.pendingTasks.splice(e,1),t.reject(new this.RemovedTaskErrorClass("task removed from the queue")))}stop(){if(!this.closed){for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.StoppedErrorClass("AwaitQueue stopped"));this.pendingTasks.length=0}}dump(){const e=new Date;let t=0;return this.pendingTasks.map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt.getTime()-r.enqueuedAt.getTime():e.getTime()-r.enqueuedAt.getTime(),executingTime:r.executedAt?e.getTime()-r.executedAt.getTime():0})))}next(){return iv(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return iv(this,void 0,void 0,(function*(){if(!e.stopped){e.executedAt=new Date;try{const t=yield e.task();if(e.stopped)return;e.resolve(t)}catch(t){if(e.stopped)return;e.reject(t)}}}))}};let cv=class{constructor(e,t,r,n,i){this.media=e,this.internalEventEmitter=t,this.peersStorage=r,this.clientEventEmitter=n,sv.set(this,new av),ov.set(this,void 0),p(this,ov,i("MediaEvents"),"f")}handleMediaEvent(e){switch(e.eventType){case Es.MEDIA_EVENT_TYPE_PRODUCER_CREATED:this.handleProducerCreated(e);break;case Es.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:this.handleProducerClosed(e);break;case Es.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:this.handleProducerPaused(e);break;case Es.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:this.handleProducerResumed(e);break;case Es.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:this.handleProducerMaxSpatialLayerChanged(e);break;case Es.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:this.handleProducerRequestMaxSpatialLayer(e).catch((e=>{l(this,ov,"f").error("Failed to handle producer max spatial layer requested event",{error:mr(e)})}));break;case Es.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:this.handleProducerForciblyClosed(e).catch((e=>{l(this,ov,"f").error("Failed to handle producer forcibly closed event",{error:mr(e)})}));break;case Es.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:this.handleConsumerClosed(e);break;case Es.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:this.handleConsumerResumed(e);break;case Es.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:this.handleConsumerPaused(e);break;case Es.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:this.handleConsumerPreferredLayersChanged(e);break;case Es.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:this.handleTransportConnectionTimeout(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}handleProducerCreated(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CREATED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(ln,Kg(e.producer))}handleProducerClosed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CLOSED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(pn,Kg(e.producer))}handleProducerPaused(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_PAUSED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t&&r&&(r.setPaused(!0),t.observer.safeEmit(en,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused}))}handleProducerResumed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_RESUMED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t&&r&&(r.setPaused(!1),t.observer.safeEmit(tn,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused}))}handleProducerMaxSpatialLayerChanged(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED");if(void 0===e.producer.maxSpatialLayer)return;const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(mn,{peerId:e.producer.peerId,producerId:e.producer.id,spatialLayer:e.producer.maxSpatialLayer})}handleProducerRequestMaxSpatialLayer(e){return u(this,void 0,void 0,(function*(){if(!e.producerSpatialLayerRequest)throw new Error("Missing producerSpatialLayerRequest in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED");const{producerId:t,spatialLayer:r}=e.producerSpatialLayerRequest;yield l(this,sv,"f").push((()=>u(this,void 0,void 0,(function*(){yield this.media.handleProducerSetMaxSpatialLayer({producerId:t,spatialLayer:r})}))),gn)}))}handleProducerForciblyClosed(e){return u(this,void 0,void 0,(function*(){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED");const t=Gg(e.producer.label),r=this.media.getTrack(t);if(!r)return;r.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Qr.trackClosed,r);const n={label:t};this.clientEventEmitter.emit(xr,n),yield this.media.deleteTrack(r)}))}handleConsumerClosed(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_CLOSED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(_n,e.consumer.id)}handleConsumerResumed(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_RESUMED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(wn,e.consumer.id)}handleConsumerPaused(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PAUSED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(bn,e.consumer.id)}handleConsumerPreferredLayersChanged(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED");if(void 0===e.consumer.spatialLayer||void 0===e.consumer.temporalLayer)return;const t=this.peersStorage.get(e.consumer.peerId);null==t||t.observer.safeEmit(Sn,{consumerId:e.consumer.id,spatialLayer:e.consumer.spatialLayer,temporalLayer:e.consumer.temporalLayer})}handleTransportConnectionTimeout(e){if(!e.transportConnectionTimeout)throw new Error("Missing transportConnectionTimeout in MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT");l(this,ov,"f").warn("Transport connection timed out",{transportId:e.transportConnectionTimeout.transportId,direction:e.transportConnectionTimeout.direction,timeout:e.transportConnectionTimeout.timeout,reason:e.transportConnectionTimeout.reason})}};sv=new WeakMap,ov=new WeakMap,cv=a([ut(),c(0,pt(Gn.Media)),c(1,pt(Gn.InternalEventEmitter)),c(2,pt(Gn.PeersStorage)),c(3,pt(Gn.ClientEventEmitter)),c(4,pt(Gn.LoggerFactory)),d("design:paramtypes",[Ug,Dt,Sa,Dt,Function])],cv);var dv=cv,uv={exports:{}},lv=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},pv=lv,hv=Object.prototype.toString;function fv(e){return"[object Array]"===hv.call(e)}function mv(e){return void 0===e}function gv(e){return null!==e&&"object"==typeof e}function vv(e){if("[object Object]"!==hv.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function yv(e){return"[object Function]"===hv.call(e)}function _v(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),fv(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var bv={isArray:fv,isArrayBuffer:function(e){return"[object ArrayBuffer]"===hv.call(e)},isBuffer:function(e){return null!==e&&!mv(e)&&null!==e.constructor&&!mv(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:gv,isPlainObject:vv,isUndefined:mv,isDate:function(e){return"[object Date]"===hv.call(e)},isFile:function(e){return"[object File]"===hv.call(e)},isBlob:function(e){return"[object Blob]"===hv.call(e)},isFunction:yv,isStream:function(e){return gv(e)&&yv(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:_v,merge:function e(){var t={};function r(r,n){vv(t[n])&&vv(r)?t[n]=e(t[n],r):vv(r)?t[n]=e({},r):fv(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)_v(arguments[n],r);return t},extend:function(e,t,r){return _v(t,(function(t,n){e[n]=r&&"function"==typeof t?pv(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},wv=bv;function Sv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Ev=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(wv.isURLSearchParams(t))n=t.toString();else{var i=[];wv.forEach(t,(function(e,t){null!=e&&(wv.isArray(e)?t+="[]":e=[e],wv.forEach(e,(function(e){wv.isDate(e)?e=e.toISOString():wv.isObject(e)&&(e=JSON.stringify(e)),i.push(Sv(t)+"="+Sv(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},Cv=bv;function Rv(){this.handlers=[]}Rv.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},Rv.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Rv.prototype.forEach=function(e){Cv.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Pv=Rv,Tv=bv,kv=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Dv=kv,Iv=function(e,t,r,n,i){var s=new Error(e);return Dv(s,t,r,n,i)},Ov=Iv,Av=bv,Lv=Av.isStandardBrowserEnv()?{write:function(e,t,r,n,i,s){var o=[];o.push(e+"="+encodeURIComponent(t)),Av.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Av.isString(n)&&o.push("path="+n),Av.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Mv=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Nv=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},xv=bv,Fv=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],jv=bv,Uv=jv.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=jv.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},Bv=bv,Vv=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(Ov("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},Hv=Lv,Wv=Ev,qv=function(e,t){return e&&!Mv(t)?Nv(e,t):t},zv=function(e){var t,r,n,i={};return e?(xv.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=xv.trim(e.substr(0,n)).toLowerCase(),r=xv.trim(e.substr(n+1)),t){if(i[t]&&Fv.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i},Gv=Uv,Yv=Iv,$v=function(e){return new Promise((function(t,r){var n=e.data,i=e.headers,s=e.responseType;Bv.isFormData(n)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",c=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(a+":"+c)}var d=qv(e.baseURL,e.url);function u(){if(o){var n="getAllResponseHeaders"in o?zv(o.getAllResponseHeaders()):null,i={data:s&&"text"!==s&&"json"!==s?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:n,config:e,request:o};Vv(t,r,i),o=null}}if(o.open(e.method.toUpperCase(),Wv(d,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,"onloadend"in o?o.onloadend=u:o.onreadystatechange=function(){o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))&&setTimeout(u)},o.onabort=function(){o&&(r(Yv("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(Yv("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(Yv(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},Bv.isStandardBrowserEnv()){var l=(e.withCredentials||Gv(d))&&e.xsrfCookieName?Hv.read(e.xsrfCookieName):void 0;l&&(i[e.xsrfHeaderName]=l)}"setRequestHeader"in o&&Bv.forEach(i,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),Bv.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),s&&"json"!==s&&(o.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),r(e),o=null)})),n||(n=null),o.send(n)}))},Kv=bv,Jv=function(e,t){Tv.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},Qv=kv,Zv={"Content-Type":"application/x-www-form-urlencoded"};function Xv(e,t){!Kv.isUndefined(e)&&Kv.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var ey,ty={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(ey=$v),ey),transformRequest:[function(e,t){return Jv(t,"Accept"),Jv(t,"Content-Type"),Kv.isFormData(e)||Kv.isArrayBuffer(e)||Kv.isBuffer(e)||Kv.isStream(e)||Kv.isFile(e)||Kv.isBlob(e)?e:Kv.isArrayBufferView(e)?e.buffer:Kv.isURLSearchParams(e)?(Xv(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Kv.isObject(e)||t&&"application/json"===t["Content-Type"]?(Xv(t,"application/json"),function(e,t,r){if(Kv.isString(e))try{return(t||JSON.parse)(e),Kv.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&Kv.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw Qv(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};ty.headers={common:{Accept:"application/json, text/plain, */*"}},Kv.forEach(["delete","get","head"],(function(e){ty.headers[e]={}})),Kv.forEach(["post","put","patch"],(function(e){ty.headers[e]=Kv.merge(Zv)}));var ry=ty,ny=bv,iy=ry,sy=function(e){return!(!e||!e.__CANCEL__)},oy=bv,ay=function(e,t,r){var n=this||iy;return ny.forEach(r,(function(r){e=r.call(n,e,t)})),e},cy=sy,dy=ry;function uy(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var ly=bv,py=function(e,t){t=t||{};var r={},n=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],o=["validateStatus"];function a(e,t){return ly.isPlainObject(e)&&ly.isPlainObject(t)?ly.merge(e,t):ly.isPlainObject(t)?ly.merge({},t):ly.isArray(t)?t.slice():t}function c(n){ly.isUndefined(t[n])?ly.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}ly.forEach(n,(function(e){ly.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),ly.forEach(i,c),ly.forEach(s,(function(n){ly.isUndefined(t[n])?ly.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),ly.forEach(o,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var d=n.concat(i).concat(s).concat(o),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===d.indexOf(e)}));return ly.forEach(u,c),r},hy={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},fy={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){fy[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var my={},gy=hy.version.split(".");function vy(e,t){for(var r=t?t.split("."):gy,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}fy.transitional=function(e,t,r){var n=t&&vy(t);function i(e,t){return"[Axios v"+hy.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,s,o){if(!1===e)throw new Error(i(s," has been removed in "+t));return n&&!my[s]&&(my[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,o)}};var yy={isOlderVersion:vy,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),i=n.length;i-- >0;){var s=n[i],o=t[s];if(o){var a=e[s],c=void 0===a||o(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:fy},_y=bv,by=Ev,wy=Pv,Sy=function(e){return uy(e),e.headers=e.headers||{},e.data=ay.call(e,e.data,e.headers,e.transformRequest),e.headers=oy.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),oy.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||dy.adapter)(e).then((function(t){return uy(e),t.data=ay.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return cy(t)||(uy(e),t&&t.response&&(t.response.data=ay.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Ey=py,Cy=yy,Ry=Cy.validators;function Py(e){this.defaults=e,this.interceptors={request:new wy,response:new wy}}Py.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Ey(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&Cy.assertOptions(t,{silentJSONParsing:Ry.transitional(Ry.boolean,"1.0.0"),forcedJSONParsing:Ry.transitional(Ry.boolean,"1.0.0"),clarifyTimeoutError:Ry.transitional(Ry.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var o=[Sy,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(s),i=Promise.resolve(e);o.length;)i=i.then(o.shift(),o.shift());return i}for(var a=e;r.length;){var c=r.shift(),d=r.shift();try{a=c(a)}catch(e){d(e);break}}try{i=Sy(a)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},Py.prototype.getUri=function(e){return e=Ey(this.defaults,e),by(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},_y.forEach(["delete","get","head","options"],(function(e){Py.prototype[e]=function(t,r){return this.request(Ey(r||{},{method:e,url:t,data:(r||{}).data}))}})),_y.forEach(["post","put","patch"],(function(e){Py.prototype[e]=function(t,r,n){return this.request(Ey(n||{},{method:e,url:t,data:r}))}}));var Ty=Py;function ky(e){this.message=e}ky.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},ky.prototype.__CANCEL__=!0;var Dy=ky,Iy=Dy;function Oy(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new Iy(e),t(r.reason))}))}Oy.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Oy.source=function(){var e,t=new Oy((function(t){e=t}));return{token:t,cancel:e}};var Ay=Oy,Ly=bv,My=lv,Ny=Ty,xy=py;function Fy(e){var t=new Ny(e),r=My(Ny.prototype.request,t);return Ly.extend(r,Ny.prototype,t),Ly.extend(r,t),r}var jy=Fy(ry);jy.Axios=Ny,jy.create=function(e){return Fy(xy(jy.defaults,e))},jy.Cancel=Dy,jy.CancelToken=Ay,jy.isCancel=sy,jy.all=function(e){return Promise.all(e)},jy.spread=function(e){return function(t){return e.apply(null,t)}},jy.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},uv.exports=jy,uv.exports.default=jy;var Uy=uv.exports,By="undefined"!=typeof Symbol&&Symbol,Vy=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0},Hy="Function.prototype.bind called on incompatible ",Wy=Array.prototype.slice,qy=Object.prototype.toString,zy=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==qy.call(t))throw new TypeError(Hy+t);for(var r,n=Wy.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(Wy.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(Wy.call(arguments)))},s=Math.max(0,t.length-n.length),o=[],a=0;a<s;a++)o.push("$"+a);if(r=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var c=function(){};c.prototype=t.prototype,r.prototype=new c,c.prototype=null}return r},Gy=Function.prototype.bind||zy,Yy="Function.prototype.bind called on incompatible ",$y=Array.prototype.slice,Ky=Object.prototype.toString,Jy=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==Ky.call(t))throw new TypeError(Yy+t);for(var r,n=$y.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat($y.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat($y.call(arguments)))},s=Math.max(0,t.length-n.length),o=[],a=0;a<s;a++)o.push("$"+a);if(r=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var c=function(){};c.prototype=t.prototype,r.prototype=new c,c.prototype=null}return r},Qy=(Function.prototype.bind||Jy).call(Function.call,Object.prototype.hasOwnProperty),Zy=SyntaxError,Xy=Function,e_=TypeError,t_=function(e){try{return Xy('"use strict"; return ('+e+").constructor;")()}catch(e){}},r_=Object.getOwnPropertyDescriptor;if(r_)try{r_({},"")}catch(Rt){r_=null}var n_=function(){throw new e_},i_=r_?function(){try{return n_}catch(e){try{return r_(arguments,"callee").get}catch(e){return n_}}}():n_,s_="function"==typeof By&&"function"==typeof Symbol&&"symbol"==typeof By("foo")&&"symbol"==typeof Symbol("bar")&&Vy(),o_=Object.getPrototypeOf||function(e){return e.__proto__},a_={},c_="undefined"==typeof Uint8Array?undefined:o_(Uint8Array),d_={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":s_?o_([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":a_,"%AsyncGenerator%":a_,"%AsyncGeneratorFunction%":a_,"%AsyncIteratorPrototype%":a_,"%Atomics%":"undefined"==typeof Atomics?undefined:Atomics,"%BigInt%":"undefined"==typeof BigInt?undefined:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?undefined:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?undefined:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?undefined:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?undefined:FinalizationRegistry,"%Function%":Xy,"%GeneratorFunction%":a_,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":s_?o_(o_([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&s_?o_((new Map)[Symbol.iterator]()):undefined,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?undefined:Promise,"%Proxy%":"undefined"==typeof Proxy?undefined:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?undefined:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?undefined:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&s_?o_((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":s_?o_(""[Symbol.iterator]()):undefined,"%Symbol%":s_?Symbol:undefined,"%SyntaxError%":Zy,"%ThrowTypeError%":i_,"%TypedArray%":c_,"%TypeError%":e_,"%Uint8Array%":"undefined"==typeof Uint8Array?undefined:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?undefined:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?undefined:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?undefined:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?undefined:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?undefined:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?undefined:WeakSet},u_=function e(t){var r;if("%AsyncFunction%"===t)r=t_("async function () {}");else if("%GeneratorFunction%"===t)r=t_("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=t_("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=o_(i.prototype))}return d_[t]=r,r},l_={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},p_=Gy,h_=Qy,f_=p_.call(Function.call,Array.prototype.concat),m_=p_.call(Function.apply,Array.prototype.splice),g_=p_.call(Function.call,String.prototype.replace),v_=p_.call(Function.call,String.prototype.slice),y_=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,__=/\\(\\)?/g,b_=function(e){var t=v_(e,0,1),r=v_(e,-1);if("%"===t&&"%"!==r)throw new Zy("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new Zy("invalid intrinsic syntax, expected opening `%`");var n=[];return g_(e,y_,(function(e,t,r,i){n[n.length]=r?g_(i,__,"$1"):t||e})),n},w_=function(e,t){var r,n=e;if(h_(l_,n)&&(n="%"+(r=l_[n])[0]+"%"),h_(d_,n)){var i=d_[n];if(i===a_&&(i=u_(n)),void 0===i&&!t)throw new e_("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new Zy("intrinsic "+e+" does not exist!")},S_=function(e,t){if("string"!=typeof e||0===e.length)throw new e_("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new e_('"allowMissing" argument must be a boolean');var r=b_(e),n=r.length>0?r[0]:"",i=w_("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],m_(r,f_([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=v_(l,0,1),h=v_(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new Zy("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),h_(d_,s="%"+(n+="."+l)+"%"))o=d_[s];else if(null!=o){if(!(l in o)){if(!t)throw new e_("base intrinsic for "+e+" exists, but the property is not available.");return}if(r_&&d+1>=r.length){var f=r_(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=h_(o,l),o=o[l];u&&!a&&(d_[s]=o)}}return o},E_={exports:{}};!function(e){var t=Gy,r=S_,n=r("%Function.prototype.apply%"),i=r("%Function.prototype.call%"),s=r("%Reflect.apply%",!0)||t.call(i,n),o=r("%Object.getOwnPropertyDescriptor%",!0),a=r("%Object.defineProperty%",!0),c=r("%Math.max%");if(a)try{a({},"a",{value:1})}catch(e){a=null}e.exports=function(e){var r=s(t,i,arguments);if(o&&a){var n=o(r,"length");n.configurable&&a(r,"length",{value:1+c(0,e.length-(arguments.length-1))})}return r};var d=function(){return s(t,n,arguments)};a?a(e.exports,"apply",{value:d}):e.exports.apply=d}(E_);var C_=S_,R_=E_.exports,P_=R_(C_("String.prototype.indexOf")),T_=g(Object.freeze({__proto__:null,default:{}})),k_="function"==typeof Map&&Map.prototype,D_=Object.getOwnPropertyDescriptor&&k_?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,I_=k_&&D_&&"function"==typeof D_.get?D_.get:null,O_=k_&&Map.prototype.forEach,A_="function"==typeof Set&&Set.prototype,L_=Object.getOwnPropertyDescriptor&&A_?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,M_=A_&&L_&&"function"==typeof L_.get?L_.get:null,N_=A_&&Set.prototype.forEach,x_="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,F_="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,j_="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,U_=Boolean.prototype.valueOf,B_=Object.prototype.toString,V_=Function.prototype.toString,H_=String.prototype.match,W_="function"==typeof BigInt?BigInt.prototype.valueOf:null,q_=Object.getOwnPropertySymbols,z_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,G_="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Y_=Object.prototype.propertyIsEnumerable,$_=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),K_=T_.custom,J_=K_&&tb(K_)?K_:null,Q_="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function Z_(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function X_(e){return String(e).replace(/"/g,"&quot;")}function eb(e){return!("[object Array]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}function tb(e){if(G_)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!z_)return!1;try{return z_.call(e),!0}catch(e){}return!1}var rb=Object.prototype.hasOwnProperty||function(e){return e in this};function nb(e,t){return rb.call(e,t)}function ib(e){return B_.call(e)}function sb(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function ob(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return ob(e.slice(0,t.maxStringLength),t)+n}return Z_(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,ab),"single",t)}function ab(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+t.toString(16).toUpperCase()}function cb(e){return"Object("+e+")"}function db(e){return e+" { ? }"}function ub(e,t,r,n){return e+" ("+t+") {"+(n?lb(r,n):r.join(", "))+"}"}function lb(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function pb(e,t){var r=eb(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=nb(e,i)?t(e[i],e):""}var s,o="function"==typeof q_?q_(e):[];if(G_){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)nb(e,c)&&(r&&String(Number(c))===c&&c<e.length||G_&&s["$"+c]instanceof Symbol||(/[^\w$]/.test(c)?n.push(t(c,e)+": "+t(e[c],e)):n.push(c+": "+t(e[c],e))));if("function"==typeof q_)for(var d=0;d<o.length;d++)Y_.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var hb=S_,fb=function(e,t){var r=C_(e,!!t);return"function"==typeof r&&P_(e,".prototype.")>-1?R_(r):r},mb=function e(t,r,n,i){var s=r||{};if(nb(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(nb(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=!nb(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(nb(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return ob(t,s);if("number"==typeof t)return 0===t?1/0/t>0?"0":"-0":String(t);if("bigint"==typeof t)return String(t)+"n";var a=void 0===s.depth?5:s.depth;if(void 0===n&&(n=0),n>=a&&a>0&&"object"==typeof t)return eb(t)?"[Array]":"[Object]";var c=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=Array(e.indent+1).join(" ")}return{base:r,prev:Array(t+1).join(r)}}(s,n);if(void 0===i)i=[];else if(sb(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return nb(s,"quoteStyle")&&(a.quoteStyle=s.quoteStyle),e(t,a,n+1,i)}return e(t,s,n+1,i)}if("function"==typeof t){var u=function(e){if(e.name)return e.name;var t=H_.call(V_.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=pb(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(tb(t)){var p=G_?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):z_.call(t);return"object"!=typeof t||G_?p:cb(p)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var h="<"+String(t.nodeName).toLowerCase(),f=t.attributes||[],m=0;m<f.length;m++)h+=" "+f[m].name+"="+Z_(X_(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(eb(t)){if(0===t.length)return"[]";var g=pb(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(sb(e[t],"\n")>=0)return!1;return!0}(g)?"["+lb(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}(t)){var v=pb(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(J_&&"function"==typeof t[J_])return t[J_]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!I_||!e||"object"!=typeof e)return!1;try{I_.call(e);try{M_.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return O_.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),ub("Map",I_.call(t),y,c)}if(function(e){if(!M_||!e||"object"!=typeof e)return!1;try{M_.call(e);try{I_.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var _=[];return N_.call(t,(function(e){_.push(d(e,t))})),ub("Set",M_.call(t),_,c)}if(function(e){if(!x_||!e||"object"!=typeof e)return!1;try{x_.call(e,x_);try{F_.call(e,F_)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return db("WeakMap");if(function(e){if(!F_||!e||"object"!=typeof e)return!1;try{F_.call(e,F_);try{x_.call(e,x_)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return db("WeakSet");if(function(e){if(!j_||!e||"object"!=typeof e)return!1;try{return j_.call(e),!0}catch(e){}return!1}(t))return db("WeakRef");if(function(e){return!("[object Number]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}(t))return cb(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!W_)return!1;try{return W_.call(e),!0}catch(e){}return!1}(t))return cb(d(W_.call(t)));if(function(e){return!("[object Boolean]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}(t))return cb(U_.call(t));if(function(e){return!("[object String]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}(t))return cb(d(String(t)));if(!function(e){return!("[object Date]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}(t)&&!function(e){return!("[object RegExp]"!==ib(e)||Q_&&"object"==typeof e&&Q_ in e)}(t)){var b=pb(t,d),w=$_?$_(t)===Object.prototype:t instanceof Object||t.constructor===Object,S=t instanceof Object?"":"null prototype",E=!w&&Q_&&Object(t)===t&&Q_ in t?ib(t).slice(8,-1):S?"Object":"",C=(w||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(E||S?"["+[].concat(E||[],S||[]).join(": ")+"] ":"");return 0===b.length?C+"{}":c?C+"{"+lb(b,c)+"}":C+"{ "+b.join(", ")+" }"}return String(t)},gb=hb("%TypeError%"),vb=hb("%WeakMap%",!0),yb=hb("%Map%",!0),_b=fb("WeakMap.prototype.get",!0),bb=fb("WeakMap.prototype.set",!0),wb=fb("WeakMap.prototype.has",!0),Sb=fb("Map.prototype.get",!0),Eb=fb("Map.prototype.set",!0),Cb=fb("Map.prototype.has",!0),Rb=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r,r},Pb=String.prototype.replace,Tb=/%20/g,kb="RFC3986",Db={default:kb,formatters:{RFC1738:function(e){return Pb.call(e,Tb,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:kb},Ib=Db,Ob=Object.prototype.hasOwnProperty,Ab=Array.isArray,Lb=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Mb=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r},Nb={arrayToObject:Mb,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var i=t[n],s=i.obj[i.prop],o=Object.keys(s),a=0;a<o.length;++a){var c=o[a],d=s[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:s,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(Ab(r)){for(var n=[],i=0;i<r.length;++i)void 0!==r[i]&&n.push(r[i]);t.obj[t.prop]=n}}}(t),e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,n,i){if(0===e.length)return e;var s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(e)),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var o="",a=0;a<s.length;++a){var c=s.charCodeAt(a);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||i===Ib.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=Lb[c]:c<2048?o+=Lb[192|c>>6]+Lb[128|63&c]:c<55296||c>=57344?o+=Lb[224|c>>12]+Lb[128|c>>6&63]+Lb[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=Lb[240|c>>18]+Lb[128|c>>12&63]+Lb[128|c>>6&63]+Lb[128|63&c])}return o},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(Ab(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function e(t,r,n){if(!r)return t;if("object"!=typeof r){if(Ab(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!Ob.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return Ab(t)&&!Ab(r)&&(i=Mb(t,n)),Ab(t)&&Ab(r)?(r.forEach((function(r,i){if(Ob.call(t,i)){var s=t[i];s&&"object"==typeof s&&r&&"object"==typeof r?t[i]=e(s,r,n):t.push(r)}else t[i]=r})),t):Object.keys(r).reduce((function(t,i){var s=r[i];return Ob.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},xb=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new gb("Side channel does not contain "+mb(e))},get:function(n){if(vb&&n&&("object"==typeof n||"function"==typeof n)){if(e)return _b(e,n)}else if(yb){if(t)return Sb(t,n)}else if(r)return function(e,t){var r=Rb(e,t);return r&&r.value}(r,n)},has:function(n){if(vb&&n&&("object"==typeof n||"function"==typeof n)){if(e)return wb(e,n)}else if(yb){if(t)return Cb(t,n)}else if(r)return function(e,t){return!!Rb(e,t)}(r,n);return!1},set:function(n,i){vb&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new vb),bb(e,n,i)):yb?(t||(t=new yb),Eb(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=Rb(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},Fb=Nb,jb=Db,Ub=Object.prototype.hasOwnProperty,Bb={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},Vb=Array.isArray,Hb=String.prototype.split,Wb=Array.prototype.push,qb=function(e,t){Wb.apply(e,Vb(t)?t:[t])},zb=Date.prototype.toISOString,Gb=jb.default,Yb={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Fb.encode,encodeValuesOnly:!1,format:Gb,formatter:jb.formatters[Gb],indices:!1,serializeDate:function(e){return zb.call(e)},skipNulls:!1,strictNullHandling:!1},$b={},Kb=function e(t,r,n,i,s,o,a,c,d,u,l,p,h,f,m,g){for(var v=t,y=g,_=0,b=!1;void 0!==(y=y.get($b))&&!b;){var w=y.get(t);if(_+=1,void 0!==w){if(w===_)throw new RangeError("Cyclic object value");b=!0}void 0===y.get($b)&&(_=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&Vb(v)&&(v=Fb.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,Yb.encoder,m,"key",p):r;v=""}if(function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"symbol"==typeof e||"bigint"==typeof e}(v)||Fb.isBuffer(v)){if(a){var S=f?r:a(r,Yb.encoder,m,"key",p);if("comma"===n&&f){for(var E=Hb.call(String(v),","),C="",R=0;R<E.length;++R)C+=(0===R?"":",")+h(a(E[R],Yb.encoder,m,"value",p));return[h(S)+(i&&Vb(v)&&1===E.length?"[]":"")+"="+C]}return[h(S)+"="+h(a(v,Yb.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var P,T=[];if(void 0===v)return T;if("comma"===n&&Vb(v))P=[{value:v.length>0?v.join(",")||null:void 0}];else if(Vb(c))P=c;else{var k=Object.keys(v);P=d?k.sort(d):k}for(var D=i&&Vb(v)&&1===v.length?r+"[]":r,I=0;I<P.length;++I){var O=P[I],A="object"==typeof O&&void 0!==O.value?O.value:v[O];if(!o||null!==A){var L=Vb(v)?"function"==typeof n?n(D,O):D:D+(u?"."+O:"["+O+"]");g.set(t,_);var M=xb();M.set($b,g),qb(T,e(A,L,n,i,s,o,a,c,d,u,l,p,h,f,m,M))}}return T},Jb=Nb,Qb=Object.prototype.hasOwnProperty,Zb=Array.isArray,Xb={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Jb.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},ew=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},tw=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},rw=function(e,t,r,n){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,o=r.depth>0&&/(\[[^[\]]*])/.exec(i),a=o?i.slice(0,o.index):i,c=[];if(a){if(!r.plainObjects&&Qb.call(Object.prototype,a)&&!r.allowPrototypes)return;c.push(a)}for(var d=0;r.depth>0&&null!==(o=s.exec(i))&&d<r.depth;){if(d+=1,!r.plainObjects&&Qb.call(Object.prototype,o[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(o[1])}return o&&c.push("["+i.slice(o.index)+"]"),function(e,t,r,n){for(var i=n?t:tw(t,r),s=e.length-1;s>=0;--s){var o,a=e[s];if("[]"===a&&r.parseArrays)o=[].concat(i);else{o=r.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,d=parseInt(c,10);r.parseArrays||""!==c?!isNaN(d)&&a!==c&&String(d)===c&&d>=0&&r.parseArrays&&d<=r.arrayLimit?(o=[])[d]=i:"__proto__"!==c&&(o[c]=i):o={0:i}}i=o}return i}(c,t,r,n)}},nw=function(e,t){var r,n=e,i=function(e){if(!e)return Yb;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Yb.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=jb.default;if(void 0!==e.format){if(!Ub.call(jb.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=jb.formatters[r],i=Yb.filter;return("function"==typeof e.filter||Vb(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Yb.addQueryPrefix,allowDots:void 0===e.allowDots?Yb.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Yb.charsetSentinel,delimiter:void 0===e.delimiter?Yb.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Yb.encode,encoder:"function"==typeof e.encoder?e.encoder:Yb.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Yb.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Yb.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Yb.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Yb.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):Vb(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in Bb?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=Bb[s];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c="comma"===a&&t&&t.commaRoundTrip;r||(r=Object.keys(n)),i.sort&&r.sort(i.sort);for(var d=xb(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||qb(o,Kb(n[l],l,a,c,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,d))}var p=o.join(i.delimiter),h=!0===i.addQueryPrefix?"?":"";return i.charsetSentinel&&("iso-8859-1"===i.charset?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),p.length>0?h+p:""},iw=function(e,t){var r=function(e){if(!e)return Xb;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?Xb.charset:e.charset;return{allowDots:void 0===e.allowDots?Xb.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:Xb.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:Xb.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:Xb.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Xb.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:Xb.comma,decoder:"function"==typeof e.decoder?e.decoder:Xb.decoder,delimiter:"string"==typeof e.delimiter||Jb.isRegExp(e.delimiter)?e.delimiter:Xb.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:Xb.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:Xb.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:Xb.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:Xb.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Xb.strictNullHandling}}(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?function(e,t){var r,n={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,s),a=-1,c=t.charset;if(t.charsetSentinel)for(r=0;r<o.length;++r)0===o[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===o[r]?c="utf-8":"utf8=%26%2310003%3B"===o[r]&&(c="iso-8859-1"),a=r,r=o.length);for(r=0;r<o.length;++r)if(r!==a){var d,u,l=o[r],p=l.indexOf("]="),h=-1===p?l.indexOf("="):p+1;-1===h?(d=t.decoder(l,Xb.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),Xb.decoder,c,"key"),u=Jb.maybeMap(tw(l.slice(h+1),t),(function(e){return t.decoder(e,Xb.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=ew(u)),l.indexOf("[]=")>-1&&(u=Zb(u)?[u]:u),Qb.call(n,d)?n[d]=Jb.combine(n[d],u):n[d]=u}return n}(e,r):e,i=r.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;o<s.length;++o){var a=s[o],c=rw(a,n[a],r,"string"==typeof e);i=Jb.merge(i,c,r)}return!0===r.allowSparse?i:Jb.compact(i)},sw={formats:Db,parse:iw,stringify:nw};let ow=class{constructor(e){this.config=e;const t=this.config.get("loadbalancer"),{baseURL:r,timeout:n,customNode:i}=t;this.api=Uy.create({baseURL:null!=r?r:"https://lb.livedigital.space/v1",timeout:null!=n?n:5e3,withCredentials:!1,paramsSerializer:e=>sw.stringify(e)}),this.customNode=i}getNode(e){return u(this,void 0,void 0,(function*(){if(this.customNode)return this.customNode;const{data:t}=yield this.api.get("/nodes/best",{params:e});return t}))}checkServiceAvailability(){return u(this,arguments,void 0,(function*(e=2e3){try{const{status:t}=yield this.api.options("/nodes/best",{timeout:e});return[vt.OK,vt.NoContent].includes(t)}catch(e){return!1}}))}setBaseUrl(e){try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw new Error("Only http and https protocols are supported.");this.api.defaults.baseURL=t.toString()}catch(e){throw new Error("Invalid URL provided")}}};ow=a([ut(),c(0,pt(Gn.Config)),d("design:paramtypes",[kt])],ow);var aw,cw=ow;let dw=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],aw.set(this,void 0),p(this,aw,t("System"),"f"),this.deviceChangeHandler=this.deviceChangeHandler.bind(this),this.listenDevices()}setIsEnableVideoDevicesLock(e){this.isEnableVideoDevicesLock=e}setIsEnableAudioDevicesLock(e){this.isEnableAudioDevicesLock=e}setAvailableVideoDevices(e){this.availableVideoDevices=e}setAvailableAudioDevices(e){this.availableAudioDevices=e}requestMediaDevicesAccess(){return u(this,arguments,void 0,(function*(e={video:!0,audio:!0}){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){if(l(this,aw,"f").error("getUserMedia()",{error:t,constraints:e}),"NotAllowedError"===t.name)throw new Error(Kn.NotAllowedError);if("NotReadableError"===t.name)throw new Error(Kn.DeviceIsBusy);if("NotFoundError"===t.name)throw new Error(Kn.NotFoundError);throw new Error(Kn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return u(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices();if(0===e.length)return!0;return e.every((e=>e.deviceId&&e.label))}))}refreshAvailableMediaDevicesList(){return u(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[],r=[];e.forEach((e=>{""!==e.deviceId&&("videoinput"===e.kind&&t.push(e),"audioinput"===e.kind&&r.push(e))})),this.setAvailableVideoDevices(t),this.setAvailableAudioDevices(r);const n=({label:e,kind:t})=>({label:e,kind:t});return l(this,aw,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return u(this,void 0,void 0,(function*(){if(this.isDevicesDetected&&!e)return;(yield this.hasAvailableMediaDevicesList())||(yield this.tryToAccessDevices()),this.isDevicesDetected=!0;const t=yield this.refreshAvailableMediaDevicesList(),r=t.some((e=>"audioinput"===e.kind)),n=t.some((e=>"videoinput"===e.kind));if(!r&&!n)throw new Error(Kn.NoDevices)}))}deviceChangeHandler(){return u(this,void 0,void 0,(function*(){if(!this.isDevicesDetected)return;yield this.refreshAvailableMediaDevicesList();const e={audio:this.availableAudioDevices,video:this.availableVideoDevices};this.clientEventEmitter.safeEmit(Mr,e)}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(){return u(this,arguments,void 0,(function*(e={video:!0,audio:!0}){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return u(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){if(e=t.message,![Kn.NotFoundError,Kn.NotAllowedError,Kn.DeviceIsBusy].includes(e))throw t;t.message!==Kn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};aw=new WeakMap,dw=a([ut(),c(0,pt(Gn.ClientEventEmitter)),c(1,pt(Gn.LoggerFactory)),d("design:paramtypes",[Dt,Function])],dw);var uw,lw,pw,hw,fw,mw,gw=dw;class vw{constructor({transport:e,statsHandler:t}){uw.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return l(this,uw,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){p(this,uw,e,"f")}}uw=new WeakMap;let yw=class{constructor(){lw.set(this,new Map),pw.set(this,new Map),hw.set(this,new Map),fw.set(this,new Map),mw.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=l(this,lw,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=l(this,pw,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=l(this,hw,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=l(this,fw,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=l(this,mw,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){l(this,lw,"f").set(e,t)}addInboundVideoHandler(e,t){l(this,pw,"f").set(e,t)}addInboundAudioHandler(e,t){l(this,hw,"f").set(e,t)}addOutboundVideoHandler(e,t){l(this,fw,"f").set(e,t)}addOutboundAudioHandler(e,t){l(this,mw,"f").set(e,t)}removeConnectionHandler(e){l(this,lw,"f").delete(e)}removeInboundVideoHandler(e){l(this,pw,"f").delete(e)}removeInboundAudioHandler(e){l(this,fw,"f").delete(e)}removeOutboundVideoHandler(e){l(this,mw,"f").delete(e)}removeOutboundAudioHandler(e){l(this,mw,"f").delete(e)}clear(){l(this,lw,"f").clear(),l(this,pw,"f").clear(),l(this,hw,"f").clear(),l(this,fw,"f").clear(),l(this,mw,"f").clear()}};lw=new WeakMap,pw=new WeakMap,hw=new WeakMap,fw=new WeakMap,mw=new WeakMap,yw=a([ut()],yw);var _w,bw,ww,Sw,Ew,Cw,Rw=yw;let Pw=class{constructor(e){_w.set(this,!1),bw.set(this,void 0),ww.set(this,void 0),Sw.set(this,void 0),Ew.set(this,void 0),Cw.set(this,void 0),p(this,bw,e("IntegrationsService"),"f")}init({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){p(this,ww,e,"f"),p(this,Sw,t,"f"),p(this,Ew,r,"f"),p(this,Cw,n,"f"),p(this,_w,!0,"f")}getStats(){try{return this.doGetStats()}catch(e){return l(this,bw,"f").error("Failed to get stats",{error:mr(e)}),{}}}clear(){p(this,ww,void 0,"f"),p(this,Sw,void 0,"f"),p(this,Ew,void 0,"f"),p(this,Cw,void 0,"f")}doGetStats(){var e,t,r,n;if(!l(this,_w,"f"))throw new Error("TransportsStatsProvider is not initialized");return Object.assign(Object.assign({},(null===(t=null===(e=l(this,ww,"f"))||void 0===e?void 0:e.connectionStats)||void 0===t?void 0:t.id)?{outbound:Object.assign(Object.assign({},l(this,ww,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(n=null===(r=l(this,Sw,"f"))||void 0===r?void 0:r.connectionStats)||void 0===n?void 0:n.id)?{inbound:Object.assign(Object.assign({},l(this,Sw,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){if(void 0===l(this,Cw,"f"))throw new Error("Peers is undefined");return l(this,Cw,"f").hosts().reduce(((e,t)=>{if(t.isMe)return e;return e+Array.from(t.tracks.values()).reduce(((e,t)=>{var r,n;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0)}),0)}calculateOutboundTracksBitrate(){if(void 0===l(this,Ew,"f"))throw new Error("Media is undefined");return l(this,Ew,"f").getAllTracks().reduce(((e,t)=>{var r,n;if(!t.isPublished)return e;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0)}};_w=new WeakMap,bw=new WeakMap,ww=new WeakMap,Sw=new WeakMap,Ew=new WeakMap,Cw=new WeakMap,Pw=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],Pw);var Tw,kw,Dw,Iw,Ow=Pw;let Aw=class{constructor(e,t,r,n,i,o,a,c,d,u,l,h,f,m,g,v,y,_,b,w){var S;this.state=e,this.myPeer=t,this.integrationsService=n,this.processorsCache=i,this.mediaEventHandler=o,this.channelEventsHandler=a,this.peerTrackFactory=c,this.peers=d,this.system=u,this.media=l,this.network=h,this.loadBalancerClient=f,this.socket=m,this.eventsQueue=g,this.clientEventEmitter=v,this.internalEventEmitter=y,this.statsHandler=_,this.transportsStatsProvider=b,this.webRtcIssueDetector=w,Tw.set(this,void 0),kw.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,Dw.set(this,!1),Iw.set(this,!1),this.mark=s.default.randomBytes(10).toString("hex"),p(this,Tw,r("Engine"),"f"),p(this,kw,r,"f"),this.watchNetworkState(),this.watchDocumentUnload(),S=this.mark,window._sdkMarks||(window._sdkMarks=new Set),window._sdkMarks.add(S)}get isChannelJoined(){return this.state.isJoined}initialize(){return u(this,void 0,void 0,(function*(){var e,t,r,n;try{const{rtpCapabilities:i}=yield this.socket.request("router.getRtpCapabilities");this.integrationsService.init(),yield this.media.loadDevice(i),l(this,Tw,"f").info("Supported capabilities",{codecs:Vn(this.media.mediasoupDevice)});const[s,o]=yield Promise.all([this.network.createSendTransport(this.media.mediasoupDevice),this.network.createRecvTransport(this.media.mediasoupDevice),this.network.createSignalingTransport(this.media.mediasoupDevice)]);null===(e=this.webRtcIssueDetector)||void 0===e||e.handleNewPeerConnection(s.handler._pc,s.id),null===(t=this.webRtcIssueDetector)||void 0===t||t.handleNewPeerConnection(o.handler._pc,o.id),this.transportsStatsProvider.init({media:this.media,peers:this.peers,receiveTransportConnectionManager:new vw({transport:o,statsHandler:this.statsHandler}),sendTransportConnectionManager:new vw({transport:s,statsHandler:this.statsHandler})}),l(this,Tw,"f").debug("initialize()",{sendTransportId:null===(r=this.network.sendTransport)||void 0===r?void 0:r.id,recvTransportId:null===(n=this.network.receiveTransport)||void 0===n?void 0:n.id}),yield this.network.createSignalingConsumer()}catch(e){l(this,Tw,"f").error("initialize()",{error:e});const t=e instanceof Error&&"UnsupportedError"===e.name&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new Mn("Device not supported",Mn.UNSUPPORTED_DEVICE_CODE);throw new Error("Error initialize engine")}}))}release(e){return u(this,void 0,void 0,(function*(){var t;if(!this.isReleasing){this.isReleasing=!0;try{this.state.isJoined=!1,this.network.peersLoaded=!1,this.state.reset(),this.myPeer.delete(),null===(t=this.webRtcIssueDetector)||void 0===t||t.stopWatchingNewPeerConnections(),yield this.peers.reset(),this.network.closeSendTransport(),this.network.closeReceiveTransport(),yield this.network.closeConnectionTransport(),yield this.media.unpublishTracks(),e||this.media.clearTracks(),this.processorsCache.reset(),this.integrationsService.reset(),this.network.closeAllDataChannels(),this.removeClientEventEmitterListeners(),this.network.reset(),this.socket.disconnect(),gr.clear(),this.transportsStatsProvider.clear(),this.statsHandler.clear(),l(this,Tw,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw l(this,Tw,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}removeClientEventEmitterListeners(){Array.from(Object.values(Qr)).forEach((e=>this.internalEventEmitter.removeAllListeners(e)))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return u(this,void 0,void 0,(function*(){this.network.checkSocketConnectionActivity(),yield this.socket.request(wr)}))}join(e){return u(this,void 0,void 0,(function*(){const t=()=>u(this,void 0,void 0,(function*(){this.watchClientEvents(),yield this.connectToSocketServerWithRetry(e),yield this.performJoin({appData:e.appData})}));try{l(this,Tw,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,yield zn(t,{maxRetries:4,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"joinWithRetry",logger:l(this,kw,"f").call(this,"RetryJoinNode"),onError:()=>u(this,void 0,void 0,(function*(){yield this.release(!0)}))})}catch(e){throw l(this,Tw,"f").error("join()",{error:e}),e}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1}}))}loadPeers(e){return u(this,void 0,void 0,(function*(){yield this.peers.load(e)}))}requestChannelStateSync(){zn((()=>u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>u(this,void 0,void 0,(function*(){if(!this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)return e();const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(l(this,Tw,"f").info("Channel state event received",{case:"Engine.requestChannelStateSync"}),e()):t(new Error("Channel state event not received"))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Br,i),e()};this.clientEventEmitter.on(Br,i)}))))}))),{minBackoffDelayMs:0,maxBackoffDelayMs:0,maxRetries:10,actionName:"triggerChannelStateEventWithRetry",logger:l(this,Tw,"f")}).catch((e=>{l(this,Tw,"f").error("Failed to request channel state event",{case:"Engine.requestChannelStateSync",error:mr(e)})}))}setPeer(e,t=!0){return this.peers.add(e,t)}removePeer(e){return u(this,void 0,void 0,(function*(){yield this.peers.remove(e)}))}updateAppData(e){return u(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Error("Need join to channel first");try{Nn(e),yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw l(this,Tw,"f").error("updateAppData()",{error:e}),new Error("Can not update peer appData")}}))}createCameraVideoTrack(e){return u(this,void 0,void 0,(function*(){const t=Ug.getCameraVideoTrackParams(e);try{const[r]=yield this.media.createUserMediaTracks({audio:!1,video:t.videoTrackOptions});return r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof Pg&&(r.setLabel((null==e?void 0:e.isPreview)?$n.CameraPreview:$n.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(Ug.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),l(this,Tw,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw l(this,Tw,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Error(`Can not create camera track: ${e.message}`)}}))}createMicrophoneAudioTrack(e){return u(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio}),r=(null==e?void 0:e.isPreview)?$n.MicrophonePreview:$n.Microphone;return t.setLabel(r),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"!==t.kind||t.getLabel()!==$n.Microphone||l(this,Iw,"f")||this.media.initDenoiser(t,e).catch((t=>{this.clientEventEmitter.emit(Kr,{cause:"Failed to initialize denoiser",error:t}),l(this,Tw,"f").error("Failed to execute initDenoiser",{case:"Denoiser",options:e,error:mr(t)})})),this.media.setTrack(t),l(this,Tw,"f").debug("createMicrophoneAudioTrack()",{options:e,trackLabel:t.getLabel()}),t}catch(t){throw l(this,Tw,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Error(`Can not create microphone track: ${t.message}`)}}))}createScreenMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=Ug.getScreenVideoTrackParams(e);try{const r=yield this.media.createDisplayMediaTracks({audio:null==e?void 0:e.audio,video:null==e?void 0:e.video});return r.forEach((r=>{if(r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{l(this,Tw,"f").error("Failed to unpublish screen track",{error:mr(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof Pg){r.setLabel($n.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=Ug.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void l(this,Tw,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel($n.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),l(this,Tw,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw l(this,Tw,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Error(`Can not create screen media tracks: ${e.message}`)}}))}createCustomAudioTrack(e){if(!e.audioTrack)throw new Error("options.audioTrack is required");try{const t=this.media.createCustomMediaTrack(e.audioTrack,{audio:e.audio});return t.mediaStreamTrack.addEventListener("ended",(()=>{t.unpublish().catch((e=>{l(this,Tw,"f").error("Failed to unpublish custom audio track",{track:t,error:mr(e)})}))}),{once:!0}),t.setStopTrackOnPause(Boolean(e.stopTrackOnPause)),t.setLabel($n.CustomAudio),e.audioEncoderConfig&&t.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(t),l(this,Tw,"f").debug("createCustomAudioTrack()",{trackParams:e.audio,encoderConfig:e.audioEncoderConfig}),t}catch(t){throw l(this,Tw,"f").error("createCustomAudioTrack()",{error:t,trackParams:e.audioTrack}),new Error(`Can not create custom media tracks: ${t.message}`)}}createCustomVideoTrack(e){const t=Ug.getScreenVideoTrackParams(e);if(!e.videoTrack)throw new Error("options.videoTrack is required");try{const r=this.media.createCustomMediaTrack(e.videoTrack,{video:e.video});r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{l(this,Tw,"f").error("Failed to unpublish custom video track",{track:r,error:mr(e)})}))}),{once:!0}),r.mediaStreamTrack.contentHint="customVideo",r.setLabel($n.CustomVideo),r.setEncoderConfig(t.encoderConfig);const n=Ug.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(n),this.media.setTrack(r),l(this,Tw,"f").debug("createCustomVideoTrack()",{trackParams:t,transformParams:n,label:r.logCtx}),r}catch(e){throw l(this,Tw,"f").error("createCustomVideoTrack()",{error:e,trackParams:t}),new Error(`Failed to create custom video track: ${e.message}`)}}deleteTrack(e){return u(this,void 0,void 0,(function*(){yield this.media.deleteTrack(e)}))}transportsStats(){return this.transportsStatsProvider.getStats()}setLoadbalancerUrl(e){if(this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)throw new Error("Method not available when joined channel");this.loadBalancerClient.setBaseUrl(e)}connectToSocketServerWithRetry(e){return u(this,void 0,void 0,(function*(){yield zn((()=>u(this,void 0,void 0,(function*(){return yield this.connectToSocketServer(e)}))),{maxRetries:15,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"connectToSocketServer",logger:l(this,kw,"f").call(this,"RetrySocketConnect"),abortOnError:e=>{var t;return"unauthorized"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.errorCode)}})}))}connectToSocketServer(e){return u(this,void 0,void 0,(function*(){const t=e.isP2pCall?Yn.P2P:Yn.Common,{webSocketUrl:r}=yield this.getAvailableNode({datacenterType:t,channelId:e.channelId,role:e.role});this.socket.connect(r,e.token);try{yield this.waitForSocketConnection()}catch(t){throw l(this,Tw,"f").error("Failed to connect to socket server",{error:t,role:e.role,channelId:e.channelId,webSocketUrl:r}),this.socket.disconnect(),t}}))}getAvailableNode(e){return u(this,void 0,void 0,(function*(){try{return{webSocketUrl:(yield this.loadBalancerClient.getNode(e)).webSocketUrl}}catch(e){throw l(this,Tw,"f").error("getAvailableNode()",{error:"No available nodes"}),e}}))}waitForSocketConnection(){return u(this,void 0,void 0,(function*(){yield new Promise(((e,t)=>{const r=n=>{const{error:i,state:s}=n,o=()=>this.socket.observer.removeListener(Jn.State,r),a=[Jn.Disconnected,Jn.Reconnecting].includes(s);return i?(o(),void t(i)):this.state.isChannelJoining&&a?(o(),void t(new Error(`Not expected socket state for new connection: ${s}`))):void(this.state.isChannelJoining&&[Jn.Connected,Jn.Reconnected].includes(s)&&(o(),e()))};this.socket.observer.on(Jn.State,r)}))}))}performJoin(e){return u(this,void 0,void 0,(function*(){try{const{appId:t,channelId:r,peerId:n}=yield this.sendJoinChannelRequestWithRetry(e);this.myPeer.id=n,this.state.appId=t,this.state.channelId=r,yield this.initialize(),yield this.network.createAllDataChannels(),this.network.channelMessagesDataConsumer&&(this.eventsQueue.setChannelEventHandler(this.channelEventsHandler.handleChannelEvent.bind(this.channelEventsHandler)),this.eventsQueue.setMediaEventHandler(this.mediaEventHandler.handleMediaEvent.bind(this.mediaEventHandler)),this.eventsQueue.subscribe(this.network.channelMessagesDataConsumer)),gr.setPeerId(n),gr.setChannelId(r),gr.setAppId(t),yield Promise.all([this.network.waitForReceiveTransportConnected(),this.network.waitForChannelMessagesDataConsumerConnected()]),this.state.isJoined=!0,l(this,Tw,"f").info("Successfully joined channel",{channelId:r})}catch(e){throw l(this,Tw,"f").error("performJoin()",{error:e}),e}}))}sendJoinChannelRequestWithRetry(e){return u(this,void 0,void 0,(function*(){return yield zn((()=>u(this,void 0,void 0,(function*(){return yield this.sendJoinChannelRequest(e)}))),{maxRetries:3,minBackoffDelayMs:300,actionName:"sendJoinChannelRequest",logger:l(this,kw,"f").call(this,"RetryJoin")})}))}sendJoinChannelRequest(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(vr,e)}))}watchClientEvents(){this.internalEventEmitter.on(Qr.trackProduced,(e=>u(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Qr.trackUnproduced,(e=>u(this,void 0,void 0,(function*(){var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{l(this,Tw,"f").debug("Failed to close peerTrack",{error:mr(e)})})),yield this.media.deleteTrack(e)})))),this.internalEventEmitter.on(Qr.trackPaused,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.pause())||void 0===r||r.catch((e=>{l(this,Tw,"f").debug("Failed to pause peerTrack",{error:mr(e)})}))})),this.internalEventEmitter.on(Qr.trackResumed,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.resume())||void 0===r||r.catch((e=>{l(this,Tw,"f").debug("Failed to resume peerTrack",{error:mr(e)})}))})),this.internalEventEmitter.on(Qr.trackClosed,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{l(this,Tw,"f").debug("Failed to close peerTrack",{error:mr(e)})}))})),this.internalEventEmitter.on(Qr.trackReopened,(e=>u(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Qr.trackFailed,(e=>{this.clientEventEmitter.safeEmit(Fr,{label:e.getLabel()})}))}createSelfPeerTrack(e){return u(this,void 0,void 0,(function*(){var t;if(!this.myPeer.id)return;const r=this.peers.get(this.myPeer.id);if(!r)return;yield null===(t=r.tracks.get(e.getLabel()))||void 0===t?void 0:t.close();const n=this.peerTrackFactory({label:e.getLabel(),mediaStreamTrack:e.mediaStreamTrack,muted:!1,paused:e.isPaused,onClose:()=>{},peerEventEmitter:r.observer});r.tracks.set(n.label,n)}))}triggerRejoinEventIfAppropriate(e){this.rejoinRequested&&!this.state.isChannelJoining||(l(this,Tw,"f").debug("Triggering channel rejoin required event",{reason:e}),this.rejoinRequested=!0,this.clientEventEmitter.emit(Lr))}watchNetworkState(){this.network.observer.on(On,(e=>{var t;if(this.isReleasing)return;const{code:r,error:n,state:i}=e,s="unauthorized"===(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.errorCode)&&this.isChannelJoined,o=r===Jn.NeedToJoinFirst&&this.isChannelJoined;if(s&&this.clientEventEmitter.safeEmit(Wr),"server.disconnect"!==r||l(this,Dw,"f")){if(o||s){const e=s?"unauthorized error":"invalid channel state";this.triggerRejoinEventIfAppropriate(e)}i===Jn.Disconnected&&this.isChannelJoined&&!l(this,Dw,"f")&&l(this,Tw,"f").info("connection lost",{channel:"socket"}),i===Jn.Reconnected&&this.isChannelJoined&&l(this,Tw,"f").info("connection restored",{channel:"socket"}),i===Jn.BufferingStart&&(p(this,Dw,!0,"f"),this.clientEventEmitter.safeEmit(Br),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),[Jn.BufferingEnd,Jn.Reconnected].includes(i)&&this.network.isNetworkActive&&(p(this,Dw,!1,"f"),this.clientEventEmitter.safeEmit(Vr))}else this.clientEventEmitter.safeEmit(Hr)})),this.network.observer.on(An,(({state:e,direction:t})=>{if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!l(this,Dw,"f")&&(p(this,Dw,!0,"f"),l(this,Tw,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Br),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),"reconnected"===e&&this.isChannelJoined&&l(this,Tw,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&l(this,Dw,"f"))){if(![this.network.receiveTransport,this.network.sendTransport].every((e=>"connected"===(null==e?void 0:e.connectionState)||"new"===(null==e?void 0:e.connectionState))))return;p(this,Dw,!1,"f"),this.clientEventEmitter.safeEmit(Vr)}}))}watchDocumentUnload(){try{window.addEventListener("unload",(()=>{var e,t;null===(e=this.network.sendTransport)||void 0===e||e.close(),null===(t=this.network.receiveTransport)||void 0===t||t.close()}))}catch(e){l(this,Tw,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId,error:mr(e)})}}waitForReconnectOrTriggerRejoinEventIfAppropriate(){l(this,Tw,"f").info("Start waiting for seamless reconnect and check loadbalancer availability",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});let e=0;const t=setInterval((()=>u(this,void 0,void 0,(function*(){if(this.isReleasing||!this.state.isJoined)return clearInterval(t),void l(this,Tw,"f").info("Stop waiting for seamless reconnect due to call end",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});try{if(!l(this,Dw,"f"))return void clearInterval(t);if(!(yield this.loadBalancerClient.checkServiceAvailability(9e3)))return void(e=0);e+=1,e>6&&(clearInterval(t),this.triggerRejoinEventIfAppropriate("loadbalancer available"))}catch(e){l(this,Tw,"f").error("Check failed",{error:mr(e),case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"})}}))),1e4)}};Tw=new WeakMap,kw=new WeakMap,Dw=new WeakMap,Iw=new WeakMap,Aw=a([ut(),c(0,pt(Gn.CallState)),c(1,pt(Gn.MyPeer)),c(2,pt(Gn.LoggerFactory)),c(3,pt(Gn.IntegrationsService)),c(4,pt(Gn.ProcessorsCache)),c(5,pt(Gn.MediaEventHandler)),c(6,pt(Gn.ChannelEventHandler)),c(7,pt(Gn.PeerTrackFactory)),c(8,pt(Gn.Peers)),c(9,pt(Gn.System)),c(10,pt(Gn.Media)),c(11,pt(Gn.Network)),c(12,pt(Gn.LoadBalancerApiClient)),c(13,pt(Gn.SocketIO)),c(14,pt(Gn.EventsQueue)),c(15,pt(Gn.ClientEventEmitter)),c(16,pt(Gn.InternalEventEmitter)),c(17,pt(Gn.StatsHandler)),c(18,pt(Gn.TransportsStatsProvider)),c(19,pt(Gn.WebRTCIssueDetector)),d("design:paramtypes",[Qn,Vs,Function,zm,Hm,dv,rv,Function,Object,gw,Ug,Ma,cw,fa,Us,Dt,Dt,Rw,Ow,dr])],Aw);var Lw=Aw;let Mw,Nw=!1;const xw=()=>{try{return Nw?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:mr(e)}),e instanceof Error&&"SecurityError"===e.name&&(Nw=!0),null}};function Fw(e){const t=xw();if(!t)return null;try{const r=t.getItem(e);return r?JSON.parse(r):null}catch(e){return null}}const jw=()=>{if(Mw)return Mw;const e=Fw("sdk_clientUniqueId");if(e)return Mw=e,e;const t=s.default.randomBytes(12).toString("hex");return Mw=t,function(e,t){const r=xw();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},Uw=()=>{const e=Fw("sdk_clientUniqueId");return e||(null!=Mw?Mw:jw())},Bw=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);function Vw(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!Bw.has(e&&e.code))(e)))}const Hw=["get","head","options"],Ww=Hw.concat(["put","delete"]);function qw(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function zw(e){return!!e.config?.method&&(qw(e)&&-1!==Ww.indexOf(e.config.method))}function Gw(e){return Vw(e)||zw(e)}function Yw(e){const t=e?.response?.headers["retry-after"];if(!t)return 0;let r=1e3*(Number(t)||0);return 0===r&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}const $w={retries:3,retryCondition:Gw,retryDelay:function(e=0,t){return Math.max(0,Yw(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Kw(e,t,r=!1){const n=function(e,t){return{...$w,...t,...e["axios-retry"]}}(e,t||{});return n.retryCount=n.retryCount||0,n.lastRequestTime&&!r||(n.lastRequestTime=Date.now()),e["axios-retry"]=n,n}const Jw=(e,t)=>{const r=e.interceptors.request.use((e=>(Kw(e,t,!0),e["axios-retry"]?.validateResponse&&(e.validateStatus=()=>!1),e))),n=e.interceptors.response.use(null,(async r=>{const{config:n}=r;if(!n)return Promise.reject(r);const i=Kw(n,t);return r.response&&i.validateResponse?.(r.response)?r.response:await async function(e,t){const{retries:r,retryCondition:n}=e,i=(e.retryCount||0)<r&&n(t);if("object"==typeof i)try{return!1!==await i}catch(e){return!1}return i}(i,r)?async function(e,t,r,n){t.retryCount+=1;const{retryDelay:i,shouldResetTimeout:s,onRetry:o}=t,a=i(t.retryCount,r);if(function(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}(e,n),!s&&n.timeout&&t.lastRequestTime){const e=Date.now()-t.lastRequestTime,i=n.timeout-e-a;if(i<=0)return Promise.reject(r);n.timeout=i}return n.transformRequest=[e=>e],await o(t.retryCount,r,n),n.signal?.aborted?Promise.resolve(e(n)):new Promise((t=>{const r=()=>{clearTimeout(i),t(e(n))},i=setTimeout((()=>{t(e(n)),n.signal?.removeEventListener&&n.signal.removeEventListener("abort",r)}),a);n.signal?.addEventListener&&n.signal.addEventListener("abort",r,{once:!0})}))}(e,i,r,n):(await async function(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}(i,r),Promise.reject(r))}));return{requestInterceptorId:r,responseInterceptorId:n}};Jw.isNetworkError=Vw,Jw.isSafeRequestError=function(e){return!!e.config?.method&&(qw(e)&&-1!==Hw.indexOf(e.config.method))},Jw.isIdempotentRequestError=zw,Jw.isNetworkOrIdempotentRequestError=Gw,Jw.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,Yw(t));return i+.2*i*Math.random()},Jw.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,Yw(r))}},Jw.isRetryableError=qw;class Qw{constructor(e){this.api=e,Jw(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}batch(e){return u(this,void 0,void 0,(function*(){yield this.api.post("/log/batch",e)}))}}class Zw{constructor(e){this.api=e,Jw(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}sendNetworkMetrics(e){return u(this,void 0,void 0,(function*(){yield this.api.post("/analytics/network-metrics",e)}))}sendWIDMetrics(e){return u(this,void 0,void 0,(function*(){yield this.api.post("/analytics/wid-metrics",Object.assign({},e))}))}}let Xw=class{constructor(){this.api=Uy.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>sw.stringify(e),headers:{"x-cl-id":Uw()}}),this.api.defaults.headers.common["Cache-Control"]="no-cache",this.api.defaults.headers.common.Pragma="no-cache",this.api.defaults.headers.common.Expires="0",this.logApi=new Qw(this.api),this.metricsApi=new Zw(this.api)}get log(){return this.logApi}get metrics(){return this.metricsApi}};Xw=a([ut(),d("design:paramtypes",[])],Xw);var eS=Xw;const tS=new Error("request for lock canceled");var rS=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class nS{constructor(e,t=tS){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(((r,n)=>{const i={resolve:r,reject:n,weight:e,priority:t},s=iS(this._queue,(e=>t<=e.priority));-1===s&&e<=this._value?this._dispatchItem(i):this._queue.splice(s+1,0,i)}))}runExclusive(e){return rS(this,arguments,void 0,(function*(e,t=1,r=0){const[n,i]=yield this.acquire(t,r);try{return yield e(n)}finally{i()}}))}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise((r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),function(e,t){const r=iS(e,(e=>t.priority<=e.priority));e.splice(r+1,0,t)}(this._weightedWaiters[e-1],{resolve:r,priority:t})}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(0===this._queue.length)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach((e=>e.resolve())),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const r=this._weightedWaiters[t-1];if(!r)continue;const n=r.findIndex((t=>t.priority<=e));(-1===n?r:r.splice(0,n)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(0===this._queue.length||this._queue[0].priority<t)&&e<=this._value}}function iS(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1}var sS,oS=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class aS{constructor(e){this._semaphore=new nS(1,e)}acquire(){return oS(this,arguments,void 0,(function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t}))}runExclusive(e,t=0){return this._semaphore.runExclusive((()=>e()),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}let cS=class{constructor(){sS.set(this,new Map)}lock(e){return u(this,void 0,void 0,(function*(){let t=l(this,sS,"f").get(e);return t||(t=new aS,l(this,sS,"f").set(e,t)),t.isLocked()&&(yield t.waitForUnlock()),yield t.acquire()}))}isLocked(e){const t=l(this,sS,"f").get(e);return!!t&&t.isLocked()}waitForUnlock(e){return u(this,void 0,void 0,(function*(){const t=l(this,sS,"f").get(e);(null==t?void 0:t.isLocked())?yield t.waitForUnlock():yield Promise.resolve()}))}};sS=new WeakMap,cS=a([ut()],cS);var dS=cS,uS={exports:{}},lS=1e3,pS=60*lS,hS=60*pS,fS=24*hS,mS=7*fS,gS=365.25*fS,vS=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*gS;case"weeks":case"week":case"w":return r*mS;case"days":case"day":case"d":return r*fS;case"hours":case"hour":case"hrs":case"hr":case"h":return r*hS;case"minutes":case"minute":case"mins":case"min":case"m":return r*pS;case"seconds":case"second":case"secs":case"sec":case"s":return r*lS;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=fS)return yS(e,t,fS,"day");if(t>=hS)return yS(e,t,hS,"hour");if(t>=pS)return yS(e,t,pS,"minute");if(t>=lS)return yS(e,t,lS,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=fS)return Math.round(e/fS)+"d";if(t>=hS)return Math.round(e/hS)+"h";if(t>=pS)return Math.round(e/pS)+"m";if(t>=lS)return Math.round(e/lS)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function yS(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var _S=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=vS,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=_S(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(uS,uS.exports);var bS=uS.exports,wS={},SS={},ES={},CS={exports:{}};
30
+ ***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof f?f:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==r.Reflect&&(n=i(r.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,d={create:o?function(){return le(Object.create(null))}:a?function(){return le({__proto__:null})}:function(){return le({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:de(),h="function"==typeof WeakMap?WeakMap:ue(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),g=se(m);function v(e,t,r,n){if(F(r)){if(!G(e))throw new TypeError;if(!$(t))throw new TypeError;return k(e,t)}if(!G(e))throw new TypeError;if(!B(t))throw new TypeError;if(!B(n)&&!F(n)&&!j(n))throw new TypeError;return j(n)&&(n=void 0),R(e,t,r=z(r),n)}function y(e,t){function r(r,n){if(!B(r))throw new TypeError;if(!F(n)&&!J(n))throw new TypeError;N(e,t,r,n)}return r}function _(e,t,r,n){if(!B(r))throw new TypeError;return F(n)||(n=z(n)),N(e,t,r,n)}function b(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),I(e,t,r)}function E(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),D(e,t,r)}function w(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),A(e,t,r)}function S(e,t,r){if(!B(t))throw new TypeError;return F(r)||(r=z(r)),O(e,t,r)}function C(e,t){if(!B(e))throw new TypeError;return F(t)||(t=z(t)),M(e,t)}function P(e,t){if(!B(e))throw new TypeError;return F(t)||(t=z(t)),L(e,t)}function T(e,t,r){if(!B(t))throw new TypeError;if(F(r)||(r=z(r)),!B(t))throw new TypeError;F(r)||(r=z(r));var n=ae(t,r,!1);return!F(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function k(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!F(n)&&!j(n)){if(!$(n))throw new TypeError;t=n}}return t}function R(e,t,r,n){for(var i=e.length-1;i>=0;--i){var s=(0,e[i])(t,r,n);if(!F(s)&&!j(s)){if(!B(s))throw new TypeError;n=s}}return n}function I(e,t,r){if(D(e,t,r))return!0;var n=re(t);return!j(n)&&I(e,n,r)}function D(e,t,r){var n=ae(t,r,!1);return!F(n)&&H(n.OrdinaryHasOwnMetadata(e,t,r))}function A(e,t,r){if(D(e,t,r))return O(e,t,r);var n=re(t);return j(n)?void 0:A(e,n,r)}function O(e,t,r){var n=ae(t,r,!1);if(!F(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function N(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function M(e,t){var r=L(e,t),n=re(e);if(null===n)return r;var i=M(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var s=new p,o=[],a=0,c=r;a<c.length;a++){var d=c[a];s.has(d)||(s.add(d),o.push(d))}for(var u=0,l=i;u<l.length;u++){d=l[u];s.has(d)||(s.add(d),o.push(d))}return o}function L(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function x(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function F(e){return void 0===e}function j(e){return null===e}function U(e){return"symbol"==typeof e}function B(e){return"object"==typeof e?null!==e:"function"==typeof e}function V(e,t){switch(x(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",n=Q(e,i);if(void 0!==n){var s=n.call(e,r);if(B(s))throw new TypeError;return s}return W(e,"default"===r?"number":r)}function W(e,t){if("string"===t){var r=e.toString;if(Y(r))if(!B(i=r.call(e)))return i;if(Y(n=e.valueOf))if(!B(i=n.call(e)))return i}else{var n;if(Y(n=e.valueOf))if(!B(i=n.call(e)))return i;var i,s=e.toString;if(Y(s))if(!B(i=s.call(e)))return i}throw new TypeError}function H(e){return!!e}function q(e){return""+e}function z(e){var t=V(e,3);return U(t)?t:q(t)}function G(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function Y(e){return"function"==typeof e}function $(e){return"function"==typeof e}function J(e){switch(x(e)){case 3:case 4:return!0;default:return!1}}function K(e,t){return e===t||e!=e&&t!=t}function Q(e,t){var r=e[t];if(null!=r){if(!Y(r))throw new TypeError;return r}}function Z(e){var t=Q(e,s);if(!Y(t))throw new TypeError;var r=t.call(e);if(!B(r))throw new TypeError;return r}function X(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function ne(){var e,r,n,i;F(f)||void 0===t.Reflect||f in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=oe(t.Reflect));var s=new h,o={registerProvider:a,getProvider:d,setProvider:m};return o;function a(t){if(!Object.isExtensible(o))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case F(r):r=t;break;case r===t:break;case F(n):n=t;break;case n===t:break;default:void 0===i&&(i=new p),i.add(t)}}function c(t,s){if(!F(r)){if(r.isProviderFor(t,s))return r;if(!F(n)){if(n.isProviderFor(t,s))return r;if(!F(i))for(var o=Z(i);;){var a=ee(o);if(!a)return;var c=X(a);if(c.isProviderFor(t,s))return te(o),c}}}if(!F(e)&&e.isProviderFor(t,s))return e}function d(e,t){var r,n=s.get(e);return F(n)||(r=n.get(t)),F(r)?(F(r=c(e,t))||(F(n)&&(n=new l,s.set(e,n)),n.set(t,r)),r):r}function u(e){if(F(e))throw new TypeError;return r===e||n===e||!F(i)&&i.has(e)}function m(e,t,r){if(!u(r))throw new Error("Metadata provider not registered.");var n=d(e,t);if(n!==r){if(!F(n))return!1;var i=s.get(e);F(i)&&(i=new l,s.set(e,i)),i.set(t,r)}return!0}}function ie(){var e;return!F(f)&&B(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),F(e)&&(e=ne()),!F(f)&&B(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,f,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!F(n)&&n.has(r)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return m.registerProvider(r),r;function n(n,i,s){var o=t.get(n),a=!1;if(F(o)){if(!s)return;o=new l,t.set(n,o),a=!0}var c=o.get(i);if(F(c)){if(!s)return;if(c=new l,o.set(i,c),!e.setProvider(n,i,r))throw o.delete(i),a&&t.delete(n),new Error("Wrong provider for target.")}return c}function i(e,t,r){var i=n(t,r,!1);return!F(i)&&H(i.has(e))}function s(e,t,r){var i=n(t,r,!1);if(!F(i))return i.get(e)}function o(e,t,r,i){n(r,i,!0).set(e,t)}function a(e,t){var r=[],i=n(e,t,!1);if(F(i))return r;for(var s=Z(i.keys()),o=0;;){var a=ee(s);if(!a)return r.length=o,r;var c=X(a);try{r[o]=c}catch(e){try{te(s)}finally{throw e}}o++}}function c(e,r,i){var s=n(r,i,!1);if(F(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var o=t.get(r);F(o)||(o.delete(i),0===o.size&&t.delete(o))}return!0}}function oe(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,s=e.deleteMetadata,o=new h,a={isProviderFor:function(e,t){var r=o.get(e);return!(F(r)||!r.has(t))||!!i(e,t).length&&(F(r)&&(r=new p,o.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:s};return a}function ae(e,t,r){var n=m.getProvider(e,t);if(!F(n))return n;if(r){if(m.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),n=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,K(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,o)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!K(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(K(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return n;function i(e,t){return e}function o(e,t){return t}function a(e,t){return[e,t]}}function de(){var e=function(){function e(){this._map=new l}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}();return e}function ue(){var e=16,t=d.create(),n=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&d.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?d.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do{e="@@WeakMap@@"+c()}while(d.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:d.create()})}return e[n]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function le(e){return e.__=void 0,delete e.__,e}e("decorate",v),e("metadata",y),e("defineMetadata",_),e("hasMetadata",b),e("hasOwnMetadata",E),e("getMetadata",w),e("getOwnMetadata",S),e("getMetadataKeys",C),e("getOwnMetadataKeys",P),e("deleteMetadata",T)}(n,r),void 0===r.Reflect&&(r.Reflect=e)}()}(h||(h={}));var v=["inject","multi_inject","name","unmanaged","named","optional"],y="Request",_="Singleton",b="Transient",E="ConstantValue",w="Constructor",S="DynamicValue",C="Factory",P="Function",T="Instance",k="Invalid",R="Provider",I="ClassProperty",D="ConstructorArgument",A="Variable",O=0;function N(){return O++}var M=function(){function e(e,t){this.id=N(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=k,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.onDeactivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===_&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.onDeactivation=this.onDeactivation,t.cache=this.cache,t},e}(),L="No matching bindings found for serviceIdentifier:",x="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",F=function(e,t){return"onDeactivation() error in class "+e+": "+t},j=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata("inversify:paramtypes",e),userGeneratedMetadata:Reflect.getMetadata("inversify:tagged",e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata("inversify:tagged_props",e)||[]},e}(),U=0,B=1;function V(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function W(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function H(e,t,r){var n="",i=r(e,t);return 0!==i.length&&(n="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=G(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function q(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||q(e.parentRequest,t))}function z(e){e.childRequests.forEach((function(e){if(q(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=W(t.serviceIdentifier);return r.push(n),null!==t.parentRequest?e(t.parentRequest,r):r}(e).reverse().join(" --\x3e ")}(e);throw new Error("Circular dependency found: "+t)}z(e)}))}function G(e){if(e.name)return e.name;var t=e.toString(),r=t.match(/^function\s*([^\s(]+)/);return r?r[1]:"Anonymous function: "+t}var Y=function(){function e(e){this.id=N(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),$=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return"named"===this.key?"named: "+String(this.value).toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+String(this.value)+" }"},e}(),J=function(e,t){this.parentContext=e,this.rootRequest=t},K=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),Q=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,r=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},r)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}(),Z=function(){function e(e,t,r,n){this.id=N(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?function(e){return e.toString().slice(7,-1)}(t):t;this.name=new Q(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new $("named",n):n instanceof $&&(s=n),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,r=this.metadata;t<r.length;t++){if(r[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag("multi_inject")},e.prototype.matchesArray=function(e){return this.matchesTag("multi_inject")(e)},e.prototype.isNamed=function(){return this.hasTag("named")},e.prototype.isTagged=function(){return this.metadata.some((function(e){return v.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag("optional")(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return"named"===e.key}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return v.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag("named")(e)},e.prototype.matchesTag=function(e){var t=this;return function(r){for(var n=0,i=t.metadata;n<i.length;n++){var s=i[n];if(s.key===e&&s.value===r)return!0}return!1}},e}(),X=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function ee(e,t,r,n){var i=e.getConstructorMetadata(r),s=i.compilerGeneratedMetadata;if(void 0===s)throw new Error("Missing required @injectable annotation in: "+t+".");var o=i.userGeneratedMetadata,a=Object.keys(o),c=0===r.length&&a.length>0,d=a.length>r.length,u=function(e,t,r,n,i){for(var s=[],o=0;o<i;o++){var a=te(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=ne(e,r,t);return X(X([],u,!0),l,!0)}function te(e,t,r,n,i){var s=i[e.toString()]||[],o=se(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof K&&(c=c.unwrap()),a){if(!t&&(c===Object||c===Function||void 0===c))throw new Error("Missing required @inject or @multiInject annotation in: argument "+e+" in class "+r+".");var u=new Z(D,o.targetName,c);return u.metadata=s,u}return null}function re(e,t,r,n){var i=e||t;if(void 0===i){var s="Missing required @injectable annotation in: for property "+String(r)+" in class "+n+".";throw new Error(s)}return i}function ne(e,t,r){for(var n=e.getPropertiesMetadata(t),i=[],s=Object.getOwnPropertySymbols(n),o=0,a=Object.keys(n).concat(s);o<a.length;o++){var c=a[o],d=n[c],u=se(d),l=u.targetName||c,p=re(u.inject,u.multiInject,c,r),h=new Z(I,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=ne(e,f,r);i=X(X([],i,!0),m,!0)}return i}function ie(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=ee(e,G(r),r,!0),i=n.map((function(e){return e.metadata.filter((function(e){return"unmanaged"===e.key}))})),s=[].concat.apply([],i).length,o=n.length-s;return o>0?o:ie(e,r)}return 0}function se(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t.inject,multiInject:t.multi_inject,targetName:t.name,unmanaged:t.unmanaged}}var oe=function(){function e(e,t,r,n,i){this.id=N(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=r,this.target=i,this.childRequests=[],this.bindings=Array.isArray(n)?n:[n],this.requestScope=null===r?new Map:null}return e.prototype.addChildRequest=function(t,r,n){var i=new e(t,this.parentContext,this,r,n);return this.childRequests.push(i),i},e}();function ae(e){return e._bindingDictionary}function ce(e,t,r,n,i){var s=ue(r.container,i.serviceIdentifier),o=[];return s.length===U&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=ue(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new oe(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case U:if(r.isOptional())return t;var i=W(e),s=L;throw s+=function(e,t){if(t.isTagged()||t.isNamed()){var r="",n=t.getNamedTag(),i=t.getCustomTags();return null!==n&&(r+=n.toString()+"\n"),null!==i&&i.forEach((function(e){r+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+r}return" "+e}(i,r),s+=H(n,i,ue),new Error(s);case B:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=W(e));throw s+=H(n,i,ue),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function de(e,t,r,n,i,s){var o,a;if(null===i){o=ce(e,t,n,null,s),a=new oe(r,n,null,o,s);var c=new J(n,a);n.addPlan(c)}else o=ce(e,t,n,i,s),a=i.addChildRequest(s.serviceIdentifier,o,s);o.forEach((function(t){var r=null;if(s.isArray())r=a.addChildRequest(t.serviceIdentifier,t,s);else{if(t.cache)return;r=a}if(t.type===T&&null!==t.implementationType){var i=function(e,t){return ee(e,G(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=ie(e,t.implementationType);if(i.length<o){var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."}(G(t.implementationType));throw new Error(c)}}i.forEach((function(t){de(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function ue(e,t){var r=[],n=ae(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=ue(e.parent,t)),r}function le(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new Y(t),d=function(e,t,r,n,i,s){var o=new $(e?"multi_inject":"inject",r),a=new Z(t,n,r,o);if(void 0!==i){var c=new $(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return de(e,a,i,c,null,d),c}catch(e){throw V(e)&&z(c.plan.rootRequest),e}}function pe(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function he(e){return!!pe(e)||Array.isArray(e)&&e.some(pe)}var fe,me=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},ge=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},ve=function(e,t,r){e.has(t.id)||e.set(t.id,r)},ye=function(e,t){e.cache=t,e.activated=!0,pe(t)&&_e(e,t)},_e=function(e,t){return me(void 0,void 0,void 0,(function(){var r,n;return ge(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t];case 1:return r=i.sent(),e.cache=r,[3,3];case 2:throw n=i.sent(),e.cache=null,e.activated=!1,n;case 3:return[2]}}))}))};!function(e){e.DynamicValue="toDynamicValue",e.Factory="toFactory",e.Provider="toProvider"}(fe||(fe={}));var be=function(){return be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},be.apply(this,arguments)},Ee=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},we=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},Se=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Ce(e,t,r){var n;if(t.length>0){var i=function(e,t){return e.reduce((function(e,r){var n=t(r);return r.target.type===D?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=he(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=be(be({},i),{constr:e});n=i.isAsync?function(e){return Ee(this,void 0,void 0,(function(){var t,r;return we(this,(function(n){switch(n.label){case 0:return[4,Te(e.constructorInjections)];case 1:return t=n.sent(),[4,Te(e.propertyInjections)];case 2:return r=n.sent(),[2,Pe(be(be({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):Pe(s)}else n=new e;return n}function Pe(e){var t,r=new((t=e.constr).bind.apply(t,Se([void 0],e.constructorInjections,!1)));return e.propertyRequests.forEach((function(t,n){var i=t.target.identifier,s=e.propertyInjections[n];t.target.isOptional()&&void 0===s||(r[i]=s)})),r}function Te(e){return Ee(this,void 0,void 0,(function(){var t,r,n,i;return we(this,(function(s){for(t=[],r=0,n=e;r<n.length;r++)i=n[r],Array.isArray(i)?t.push(Promise.all(i)):t.push(i);return[2,Promise.all(t)]}))}))}function ke(e,t){var r=function(e,t){var r,n;if(Reflect.hasMetadata("post_construct",e)){var i=Reflect.getMetadata("post_construct",e);try{return null===(n=(r=t)[i.value])||void 0===n?void 0:n.call(r)}catch(t){if(t instanceof Error)throw new Error((s=e.name,o=t.message,"@postConstruct error in class "+s+": "+o))}}var s,o}(e,t);return pe(r)?r.then((function(){return t})):t}function Re(e,t){e.scope!==_&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===y?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(F(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Ie=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},De=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},Ae=function(e){return function(t){t.parentContext.setCurrentRequest(t);var r=t.bindings,n=t.childRequests,i=t.target&&t.target.isArray(),s=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(i&&s)return n.map((function(t){return Ae(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return Le(e,t,o)}}},Oe=function(e,t){var r=function(e){switch(e.type){case C:return{factory:e.factory,factoryType:fe.Factory};case R:return{factory:e.provider,factoryType:fe.Provider};case S:return{factory:e.dynamicValue,factoryType:fe.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw V(e)&&(e=t()),e}}((function(){return r.factory.bind(e)(t)}),(function(){return new Error((e=r.factoryType,n=t.currentRequest.serviceIdentifier.toString(),"It looks like there is a circular dependency in one of the '"+e+"' bindings. Please investigate bindings with service identifier '"+n+"'."));var e,n}))},Ne=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case E:case P:t=e.cache;break;case w:case T:t=e.implementationType;break;case S:t=e.dynamicValue;break;case R:t=e.provider;break;case C:t=e.factory}if(null===t){var r=W(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case E:case P:n=r.cache;break;case w:n=r.implementationType;break;case T:n=function(e,t,r,n){Re(e,t);var i=Ce(t,r,n);return pe(i)?i.then((function(e){return ke(t,e)})):ke(t,i)}(r,r.implementationType,i,Ae(e));break;default:n=Oe(r,t.parentContext)}return n},Me=function(e,t,r){var n=function(e,t){return t.scope===_&&t.activated?t.cache:t.scope===y&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===_&&ye(t,r),t.scope===y&&ve(e,t,r)}(e,t,n=r()),n},Le=function(e,t,r){return Me(e,r,(function(){var n=Ne(e,t,r);return n=pe(n)?n.then((function(e){return xe(t,r,e)})):xe(t,r,n)}))};function xe(e,t,r){var n,i=Fe(e.parentContext,t,r),s=Ve(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=Be(n,c);i=pe(i)?Ue(d,a,i):je(d,a,i),o=s.next()}while(!0!==o.done&&!ae(n).hasKey(e.serviceIdentifier));return i}var Fe=function(e,t,r){return"function"==typeof t.onActivation?t.onActivation(e,r):r},je=function(e,t,r){for(var n=e.next();!n.done;){if(pe(r=n.value(t,r)))return Ue(e,t,r);n=e.next()}return r},Ue=function(e,t,r){return Ie(void 0,void 0,void 0,(function(){var n,i;return De(this,(function(s){switch(s.label){case 0:return[4,r];case 1:n=s.sent(),i=e.next(),s.label=2;case 2:return i.done?[3,4]:[4,i.value(t,n)];case 3:return n=s.sent(),i=e.next(),[3,2];case 4:return[2,n]}}))}))},Be=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},Ve=function(e){for(var t=[e],r=e.parent;null!==r;)t.push(r),r=r.parent;return{next:function(){var e=t.pop();return void 0!==e?{done:!1,value:e}:{done:!0,value:void 0}}}};var We=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||We(r,t))},He=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new $(e,t),r}},qe=He("named"),ze=function(e){return function(t){var r=null;if(null!==t){if(r=t.bindings[0],"string"==typeof e)return r.serviceIdentifier===e;var n=t.bindings[0].implementationType;return e===n}return!1}},Ge=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new Ye(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=qe(e),new Ye(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e&&(null!==e.target&&!e.target.isNamed()&&!e.target.isTagged())},new Ye(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=He(e)(t),new Ye(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&ze(e)(t.parentRequest)},new Ye(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&qe(e)(t.parentRequest)},new Ye(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&He(e)(t)(r.parentRequest)},new Ye(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&We(t,ze(e))},new Ye(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!We(t,ze(e))},new Ye(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&We(t,qe(e))},new Ye(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!We(t,qe(e))},new Ye(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&We(r,He(e)(t))},new Ye(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!We(r,He(e)(t))},new Ye(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&We(t,e)},new Ye(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!We(t,e)},new Ye(this._binding)},e}(),Ye=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new Ge(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new Ge(this._binding)},e}(),$e=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ge(this._binding),this._bindingOnSyntax=new Ye(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),Je=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=y,new $e(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=_,new $e(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=b,new $e(this._binding)},e}(),Ke=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ge(this._binding),this._bindingOnSyntax=new Ye(this._binding),this._bindingInSyntax=new Je(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),Qe=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=T,this._binding.implementationType=e,new Ke(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error("The toSelf function can only be applied when a constructor is used as service identifier");var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=E,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=_,new $e(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=S,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new Ke(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=w,this._binding.implementationType=e,this._binding.scope=_,new $e(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=C,this._binding.factory=e,this._binding.scope=_,new $e(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error("Value provided to function binding must be a function!");var t=this.toConstantValue(e);return this._binding.type=P,this._binding.scope=_,t},e.prototype.toAutoFactory=function(e){return this._binding.type=C,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=_,new $e(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=C,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new $e(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=R,this._binding.provider=e,this._binding.scope=_,new $e(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Ze=function(){function e(){}return e.of=function(t,r,n,i,s){var o=new e;return o.bindings=t,o.middleware=r,o.deactivations=i,o.activations=n,o.moduleActivationStore=s,o},e}();var Xe=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error("NULL argument");if(null==t)throw new Error("NULL argument");var r=this._map.get(e);void 0!==r?r.push(t):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error("NULL argument");var t=this._map.get(e);if(void 0!==t)return t;throw new Error("Key Not Found")},e.prototype.remove=function(e){if(null==e)throw new Error("NULL argument");if(!this._map.delete(e))throw new Error("Key Not Found")},e.prototype.removeIntersection=function(e){var t=this;this.traverse((function(r,n){var i=e.hasKey(r)?e.get(r):void 0;if(void 0!==i){var s=n.filter((function(e){return!i.some((function(t){return e===t}))}));t._setValue(r,s)}}))},e.prototype.removeByCondition=function(e){var t=this,r=[];return this._map.forEach((function(n,i){for(var s=[],o=0,a=n;o<a.length;o++){var c=a[o];e(c)?r.push(c):s.push(c)}t._setValue(i,s)})),r},e.prototype.hasKey=function(e){if(null==e)throw new Error("NULL argument");return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){e.forEach((function(e){return t.add(r,"object"==typeof(n=e)&&null!==n&&"clone"in n&&"function"==typeof n.clone?e.clone():e);var n}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,r){e(r,t)}))},e.prototype._setValue=function(e,t){t.length>0?this._map.set(e,t):this._map.delete(e)},e}(),et=function(){function e(){this._map=new Map}return e.prototype.remove=function(e){if(this._map.has(e)){var t=this._map.get(e);return this._map.delete(e),t}return this._getEmptyHandlersStore()},e.prototype.addDeactivation=function(e,t,r){this._getModuleActivationHandlers(e).onDeactivations.add(t,r)},e.prototype.addActivation=function(e,t,r){this._getModuleActivationHandlers(e).onActivations.add(t,r)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){t._map.set(r,{onActivations:e.onActivations.clone(),onDeactivations:e.onDeactivations.clone()})})),t},e.prototype._getModuleActivationHandlers=function(e){var t=this._map.get(e);return void 0===t&&(t=this._getEmptyHandlersStore(),this._map.set(e,t)),t},e.prototype._getEmptyHandlersStore=function(){return{onActivations:new Xe,onDeactivations:new Xe}},e}(),tt=function(){return tt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},tt.apply(this,arguments)},rt=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},nt=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},it=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},st=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error("Invalid Container constructor argument. Container options must be an object.");if(void 0===t.defaultScope)t.defaultScope=b;else if(t.defaultScope!==_&&t.defaultScope!==b&&t.defaultScope!==y)throw new Error('Invalid Container option. Default scope must be a string ("singleton" or "transient").');if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error("Invalid Container option. Auto bind injectable must be a boolean");if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error("Invalid Container option. Skip base check must be a boolean");this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=N(),this._bindingDictionary=new Xe,this._snapshots=[],this._middleware=null,this._activations=new Xe,this._deactivations=new Xe,this.parent=null,this._metadataReader=new j,this._moduleActivationStore=new et}return e.merge=function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=new e,o=it([t,r],n,!0).map((function(e){return ae(e)})),a=ae(s);function c(e,t){e.traverse((function(e,r){r.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return o.forEach((function(e){c(e,a)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=this._getContainerModuleHelpersFactory(),n=0,i=e;n<i.length;n++){var s=i[n],o=r(s.id);s.registry(o.bindFunction,o.unbindFunction,o.isboundFunction,o.rebindFunction,o.unbindAsyncFunction,o.onActivationFunction,o.onDeactivationFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rt(this,void 0,void 0,(function(){var t,r,n,i,s;return nt(this,(function(o){switch(o.label){case 0:t=this._getContainerModuleHelpersFactory(),r=0,n=e,o.label=1;case 1:return r<n.length?(i=n[r],s=t(i.id),[4,i.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction,s.unbindAsyncFunction,s.onActivationFunction,s.onDeactivationFunction)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.forEach((function(t){var r=e._removeModuleBindings(t.id);e._deactivateSingletons(r),e._removeModuleHandlers(t.id)}))},e.prototype.unloadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rt(this,void 0,void 0,(function(){var t,r,n,i;return nt(this,(function(s){switch(s.label){case 0:t=0,r=e,s.label=1;case 1:return t<r.length?(n=r[t],i=this._removeModuleBindings(n.id),[4,this._deactivateSingletonsAsync(i)]):[3,4];case 2:s.sent(),this._removeModuleHandlers(n.id),s.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},e.prototype.bind=function(e){var t=this.options.defaultScope||b,r=new M(e,t);return this._bindingDictionary.add(e,r),new Qe(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return rt(this,void 0,void 0,(function(){return nt(this,(function(t){switch(t.label){case 0:return[4,this.unbindAsync(e)];case 1:return t.sent(),[2,this.bind(e)]}}))}))},e.prototype.unbind=function(e){if(this._bindingDictionary.hasKey(e)){var t=this._bindingDictionary.get(e);this._deactivateSingletons(t)}this._removeServiceFromDictionary(e)},e.prototype.unbindAsync=function(e){return rt(this,void 0,void 0,(function(){var t;return nt(this,(function(r){switch(r.label){case 0:return this._bindingDictionary.hasKey(e)?(t=this._bindingDictionary.get(e),[4,this._deactivateSingletonsAsync(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return this._removeServiceFromDictionary(e),[2]}}))}))},e.prototype.unbindAll=function(){var e=this;this._bindingDictionary.traverse((function(t,r){e._deactivateSingletons(r)})),this._bindingDictionary=new Xe},e.prototype.unbindAllAsync=function(){return rt(this,void 0,void 0,(function(){var e,t=this;return nt(this,(function(r){switch(r.label){case 0:return e=[],this._bindingDictionary.traverse((function(r,n){e.push(t._deactivateSingletonsAsync(n))})),[4,Promise.all(e)];case 1:return r.sent(),this._bindingDictionary=new Xe,[2]}}))}))},e.prototype.onActivation=function(e,t){this._activations.add(e,t)},e.prototype.onDeactivation=function(e,t){this._deactivations.add(e,t)},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isCurrentBound=function(e){return this._bindingDictionary.hasKey(e)},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,"named",t)},e.prototype.isBoundTagged=function(e,t,r){var n=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),s=function(e,t,r,n){var i=new Z(A,"",t,new $(r,n)),s=new Y(e);return new oe(t,s,null,[],i)}(this,e,t,r);n=i.some((function(e){return e.constraint(s)}))}return!n&&this.parent&&(n=this.parent.isBoundTagged(e,t,r)),n},e.prototype.snapshot=function(){this._snapshots.push(Ze.of(this._bindingDictionary.clone(),this._middleware,this._activations.clone(),this._deactivations.clone(),this._moduleActivationStore.clone()))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error("No snapshot available to restore.");this._bindingDictionary=e.bindings,this._activations=e.activations,this._deactivations=e.deactivations,this._middleware=e.middleware,this._moduleActivationStore=e.moduleActivationStore},e.prototype.createChild=function(t){var r=new e(t||this.options);return r.parent=this,r},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),r)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){var t=this._getNotAllArgs(e,!1);return this._getButThrowIfAsync(t)},e.prototype.getAsync=function(e){return rt(this,void 0,void 0,(function(){var t;return nt(this,(function(r){return t=this._getNotAllArgs(e,!1),[2,this._get(t)]}))}))},e.prototype.getTagged=function(e,t,r){var n=this._getNotAllArgs(e,!1,t,r);return this._getButThrowIfAsync(n)},e.prototype.getTaggedAsync=function(e,t,r){return rt(this,void 0,void 0,(function(){var n;return nt(this,(function(i){return n=this._getNotAllArgs(e,!1,t,r),[2,this._get(n)]}))}))},e.prototype.getNamed=function(e,t){return this.getTagged(e,"named",t)},e.prototype.getNamedAsync=function(e,t){return this.getTaggedAsync(e,"named",t)},e.prototype.getAll=function(e){var t=this._getAllArgs(e);return this._getButThrowIfAsync(t)},e.prototype.getAllAsync=function(e){var t=this._getAllArgs(e);return this._getAll(t)},e.prototype.getAllTagged=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getButThrowIfAsync(n)},e.prototype.getAllTaggedAsync=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getAll(n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,"named",t)},e.prototype.getAllNamedAsync=function(e,t){return this.getAllTaggedAsync(e,"named",t)},e.prototype.resolve=function(e){var t=this.isBound(e);t||this.bind(e).toSelf();var r=this.get(e);return t||this.unbind(e),r},e.prototype._preDestroy=function(e,t){var r,n;if(Reflect.hasMetadata("pre_destroy",e))return null===(n=(r=t)[Reflect.getMetadata("pre_destroy",e).value])||void 0===n?void 0:n.call(r)},e.prototype._removeModuleHandlers=function(e){var t=this._moduleActivationStore.remove(e);this._activations.removeIntersection(t.onActivations),this._deactivations.removeIntersection(t.onDeactivations)},e.prototype._removeModuleBindings=function(e){return this._bindingDictionary.removeByCondition((function(t){return t.moduleId===e}))},e.prototype._deactivate=function(e,t){var r=this,n=Object.getPrototypeOf(t).constructor;try{if(this._deactivations.hasKey(e.serviceIdentifier)){var i=this._deactivateContainer(t,this._deactivations.get(e.serviceIdentifier).values());if(pe(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(pe(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(F(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return rt(this,void 0,void 0,(function(){var r;return nt(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e];case 1:return n.sent(),[3,3];case 2:if((r=n.sent())instanceof Error)throw new Error(F(t.name,r.message));return[3,3];case 3:return[2]}}))}))},e.prototype._deactivateContainer=function(e,t){for(var r=this,n=t.next();n.value;){var i=n.value(e);if(pe(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return rt(this,void 0,void 0,(function(){var r;return nt(this,(function(n){switch(n.label){case 0:r=t.next(),n.label=1;case 1:return r.value?[4,r.value(e)]:[3,3];case 2:return n.sent(),r=t.next(),[3,1];case 3:return[2]}}))}))},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},r=function(r){return function(n){var i=e.rebind(n);return t(i,r),i}},n=function(t){return function(r,n){e._moduleActivationStore.addActivation(t,r,n),e.onActivation(r,n)}},i=function(t){return function(r,n){e._moduleActivationStore.addDeactivation(t,r,n),e.onDeactivation(r,n)}};return function(s){return{bindFunction:(o=s,function(r){var n=e.bind(r);return t(n,o),n}),isboundFunction:function(t){return e.isBound(t)},onActivationFunction:n(s),onDeactivationFunction:i(s),rebindFunction:r(s),unbindFunction:function(t){return e.unbind(t)},unbindAsyncFunction:function(t){return e.unbindAsync(t)}};var o}},e.prototype._getAll=function(e){return Promise.all(this._get(e))},e.prototype._get=function(e){var t=tt(tt({},e),{contextInterceptor:function(e){return e},targetType:A});if(this._middleware){var r=this._middleware(t);if(null==r)throw new Error("Invalid return type in middleware. Middleware must return!");return r}return this._planAndResolve()(t)},e.prototype._getButThrowIfAsync=function(e){var t=this._get(e);if(he(t))throw new Error("You are attempting to construct '"+e.serviceIdentifier+"' in a synchronous way\n but it has asynchronous dependencies.");return t},e.prototype._getAllArgs=function(e){return{avoidConstraints:!0,isMultiInject:!0,serviceIdentifier:e}},e.prototype._getNotAllArgs=function(e,t,r,n){return{avoidConstraints:!1,isMultiInject:t,serviceIdentifier:e,key:r,value:n}},e.prototype._planAndResolve=function(){var e=this;return function(t){var r=le(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return Ae(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return pe(e.cache)?e.cache.then((function(r){return t._deactivate(e,r)})):this._deactivate(e,e.cache)},e.prototype._deactivateSingletons=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(pe(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return rt(this,void 0,void 0,(function(){var t=this;return nt(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return t._deactivateIfSingleton(e)})))];case 1:return r.sent(),[2]}}))}))},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroy=function(e,t,r){return this.parent?this._deactivate.bind(this.parent)(e,t):this._bindingDeactivationAndPreDestroy(e,t,r)},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroyAsync=function(e,t,r){return rt(this,void 0,void 0,(function(){return nt(this,(function(n){switch(n.label){case 0:return this.parent?[4,this._deactivate.bind(this.parent)(e,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this._bindingDeactivationAndPreDestroyAsync(e,t,r)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.prototype._removeServiceFromDictionary=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error("Could not unbind serviceIdentifier: "+W(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(pe(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return rt(this,void 0,void 0,(function(){return nt(this,(function(n){switch(n.label){case 0:return"function"!=typeof e.onDeactivation?[3,2]:[4,e.onDeactivation(t)];case 1:n.sent(),n.label=2;case 2:return[4,this._preDestroy(r,t)];case 3:return n.sent(),[2]}}))}))},e}();function ot(e,t,r,n){!function(e){if(void 0!==e)throw new Error(x)}(t),ct("inversify:tagged",e,r.toString(),n)}function at(e){var t=[];if(Array.isArray(e)){var r=function(e){for(var t=new Set,r=0,n=e;r<n.length;r++){var i=n[r];if(t.has(i))return i;t.add(i)}}((t=e).map((function(e){return e.key})));if(void 0!==r)throw new Error("Metadata key was used more than once in a parameter: "+r.toString())}else t=[e];return t}function ct(e,t,r,n){var i=at(n),s={};Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var o=s[r];if(void 0===o)o=[];else for(var a=function(e){if(i.some((function(t){return t.key===e.key})))throw new Error("Metadata key was used more than once in a parameter: "+e.key.toString())},c=0,d=o;c<d.length;c++){a(d[c])}o.push.apply(o,i),s[r]=o,Reflect.defineMetadata(e,s,t)}function dt(e){return function(t,r,n){"number"==typeof n?ot(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(x);ct("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function ut(){return function(e){if(Reflect.hasOwnMetadata("inversify:paramtypes",e))throw new Error("Cannot apply @injectable decorator multiple times.");var t=Reflect.getMetadata("design:paramtypes",e)||[];return Reflect.defineMetadata("inversify:paramtypes",t,e),e}}var lt,pt=(lt="inject",function(e){return function(t,r,n){if(void 0===e){var i="function"==typeof t?t.name:t.constructor.name;throw new Error(function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation."}(i))}return dt(new $(lt,e))(t,r,n)}});const ht=3,ft=4,mt=6,gt=7;var vt;!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.OK=200]="OK",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(vt||(vt={}));var yt;const _t={baseURL:"https://lb.livedigital.space/v1",timeout:5e3},bt={customerId:String(process.env.ASDK_CUSTOMER_ID),sdk_url:String("https://effectssdk.ai/sdk/audio/"),api_url:String("https://effectssdk.ai/sdk/session/"),version:"2.3.5"},Et={customerId:String("89c41ecf3b3f46fef5dfa9f96842014c21d4901c"),sdk_url:String("https://effectssdk.ai/sdk/"),api_url:String("https://effectssdk.ai/sdk/session/")},wt=()=>{};let St=class{constructor(e){var t,r,n,i,s,o,a,c,d;yt.set(this,void 0),p(this,yt,{denoiser:null!==(t=e.denoiser)&&void 0!==t?t:"rnnoise",asdk:Object.assign(Object.assign({},bt),e.asdk),loadbalancer:Object.assign(_t,null!==(n=null===(r=e.network)||void 0===r?void 0:r.loadbalancer)&&void 0!==n?n:{}),logLevel:null!==(i=e.logLevel)&&void 0!==i?i:ht,sendAnalytics:null!==(s=e.sendAnalytics)&&void 0!==s&&s,onLogMessage:null!==(o=e.onLogMessage)&&void 0!==o?o:wt,onIssues:null!==(a=e.onIssues)&&void 0!==a?a:wt,disableWid:null!==(c=e.disableWid)&&void 0!==c&&c,effectsSDKParams:Object.assign(Object.assign({},Et),e.effectsSDKParams),onNetworkScoresUpdated:null!==(d=e.onNetworkScoresUpdated)&&void 0!==d?d:wt,staticFilesPath:e.staticFilesPath||window.location.origin},"f")}get(e){return l(this,yt,"f")[e]}set(e,t){l(this,yt,"f")[e]=t}};yt=new WeakMap,St=a([ut(),d("design:paramtypes",[Object])],St);var Ct,Pt,Tt,kt,Rt=St;class It extends e.EventEmitter{constructor(){super(),this.addListener=(e,t)=>this.on(e,t),this.removeListener=(e,t)=>this.off(e,t),this.prependListener=(e,t)=>(super.prependListener(e,t),this),this.prependOnceListener=(e,t)=>(super.prependOnceListener(e,t),this),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){try{super.emit("listenererror",e,t)}catch(e){}return!!super.listenerCount(e)}}on(e,t){return super.on(e,t)}off(e,t){return super.off(e,t)}once(e,t){return super.once(e,t)}removeAllListeners(e){return super.removeAllListeners(e),this}}function Dt(){}function At(){At.init.call(this)}function Ot(e){return void 0===e._maxListeners?At.defaultMaxListeners:e._maxListeners}function Nt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Vt(e,n),s=0;s<n;++s)i[s].call(r)}function Mt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Vt(e,i),o=0;o<i;++o)s[o].call(r,n)}function Lt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Vt(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function xt(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Vt(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Ft(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Vt(e,i),o=0;o<i;++o)s[o].apply(r,n)}function jt(e,t,r,n){var i,s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=new Dt,e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=Ot(e))&&i>0&&o.length>i){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=s[t]=r,++e._eventsCount;return e}function Ut(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Bt(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Vt(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}Dt.prototype=Object.create(null),At.EventEmitter=At,At.usingDomains=!1,At.prototype.domain=void 0,At.prototype._events=void 0,At.prototype._maxListeners=void 0,At.defaultMaxListeners=10,At.init=function(){this.domain=null,At.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Dt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},At.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},At.prototype.getMaxListeners=function(){return Ot(this)},At.prototype.emit=function(e){var t,r,n,i,s,o,a,c="error"===e;if(o=this._events)c=c&&null==o.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var d=new Error('Uncaught, unspecified "error" event. ('+t+")");throw d.context=t,d}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=o[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:Nt(r,u,this);break;case 2:Mt(r,u,this,arguments[1]);break;case 3:Lt(r,u,this,arguments[1],arguments[2]);break;case 4:xt(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];Ft(r,u,this,i)}return!0},At.prototype.addListener=function(e,t){return jt(this,e,t,!1)},At.prototype.on=At.prototype.addListener,At.prototype.prependListener=function(e,t){return jt(this,e,t,!0)},At.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ut(this,e,t)),this},At.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ut(this,e,t)),this},At.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Dt:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Dt,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},At.prototype.off=function(e,t){return this.removeListener(e,t)},At.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Dt,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Dt:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),s=0;s<i.length;++s)"removeListener"!==(n=i[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Dt,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},At.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},At.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Bt.call(e,t)},At.prototype.listenerCount=Bt,At.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Wt extends At{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(Ct||(Ct={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(Pt||(Pt={})),function(e){e.OutboundNetworkQuality="outbound-network-quality",e.InboundNetworkQuality="inbound-network-quality",e.OutboundNetworkMediaLatency="outbound-network-media-latency",e.InboundNetworkMediaLatency="inbound-network-media-latency",e.NetworkMediaSyncFailure="network-media-sync-failure",e.OutboundNetworkThroughput="outbound-network-throughput",e.InboundNetworkThroughput="inbound-network-throughput",e.EncoderCPUThrottling="encoder-cpu-throttling",e.DecoderCPUThrottling="decoder-cpu-throttling",e.ServerIssue="server-issue",e.UnknownVideoDecoderIssue="unknown-video-decoder",e.LowInboundMOS="low-inbound-mean-opinion-score",e.LowOutboundMOS="low-outbound-mean-opinion-score",e.FrozenVideoTrack="frozen-video-track",e.MissingVideoStreamData="missing-video-stream-data",e.MissingAudioStreamData="missing-audio-stream-data"}(Tt||(Tt={})),function(e){e[e.BAD=2.1]="BAD",e[e.POOR=2.6]="POOR",e[e.FAIR=3.1]="FAIR",e[e.GOOD=3.8]="GOOD",e[e.EXCELLENT=4.3]="EXCELLENT"}(kt||(kt={}));class Ht extends At{static STATS_REPORT_READY_EVENT="stats-report-ready";static STATS_REPORTS_PARSED="stats-reports-parsed";isStopped=!1;reportTimer;getStatsInterval;compositeStatsParser;constructor(e){super(),this.compositeStatsParser=e.compositeStatsParser,this.getStatsInterval=e.getStatsInterval??1e4}get isRunning(){return!!this.reportTimer&&!this.isStopped}startReporting(){if(this.reportTimer)return;const e=()=>setTimeout((()=>{this.isStopped?this.reportTimer=void 0:this.parseReports().finally((()=>{this.reportTimer=e()}))}),this.getStatsInterval);this.isStopped=!1,this.reportTimer=e()}stopReporting(){this.isStopped=!0,this.reportTimer&&(clearTimeout(this.reportTimer),this.reportTimer=void 0)}async parseReports(){const e=Date.now(),t=await this.compositeStatsParser.parse(),r=Date.now()-e;this.emit(Ht.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(Ht.STATS_REPORT_READY_EVENT,e)}))}}const qt=(()=>{const e=new Map;return t=>{const{taskId:r,delayMs:n,maxJitterMs:i,callback:s}=t,o=Math.ceil(Math.random()*(i||0)),a=e.get(r);a&&clearTimeout(a);const c=setTimeout((()=>{s(),e.delete(r)}),n+o);e.set(r,c)}})();class zt{#e={};calculate(e){const{connection:{id:t}}=e,{mos:r,stats:n}=this.calculateOutboundScore(e)||{},{mos:i,stats:s}=this.calculateInboundScore(e)||{};return this.#e[t]=e,qt({taskId:t,delayMs:35e3,callback:()=>delete this.#e[t]}),{outbound:r,inbound:i,connectionId:t,statsSamples:{inboundStatsSample:s,outboundStatsSample:n}}}calculateOutboundScore(e){const t=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.remote?.audio.inbound||[],...r.remote?.video.inbound||[]],{packetsSent:i}=e.connection,s=r.connection.packetsSent,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateInboundScore(e){const t=[...e.audio?.inbound,...e.video?.inbound];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.video?.inbound,...r.audio?.inbound],{packetsReceived:i}=e.connection,s=r.connection.packetsReceived,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateMOS({avgJitter:e,rtt:t,packetsLoss:r}){const n=t+2*e+10;let i=n<160?93.2-n/40:93.2-n/120-10;return i-=2.5*r,1+.035*i+7e-6*i*(i-60)*(100-i)}}class Gt{#t=new Map;#r;#n;constructor(e={}){this.#r=e.statsCleanupTtlMs??35e3,this.#n=e.maxParsedStatsStorageSize??5}detect(e,t){const r={...e,networkScores:{...t,statsSamples:t?.statsSamples||{}}},n=this.performDetection(r);return this.setLastProcessedStats(e.connection.id,r),this.performPrevStatsCleanup({connectionId:e.connection.id}),n}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#t.has(t)&&qt({taskId:t,delayMs:this.#r,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){if(!e||t.connection.id!==e)return;const r=this.#t.get(e)??[];r.push(t),r.length>this.#n&&r.shift(),this.#t.set(e,r)}getLastProcessedStats(e){const t=this.#t.get(e);return t?.[t.length-1]}getAllLastProcessedStats(e){return this.#t.get(e)??[]}deleteLastProcessedStats(e){this.#t.delete(e)}}class Yt extends Gt{#i;constructor(e={}){super(e),this.#i=e.availableOutgoingBitrateThreshold??1e5}performDetection(e){const t=[],{availableOutgoingBitrate:r}=e.connection;if(void 0===r)return t;const n=e.audio.outbound.reduce(((e,t)=>e+t.targetBitrate),0),i=e.video.outbound.reduce(((e,t)=>e+t.bitrate),0);if(!n&&!i)return t;const s={availableOutgoingBitrate:r,videoStreamsTotalBitrate:i,audioStreamsTotalTargetBitrate:n};return n>r||i>0&&r<this.#i?(t.push({statsSample:s,type:Pt.Network,reason:Tt.OutboundNetworkThroughput}),t):t}}class $t extends Gt{#s;#o;#a;#c;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200,this.#a=e.highJitterBufferDelayThresholdMs??500,this.#c=e.highRttThresholdMs??250}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.audio?.inbound,...e.video?.inbound];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.video?.inbound,...n.audio?.inbound],{packetsReceived:s}=e.connection,o=n.connection.packetsReceived,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc)),n=r?.jitterBufferDelay||0,s=r?.jitterBufferEmittedCount||0,o=t.jitterBufferDelay-n,a=t.jitterBufferEmittedCount-s,c=o&&a?1e3*o/a:0;return{sumJitter:e.sumJitter+t.jitter,sumJitterBufferDelayMs:e.sumJitterBufferDelayMs+c,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,sumJitterBufferDelayMs:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d,sumJitterBufferDelayMs:u}=a,l=d/r.length,p=u/r.length,h=s-o,f=a.packetsLost-a.lastPacketsLost,m=h&&f?Math.round(100*f/(h+f)):0,g=m>this.#s,v=l>=this.#o,y=c>=this.#c,_=p>this.#a,b=y&&!v&&!g,E=g&&v,w=v&&_,S={rtt:c,packetLossPct:m,avgJitter:l,avgJitterBufferDelay:p};return(v||g)&&t.push({statsSample:S,type:Pt.Network,reason:Tt.InboundNetworkQuality,iceCandidate:e.connection.local.id}),b&&t.push({statsSample:S,type:Pt.Server,reason:Tt.ServerIssue,iceCandidate:e.connection.remote.id}),E&&t.push({statsSample:S,type:Pt.Network,reason:Tt.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:S,type:Pt.Network,reason:Tt.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class Jt extends Gt{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){return this.processData(e)}processData(e){const t=e.audio.inbound,r=[],n=this.getLastProcessedStats(e.connection.id)?.audio.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i=e.track.insertedSamplesForDeceleration+e.track.removedSamplesForAcceleration,s=t.track.insertedSamplesForDeceleration+t.track.removedSamplesForAcceleration;if(i===s)return;const o=e.track.totalSamplesReceived-t.track.totalSamplesReceived,a=i-s,c=Math.round(100*a/o),d={correctedSamplesPct:c};c>this.#d&&r.push({statsSample:d,type:Pt.Network,reason:Tt.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class Kt extends Gt{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.remote?.audio.inbound||[],...n.remote?.video.inbound||[]],{packetsSent:s}=e.connection,o=n.connection.packetsSent,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d}=a,u=d/r.length,l=s-o,p=a.packetsLost-a.lastPacketsLost,h=l&&p?Math.round(100*p/(l+p)):0,f=h>this.#s,m=u>=this.#o,g=!f&&m||m||f,v={rtt:c,avgJitter:u,packetLossPct:h};return f&&m&&t.push({statsSample:v,type:Pt.Network,reason:Tt.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:Pt.Network,reason:Tt.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Qt extends Gt{performDetection(e){return this.processData(e)}processData(e){const t=e.video.outbound.filter((e=>"none"!==e.qualityLimitationReason)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.outbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i={qualityLimitationReason:e.qualityLimitationReason};e.framesSent>t.framesSent||("cpu"===e.qualityLimitationReason&&r.push({statsSample:i,type:Pt.CPU,reason:Tt.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:Pt.Network,reason:Tt.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class Zt extends Gt{UNKNOWN_DECODER="unknown";#u={};performDetection(e){return this.processData(e)}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;super.performPrevStatsCleanup({...e,cleanupCallback:()=>{delete this.#u[t],"function"==typeof r&&r()}})}processData(e){const t=[],{id:r}=e.connection,n=this.getLastProcessedStats(r)?.video.inbound;return e.video.inbound.forEach((e=>{const{decoderImplementation:i,ssrc:s}=e,o=n?.find((e=>e.ssrc===s));if(o)if(i===this.UNKNOWN_DECODER){if(!this.hadLastDecoderWithIssue(r,s)){this.setLastDecoderWithIssue(r,s,this.UNKNOWN_DECODER);const n={mimeType:e.mimeType,decoderImplementation:i};t.push({ssrc:s,statsSample:n,type:Pt.Stream,reason:Tt.UnknownVideoDecoderIssue,trackIdentifier:e.track.trackIdentifier})}}else this.setLastDecoderWithIssue(r,s,void 0)})),t}setLastDecoderWithIssue(e,t,r){const n=this.#u[e]??{};void 0===r?delete n[t]:n[t]=r,this.#u[e]=n}hadLastDecoderWithIssue(e,t){const r=this.#u[e];return(r&&r[t])===this.UNKNOWN_DECODER}}const Xt=e=>e.reduce(((e,t)=>e+t),0)/e.length,er=(e,t,r=30)=>{const n=[];for(let r=1;r<t.length-1;r+=1){const i=t[r]?.video?.inbound.find((t=>t.ssrc===e));if(!i)continue;const s=t[r-1]?.video?.inbound?.find((t=>t.ssrc===e));if(!i||!s)continue;const o=i.timestamp-s.timestamp,a=i.framesDecoded-s.framesDecoded;if(a>0){const e=o/a;n.push(e)}}return!(n.length<=1)&&(e=>{const t=((e,t)=>t.reduce(((t,r)=>t+(r-e)**2),0)/t.length)(Xt(e),e);return Math.sqrt(t)})(n)>r},tr=(e,t)=>{for(let r=1;r<t.length;r+=1){const n=t[r].video.inbound.find((t=>t.ssrc===e));if(!n)continue;const i=t[r-1].video.inbound.find((t=>t.ssrc===e)),s=n.frameWidth!==i?.frameWidth,o=n.frameHeight!==i?.frameHeight;if(s||o)return!0}return!1};class rr extends Gt{#l;#p;#h;constructor(e={}){super(),this.#l=e.avgFreezeDurationThresholdMs??1e3,this.#p=e.frozenDurationThresholdPct??30,this.#h=e.minMosQuality??kt.BAD}performDetection(e){const t=e.networkScores.inbound;return void 0!==t&&t<=this.#h?[]:this.processData(e)}processData(e){const t=[],r=this.getAllLastProcessedStats(e.connection.id);if(0===r.length)return[];const n=e.video.inbound.map((t=>{const n=r[r.length-1].video.inbound.find((e=>e.ssrc===t.ssrc));if(!n)return;if(tr(t.ssrc,[r[r.length-1],e]))return;if(er(t.ssrc,r))return;const i=t.freezeCount-(n.freezeCount??0),s=1e3*(t.totalFreezesDuration-(n.totalFreezesDuration??0)),o=i>0?s/i:0,a=s/(t.timestamp-n.timestamp)*100;return a>this.#p||o>this.#l?{ssrc:t.ssrc,avgFreezeDurationMs:o,frozenDurationPct:a}:void 0})).filter((e=>void 0!==e));return n.length>0&&(t.push({type:Pt.Stream,reason:Tt.FrozenVideoTrack,statsSample:{ssrcs:n.map((e=>e.ssrc))}}),this.deleteLastProcessedStats(e.connection.id)),t}}class nr extends Gt{#f;#m;#h;constructor(e={}){super(e),this.#f=e.volatilityThreshold??8,this.#m=e.affectedStreamsPercentThreshold??30,this.#h=e.minMosQuality??kt.BAD}performDetection(e){return[...this.getAllLastProcessedStats(e.connection.id),e].find((e=>void 0!==e.networkScores.inbound&&e.networkScores.inbound<=this.#h))?[]:this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e],n=e.video.inbound.map((e=>{if(r.length<5)return;if(tr(e.ssrc,r))return;const t=[];for(let n=0;n<r.length-1;n+=1){const i=r[n].video.inbound.find((t=>t.ssrc===e.ssrc));void 0!==i?.framesPerSecond&&t.push(i.framesPerSecond)}if(t.length<5)return;if(er(e.ssrc,r))return;const n=(e=>{if(0===e.length)throw new Error("Cannot calculate volatility for empty array");const t=Xt(e);return e.reduce(((e,r)=>e+Math.abs(r-t)),0)/e.length*100/t})(t);return n>this.#f?{ssrc:e.ssrc,allFps:t,volatility:n}:void 0})).filter((e=>Boolean(e)));if(0===n.length)return t;const i=n.length/(e.video.inbound.length/100);return i>this.#m&&(t.push({type:Pt.CPU,reason:Tt.DecoderCPUThrottling,statsSample:{affectedStreamsPercent:i,throtthedStreams:n}}),this.deleteLastProcessedStats(e.connection.id)),t}}const ir=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,sr=(e,t,r)=>8*((e,t,r)=>{if(!t)return 0;const n=e[r],i=t[r];if(null==n||null==i)return 0;const s=Math.floor(e.timestamp)-Math.floor(t.timestamp);return 0===s?0:(Number(n)-Number(i))/s*1e3})(e,t,r);class or{connections=[];statsParser;constructor(e){this.statsParser=e.statsParser}listConnections(){return[...this.connections]}addPeerConnection(e){this.connections.push({id:e.id??String(Date.now()+Math.random().toString(32)),pc:e.pc})}removePeerConnection(e){const t=this.connections.findIndex((({pc:t})=>t===e.pc));t>=0&&this.removeConnectionsByIndexes([t])}async parse(){const e=[],t=this.connections.map((async(t,r)=>{if(!ir(t.pc))return this.statsParser.parse(t);e.unshift(r)}));return e.length&&this.removeConnectionsByIndexes(e),(await Promise.all(t)).filter((e=>void 0!==e))}removeConnectionsByIndexes(e){e.forEach((e=>{this.connections.splice(e,1)}))}}class ar{prevStats=new Map;allowedReportTypes=new Set(["candidate-pair","inbound-rtp","outbound-rtp","remote-outbound-rtp","remote-inbound-rtp","track","transport"]);ignoreSSRCList;logger;constructor(e){this.ignoreSSRCList=e.ignoreSSRCList??[],this.logger=e.logger}get previouslyParsedStatsConnectionsIds(){return[...this.prevStats.keys()]}async parse(e){if(!ir(e.pc))return this.getConnectionStats(e);this.logger.debug("Skip stats parsing. Connection is closed.",{connection:e})}async getConnectionStats(e){const{pc:t,id:r}=e;try{const n=Date.now(),i=t.getReceivers().filter((e=>e.track?.enabled)),s=t.getSenders().filter((e=>e.track?.enabled)),o=await Promise.all(i.map((e=>e.getStats()))),a=await Promise.all(s.map((e=>e.getStats())));return{id:r,stats:this.mapReportsStats([...o,...a],e),timeTaken:Date.now()-n}}catch(e){return void this.logger.error("Failed to get stats for PC",{id:r,pc:t,error:e})}}mapReportsStats(e,t){const r={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]},connection:{},remote:{video:{inbound:[],outbound:[]},audio:{inbound:[],outbound:[]}}};e.forEach((e=>{e.forEach((t=>{this.allowedReportTypes.has(t.type)&&this.updateMappedStatsWithReportItemData(t,r,e)}))}));const{id:n}=t,i=this.prevStats.get(n);return i&&this.propagateStatsWithRateValues(r,i.stats),this.prevStats.set(n,{stats:r,ts:Date.now()}),qt({taskId:n,delayMs:35e3,callback:()=>this.prevStats.delete(n)}),r}updateMappedStatsWithReportItemData(e,t,r){const n=e.type;if("candidate-pair"===n&&"succeeded"===e.state&&e.nominated)return void(t.connection=this.prepareConnectionStats(e,r));const i=this.getMediaType(e);if(!i)return;const s=e.ssrc;if(!s||!this.ignoreSSRCList.includes(s))if("outbound-rtp"!==n)if("inbound-rtp"!==n)"remote-outbound-rtp"!==n?"remote-inbound-rtp"===n&&(this.mapConnectionStatsIfNecessary(t,e,r),t.remote[i].inbound.push({...e})):t.remote[i].outbound.push({...e});else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{};this.mapConnectionStatsIfNecessary(t,e,r);const s={...e,track:{...n}};t[i].inbound.push(s)}else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{},s={...e,track:{...n}};t[i].outbound.push(s)}}getMediaType(e){const t=e.mediaType||e.kind;if(!["audio","video"].includes(t)){const{id:t}=e;if(!t)return;return String(t).includes("Video")?"video":String(t).includes("Audio")?"audio":void 0}return t}propagateStatsWithRateValues(e,t){e.audio.inbound.forEach((e=>{const r=t.audio.inbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesReceived"),e.packetRate=sr(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesSent"),e.packetRate=sr(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesReceived"),e.packetRate=sr(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=sr(e,r,"bytesSent"),e.packetRate=sr(e,r,"packetsSent")}))}mapConnectionStatsIfNecessary(e,t,r){if(e.connection.id||!t.transportId)return;const n=r.get(t.transportId);if(n&&n.selectedCandidatePairId){const t=r.get(n.selectedCandidatePairId);e.connection=this.prepareConnectionStats(t,r)}}prepareConnectionStats(e,t){if(!e||!t)return{};const r={...e};if(r.remoteCandidateId){const e=t.get(r.remoteCandidateId);r.remote={...e}}if(r.localCandidateId){const e=t.get(r.localCandidateId);r.local={...e}}return r}}class cr extends Gt{#g=new Map;#v;#y;constructor(e={}){super(),this.#v=e.timeoutMs??15e3,this.#y=e.steps??3}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e];if(r.length<this.#y)return t;const n=r.slice(-this.#y),i=n.map((e=>e.video.inbound)),s=n.map((e=>e.audio.inbound));return t.push(...this.detectMissingData(s,Pt.Stream,Tt.MissingAudioStreamData)),t.push(...this.detectMissingData(i,Pt.Stream,Tt.MissingVideoStreamData)),new Set(this.#g.keys()).forEach((e=>{const t=this.#g.get(e);t&&Date.now()-t>this.#v&&this.removeMarkedIssue(e)})),t}detectMissingData(e,t,r){const n=[],i=e.pop(),s=cr.mapStatsByTrackId(e);return i.forEach((e=>{const i=e.track.trackIdentifier,o=s.get(i);if(!Array.isArray(o)||0===o.length)return;if(e.track.detached||e.track.ended)return;if(!cr.isAllBytesReceivedDidntChange(e.bytesReceived,o))return void this.removeMarkedIssue(i);if(!this.markIssue(i))return;const a={bytesReceived:e.bytesReceived};n.push({type:t,reason:r,statsSample:a,trackIdentifier:i})})),n}static mapStatsByTrackId(e){const t=new Map;return e.forEach((e=>{e.forEach((e=>{const r=t.get(e.track.trackIdentifier)||[];r.push(e),t.set(e.track.trackIdentifier,r)}))})),t}static isAllBytesReceivedDidntChange(e,t){for(let r=0;r<t.length;r+=1)if(t[r].bytesReceived!==e)return!1;return!0}markIssue(e){const t=Date.now(),r=this.#g.get(e);return(!r||t-r>this.#v)&&(this.#g.set(e,t),!0)}removeMarkedIssue(e){this.#g.delete(e)}}class dr{eventEmitter;#_=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Wt,e.onIssues&&this.eventEmitter.on(Ct.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(Ct.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Qt,new $t,new Kt,new Jt,new Yt,new Zt,new rr,new nr,new cr],this.networkScoresCalculator=e.networkScoresCalculator??new zt,this.compositeStatsParser=e.compositeStatsParser??new or({statsParser:new ar({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new Ht({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(Ht.STATS_REPORT_READY_EVENT,(e=>{const t=this.calculateNetworkScores(e.stats);this.detectIssues({data:e.stats},t)})),this.statsReporter.on(Ht.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(Ct.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#_?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#_=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#_?(this.logger.info("Stop watching peer connections"),this.#_=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#_||!this.autoAddPeerConnections?(this.#_||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#_=!0,this.statsReporter.startReporting()),this.logger.debug("Handling new peer connection",e),this.compositeStatsParser.addPeerConnection({pc:e,id:t})):this.logger.debug("Skip handling new peer connection. Detector is not running",e)}emitIssues(e){this.eventEmitter.emit(Ct.Issue,e)}detectIssues({data:e},t){const r=this.detectors.reduce(((r,n)=>[...r,...n.detect(e,t)]),[]);r.length>0&&this.emitIssues(r)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);return this.eventEmitter.emit(Ct.NetworkScoresUpdated,t),t}wrapRTCPeerConnection(){if(!window.RTCPeerConnection)return void this.logger.warn("No RTCPeerConnection found in browser window. Skipping");const e=window.RTCPeerConnection,t=e=>this.handleNewPeerConnection(e);function r(r){const n=new e(r);return t(n),n}r.prototype=e.prototype,window.RTCPeerConnection=r}}Error;const ur=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],lr=({from:e,seen:t,to_:r,forceEnumerable:n})=>{const i=r||(Array.isArray(e)?[]:{});t.push(e);for(const[r,s]of Object.entries(e))"function"!=typeof s&&(s&&"object"==typeof s?t.includes(e[r])?i[r]="[Circular]":i[r]=lr({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of ur)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var pr,hr,fr,mr=e=>"object"==typeof e&&null!==e?lr({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;pr=new WeakMap,hr=new WeakMap,fr=new WeakMap;var gr=new class{constructor(){pr.set(this,void 0),hr.set(this,void 0),fr.set(this,void 0)}get meta(){return{peerId:l(this,pr,"f"),channelId:l(this,hr,"f"),appId:l(this,fr,"f")}}setPeerId(e){p(this,pr,e,"f")}setChannelId(e){p(this,hr,e,"f")}setAppId(e){p(this,fr,e,"f")}clear(){p(this,pr,void 0,"f"),p(this,hr,void 0,"f"),p(this,fr,void 0,"f")}};const vr="channel.join",yr="channel.getPeers",_r="channel.triggerStateEvent",br="peer.updateAppData",Er="channel.confirmActivity",wr="channel.getAudioObserverProducer",Sr="peer.changeProducePermissions",Cr="peer.addProducePermissions",Pr="peer.removeProducePermissions",Tr="peer.ping",kr="channel-event",Rr="peer-joined",Ir="peer-left",Dr="channel-activity-confirmation-required",Ar="channel-activity-confirmation-acquired",Or="channel-activity-confirmation-expired",Nr="channel-rejoin-required",Mr="devices-list-updated",Lr="transport-connection-timeout",xr="track-force-closed",Fr="track-failed",jr="active-speaker-changed",Ur="channel-state-inconsistent",Br="connection-lost",Vr="connection-restored",Wr="forced-disconnect",Hr="reject-unauthorized",qr="denoiser-initializing",zr="channel-state-synced",Gr="denoiser-enabled",Yr="denoiser-disabled",$r="denoiser-fallback",Jr="denoiser-failed",Kr="volume-changed",Qr={trackProduced:"track-produced",trackUnproduced:"track-unproduced",trackPaused:"track-paused",trackResumed:"track-resumed",trackClosed:"track-closed",trackReopened:"track-reopened",trackFailed:"track-failed"},Zr="media-published",Xr="media-unpublished",en="publisher-paused",tn="publisher-resumed",rn="track-start",nn="track-end",sn="track-paused",on="track-resumed",an="track-failed",cn="app-data-updated",dn="produce-permissions-changed",un="groups-changed",ln="peer.newProducer",pn="producer.close",hn="producer.pause",fn="producer.resume",mn="producer.setMaxSpatialLayer",gn="producer.requestMaxSpatialLayer",vn="consumer.create",yn="dataConsumer.create",_n="consumer.close",bn="consumer.pause",En="consumer.resume",wn="consumer.changeConsumerPreferredLayers",Sn="consumer.requestKeyFrame",Cn="transport.create",Pn="transport.connect",Tn="transport.produce",kn="transport.produceData",Rn="transport.connectionTimeout",In="transport.getIceParameters",Dn=[Cn,Pn,Tn,kn,In,pn,hn,fn,bn,En,vn,_n,Tr],An="socket-state",On="transport-state";class Nn extends Error{constructor(e,t,r){super(e),this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class Mn extends Nn{constructor(e,t){super(e,null!=t?t:"unsupported_error")}}Mn.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",Mn.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error";const Ln=e=>{let t;try{t=JSON.stringify(e)}catch(e){throw new Error("Invalid appData")}if(!((new TextEncoder).encode(t).length<=2048))throw new Error("Maximum size appData reached")};function xn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Fn(e,t){const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;let i=!0;return r.forEach((r=>{const n=e[r],s=t[r],o=xn(n)&&xn(s);(o&&!Fn(n,s)||!o&&n!==s)&&(i=!1)})),i}function jn(e,t,r=!1){let n=null;return function(...i){return u(this,void 0,void 0,(function*(){const s=r&&!n;"number"==typeof n&&clearTimeout(n),n=setTimeout((()=>u(this,void 0,void 0,(function*(){n=null,r||(yield e.apply(this,i))}))),t),s&&(yield e.apply(this,i))}))}}var Un={exports:{}},Bn=m(Un.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),o=Math.max(i,s),a=0,c=e.map([t,r],(function(t){var r=o-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(a=o-Math.min(i,s)),o-=1;o>=a;){if(c[0][o]>c[1][o])return 1;if(c[0][o]===c[1][o]){if(o===a)return 0;o-=1}else if(c[0][o]<c[1][o])return-1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var a=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t]}))};for(t=0,r=s.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function o(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,n.key,n)}}var a=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&o(t.prototype,r),n&&o(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=c(r(92)),i=c(r(93)),s=c(r(94)),o=c(r(95)),a=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var o=e[t];"string"==typeof o?(i[t]=o,s+=1):"object"==typeof o&&(r[t]=o,n+=1)})),n>0){var o=Object.keys(r),c=a.default.find(o,(function(e){return t.isOS(e)}));if(c){var d=this.satisfies(r[c]);if(void 0!==d)return d}var u=a.default.find(o,(function(e){return t.isPlatform(e)}));if(u){var l=this.satisfies(r[u]);if(void 0!==l)return l}}if(s>0){var p=Object.keys(i),h=a.default.find(p,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:s.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=o,e.exports=t.default}}));const Vn=e=>{var t,r;return null!==(r=null===(t=e.rtpCapabilities.codecs)||void 0===t?void 0:t.reduce(((e,t)=>{var r;const n=null===(r=t.mimeType)||void 0===r?void 0:r.toLowerCase();return n&&!e.includes(n)&&e.push(n),e}),[]))&&void 0!==r?r:[]},Wn=e=>["video/vp9","vp9"].includes(e.toLowerCase());class Hn{sleepMs(e){return u(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}}const qn=new Hn,zn=(e,...t)=>u(void 0,[e,...t],void 0,(function*(e,t={}){var r,n,i,s;const o=null!==(r=t.maxRetries)&&void 0!==r?r:2,a=null!==(n=t.minBackoffDelayMs)&&void 0!==n?n:50;let c,d=0;for(;d<o;){d+=1;try{return yield e()}catch(e){if(c=e,t.logger&&t.logger.info("Action retry failed",{currentAttempt:d,actionName:t.actionName,error:mr(e)}),null===(i=t.abortOnError)||void 0===i?void 0:i.call(t,e))throw c;if(t.onError&&(yield t.onError(e)),d<o){const e=Math.pow(2,d-1)*a;yield qn.sleepMs(Math.min(e,null!==(s=t.maxBackoffDelayMs)&&void 0!==s?s:e))}}}throw null!=c?c:new Error("retryAsync logic failed")}));var Gn,Yn,$n,Jn,Kn;!function(e){e.Config="Config",e.Engine="Engine",e.System="System",e.Media="Media",e.Network="Network",e.MediaEventHandler="MediaEventHandler",e.ChannelEventHandler="ChannelEventHandler",e.ChannelAudioObserverEventHandler="ChannelAudioObserverEventHandler",e.ChannelStateSynchronizer="ChannelStateSynchronizer",e.ChannelStateSyncEventHandler="ChannelStateSyncEventHandler",e.WebRTCIssueDetector="WebRTCIssueDetector",e.LoggerFactory="LoggerFactory",e.MediaStreamTrackManager="MediaStreamTrackManager",e.SocketIO="SocketIO",e.LoadBalancerApiClient="LoadBalancerApiClient",e.EventsQueue="EventsQueue",e.ClientEventEmitter="ClientEventEmitter",e.Peers="Peers",e.CallState="CallState",e.RemotePeerTracks="RemotePeerTracks",e.MyPeer="MyPeer",e.InternalEventEmitter="InternalEventEmitter",e.PeerTrackFactory="PeerTrackFactory",e.PeerFactory="PeerFactory",e.PeerConsumerFactory="PeerConsumerFactory",e.AudioTrackFactory="AudioTrackFactory",e.VideoTrackFactory="VideoTrackFactory",e.AudioTrackProcessorFactory="AudioTrackProcessorFactory",e.IntegrationsService="IntegrationsService",e.ProcessorsCache="ProcessorsCache",e.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager",e.WIDHandler="WIDHandler",e.AnalyticsApiClient="AnalyticsApiClient",e.TransportsStatsProvider="TransportsStatsProvider",e.LocalMutex="LocalMutex",e.PeersStorage="PeersStorage"}(Gn||(Gn={})),function(e){e.P2P="p2p",e.Common="common"}(Yn||(Yn={})),function(e){e.Camera="camera",e.CameraPreview="camera-preview",e.Microphone="microphone",e.MicrophonePreview="microphone-preview",e.ScreenVideo="screen-video",e.ScreenAudio="screen-audio",e.CustomVideo="custom-video",e.CustomAudio="custom-audio",e.Unknown="unknown"}($n||($n={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Jn||(Jn={})),function(e){e.Connect="connect",e.Connected="connected",e.ConnectError="connect_error",e.Reconnect="reconnect",e.Reconnecting="reconnecting",e.Reconnected="reconnected",e.ReconnectAttempt="reconnect_attempt",e.ReconnectFailed="reconnect_failed",e.ReconnectError="reconnect_error",e.NeedToJoinFirst="need_to_join_first",e.Disconnect="disconnect",e.Disconnected="disconnected",e.Error="error",e.State="state",e.BufferingStart="buffering_start",e.BufferingEnd="buffering_end"}(Kn||(Kn={}));let Qn=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0}};function Zn(){let e=0,t=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(15&r)<<28,t=(112&r)>>4,0==(128&r))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Xn(e,t,r){for(let n=0;n<28;n+=7){const i=e>>>n,s=!(i>>>7==0&&0==t),o=255&(s?128|i:i);if(r.push(o),!s)return}const n=e>>>28&15|(7&t)<<4,i=!(t>>3==0);if(r.push(255&(i?128|n:n)),i){for(let e=3;e<31;e+=7){const n=t>>>e,i=!(n>>>7==0),s=255&(i?128|n:n);if(r.push(s),!i)return}r.push(t>>>31&1)}}Qn=a([ut()],Qn);function ei(e){const t="-"===e[0];t&&(e=e.slice(1));const r=1e6;let n=0,i=0;function s(t,s){const o=Number(e.slice(t,s));i*=r,n=n*r+o,n>=4294967296&&(i+=n/4294967296|0,n%=4294967296)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?ni(n,i):ri(n,i)}function ti(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(4294967296*t+e);const r=16777215&(e>>>24|t<<8),n=t>>16&65535;let i=(16777215&e)+6777216*r+6710656*n,s=r+8147497*n,o=2*n;const a=1e7;return i>=a&&(s+=Math.floor(i/a),i%=a),s>=a&&(o+=Math.floor(s/a),s%=a),o.toString()+ii(s)+ii(i)}function ri(e,t){return{lo:0|e,hi:0|t}}function ni(e,t){return t=~t,e?e=1+~e:t+=1,ri(e,t)}const ii=e=>{const t=String(e);return"0000000".slice(t.length)+t};function si(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let r=0;r<9;r++)t.push(127&e|128),e>>=7;t.push(1)}}function oi(){let e=this.buf[this.pos++],t=127&e;if(0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,0==(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;0!=(128&e)&&t<10;t++)e=this.buf[this.pos++];if(0!=(128&e))throw new Error("invalid varint");return this.assertBounds(),t>>>0}const ai=ci();function ci(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),n=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const n="bigint"==typeof e?e:BigInt(e);if(n>r||n<t)throw new Error(`invalid int64: ${e}`);return n},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>i||t<n)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigInt64(0,!0)),uDec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),di(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),ui(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),di(e),ei(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),ui(e),ei(e)),dec:(e,t)=>function(e,t){let r=ri(e,t);const n=2147483648&r.hi;n&&(r=ni(r.lo,r.hi));const i=ti(r.lo,r.hi);return n?"-"+i:i}(e,t),uDec:(e,t)=>ti(e,t)}}function di(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function ui(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const li=Symbol.for("@bufbuild/protobuf/text-encoding");function pi(){if(null==globalThis[li]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[li]={encodeUtf8:t=>e.encode(t),decodeUtf8:e=>t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[li]}var hi;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(hi||(hi={}));const fi=34028234663852886e22,mi=-34028234663852886e22;class gi{constructor(e=pi().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),r=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],r),r+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(_i(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return yi(e),si(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>fi||e<mi))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){_i(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){yi(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return yi(e),si(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=ai.enc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=ai.uEnc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=ai.enc(e);return Xn(t.lo,t.hi,this.buf),this}sint64(e){const t=ai.enc(e),r=t.hi>>31;return Xn(t.lo<<1^r,(t.hi<<1|t.lo>>>31)^r,this.buf),this}uint64(e){const t=ai.uEnc(e);return Xn(t.lo,t.hi,this.buf),this}}class vi{constructor(e,t=pi().decodeUtf8){this.decodeUtf8=t,this.varint64=Zn,this.uint32=oi,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,r=7&e;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case hi.Varint:for(;128&this.buf[this.pos++];);break;case hi.Bit64:this.pos+=4;case hi.Bit32:this.pos+=4;break;case hi.LengthDelimited:let r=this.uint32();this.pos+=r;break;case hi.StartGroup:for(;;){const[e,r]=this.tag();if(r===hi.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(r,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return ai.dec(...this.varint64())}uint64(){return ai.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(1&e);return e=(e>>>1|(1&t)<<31)^r,t=t>>>1^r,ai.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ai.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ai.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}function yi(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function _i(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const bi={encode:(e,t=new gi)=>(0!==e.time&&t.uint32(8).int64(e.time),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={time:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.time=Ei(r.int64());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({time:wi(e.time)?globalThis.Number(e.time):0}),toJSON(e){const t={};return 0!==e.time&&(t.time=Math.round(e.time)),t},create:e=>bi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={time:0};return r.time=null!==(t=e.time)&&void 0!==t?t:0,r}};function Ei(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function wi(e){return null!=e}var Si;function Ci(e){switch(e){case 0:case"NULL_VALUE":return Si.NULL_VALUE;default:return Si.UNRECOGNIZED}}!function(e){e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Si||(Si={}));const Pi={encode:(e,t=new gi)=>(Object.entries(e.fields).forEach((([e,r])=>{void 0!==r&&Ti.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={fields:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=Ti.decode(r,r.uint32());void 0!==t.value&&(i.fields[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({fields:Ii(e.fields)?Object.entries(e.fields).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}}),toJSON(e){const t={};if(e.fields){const r=Object.entries(e.fields);r.length>0&&(t.fields={},r.forEach((([e,r])=>{t.fields[e]=r})))}return t},create:e=>Pi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={fields:{}};return r.fields=Object.entries(null!==(t=e.fields)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r},wrap(e){const t={fields:{}};if(void 0!==e)for(const r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){const t={};if(e.fields)for(const r of Object.keys(e.fields))t[r]=e.fields[r];return t}};const Ti={encode:(e,t=new gi)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ki.encode(ki.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ki.unwrap(ki.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:Di(e.key)?globalThis.String(e.key):"",value:Di(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Ti.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};const ki={encode:(e,t=new gi)=>(void 0!==e.nullValue&&t.uint32(8).int32(e.nullValue),void 0!==e.numberValue&&t.uint32(17).double(e.numberValue),void 0!==e.stringValue&&t.uint32(26).string(e.stringValue),void 0!==e.boolValue&&t.uint32(32).bool(e.boolValue),void 0!==e.structValue&&Pi.encode(Pi.wrap(e.structValue),t.uint32(42).fork()).join(),void 0!==e.listValue&&Ri.encode(Ri.wrap(e.listValue),t.uint32(50).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.nullValue=r.int32();continue;case 2:if(17!==e)break;i.numberValue=r.double();continue;case 3:if(26!==e)break;i.stringValue=r.string();continue;case 4:if(32!==e)break;i.boolValue=r.bool();continue;case 5:if(42!==e)break;i.structValue=Pi.unwrap(Pi.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.listValue=Ri.unwrap(Ri.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({nullValue:Di(e.nullValue)?Ci(e.nullValue):void 0,numberValue:Di(e.numberValue)?globalThis.Number(e.numberValue):void 0,stringValue:Di(e.stringValue)?globalThis.String(e.stringValue):void 0,boolValue:Di(e.boolValue)?globalThis.Boolean(e.boolValue):void 0,structValue:Ii(e.structValue)?e.structValue:void 0,listValue:globalThis.Array.isArray(e.listValue)?[...e.listValue]:void 0}),toJSON(e){const t={};return void 0!==e.nullValue&&(t.nullValue=function(e){switch(e){case Si.NULL_VALUE:return"NULL_VALUE";case Si.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.nullValue)),void 0!==e.numberValue&&(t.numberValue=e.numberValue),void 0!==e.stringValue&&(t.stringValue=e.stringValue),void 0!==e.boolValue&&(t.boolValue=e.boolValue),void 0!==e.structValue&&(t.structValue=e.structValue),void 0!==e.listValue&&(t.listValue=e.listValue),t},create:e=>ki.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o;const a={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};return a.nullValue=null!==(t=e.nullValue)&&void 0!==t?t:void 0,a.numberValue=null!==(r=e.numberValue)&&void 0!==r?r:void 0,a.stringValue=null!==(n=e.stringValue)&&void 0!==n?n:void 0,a.boolValue=null!==(i=e.boolValue)&&void 0!==i?i:void 0,a.structValue=null!==(s=e.structValue)&&void 0!==s?s:void 0,a.listValue=null!==(o=e.listValue)&&void 0!==o?o:void 0,a},wrap(e){const t={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};if(null===e)t.nullValue=Si.NULL_VALUE;else if("boolean"==typeof e)t.boolValue=e;else if("number"==typeof e)t.numberValue=e;else if("string"==typeof e)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if("object"==typeof e)t.structValue=e;else if(void 0!==e)throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap:e=>void 0!==e.stringValue?e.stringValue:void 0!==(null==e?void 0:e.numberValue)?e.numberValue:void 0!==(null==e?void 0:e.boolValue)?e.boolValue:void 0!==(null==e?void 0:e.structValue)?e.structValue:void 0!==(null==e?void 0:e.listValue)?e.listValue:void 0!==(null==e?void 0:e.nullValue)?null:void 0};const Ri={encode(e,t=new gi){for(const r of e.values)ki.encode(ki.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={values:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.values.push(ki.unwrap(ki.decode(r,r.uint32())));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({values:globalThis.Array.isArray(null==e?void 0:e.values)?[...e.values]:[]}),toJSON(e){var t;const r={};return(null===(t=e.values)||void 0===t?void 0:t.length)&&(r.values=e.values),r},create:e=>Ri.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={values:[]};return r.values=(null===(t=e.values)||void 0===t?void 0:t.map((e=>e)))||[],r},wrap(e){const t={values:[]};return t.values=null!=e?e:[],t},unwrap:e=>(null==e?void 0:e.hasOwnProperty("values"))&&globalThis.Array.isArray(e.values)?e.values:e};function Ii(e){return"object"==typeof e&&null!==e}function Di(e){return null!=e}const Ai={encode:(e,t=new gi)=>(Object.entries(e.event).forEach((([e,r])=>{void 0!==r&&Oi.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={event:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=Oi.decode(r,r.uint32());void 0!==t.value&&(i.event[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({event:Ni(e.event)?Object.entries(e.event).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}}),toJSON(e){const t={};if(e.event){const r=Object.entries(e.event);r.length>0&&(t.event={},r.forEach((([e,r])=>{t.event[e]=r})))}return t},create:e=>Ai.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={event:{}};return r.event=Object.entries(null!==(t=e.event)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r}};const Oi={encode:(e,t=new gi)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ki.encode(ki.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ki.unwrap(ki.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:Mi(e.key)?globalThis.String(e.key):"",value:Mi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Oi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function Ni(e){return"object"==typeof e&&null!==e}function Mi(e){return null!=e}var Li,xi;function Fi(e){switch(e){case 0:case"PEER_GROUP_UNSPECIFIED":return Li.PEER_GROUP_UNSPECIFIED;case 1:case"PEER_GROUP_MODERATOR":return Li.PEER_GROUP_MODERATOR;case 2:case"PEER_GROUP_USER":return Li.PEER_GROUP_USER;default:return Li.UNRECOGNIZED}}function ji(e){switch(e){case Li.PEER_GROUP_UNSPECIFIED:return"PEER_GROUP_UNSPECIFIED";case Li.PEER_GROUP_MODERATOR:return"PEER_GROUP_MODERATOR";case Li.PEER_GROUP_USER:return"PEER_GROUP_USER";case Li.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function Ui(e){switch(e){case 0:case"PRODUCER_LABEL_UNSPECIFIED":return xi.PRODUCER_LABEL_UNSPECIFIED;case 1:case"PRODUCER_LABEL_CAMERA":return xi.PRODUCER_LABEL_CAMERA;case 2:case"PRODUCER_LABEL_MICROPHONE":return xi.PRODUCER_LABEL_MICROPHONE;case 3:case"PRODUCER_LABEL_SCREEN_VIDEO":return xi.PRODUCER_LABEL_SCREEN_VIDEO;case 4:case"PRODUCER_LABEL_SCREEN_AUDIO":return xi.PRODUCER_LABEL_SCREEN_AUDIO;case 5:case"PRODUCER_LABEL_CUSTOM_VIDEO":return xi.PRODUCER_LABEL_CUSTOM_VIDEO;case 6:case"PRODUCER_LABEL_CUSTOM_AUDIO":return xi.PRODUCER_LABEL_CUSTOM_AUDIO;case 7:case"PRODUCER_LABEL_UNKNOWN":return xi.PRODUCER_LABEL_UNKNOWN;default:return xi.UNRECOGNIZED}}function Bi(e){switch(e){case xi.PRODUCER_LABEL_UNSPECIFIED:return"PRODUCER_LABEL_UNSPECIFIED";case xi.PRODUCER_LABEL_CAMERA:return"PRODUCER_LABEL_CAMERA";case xi.PRODUCER_LABEL_MICROPHONE:return"PRODUCER_LABEL_MICROPHONE";case xi.PRODUCER_LABEL_SCREEN_VIDEO:return"PRODUCER_LABEL_SCREEN_VIDEO";case xi.PRODUCER_LABEL_SCREEN_AUDIO:return"PRODUCER_LABEL_SCREEN_AUDIO";case xi.PRODUCER_LABEL_CUSTOM_VIDEO:return"PRODUCER_LABEL_CUSTOM_VIDEO";case xi.PRODUCER_LABEL_CUSTOM_AUDIO:return"PRODUCER_LABEL_CUSTOM_AUDIO";case xi.PRODUCER_LABEL_UNKNOWN:return"PRODUCER_LABEL_UNKNOWN";case xi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.PEER_GROUP_UNSPECIFIED=0]="PEER_GROUP_UNSPECIFIED",e[e.PEER_GROUP_MODERATOR=1]="PEER_GROUP_MODERATOR",e[e.PEER_GROUP_USER=2]="PEER_GROUP_USER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Li||(Li={})),function(e){e[e.PRODUCER_LABEL_UNSPECIFIED=0]="PRODUCER_LABEL_UNSPECIFIED",e[e.PRODUCER_LABEL_CAMERA=1]="PRODUCER_LABEL_CAMERA",e[e.PRODUCER_LABEL_MICROPHONE=2]="PRODUCER_LABEL_MICROPHONE",e[e.PRODUCER_LABEL_SCREEN_VIDEO=3]="PRODUCER_LABEL_SCREEN_VIDEO",e[e.PRODUCER_LABEL_SCREEN_AUDIO=4]="PRODUCER_LABEL_SCREEN_AUDIO",e[e.PRODUCER_LABEL_CUSTOM_VIDEO=5]="PRODUCER_LABEL_CUSTOM_VIDEO",e[e.PRODUCER_LABEL_CUSTOM_AUDIO=6]="PRODUCER_LABEL_CUSTOM_AUDIO",e[e.PRODUCER_LABEL_UNKNOWN=7]="PRODUCER_LABEL_UNKNOWN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(xi||(xi={}));const Vi={encode(e,t=new gi){t.uint32(10).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(18).fork();for(const r of e.producePermissions)t.int32(r);t.join(),t.uint32(26).fork();for(const r of e.changedProducePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={groups:[],producePermissions:[],changedProducePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8===e){i.groups.push(r.int32());continue}if(10===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 2:if(16===e){i.producePermissions.push(r.int32());continue}if(18===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}break;case 3:if(24===e){i.changedProducePermissions.push(r.int32());continue}if(26===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.changedProducePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>Fi(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ui(e))):[],changedProducePermissions:globalThis.Array.isArray(null==e?void 0:e.changedProducePermissions)?e.changedProducePermissions.map((e=>Ui(e))):[]}),toJSON(e){var t,r,n;const i={};return(null===(t=e.groups)||void 0===t?void 0:t.length)&&(i.groups=e.groups.map((e=>ji(e)))),(null===(r=e.producePermissions)||void 0===r?void 0:r.length)&&(i.producePermissions=e.producePermissions.map((e=>Bi(e)))),(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.length)&&(i.changedProducePermissions=e.changedProducePermissions.map((e=>Bi(e)))),i},create:e=>Vi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={groups:[],producePermissions:[],changedProducePermissions:[]};return i.groups=(null===(t=e.groups)||void 0===t?void 0:t.map((e=>e)))||[],i.producePermissions=(null===(r=e.producePermissions)||void 0===r?void 0:r.map((e=>e)))||[],i.changedProducePermissions=(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.map((e=>e)))||[],i}};const Wi={encode:(e,t=new gi)=>(0!==e.seconds&&t.uint32(8).int64(e.seconds),0!==e.nanos&&t.uint32(16).int32(e.nanos),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={seconds:0,nanos:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.seconds=Hi(r.int64());continue;case 2:if(16!==e)break;i.nanos=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({seconds:qi(e.seconds)?globalThis.Number(e.seconds):0,nanos:qi(e.nanos)?globalThis.Number(e.nanos):0}),toJSON(e){const t={};return 0!==e.seconds&&(t.seconds=Math.round(e.seconds)),0!==e.nanos&&(t.nanos=Math.round(e.nanos)),t},create:e=>Wi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={seconds:0,nanos:0};return n.seconds=null!==(t=e.seconds)&&void 0!==t?t:0,n.nanos=null!==(r=e.nanos)&&void 0!==r?r:0,n}};function Hi(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function qi(e){return null!=e}var zi;function Gi(e){switch(e){case 0:case"PRODUCER_KIND_UNSPECIFIED":return zi.PRODUCER_KIND_UNSPECIFIED;case 1:case"PRODUCER_KIND_AUDIO":return zi.PRODUCER_KIND_AUDIO;case 2:case"PRODUCER_KIND_VIDEO":return zi.PRODUCER_KIND_VIDEO;default:return zi.UNRECOGNIZED}}!function(e){e[e.PRODUCER_KIND_UNSPECIFIED=0]="PRODUCER_KIND_UNSPECIFIED",e[e.PRODUCER_KIND_AUDIO=1]="PRODUCER_KIND_AUDIO",e[e.PRODUCER_KIND_VIDEO=2]="PRODUCER_KIND_VIDEO",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(zi||(zi={}));const Yi={encode(e,t=new gi){""!==e.id&&t.uint32(10).string(e.id),0!==e.kind&&t.uint32(16).int32(e.kind),0!==e.label&&t.uint32(24).int32(e.label),""!==e.peerId&&t.uint32(34).string(e.peerId),!1!==e.paused&&t.uint32(40).bool(e.paused);for(const r of e.encodings)ki.encode(ki.wrap(r),t.uint32(50).fork()).join();return void 0!==e.maxSpatialLayer&&t.uint32(56).uint32(e.maxSpatialLayer),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.kind=r.int32();continue;case 3:if(24!==e)break;i.label=r.int32();continue;case 4:if(34!==e)break;i.peerId=r.string();continue;case 5:if(40!==e)break;i.paused=r.bool();continue;case 6:if(50!==e)break;i.encodings.push(ki.unwrap(ki.decode(r,r.uint32())));continue;case 7:if(56!==e)break;i.maxSpatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:$i(e.id)?globalThis.String(e.id):"",kind:$i(e.kind)?Gi(e.kind):0,label:$i(e.label)?Ui(e.label):0,peerId:$i(e.peerId)?globalThis.String(e.peerId):"",paused:!!$i(e.paused)&&globalThis.Boolean(e.paused),encodings:globalThis.Array.isArray(null==e?void 0:e.encodings)?[...e.encodings]:[],maxSpatialLayer:$i(e.maxSpatialLayer)?globalThis.Number(e.maxSpatialLayer):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),0!==e.kind&&(r.kind=function(e){switch(e){case zi.PRODUCER_KIND_UNSPECIFIED:return"PRODUCER_KIND_UNSPECIFIED";case zi.PRODUCER_KIND_AUDIO:return"PRODUCER_KIND_AUDIO";case zi.PRODUCER_KIND_VIDEO:return"PRODUCER_KIND_VIDEO";case zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.kind)),0!==e.label&&(r.label=Bi(e.label)),""!==e.peerId&&(r.peerId=e.peerId),!1!==e.paused&&(r.paused=e.paused),(null===(t=e.encodings)||void 0===t?void 0:t.length)&&(r.encodings=e.encodings),void 0!==e.maxSpatialLayer&&(r.maxSpatialLayer=Math.round(e.maxSpatialLayer)),r},create:e=>Yi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a;const c={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};return c.id=null!==(t=e.id)&&void 0!==t?t:"",c.kind=null!==(r=e.kind)&&void 0!==r?r:0,c.label=null!==(n=e.label)&&void 0!==n?n:0,c.peerId=null!==(i=e.peerId)&&void 0!==i?i:"",c.paused=null!==(s=e.paused)&&void 0!==s&&s,c.encodings=(null===(o=e.encodings)||void 0===o?void 0:o.map((e=>e)))||[],c.maxSpatialLayer=null!==(a=e.maxSpatialLayer)&&void 0!==a?a:void 0,c}};function $i(e){return null!=e}var Ji;function Ki(e){switch(e){case 0:case"PEER_ROLE_UNSPECIFIED":return Ji.PEER_ROLE_UNSPECIFIED;case 1:case"PEER_ROLE_HOST":return Ji.PEER_ROLE_HOST;case 2:case"PEER_ROLE_AUDIENCE":return Ji.PEER_ROLE_AUDIENCE;default:return Ji.UNRECOGNIZED}}!function(e){e[e.PEER_ROLE_UNSPECIFIED=0]="PEER_ROLE_UNSPECIFIED",e[e.PEER_ROLE_HOST=1]="PEER_ROLE_HOST",e[e.PEER_ROLE_AUDIENCE=2]="PEER_ROLE_AUDIENCE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ji||(Ji={}));const Qi={encode(e,t=new gi){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.channelIds)t.uint32(18).string(r);for(const r of e.producers)Yi.encode(r,t.uint32(26).fork()).join();""!==e.uid&&t.uint32(50).string(e.uid),""!==e.appId&&t.uint32(58).string(e.appId),Object.entries(e.appData).forEach((([e,r])=>{void 0!==r&&Zi.encode({key:e,value:r},t.uint32(66).fork()).join()})),0!==e.role&&t.uint32(72).int32(e.role),void 0!==e.loginDate&&Wi.encode(function(e){const t=Math.trunc(e.getTime()/1e3),r=e.getTime()%1e3*1e6;return{seconds:t,nanos:r}}(e.loginDate),t.uint32(82).fork()).join(),t.uint32(90).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(98).fork();for(const r of e.producePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.channelIds.push(r.string());continue;case 3:if(26!==e)break;i.producers.push(Yi.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.uid=r.string();continue;case 7:if(58!==e)break;i.appId=r.string();continue;case 8:{if(66!==e)break;const t=Zi.decode(r,r.uint32());void 0!==t.value&&(i.appData[t.key]=t.value);continue}case 9:if(72!==e)break;i.role=r.int32();continue;case 10:if(82!==e)break;i.loginDate=Xi(Wi.decode(r,r.uint32()));continue;case 11:if(88===e){i.groups.push(r.int32());continue}if(90===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 12:if(96===e){i.producePermissions.push(r.int32());continue}if(98===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:rs(e.id)?globalThis.String(e.id):"",channelIds:globalThis.Array.isArray(null==e?void 0:e.channelIds)?e.channelIds.map((e=>globalThis.String(e))):[],producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>Yi.fromJSON(e))):[],uid:rs(e.uid)?globalThis.String(e.uid):"",appId:rs(e.appId)?globalThis.String(e.appId):"",appData:ts(e.appData)?Object.entries(e.appData).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{},role:rs(e.role)?Ki(e.role):0,loginDate:rs(e.loginDate)?es(e.loginDate):void 0,groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>Fi(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ui(e))):[]}),toJSON(e){var t,r,n,i;const s={};if(""!==e.id&&(s.id=e.id),(null===(t=e.channelIds)||void 0===t?void 0:t.length)&&(s.channelIds=e.channelIds),(null===(r=e.producers)||void 0===r?void 0:r.length)&&(s.producers=e.producers.map((e=>Yi.toJSON(e)))),""!==e.uid&&(s.uid=e.uid),""!==e.appId&&(s.appId=e.appId),e.appData){const t=Object.entries(e.appData);t.length>0&&(s.appData={},t.forEach((([e,t])=>{s.appData[e]=t})))}return 0!==e.role&&(s.role=function(e){switch(e){case Ji.PEER_ROLE_UNSPECIFIED:return"PEER_ROLE_UNSPECIFIED";case Ji.PEER_ROLE_HOST:return"PEER_ROLE_HOST";case Ji.PEER_ROLE_AUDIENCE:return"PEER_ROLE_AUDIENCE";case Ji.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.role)),void 0!==e.loginDate&&(s.loginDate=e.loginDate.toISOString()),(null===(n=e.groups)||void 0===n?void 0:n.length)&&(s.groups=e.groups.map((e=>ji(e)))),(null===(i=e.producePermissions)||void 0===i?void 0:i.length)&&(s.producePermissions=e.producePermissions.map((e=>Bi(e)))),s},create:e=>Qi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a,c,d,u;const l={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};return l.id=null!==(t=e.id)&&void 0!==t?t:"",l.channelIds=(null===(r=e.channelIds)||void 0===r?void 0:r.map((e=>e)))||[],l.producers=(null===(n=e.producers)||void 0===n?void 0:n.map((e=>Yi.fromPartial(e))))||[],l.uid=null!==(i=e.uid)&&void 0!==i?i:"",l.appId=null!==(s=e.appId)&&void 0!==s?s:"",l.appData=Object.entries(null!==(o=e.appData)&&void 0!==o?o:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),l.role=null!==(a=e.role)&&void 0!==a?a:0,l.loginDate=null!==(c=e.loginDate)&&void 0!==c?c:void 0,l.groups=(null===(d=e.groups)||void 0===d?void 0:d.map((e=>e)))||[],l.producePermissions=(null===(u=e.producePermissions)||void 0===u?void 0:u.map((e=>e)))||[],l}};const Zi={encode:(e,t=new gi)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ki.encode(ki.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ki.unwrap(ki.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:rs(e.key)?globalThis.String(e.key):"",value:rs(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Zi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function Xi(e){let t=1e3*(e.seconds||0);return t+=(e.nanos||0)/1e6,new globalThis.Date(t)}function es(e){return e instanceof globalThis.Date?e:"string"==typeof e?new globalThis.Date(e):Xi(Wi.fromJSON(e))}function ts(e){return"object"==typeof e&&null!==e}function rs(e){return null!=e}const ns={encode(e,t=new gi){for(const r of e.peers)Qi.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(Qi.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>Qi.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>Qi.toJSON(e)))),r},create:e=>ns.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>Qi.fromPartial(e))))||[],r}};const is={encode:(e,t=new gi)=>(""!==e.id&&t.uint32(10).string(e.id),!1!==e.paused&&t.uint32(16).bool(e.paused),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",paused:!1};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.paused=r.bool();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:as(e.id)?globalThis.String(e.id):"",paused:!!as(e.paused)&&globalThis.Boolean(e.paused)}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),!1!==e.paused&&(t.paused=e.paused),t},create:e=>is.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={id:"",paused:!1};return n.id=null!==(t=e.id)&&void 0!==t?t:"",n.paused=null!==(r=e.paused)&&void 0!==r&&r,n}};const ss={encode(e,t=new gi){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.producers)is.encode(r,t.uint32(18).fork()).join();return void 0!==e.appDataHash&&t.uint32(26).string(e.appDataHash),t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",producers:[],appDataHash:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.producers.push(is.decode(r,r.uint32()));continue;case 3:if(26!==e)break;i.appDataHash=r.string();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:as(e.id)?globalThis.String(e.id):"",producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>is.fromJSON(e))):[],appDataHash:as(e.appDataHash)?globalThis.String(e.appDataHash):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),(null===(t=e.producers)||void 0===t?void 0:t.length)&&(r.producers=e.producers.map((e=>is.toJSON(e)))),void 0!==e.appDataHash&&(r.appDataHash=e.appDataHash),r},create:e=>ss.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={id:"",producers:[],appDataHash:void 0};return i.id=null!==(t=e.id)&&void 0!==t?t:"",i.producers=(null===(r=e.producers)||void 0===r?void 0:r.map((e=>is.fromPartial(e))))||[],i.appDataHash=null!==(n=e.appDataHash)&&void 0!==n?n:void 0,i}};const os={encode(e,t=new gi){for(const r of e.peers)ss.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(ss.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>ss.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>ss.toJSON(e)))),r},create:e=>os.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>ss.fromPartial(e))))||[],r}};function as(e){return null!=e}var cs;function ds(e){switch(e){case 0:case"CHANNEL_EVENT_TYPE_UNSPECIFIED":return cs.CHANNEL_EVENT_TYPE_UNSPECIFIED;case 1:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE":return cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE;case 2:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT":return cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT;case 3:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED;case 4:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED;case 5:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED;case 6:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED;case 7:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED":return cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED;case 8:case"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT":return cs.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT;case 14:case"CHANNEL_EVENT_TYPE_PEER_JOINED":return cs.CHANNEL_EVENT_TYPE_PEER_JOINED;case 15:case"CHANNEL_EVENT_TYPE_PEER_LEFT":return cs.CHANNEL_EVENT_TYPE_PEER_LEFT;case 16:case"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED":return cs.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED;case 17:case"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED":return cs.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED;case 18:case"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED":return cs.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED;default:return cs.UNRECOGNIZED}}function us(e){switch(e){case cs.CHANNEL_EVENT_TYPE_UNSPECIFIED:return"CHANNEL_EVENT_TYPE_UNSPECIFIED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE";case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT";case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED";case cs.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:return"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT";case cs.CHANNEL_EVENT_TYPE_PEER_JOINED:return"CHANNEL_EVENT_TYPE_PEER_JOINED";case cs.CHANNEL_EVENT_TYPE_PEER_LEFT:return"CHANNEL_EVENT_TYPE_PEER_LEFT";case cs.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED";case cs.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED";case cs.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED";case cs.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.CHANNEL_EVENT_TYPE_UNSPECIFIED=0]="CHANNEL_EVENT_TYPE_UNSPECIFIED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE=1]="CHANNEL_EVENT_TYPE_CHANNEL_STATE",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT=2]="CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED=3]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED=4]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED=5]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED=6]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED=7]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT=8]="CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT",e[e.CHANNEL_EVENT_TYPE_PEER_JOINED=14]="CHANNEL_EVENT_TYPE_PEER_JOINED",e[e.CHANNEL_EVENT_TYPE_PEER_LEFT=15]="CHANNEL_EVENT_TYPE_PEER_LEFT",e[e.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED=16]="CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED=17]="CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED=18]="CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(cs||(cs={}));const ls={encode:(e,t=new gi)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.channelState&&ns.encode(e.channelState,t.uint32(18).fork()).join(),void 0!==e.channelStateShort&&os.encode(e.channelStateShort,t.uint32(26).fork()).join(),void 0!==e.channelActivityConfirmationTime&&bi.encode(e.channelActivityConfirmationTime,t.uint32(34).fork()).join(),void 0!==e.channelManagementEvent&&Ai.encode(e.channelManagementEvent,t.uint32(42).fork()).join(),void 0!==e.channelProducePermissions&&Vi.encode(e.channelProducePermissions,t.uint32(50).fork()).join(),void 0!==e.peer&&Qi.encode(e.peer,t.uint32(58).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.channelState=ns.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.channelStateShort=os.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.channelActivityConfirmationTime=bi.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.channelManagementEvent=Ai.decode(r,r.uint32());continue;case 6:if(50!==e)break;i.channelProducePermissions=Vi.decode(r,r.uint32());continue;case 7:if(58!==e)break;i.peer=Qi.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:ps(e.eventType)?ds(e.eventType):0,channelState:ps(e.channelState)?ns.fromJSON(e.channelState):void 0,channelStateShort:ps(e.channelStateShort)?os.fromJSON(e.channelStateShort):void 0,channelActivityConfirmationTime:ps(e.channelActivityConfirmationTime)?bi.fromJSON(e.channelActivityConfirmationTime):void 0,channelManagementEvent:ps(e.channelManagementEvent)?Ai.fromJSON(e.channelManagementEvent):void 0,channelProducePermissions:ps(e.channelProducePermissions)?Vi.fromJSON(e.channelProducePermissions):void 0,peer:ps(e.peer)?Qi.fromJSON(e.peer):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=us(e.eventType)),void 0!==e.channelState&&(t.channelState=ns.toJSON(e.channelState)),void 0!==e.channelStateShort&&(t.channelStateShort=os.toJSON(e.channelStateShort)),void 0!==e.channelActivityConfirmationTime&&(t.channelActivityConfirmationTime=bi.toJSON(e.channelActivityConfirmationTime)),void 0!==e.channelManagementEvent&&(t.channelManagementEvent=Ai.toJSON(e.channelManagementEvent)),void 0!==e.channelProducePermissions&&(t.channelProducePermissions=Vi.toJSON(e.channelProducePermissions)),void 0!==e.peer&&(t.peer=Qi.toJSON(e.peer)),t},create:e=>ls.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.channelState=void 0!==e.channelState&&null!==e.channelState?ns.fromPartial(e.channelState):void 0,r.channelStateShort=void 0!==e.channelStateShort&&null!==e.channelStateShort?os.fromPartial(e.channelStateShort):void 0,r.channelActivityConfirmationTime=void 0!==e.channelActivityConfirmationTime&&null!==e.channelActivityConfirmationTime?bi.fromPartial(e.channelActivityConfirmationTime):void 0,r.channelManagementEvent=void 0!==e.channelManagementEvent&&null!==e.channelManagementEvent?Ai.fromPartial(e.channelManagementEvent):void 0,r.channelProducePermissions=void 0!==e.channelProducePermissions&&null!==e.channelProducePermissions?Vi.fromPartial(e.channelProducePermissions):void 0,r.peer=void 0!==e.peer&&null!==e.peer?Qi.fromPartial(e.peer):void 0,r}};function ps(e){return null!=e}const hs={encode:(e,t=new gi)=>(""!==e.id&&t.uint32(10).string(e.id),""!==e.peerId&&t.uint32(18).string(e.peerId),""!==e.producerPeerId&&t.uint32(26).string(e.producerPeerId),void 0!==e.spatialLayer&&t.uint32(32).uint32(e.spatialLayer),void 0!==e.temporalLayer&&t.uint32(40).uint32(e.temporalLayer),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.peerId=r.string();continue;case 3:if(26!==e)break;i.producerPeerId=r.string();continue;case 4:if(32!==e)break;i.spatialLayer=r.uint32();continue;case 5:if(40!==e)break;i.temporalLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:fs(e.id)?globalThis.String(e.id):"",peerId:fs(e.peerId)?globalThis.String(e.peerId):"",producerPeerId:fs(e.producerPeerId)?globalThis.String(e.producerPeerId):"",spatialLayer:fs(e.spatialLayer)?globalThis.Number(e.spatialLayer):void 0,temporalLayer:fs(e.temporalLayer)?globalThis.Number(e.temporalLayer):void 0}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),""!==e.peerId&&(t.peerId=e.peerId),""!==e.producerPeerId&&(t.producerPeerId=e.producerPeerId),void 0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),void 0!==e.temporalLayer&&(t.temporalLayer=Math.round(e.temporalLayer)),t},create:e=>hs.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s;const o={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};return o.id=null!==(t=e.id)&&void 0!==t?t:"",o.peerId=null!==(r=e.peerId)&&void 0!==r?r:"",o.producerPeerId=null!==(n=e.producerPeerId)&&void 0!==n?n:"",o.spatialLayer=null!==(i=e.spatialLayer)&&void 0!==i?i:void 0,o.temporalLayer=null!==(s=e.temporalLayer)&&void 0!==s?s:void 0,o}};function fs(e){return null!=e}const ms={encode:(e,t=new gi)=>(""!==e.producerId&&t.uint32(10).string(e.producerId),0!==e.spatialLayer&&t.uint32(16).uint32(e.spatialLayer),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={producerId:"",spatialLayer:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.producerId=r.string();continue;case 2:if(16!==e)break;i.spatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({producerId:gs(e.producerId)?globalThis.String(e.producerId):"",spatialLayer:gs(e.spatialLayer)?globalThis.Number(e.spatialLayer):0}),toJSON(e){const t={};return""!==e.producerId&&(t.producerId=e.producerId),0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),t},create:e=>ms.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={producerId:"",spatialLayer:0};return n.producerId=null!==(t=e.producerId)&&void 0!==t?t:"",n.spatialLayer=null!==(r=e.spatialLayer)&&void 0!==r?r:0,n}};function gs(e){return null!=e}var vs,ys;function _s(e){switch(e){case 0:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED":return vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED;case 1:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS":return vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS;case 2:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE":return vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE;default:return vs.UNRECOGNIZED}}function bs(e){switch(e){case 0:case"TRANSPORT_DIRECTION_UNSPECIFIED":return ys.TRANSPORT_DIRECTION_UNSPECIFIED;case 1:case"TRANSPORT_DIRECTION_SEND":return ys.TRANSPORT_DIRECTION_SEND;case 2:case"TRANSPORT_DIRECTION_RECEIVE":return ys.TRANSPORT_DIRECTION_RECEIVE;default:return ys.UNRECOGNIZED}}!function(e){e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED=0]="TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS=1]="TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE=2]="TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(vs||(vs={})),function(e){e[e.TRANSPORT_DIRECTION_UNSPECIFIED=0]="TRANSPORT_DIRECTION_UNSPECIFIED",e[e.TRANSPORT_DIRECTION_SEND=1]="TRANSPORT_DIRECTION_SEND",e[e.TRANSPORT_DIRECTION_RECEIVE=2]="TRANSPORT_DIRECTION_RECEIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(ys||(ys={}));const Es={encode:(e,t=new gi)=>(""!==e.transportId&&t.uint32(10).string(e.transportId),0!==e.timeout&&t.uint32(16).uint32(e.timeout),0!==e.direction&&t.uint32(24).int32(e.direction),0!==e.reason&&t.uint32(32).int32(e.reason),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={transportId:"",timeout:0,direction:0,reason:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.transportId=r.string();continue;case 2:if(16!==e)break;i.timeout=r.uint32();continue;case 3:if(24!==e)break;i.direction=r.int32();continue;case 4:if(32!==e)break;i.reason=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({transportId:ws(e.transportId)?globalThis.String(e.transportId):"",timeout:ws(e.timeout)?globalThis.Number(e.timeout):0,direction:ws(e.direction)?bs(e.direction):0,reason:ws(e.reason)?_s(e.reason):0}),toJSON(e){const t={};return""!==e.transportId&&(t.transportId=e.transportId),0!==e.timeout&&(t.timeout=Math.round(e.timeout)),0!==e.direction&&(t.direction=function(e){switch(e){case ys.TRANSPORT_DIRECTION_UNSPECIFIED:return"TRANSPORT_DIRECTION_UNSPECIFIED";case ys.TRANSPORT_DIRECTION_SEND:return"TRANSPORT_DIRECTION_SEND";case ys.TRANSPORT_DIRECTION_RECEIVE:return"TRANSPORT_DIRECTION_RECEIVE";case ys.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.direction)),0!==e.reason&&(t.reason=function(e){switch(e){case vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED";case vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS";case vs.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE";case vs.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.reason)),t},create:e=>Es.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i;const s={transportId:"",timeout:0,direction:0,reason:0};return s.transportId=null!==(t=e.transportId)&&void 0!==t?t:"",s.timeout=null!==(r=e.timeout)&&void 0!==r?r:0,s.direction=null!==(n=e.direction)&&void 0!==n?n:0,s.reason=null!==(i=e.reason)&&void 0!==i?i:0,s}};function ws(e){return null!=e}var Ss;function Cs(e){switch(e){case 0:case"MEDIA_EVENT_TYPE_UNSPECIFIED":return Ss.MEDIA_EVENT_TYPE_UNSPECIFIED;case 1:case"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT":return Ss.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT;case 2:case"MEDIA_EVENT_TYPE_PRODUCER_CREATED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_CREATED;case 3:case"MEDIA_EVENT_TYPE_PRODUCER_PAUSED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_PAUSED;case 4:case"MEDIA_EVENT_TYPE_PRODUCER_RESUMED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_RESUMED;case 5:case"MEDIA_EVENT_TYPE_PRODUCER_CLOSED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_CLOSED;case 6:case"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED;case 7:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED;case 8:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED":return Ss.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED;case 9:case"MEDIA_EVENT_TYPE_CONSUMER_CLOSED":return Ss.MEDIA_EVENT_TYPE_CONSUMER_CLOSED;case 10:case"MEDIA_EVENT_TYPE_CONSUMER_PAUSED":return Ss.MEDIA_EVENT_TYPE_CONSUMER_PAUSED;case 11:case"MEDIA_EVENT_TYPE_CONSUMER_RESUMED":return Ss.MEDIA_EVENT_TYPE_CONSUMER_RESUMED;case 12:case"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED":return Ss.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED;default:return Ss.UNRECOGNIZED}}function Ps(e){switch(e){case Ss.MEDIA_EVENT_TYPE_UNSPECIFIED:return"MEDIA_EVENT_TYPE_UNSPECIFIED";case Ss.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:return"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT";case Ss.MEDIA_EVENT_TYPE_PRODUCER_CREATED:return"MEDIA_EVENT_TYPE_PRODUCER_CREATED";case Ss.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:return"MEDIA_EVENT_TYPE_PRODUCER_PAUSED";case Ss.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:return"MEDIA_EVENT_TYPE_PRODUCER_RESUMED";case Ss.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_CLOSED";case Ss.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED";case Ss.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED";case Ss.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED";case Ss.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:return"MEDIA_EVENT_TYPE_CONSUMER_CLOSED";case Ss.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:return"MEDIA_EVENT_TYPE_CONSUMER_PAUSED";case Ss.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:return"MEDIA_EVENT_TYPE_CONSUMER_RESUMED";case Ss.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:return"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED";case Ss.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.MEDIA_EVENT_TYPE_UNSPECIFIED=0]="MEDIA_EVENT_TYPE_UNSPECIFIED",e[e.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT=1]="MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT",e[e.MEDIA_EVENT_TYPE_PRODUCER_CREATED=2]="MEDIA_EVENT_TYPE_PRODUCER_CREATED",e[e.MEDIA_EVENT_TYPE_PRODUCER_PAUSED=3]="MEDIA_EVENT_TYPE_PRODUCER_PAUSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_RESUMED=4]="MEDIA_EVENT_TYPE_PRODUCER_RESUMED",e[e.MEDIA_EVENT_TYPE_PRODUCER_CLOSED=5]="MEDIA_EVENT_TYPE_PRODUCER_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED=6]="MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED=7]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED=8]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED",e[e.MEDIA_EVENT_TYPE_CONSUMER_CLOSED=9]="MEDIA_EVENT_TYPE_CONSUMER_CLOSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PAUSED=10]="MEDIA_EVENT_TYPE_CONSUMER_PAUSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_RESUMED=11]="MEDIA_EVENT_TYPE_CONSUMER_RESUMED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED=12]="MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ss||(Ss={}));const Ts={encode:(e,t=new gi)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.producer&&Yi.encode(e.producer,t.uint32(18).fork()).join(),void 0!==e.consumer&&hs.encode(e.consumer,t.uint32(26).fork()).join(),void 0!==e.producerSpatialLayerRequest&&ms.encode(e.producerSpatialLayerRequest,t.uint32(34).fork()).join(),void 0!==e.transportConnectionTimeout&&Es.encode(e.transportConnectionTimeout,t.uint32(42).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.producer=Yi.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.consumer=hs.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.producerSpatialLayerRequest=ms.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.transportConnectionTimeout=Es.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:ks(e.eventType)?Cs(e.eventType):0,producer:ks(e.producer)?Yi.fromJSON(e.producer):void 0,consumer:ks(e.consumer)?hs.fromJSON(e.consumer):void 0,producerSpatialLayerRequest:ks(e.producerSpatialLayerRequest)?ms.fromJSON(e.producerSpatialLayerRequest):void 0,transportConnectionTimeout:ks(e.transportConnectionTimeout)?Es.fromJSON(e.transportConnectionTimeout):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=Ps(e.eventType)),void 0!==e.producer&&(t.producer=Yi.toJSON(e.producer)),void 0!==e.consumer&&(t.consumer=hs.toJSON(e.consumer)),void 0!==e.producerSpatialLayerRequest&&(t.producerSpatialLayerRequest=ms.toJSON(e.producerSpatialLayerRequest)),void 0!==e.transportConnectionTimeout&&(t.transportConnectionTimeout=Es.toJSON(e.transportConnectionTimeout)),t},create:e=>Ts.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.producer=void 0!==e.producer&&null!==e.producer?Yi.fromPartial(e.producer):void 0,r.consumer=void 0!==e.consumer&&null!==e.consumer?hs.fromPartial(e.consumer):void 0,r.producerSpatialLayerRequest=void 0!==e.producerSpatialLayerRequest&&null!==e.producerSpatialLayerRequest?ms.fromPartial(e.producerSpatialLayerRequest):void 0,r.transportConnectionTimeout=void 0!==e.transportConnectionTimeout&&null!==e.transportConnectionTimeout?Es.fromPartial(e.transportConnectionTimeout):void 0,r}};function ks(e){return null!=e}const Rs={encode:(e,t=new gi)=>(0!==e.id&&t.uint32(8).int32(e.id),void 0!==e.channelEvent&&ls.encode(e.channelEvent,t.uint32(18).fork()).join(),void 0!==e.mediaEvent&&Ts.encode(e.mediaEvent,t.uint32(26).fork()).join(),t),decode(e,t){const r=e instanceof vi?e:new vi(e),n=void 0===t?r.len:r.pos+t,i={id:0,channelEvent:void 0,mediaEvent:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.id=r.int32();continue;case 2:if(18!==e)break;i.channelEvent=ls.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.mediaEvent=Ts.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Is(e.id)?globalThis.Number(e.id):0,channelEvent:Is(e.channelEvent)?ls.fromJSON(e.channelEvent):void 0,mediaEvent:Is(e.mediaEvent)?Ts.fromJSON(e.mediaEvent):void 0}),toJSON(e){const t={};return 0!==e.id&&(t.id=Math.round(e.id)),void 0!==e.channelEvent&&(t.channelEvent=ls.toJSON(e.channelEvent)),void 0!==e.mediaEvent&&(t.mediaEvent=Ts.toJSON(e.mediaEvent)),t},create:e=>Rs.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={id:0,channelEvent:void 0,mediaEvent:void 0};return r.id=null!==(t=e.id)&&void 0!==t?t:0,r.channelEvent=void 0!==e.channelEvent&&null!==e.channelEvent?ls.fromPartial(e.channelEvent):void 0,r.mediaEvent=void 0!==e.mediaEvent&&null!==e.mediaEvent?Ts.fromPartial(e.mediaEvent):void 0,r}};function Is(e){return null!=e}var Ds,As,Os,Ns,Ms,Ls,xs,Fs;let js=class{constructor(e){Ds.set(this,[]),As.set(this,!1),Os.set(this,!1),Ns.set(this,void 0),Ms.set(this,void 0),Ls.set(this,new Map),xs.set(this,void 0),Fs.set(this,new Set),p(this,xs,e("EventsQueue"),"f")}setMediaEventHandler(e){p(this,Ns,e,"f"),l(this,xs,"f").info("Media event handler set",{case:"EventsQueue"})}setChannelEventHandler(e){p(this,Ms,e,"f"),l(this,xs,"f").info("Channel event handler set",{case:"EventsQueue"})}subscribe(e){p(this,Fs,new Set,"f");let t=0;const r=e=>{try{const r=this.processMessageChunk(e);if(!r||!this.isPendingMessageFullyReceived(r))return;const n=this.finalizeMessageBytes(r),i=Rs.decode(n);i.id&&(l(this,Fs,"f").has(i.id)&&l(this,xs,"f").warn("Received duplicate message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id}),i.id>t+1&&l(this,xs,"f").warn("Received out of order message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id})),l(this,Fs,"f").add(i.id),t=i.id,this.push(i)}catch(e){l(this,xs,"f").error("Failed to parse channel message",{error:mr(e),case:"EventsQueue"})}},n=()=>{e.removeListener("message",r),e.removeListener("close",n)};e.on("close",n),e.on("message",r),l(this,xs,"f").info("Subscribed to data channel",{case:"EventsQueue"})}push(e){l(this,Ds,"f").push(e),this.process()}process(){return u(this,void 0,void 0,(function*(){if(!l(this,As,"f")&&!l(this,Os,"f")){for(p(this,Os,!0,"f");!l(this,As,"f")&&l(this,Ds,"f").length>0;){const e=l(this,Ds,"f").shift();if(e)try{if(e.channelEvent&&l(this,Ms,"f")){l(this,xs,"f").debug("Handle channel event",{case:"EventsQueue",id:e.id,type:us(e.channelEvent.eventType),event:e.channelEvent}),yield l(this,Ms,"f").call(this,e.channelEvent);continue}if(e.mediaEvent&&l(this,Ns,"f")){l(this,xs,"f").debug("Handle media event",{case:"EventsQueue",id:e.id,type:Ps(e.mediaEvent.eventType),event:e.mediaEvent}),yield l(this,Ns,"f").call(this,e.mediaEvent);continue}l(this,xs,"f").warn("Received unknown message",{message:e,case:"EventsQueue"})}catch(t){l(this,xs,"f").error("Failed to handle event",{case:"EventsQueue",id:e.id,error:mr(t)})}}p(this,Os,!1,"f"),!l(this,As,"f")&&l(this,Ds,"f").length>0&&queueMicrotask((()=>{this.process()}))}}))}processMessageChunk(e){const t=new Uint8Array(e);if(t.length<12)return void l(this,xs,"f").warn("Chunk too small",{case:"EventsQueue",bytesLength:t.length});const{msgId:r,index:n,total:i}=this.parseMessageChunkHeader(t),s=t.slice(12);l(this,Ls,"f").has(r)||l(this,Ls,"f").set(r,{msgId:r,total:i,received:[]});const o=l(this,Ls,"f").get(r);if(o)return o.received[n]=s,o.msgId=r,o;l(this,xs,"f").warn("Chunk buffer entry not found for msgId",{msgId:r,case:"EventsQueue"})}parseMessageChunkHeader(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{msgId:t.getUint32(0),index:t.getUint32(4),total:t.getUint32(8)}}isPendingMessageFullyReceived(e){return e.received.filter(Boolean).length===e.total}finalizeMessageBytes(e){const t=new Uint8Array(e.received.reduce(((e,t)=>e+t.length),0));let r=0;for(const n of e.received)t.set(n,r),r+=n.length;return l(this,Ls,"f").delete(e.msgId),t}pause(){p(this,As,!0,"f")}size(){return l(this,Ds,"f").length}resume(){p(this,As,!1,"f"),this.process()}isMessageReceived(e){return l(this,Fs,"f").has(e)}};Ds=new WeakMap,As=new WeakMap,Os=new WeakMap,Ns=new WeakMap,Ms=new WeakMap,Ls=new WeakMap,xs=new WeakMap,Fs=new WeakMap,js=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],js);var Us=js;function Bs(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let Vs=class{get(){return this.peer}set(e){this.peer=e}delete(){this.peer=void 0}get canPublish(){var e;return"host"===(null===(e=this.peer)||void 0===e?void 0:e.role)}};Vs=a([ut()],Vs);class Ws extends Nn{constructor(e,t,r){super(e,null!=t?t:"something_went_wrong",r)}}const Hs=Object.create(null);Hs.open="0",Hs.close="1",Hs.ping="2",Hs.pong="3",Hs.message="4",Hs.upgrade="5",Hs.noop="6";const qs=Object.create(null);Object.keys(Hs).forEach((e=>{qs[Hs[e]]=e}));const zs={type:"error",data:"parser error"},Gs="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Ys="function"==typeof ArrayBuffer,$s=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Js=({type:e,data:t},r,n)=>Gs&&t instanceof Blob?r?n(t):Ks(t,n):Ys&&(t instanceof ArrayBuffer||$s(t))?r?n(t):Ks(new Blob([t]),n):n(Hs[e]+(t||"")),Ks=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function Qs(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Zs;const Xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",eo="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<Xs.length;e++)eo[Xs.charCodeAt(e)]=e;const to="function"==typeof ArrayBuffer,ro=(e,t)=>{if("string"!=typeof e)return{type:"message",data:io(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:no(e.substring(1),t)};return qs[r]?e.length>1?{type:qs[r],data:e.substring(1)}:{type:qs[r]}:zs},no=(e,t)=>{if(to){const r=(e=>{let t,r,n,i,s,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const d=new ArrayBuffer(o),u=new Uint8Array(d);for(t=0;t<a;t+=4)r=eo[e.charCodeAt(t)],n=eo[e.charCodeAt(t+1)],i=eo[e.charCodeAt(t+2)],s=eo[e.charCodeAt(t+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return d})(e);return io(r,t)}return{base64:!0,data:e}},io=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,so=String.fromCharCode(30);function oo(){return new TransformStream({transform(e,t){!function(e,t){Gs&&e.data instanceof Blob?e.data.arrayBuffer().then(Qs).then(t):Ys&&(e.data instanceof ArrayBuffer||$s(e.data))?t(Qs(e.data)):Js(e,!1,(e=>{Zs||(Zs=new TextEncoder),t(Zs.encode(e))}))}(e,(r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,n)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(n))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(r)}))}})}let ao;function co(e){return e.reduce(((e,t)=>e+t.length),0)}function uo(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let i=0;i<t;i++)r[i]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function lo(e){if(e)return function(e){for(var t in lo.prototype)e[t]=lo.prototype[t];return e}(e)}lo.prototype.on=lo.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},lo.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},lo.prototype.off=lo.prototype.removeListener=lo.prototype.removeAllListeners=lo.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<n.length;i++)if((r=n[i])===t||r.fn===t){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},lo.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,t)}return this},lo.prototype.emitReserved=lo.prototype.emit,lo.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},lo.prototype.hasListeners=function(e){return!!this.listeners(e).length};const po="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function ho(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const fo=po.setTimeout,mo=po.clearTimeout;function go(e,t){t.useNativeTimers?(e.setTimeoutFn=fo.bind(po),e.clearTimeoutFn=mo.bind(po)):(e.setTimeoutFn=po.setTimeout.bind(po),e.clearTimeoutFn=po.clearTimeout.bind(po))}class vo extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class yo extends lo{constructor(e){super(),this.writable=!1,go(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new vo(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=ro(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}(e);return t.length?"?"+t:""}}const _o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),bo={};let Eo,wo=0,So=0;function Co(e){let t="";do{t=_o[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Po(){const e=Co(+new Date);return e!==Eo?(wo=0,Eo=e):e+"."+Co(wo++)}for(;So<64;So++)bo[_o[So]]=So;let To=!1;try{To="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const ko=To;function Ro(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||ko))return new XMLHttpRequest}catch(e){}if(!t)try{return new(po[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function Io(){}const Do=null!=new Ro({xdomain:!1}).responseType;class Ao extends lo{constructor(e,t){super(),go(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=ho(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new Ro(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{r.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Ao.requestsCount++,Ao.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Io,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Ao.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Ao.requestsCount=0,Ao.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Oo);else if("function"==typeof addEventListener){addEventListener("onpagehide"in po?"pagehide":"unload",Oo,!1)}function Oo(){for(let e in Ao.requests)Ao.requests.hasOwnProperty(e)&&Ao.requests[e].abort()}const No="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Mo=po.WebSocket||po.MozWebSocket,Lo="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const xo={websocket:class extends yo{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=Lo?{}:ho(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=Lo?new Mo(e,t,r):t?new Mo(e,t):new Mo(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;Js(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}n&&No((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Po()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Mo}},webtransport:class extends yo{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){ao||(ao=new TextDecoder);const r=[];let n=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(r.push(o);;){if(0===n){if(co(r)<1)break;const e=uo(r,1);s=128==(128&e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(co(r)<2)break;const e=uo(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(co(r)<8)break;const e=uo(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(zs);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(co(r)<i)break;const e=uo(r,i);a.enqueue(ro(s?e:ao.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(zs);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=oo();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();const i=()=>{r.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;this.writer.write(r).then((()=>{n&&No((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends yo{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=Do&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const r=e.split(so),n=[];for(let e=0;e<r.length;e++){const i=ro(r[e],t);if(n.push(i),"error"===i.type)break}return n})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const r=e.length,n=new Array(r);let i=0;e.forEach(((e,s)=>{Js(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(so))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Po()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ao(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},Fo=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,jo=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Uo(e){const t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let i=Fo.exec(e||""),s={},o=14;for(;o--;)s[jo[o]]=i[o]||"";return-1!=r&&-1!=n&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1);"/"==t.slice(-1)&&n.splice(n.length-1,1);return n}(0,s.path),s.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(r[t]=n)})),r}(0,s.query),s}class Bo extends lo{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=Uo(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Uo(t.host).host),go(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},r=e.split("&");for(let e=0,n=r.length;e<n;e++){let n=r[e].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new xo[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Bo.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),r=!1;Bo.priorWebsocketSuccess=!1;const n=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!r)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Bo.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){r||(r=!0,d(),t.close(),t=null)}const s=e=>{const r=new Error("probe error: "+e);r.transport=t.name,i(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&i()}const d=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",n),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{r||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",Bo.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const n=this.writeBuffer[r].data;if(n&&(e+="string"==typeof(t=n)?function(e){let t=0,r=0;for(let n=0,i=e.length;n<i;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}(t):Math.ceil(1.33*(t.byteLength||t.size))),r>0&&e>this.maxPayload)return this.writeBuffer.slice(0,r);e+=2}var t;return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(e){Bo.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}Bo.protocol=4;const Vo="function"==typeof ArrayBuffer,Wo=Object.prototype.toString,Ho="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Wo.call(Blob),qo="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Wo.call(File);function zo(e){return Vo&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||Ho&&e instanceof Blob||qo&&e instanceof File}function Go(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(Go(e[t]))return!0;return!1}if(zo(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return Go(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Go(e[t]))return!0;return!1}function Yo(e){const t=[],r=e.data,n=e;return n.data=$o(r,t),n.attachments=t.length,{packet:n,buffers:t}}function $o(e,t){if(!e)return e;if(zo(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=$o(e[n],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=$o(e[n],t));return r}return e}function Jo(e,t){return e.data=Ko(e.data,t),delete e.attachments,e}function Ko(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=Ko(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Ko(e[r],t));return e}const Qo=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Zo;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Zo||(Zo={}));function Xo(e){return"[object Object]"===Object.prototype.toString.call(e)}class ea extends lo{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===Zo.BINARY_EVENT;r||t.type===Zo.BINARY_ACK?(t.type=r?Zo.EVENT:Zo.ACK,this.reconstructor=new ta(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!zo(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===Zo[r.type])throw new Error("unknown packet type "+r.type);if(r.type===Zo.BINARY_EVENT||r.type===Zo.BINARY_ACK){const n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(n,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(t+1)){const n=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(n,t)}else r.nsp="/";const n=e.charAt(t+1);if(""!==n&&Number(n)==n){const n=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){const n=this.tryParse(e.substr(t));if(!ea.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Zo.CONNECT:return Xo(t);case Zo.DISCONNECT:return void 0===t;case Zo.CONNECT_ERROR:return"string"==typeof t||Xo(t);case Zo.EVENT:case Zo.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Qo.indexOf(t[0]));case Zo.ACK:case Zo.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ta{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Jo(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var ra=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Zo},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Zo.EVENT&&e.type!==Zo.ACK||!Go(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Zo.EVENT?Zo.BINARY_EVENT:Zo.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Zo.BINARY_EVENT&&e.type!==Zo.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Yo(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Decoder:ea});function na(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const ia=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sa extends lo{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[na(e,"open",this.onopen.bind(this)),na(e,"packet",this.onpacket.bind(this)),na(e,"error",this.onerror.bind(this)),na(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(ia.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:Zo.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),r.id=e}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const n=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===n)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),n);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const r=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((n,i)=>{t.push(((e,t)=>r?e?i(e):n(t):n(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...n)=>{if(r!==this._queue[0])return;return null!==e?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Zo.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Zo.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Zo.EVENT:case Zo.BINARY_EVENT:this.onevent(e);break;case Zo.ACK:case Zo.BINARY_ACK:this.onack(e);break;case Zo.DISCONNECT:this.ondisconnect();break;case Zo.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...n){r||(r=!0,t.packet({type:Zo.ACK,id:e,data:n}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Zo.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function oa(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}oa.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},oa.prototype.reset=function(){this.attempts=0},oa.prototype.setMin=function(e){this.ms=e},oa.prototype.setMax=function(e){this.max=e},oa.prototype.setJitter=function(e){this.jitter=e};class aa extends lo{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,go(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new oa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||ra;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Bo(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=na(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=na(t,"error",i);if(!1!==this._timeout){const e=this._timeout,r=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(n),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(na(e,"ping",this.onping.bind(this)),na(e,"data",this.ondata.bind(this)),na(e,"error",this.onerror.bind(this)),na(e,"close",this.onclose.bind(this)),na(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){No((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new sa(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const ca={};function da(e,t){"object"==typeof e&&(t=e,e=void 0);const r=function(e,t="",r){let n=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),n=Uo(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),n=r.source,i=r.id,s=r.path,o=ca[i]&&s in ca[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new aa(n,t):(ca[i]||(ca[i]=new aa(n,t)),a=ca[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}var ua,la;Object.assign(da,{Manager:aa,Socket:sa,io:da,connect:da});let pa=class{constructor(e){this.reconnectingAttempt=0,this.isConnected=!1,this._observer=new It,ua.set(this,void 0),this.knownDisconnectReasonsCodes={"io server disconnect":"server.disconnect","io client disconnect":"client.disconnect","ping timeout":"ping.timeout","transport close":"transport.close","transport error":"transport.error"},la.set(this,!1),p(this,ua,e("Socket"),"f")}get observer(){return this._observer}get id(){var e;return null===(e=this.connection)||void 0===e?void 0:e.id}connect(e,t){const r=da(e,{multiplex:!0,randomizationFactor:.2,reconnectionDelay:1e3,reconnection:!0,transports:["polling","websocket"],upgrade:!0,rememberUpgrade:!1,auth:{token:t,apiVersion:6}});this.connection=r,this.serverUrl=e,r.on(Kn.Connect,(()=>{const e=this.reconnectingAttempt?Kn.Reconnected:Kn.Connected;this.isConnected=!0,this.setReconnectingAttempt(0),l(this,ua,"f").debug(`connection.on('${Kn.Connect}')`,{connectionId:r.id,recovered:r.recovered}),this.observer.safeEmit(Kn.State,{state:e})})),r.on(Kn.ConnectError,(e=>{this.connectionError=e,l(this,ua,"f").error(`connection.on('${Kn.ConnectError}')`,{error:mr(e)}),this.observer.safeEmit(Kn.State,{state:Kn.Error,error:e}),this.reconnectingAttempt>100&&(r.disconnect(),this.observer.safeEmit(Kn.State,{state:Kn.Disconnected,code:"server.disconnect"}))})),r.on(Kn.ReconnectError,(e=>{l(this,ua,"f").error(`connection.on('${Kn.ReconnectError}')`,{case:"SocketReconnect",error:mr(e)})})),r.on(Kn.Disconnect,(e=>{this.isConnected=!1,this.setReconnectingAttempt(0),this.disconnectReason=e,l(this,ua,"f").info(`connection.on('${Kn.Disconnect}')`,{reason:e});const t=this.getDisconnectReasonCode(e);"server.disconnect"===t&&r.disconnect(),this.observer.safeEmit(Kn.State,{state:Kn.Disconnected,code:t})})),r.io.on(Kn.ReconnectAttempt,(e=>{this.setReconnectingAttempt(e),l(this,ua,"f").info(`connection.on('${Kn.ReconnectAttempt}')`,{attempt:e}),this.observer.safeEmit(Kn.State,{state:Kn.Reconnecting})})),r.io.on(Kn.Reconnect,(()=>{l(this,ua,"f").debug(`connection.on('${Kn.Reconnect}')`,{connectionId:r.id}),this.observer.safeEmit(Kn.State,{state:Kn.Reconnect})}))}disconnect(){this.connection&&(this.connection.offAny(),this.connection.volatile.offAny(),this.connection.disconnect(),this.connection.io.removeAllListeners(),this.setReconnectingAttempt(0))}request(e){return u(this,arguments,void 0,(function*(e,t={}){return yield new Promise(((r,n)=>{this.connection?this.connection.timeout(8e3).emit(e,t,((t,i)=>{if(t){const r=Dn.includes(e);return"operation has timed out"===(null==t?void 0:t.message)&&!l(this,la,"f")&&r&&(p(this,la,!0,"f"),this.observer.safeEmit(Kn.State,{state:Kn.BufferingStart})),void n(t)}i&&i.error?("Need join to channel first"===i.error&&this.observer.safeEmit(Kn.State,{code:Kn.NeedToJoinFirst}),n(new Ws(i.error,i.errorCode,Object.assign({},i)))):(l(this,la,"f")&&(p(this,la,!1,"f"),this.observer.safeEmit(Kn.State,{state:Kn.BufferingEnd})),r(i))})):n(new Error("Socket request: Socket connection is not initialized"))}))}))}getServerUrl(){return this.serverUrl}getDisconnectReasonCode(e){const t=String(e).toLowerCase();return this.knownDisconnectReasonsCodes[t]||t}setReconnectingAttempt(e){this.reconnectingAttempt=e}};ua=new WeakMap,la=new WeakMap,pa=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],pa);var ha,fa=pa;class ma extends Nn{constructor(e,t){super(e,null!=t?t:"invalid_payload")}}!function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(ha||(ha={}));let ga=class{constructor(){this.peers=new Map}has(e){return this.peers.has(e)}set(e,t){this.peers.set(e,t)}get(e){return this.peers.get(e)}delete(e){return this.peers.delete(e)}all(){return Array.from(this.peers.values())}hosts(){return this.all().filter((e=>"host"===e.role))}audience(){return this.all().filter((e=>"audience"===e.role))}clear(){this.peers.clear()}};ga=a([ut()],ga);var va,ya,_a,ba,Ea,wa=ga;let Sa=Ea=class{constructor(e,t,r){this.peersStorage=e,this.clientEventEmitter=t,va.set(this,void 0),ya.set(this,void 0),_a.set(this,void 0),ba.set(this,void 0),p(this,va,r("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(Ea.validateEventPayload(t),t.event){case ha.DominantSpeaker:this.handleDominantSpeaker(t);break;case ha.PeersVolumes:this.handlePeerVolumes(t);break;case ha.Silence:this.handleSilence()}}catch(t){l(this,va,"f").warn("Failed to handle audio observer event",{error:mr(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peersStorage.get(t);p(this,_a,r,"f"),p(this,ba,r,"f"),this.setActiveSpeaker(r)}handlePeerVolumes(e){e.volumes.forEach((e=>{var t;const{peerId:r,trackLabel:n,value:i}=e,s=this.peersStorage.get(r);if(!s)return;i>0&&!l(this,_a,"f")&&s.id===(null===(t=l(this,ba,"f"))||void 0===t?void 0:t.id)&&(p(this,_a,s,"f"),this.setActiveSpeaker(s));const o=null==s?void 0:s.tracks.get(n);o&&o.setVolume(i)}))}handleSilence(){this.peersStorage.all().flatMap((e=>Array.from(e.tracks.values()))).forEach((e=>e.setVolume(0))),p(this,_a,void 0,"f"),this.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(Ir,(e=>{var t;e===(null===(t=l(this,_a,"f"))||void 0===t?void 0:t.id)&&this.setActiveSpeaker(void 0)}))}setActiveSpeaker(e){l(this,ya,"f")!==(null==e?void 0:e.id)&&(p(this,ya,null==e?void 0:e.id,"f"),this.clientEventEmitter.safeEmit(jr,{peer:e}))}static validateEventPayload(e){switch(e.event){case ha.Silence:break;case ha.DominantSpeaker:{e.data||Ea.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===$n.Microphone||Ea.throwInvalidPayload();break}case ha.PeersVolumes:Array.isArray(e.volumes)||Ea.throwInvalidPayload(),e.volumes.forEach((e=>{const{peerId:t,producerId:r,value:n,trackLabel:i}=e;"string"==typeof t&&"string"==typeof r&&"number"==typeof n&&i===$n.Microphone||Ea.throwInvalidPayload()}));break;default:Ea.throwInvalidPayload()}}static throwInvalidPayload(){throw new ma("Invalid channel audio observer event handler payload")}};va=new WeakMap,ya=new WeakMap,_a=new WeakMap,ba=new WeakMap,Sa=Ea=a([ut(),c(0,pt(Gn.PeersStorage)),c(1,pt(Gn.ClientEventEmitter)),c(2,pt(Gn.LoggerFactory)),d("design:paramtypes",[wa,It,Function])],Sa);var Ca,Pa,Ta,ka=Sa;let Ra=class{constructor(e,t,r,n,i){this.state=e,this.myPeer=r,this.socket=n,this.channelAudioObserverEventHandler=i,Ca.set(this,void 0),Pa.set(this,void 0),Ta.set(this,void 0),p(this,Ca,t("DataChannels"),"f")}get channelMessagesDataConsumer(){return l(this,Ta,"f")}createAudioObserver(e){return u(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{producerId:t}=yield this.getAudioObserverProducer();p(this,Pa,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,transport:e}),"f");const n=this.channelAudioObserverEventHandler.handle.bind(this.channelAudioObserverEventHandler),i=()=>{var e,t;null===(e=l(this,Pa,"f"))||void 0===e||e.removeListener("message",n),null===(t=l(this,Pa,"f"))||void 0===t||t.removeListener("close",i)};l(this,Pa,"f").on("close",i),l(this,Pa,"f").on("message",n),l(this,Ca,"f").debug("Successfully create audio observer",r)}catch(e){l(this,Ca,"f").error("Failed to create audio observer",Object.assign(Object.assign({},r),{error:mr(e)}))}}))}createChannelMessagesDataConsumer(e){return u(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{id:t}=yield this.createDataProducer(e.id,"channel-messages-data-producer");p(this,Ta,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,ordered:!0,transport:e}),"f"),l(this,Ca,"f").debug("Successfully created channel messages data consumer",Object.assign(Object.assign({},r),{producerId:t}))}catch(e){throw l(this,Ca,"f").error("Failed to create channel messages data consumer",Object.assign(Object.assign({},r),{error:e})),e}}))}closeAudioObserver(){var e;null===(e=l(this,Pa,"f"))||void 0===e||e.close()}closeChannelMessagesDataConsumer(){var e;null===(e=l(this,Ta,"f"))||void 0===e||e.close()}createDataProducer(e,t){return u(this,void 0,void 0,(function*(){return yield this.socket.request(kn,{transportId:e,label:t})}))}createDataConsumer(e){return u(this,arguments,void 0,(function*({producerId:e,appId:t,channelId:r,ordered:n,transport:i}){if(!i)throw l(this,Ca,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");l(this,Ca,"f").debug("createDataConsumer()",{producerId:e});const s=yield this.socket.request(yn,{ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}}),o=yield i.consumeData(s);return l(this,Ca,"f").debug("Data consumer created",{consumerId:o.id}),o}))}getAudioObserverProducer(){return u(this,void 0,void 0,(function*(){return yield this.socket.request(wr)}))}};Ca=new WeakMap,Pa=new WeakMap,Ta=new WeakMap,Ra=a([ut(),c(0,pt(Gn.CallState)),c(1,pt(Gn.LoggerFactory)),c(2,pt(Gn.MyPeer)),c(3,pt(Gn.SocketIO)),c(4,pt(Gn.ChannelAudioObserverEventHandler)),d("design:paramtypes",[Qn,Function,Vs,fa,ka])],Ra);var Ia,Da,Aa,Oa=Ra;let Na=class{constructor(e,t,r,n,i,s){this.state=e,this.myPeer=t,this.socket=n,this.clientEventEmitter=i,this.dataChannelsManager=s,Ia.set(this,{send:void 0,recv:void 0}),Da.set(this,void 0),Aa.set(this,void 0),this.peersLoaded=!1,p(this,Aa,r("Network"),"f"),p(this,Da,new It,"f"),this.socket.observer.on(Kn.State,(e=>{l(this,Da,"f").safeEmit(An,e)}))}get isNetworkActive(){var e,t,r,n,i;return!!(null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&["connected","new"].includes(null!==(r=null===(t=this.receiveTransport)||void 0===t?void 0:t.connectionState)&&void 0!==r?r:"")&&["connected","new"].includes(null!==(i=null===(n=this.sendTransport)||void 0===n?void 0:n.connectionState)&&void 0!==i?i:"")}get observer(){return l(this,Da,"f")}get isSocketConnectionActive(){try{return this.checkSocketConnectionActivity(),!0}catch(e){return l(this,Aa,"f").warn("isSocketConnectionActive()",{error:mr(e)}),!1}}checkSocketConnectionActivity(){var e;if(!this.state.channelId||this.state.isChannelJoining)throw new Error("Connect to the channel first");if(!(null===(e=this.socket.connection)||void 0===e?void 0:e.active))throw new Error("Socket is inactive");if(!this.socket.connection.connected)throw new Error("Socket disconnected")}removeEventListeners(){const{sendTransport:e,receiveTransport:t,signalingTransport:r}=this;if(e){["connect","produce","connectionstatechange"].forEach((t=>e.removeAllListeners(t)))}if(t){["connect","produce","connectionstatechange"].forEach((e=>t.removeAllListeners(e)))}if(r){["connect","produce","producedata","connectionstatechange"].forEach((e=>r.removeAllListeners(e)))}}reset(){this.stopRestartIceAttempts(),this.removeEventListeners()}closeRemoteProducer(e){return u(this,void 0,void 0,(function*(){yield this.socket.request(pn,{peerId:this.myPeer.id,producerId:e})}))}closeSendTransport(){var e;this.sendTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&this.closeTransport(this.sendTransport),this.sendTransport.close(),this.sendTransport=void 0):l(this,Aa,"f").warn("closeSendTransport()",{message:"No available send transport"})}closeReceiveTransport(){var e;this.receiveTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&this.closeTransport(this.receiveTransport),this.receiveTransport.close(),this.receiveTransport=void 0):l(this,Aa,"f").warn("closeReceiveTransport()",{message:"No available receive transport"})}closeConnectionTransport(){return u(this,void 0,void 0,(function*(){var e;this.signalingTransport?(yield this.closePingConsumer(),(null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&this.closeTransport(this.signalingTransport),this.signalingTransport.close(),this.signalingTransport=void 0):l(this,Aa,"f").warn("closeConnectionTransport()",{message:"No available connection transport"})}))}closeTransport(e){try{e.close(),l(this,Aa,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){l(this,Aa,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}createSendTransport(e){return u(this,void 0,void 0,(function*(){if(this.sendTransport)throw l(this,Aa,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new Nn("Send transport already exists","already_exists");const t=yield this.socket.request(Cn,{sctpCapabilities:e.sctpCapabilities,localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return l(this,Aa,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return u(this,void 0,void 0,(function*(){if(this.receiveTransport)throw l(this,Aa,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new Nn("Receive transport already exists","already_exists");const t=yield this.socket.request(Cn,{localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return l(this,Aa,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}createSignalingTransport(e){return u(this,void 0,void 0,(function*(){if(this.signalingTransport)throw l(this,Aa,"f").warn("createConnectionTransport()",{message:"Connection transport already exists"}),new Nn("Connection transport already exists","already_exists");const t=yield this.socket.request(Cn,{localDirection:"receive",tcpOnly:!0}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return l(this,Aa,"f").debug("createConnectionTransport()",{transportId:r.id,direction:r.direction,tcpOnly:!0}),this.signalingTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return u(this,void 0,void 0,(function*(){const t=yield this.socket.request(In,{transportId:e.id}),{error:r}=t;if(r)throw new Error(r);const{iceParameters:n}=t;return l(this,Aa,"f").debug("getIceParameters()",{iceParameters:n}),n}))}restartIce(e){return u(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),l(this,Aa,"f").info("restartIce completed",{iceParameters:t})}catch(e){l(this,Aa,"f").error("restartIce error",{error:e})}}))}createConsumer(e){return u(this,arguments,void 0,(function*({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;const o=this.receiveTransport;if(!o)throw l(this,Aa,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");let a;l(this,Aa,"f").debug("createConsumer()",{producerId:e});try{a=yield this.socket.request(vn,{producerId:e,transportId:o.id,rtpCapabilities:t,appData:{peerId:this.myPeer.id,appId:r,channelId:n},producerPeerId:i})}catch(o){if(!(o instanceof Ws&&(null===(s=o.meta)||void 0===s?void 0:s.existedConsumer)))throw l(this,Aa,"f").error("Failed to get consumer options",{producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i,error:mr(o)}),new Error("Failed to create consumer");a=o.meta.existedConsumer}const c=yield o.consume(a),{producerPaused:d}=a;return d&&c.pause(),l(this,Aa,"f").debug("Consumer created",{consumerId:c.id,label:c.appData.label,isProducerPaused:d}),{consumer:c,isProducerPaused:d}}))}createSignalingConsumer(){return u(this,void 0,void 0,(function*(){var e,t;const r=this.signalingTransport;if(!r)throw l(this,Aa,"f").error("createSignalingConsumer()",{reason:"missing signaling transport"}),new Error("Failed to create data consumer");this.signalingDataProducer=yield r.produceData({label:"signaling-data-channel",protocol:"json"});const n=null===(e=this.signalingDataProducer)||void 0===e?void 0:e.id;if(!n)throw new TypeError("dataProducerId is missing for connectionTransport");try{const e=yield this.socket.request(yn,{ordered:!0,dataProducerId:n,transportId:r.id,appData:{peerId:this.myPeer.id,producerId:n,appId:this.state.appId,channelId:this.state.channelId}});this.signalingConsumerId=e.consumerId}catch(e){l(this,Aa,"f").error("Failed to setup TCP DataChannel for connectionTransport",{transportId:r.id,dataProducerId:null===(t=this.signalingDataProducer)||void 0===t?void 0:t.id,error:mr(e)})}}))}get channelMessagesDataConsumer(){return this.dataChannelsManager.channelMessagesDataConsumer}closePingConsumer(){return u(this,void 0,void 0,(function*(){try{if(!this.signalingConsumerId)return;yield this.closeRemoteConsumer(this.signalingConsumerId)}catch(e){l(this,Aa,"f").debug("closeConsumer()",{track:this,error:mr(e)})}}))}closeRemoteConsumer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(_n,{peerId:this.myPeer.id,consumerId:e})}))}resumeRemoteConsumer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(En,{consumerId:e})}))}pauseRemoteProducer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(hn,{producerId:e})}))}pauseRemoteConsumer(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(bn,{consumerId:e})}))}updatePeerAppData(e){return u(this,arguments,void 0,(function*({peerId:e,appData:t}){return yield this.socket.request(br,{peerId:e,appData:t})}))}getTransportsStateInfo(){return u(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getParsedTransportStats(this.receiveTransport),this.getParsedTransportStats(this.sendTransport)]);return{receive:e,send:t}}))}setPreferRelay(e){this.preferRelay=e}getPreferRelay(){var e;return null!==(e=this.preferRelay)&&void 0!==e&&e}getChannelPeers(e){return u(this,void 0,void 0,(function*(){const t=yield this.socket.request(yr,{role:e});return this.peersLoaded=!0,t}))}createAllDataChannels(){return u(this,void 0,void 0,(function*(){if(!this.receiveTransport)throw new Error("Receive transport is not created");yield Promise.all([this.dataChannelsManager.createAudioObserver(this.receiveTransport),this.dataChannelsManager.createChannelMessagesDataConsumer(this.receiveTransport)])}))}closeAllDataChannels(){this.dataChannelsManager.closeAudioObserver(),this.dataChannelsManager.closeChannelMessagesDataConsumer()}waitForReceiveTransportConnected(){return u(this,void 0,void 0,(function*(){if(!this.receiveTransport)throw new Error("receiveTransport is not initialized");yield this.waitForTransportConnected(this.receiveTransport)}))}triggerChannelStateEvent(e){return u(this,void 0,void 0,(function*(){const{messageId:t}=yield this.socket.request(_r,{peersRole:e});return t}))}waitForChannelMessagesDataConsumerConnected(){return u(this,void 0,void 0,(function*(){if(!this.dataChannelsManager.channelMessagesDataConsumer)throw new Error("channelMessagesDataConsumer is not initialized");yield this.waitForDataConsumerConnected(this.dataChannelsManager.channelMessagesDataConsumer)}))}waitForTransportConnected(e){return u(this,arguments,void 0,(function*(e,t=6e4){"connected"!==e.connectionState&&(yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),n(new Error("Timed out waiting for receiveTransport to connect"))}),t),s=()=>{clearTimeout(i),e.off("connectionstatechange",o)},o=()=>{"connected"===e.connectionState?(s(),r()):"failed"!==e.connectionState&&"closed"!==e.connectionState||(s(),n(new Error(`receiveTransport connection failed: ${e.connectionState}`)))};e.on("connectionstatechange",o)})))}))}waitForDataConsumerConnected(e){return u(this,arguments,void 0,(function*(e,t=6e4){if(!e)throw new Error("Data consumer is not initialized");"open"!==e.readyState&&(yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),n(new Error("Timed out waiting for data consumer to connect"))}),t),s=()=>{clearTimeout(i),e.off("open",o),e.off("close",a)},o=()=>{s(),r()},a=()=>{s(),n(new Error(`Data consumer closed unexpectedly: ${e.readyState}`))};e.on("open",o),e.on("close",a)})))}))}getParsedTransportStats(e){return u(this,void 0,void 0,(function*(){if(e)try{const t=Array.from((yield e.getStats()).values()),r=t.find((e=>"local-candidate"===e.type)),n=t.find((e=>"remote-candidate"===e.type)),i=t.find((e=>"transport"===e.type));return{dtlsState:null==i?void 0:i.dtlsState,iceState:null==i?void 0:i.iceState,dtlsRole:null==i?void 0:i.dtlsRole,iceRole:null==i?void 0:i.iceRole,selectedCandidatePairChanges:null==i?void 0:i.selectedCandidatePairChanges,tlsVersion:null==i?void 0:i.tlsVersion,localCandidateState:{ip:null==r?void 0:r.ip,address:null==r?void 0:r.address,port:null==r?void 0:r.port,protocol:null==r?void 0:r.protocol,candidateType:null==r?void 0:r.candidateType},remoteCandidateState:{ip:null==n?void 0:n.ip,address:null==n?void 0:n.address,port:null==n?void 0:n.port,protocol:null==n?void 0:n.protocol,candidateType:null==n?void 0:n.candidateType}}}catch(e){return void l(this,Aa,"f").warn("getParsedTransportStats()",{error:e})}else l(this,Aa,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){return u(this,void 0,void 0,(function*(){var t,r,n,i;let s;try{s=yield e.getStats()}catch(t){return void l(this,Aa,"f").error("Failed to log detailed WebRTC transport stats",{error:mr(t),transportId:e.id,reason:"failed to parse getStats"})}try{const o=[...s],[,a]=null!==(t=o.find((([,e])=>"transport"===(null==e?void 0:e.type))))&&void 0!==t?t:[],[,c]=null!==(r=o.find((([,e])=>"candidate-pair"===e.type&&"succeeded"===e.state&&e.nominated)))&&void 0!==r?r:[],d=s.get(String(null!==(n=null==c?void 0:c.localCandidateId)&&void 0!==n?n:"-")),u=s.get(String(null!==(i=null==c?void 0:c.remoteCandidateId)&&void 0!==i?i:"-")),p={hasNominatedPair:!!c,transportId:e.id,iceRole:null==a?void 0:a.iceRole,iceState:null==a?void 0:a.iceState,dtlsRole:null==a?void 0:a.dtlsRole,dtlsState:null==a?void 0:a.dtlsState,local:{address:null==d?void 0:d.address,candidateType:null==d?void 0:d.candidateType,foundation:null==d?void 0:d.foundation,networkType:null==d?void 0:d.networkType,isRemote:null==d?void 0:d.isRemote,port:null==d?void 0:d.port,protocol:null==d?void 0:d.protocol,relatedAddress:null==d?void 0:d.relatedAddress,relatedPort:null==d?void 0:d.relatedPort,transportId:null==d?void 0:d.transportId,relayProtocol:null==d?void 0:d.relayProtocol,url:null==d?void 0:d.url},remote:{address:null==u?void 0:u.address,candidateType:null==u?void 0:u.candidateType,foundation:null==u?void 0:u.foundation,isRemote:null==u?void 0:u.isRemote,port:null==u?void 0:u.port,protocol:null==u?void 0:u.protocol,transportId:null==u?void 0:u.transportId}};(null==c?void 0:c.totalRoundTripTime)&&(null==c?void 0:c.responsesReceived)&&(p.pairRoundTripTime=Math.round(c.totalRoundTripTime/c.responsesReceived*1e3)),l(this,Aa,"f").info("Detailed WebRTC transport stats",p)}catch(t){l(this,Aa,"f").error("Failed to log detailed WebRTC transport stats",{error:mr(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAttempts(){clearInterval(l(this,Ia,"f").send),clearInterval(l(this,Ia,"f").recv)}subscribeCommonTransportEvents(e){e.on("connect",((t,r,n)=>u(this,[t,r,n],void 0,(function*({dtlsParameters:t},r,n){try{yield this.socket.request(Pn,{transportId:e.id,dtlsParameters:t}),r(),l(this,Aa,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>u(this,void 0,void 0,(function*(){return yield this.logTransportDetails(e)}))),2e3),setTimeout((()=>u(this,void 0,void 0,(function*(){return yield this.checkTransportState(e)}))),15e3)}catch(t){l(this,Aa,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>u(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(Tn,{transportId:e.id,kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData});r({id:n}),l(this,Aa,"f").debug(`${e.direction}Transport.produce()`,{producerId:n,transportId:e.id,kind:t.kind})}catch(r){l(this,Aa,"f").error(`${e.direction}Transport.produce()`,{error:mr(r),transportId:e.id,kind:t.kind}),n(r)}})))),e.on("producedata",((t,r,n)=>u(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(kn,{transportId:e.id,label:t.label,sctpParameters:t.sctpStreamParameters,appData:t.appData});r({id:n}),l(this,Aa,"f").debug(`${e.direction}Transport.produceData()`,{producerId:n,transportId:e.id,label:t.label})}catch(r){l(this,Aa,"f").error(`${e.direction}Transport.produceData()`,{error:mr(r),transportId:e.id,label:t.label}),n(r)}})))),e.on("connectionstatechange",(t=>{if(l(this,Aa,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return l(this,Da,"f").safeEmit(On,{state:t,direction:e.direction}),l(this,Ia,"f")[e.direction]&&(l(this,Aa,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(l(this,Ia,"f")[e.direction]),l(this,Ia,"f")[e.direction]=void 0,"connected"===t&&l(this,Da,"f").safeEmit(On,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>{this.logTransportDetails(e).catch((e=>{l(this,Aa,"f").debug("Failed to log transport details",{error:mr(e)})}))}),1500));if(l(this,Da,"f").safeEmit(On,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(l(this,Ia,"f")[e.direction])return;"failed"===t&&(l(this,Aa,"f").debug(`${e.direction}Transport.restartIce()`,{recvTransportId:e.id}),this.restartIce(e).catch((e=>{l(this,Aa,"f").debug("Failed to execute restartIce",{error:mr(e)})}))),l(this,Ia,"f")[e.direction]=setInterval((()=>{this.restartIce(e).catch((e=>{l(this,Aa,"f").debug("Failed to execute restartIce",{error:mr(e)})})),l(this,Aa,"f").debug(`${e.direction}Transport.restartIce() attempt`,{recvTransportId:e.id})}),5e3)}})),e.on("icegatheringstatechange",(t=>{l(this,Aa,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}checkTransportState(e){return u(this,void 0,void 0,(function*(){try{const t=yield this.getParsedTransportStats(e);if(!t)return;const r="send"===e.direction?"send":"receive";if("connected"!==t.iceState)return this.clientEventEmitter.emit(Lr,{direction:r,reason:"ice"}),void l(this,Aa,"f").warn(Rn,{reason:"ice",transportId:e.id,direction:r});"connected"!==t.dtlsState&&(this.clientEventEmitter.emit(Lr,{direction:r,reason:"dtls"}),l(this,Aa,"f").warn(Rn,{reason:"dtls",transportId:e.id,direction:r}))}catch(t){l(this,Aa,"f").error("checkTransportState()",{error:mr(t),transportId:e.id,direction:e.direction})}}))}};Ia=new WeakMap,Da=new WeakMap,Aa=new WeakMap,Na=a([ut(),c(0,pt(Gn.CallState)),c(1,pt(Gn.MyPeer)),c(2,pt(Gn.LoggerFactory)),c(3,pt(Gn.SocketIO)),c(4,pt(Gn.ClientEventEmitter)),c(5,pt(Gn.DataChannelsManager)),d("design:paramtypes",[Qn,Vs,Function,fa,It,Oa])],Na);var Ma=Na;let La=class{constructor(e,t,r,n,i){this.myPeer=e,this.network=t,this.peerFactory=r,this.clientEventEmitter=n,this.peersStorage=i}has(e){return this.peersStorage.has(e)}set(e,t){e===this.myPeer.id&&this.myPeer.set(t),this.peersStorage.set(e,t)}get(e){return this.peersStorage.get(e)}delete(e){return e===this.myPeer.id&&this.myPeer.delete(),this.peersStorage.delete(e)}remove(e){return u(this,void 0,void 0,(function*(){const t=this.get(e);t&&(yield t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(Ir,e))}))}all(){return this.peersStorage.all()}hosts(){return this.peersStorage.hosts()}audience(){return this.peersStorage.audience()}reset(){return u(this,void 0,void 0,(function*(){yield Promise.all(this.peersStorage.all().map((e=>u(this,void 0,void 0,(function*(){return yield e.reset()}))))),this.peersStorage.clear()}))}load(e){return u(this,void 0,void 0,(function*(){const{peers:t}=yield this.network.getChannelPeers(e);t.filter((e=>!this.has(e.id))).forEach((e=>this.add(e,!1)))}))}add(e,t=!0){const r=this.get(e.id);if(r)return r;const n=this.peerFactory(e);return this.set(n.id,n),t&&this.clientEventEmitter.safeEmit(Rr,n),n}isModerator(e){if(void 0===e)return!1;const t=this.get(e);return!!t&&t.isModerator}};function xa(e,t){var r,n;if(0===t.length)return e;for(r=0,n=t.length;r<n;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e<0?-2*e:e}function Fa(e,t,r,n){var i=xa(xa(xa(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return xa(i,"null");if(void 0===t)return xa(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return xa(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Fa(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return xa(s,String(t.valueOf()))}catch(e){return xa(s,"[valueOf exception]"+(e.stack||e.message))}}return xa(i,t.toString())}La=a([ut(),c(0,pt(Gn.MyPeer)),c(1,pt(Gn.Network)),c(2,pt(Gn.PeerFactory)),c(3,pt(Gn.ClientEventEmitter)),c(4,pt(Gn.PeersStorage)),d("design:paramtypes",[Vs,Ma,Function,It,wa])],La);var ja=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Fa(0,e,"",[]).toString(16),8)};class Ua{constructor(e){this.missingPeers=e.missingPeers,this.missingProducers=e.missingProducers,this.consumersWithInconsistentState=e.consumersWithInconsistentState,this.producersWithInconsistentState=e.producersWithInconsistentState,this.peersWithInconsistentAppData=e.peersWithInconsistentAppData}hasInconsistencyCases(){return this.missingPeers.length>0||this.missingProducers.length>0||this.consumersWithInconsistentState.length>0||this.producersWithInconsistentState.length>0||this.peersWithInconsistentAppData.length>0}}class Ba{constructor(e){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[],this.localState=e.localState,this.remoteState=e.remoteState}check(){return this.resetPreviousCheckResults(),this.remoteState.peers.forEach((e=>{const t=this.findLocalPeerById(e.id);if(!t)return void this.missingPeers.push(e.id);t.appDataHash!==e.appDataHash&&this.peersWithInconsistentAppData.push(e.id),e.producers.forEach((e=>{const r=this.findLocalConsumerByProducerId(t,e.id);r&&r.paused!==e.paused&&this.consumersWithInconsistentState.push(r.id);const n=this.findLocalProducerById(t,e.id);if(n||this.missingProducers.push(e.id),!n)return;n.paused!==e.paused&&this.producersWithInconsistentState.push(e.id)}))})),new Ua({missingPeers:this.missingPeers,missingProducers:this.missingProducers,consumersWithInconsistentState:this.consumersWithInconsistentState,producersWithInconsistentState:this.producersWithInconsistentState,peersWithInconsistentAppData:this.peersWithInconsistentAppData})}getMissingPeers(){return this.missingPeers}getMissingProducers(){return this.missingProducers}getConsumersWithInconsistentState(){return this.consumersWithInconsistentState}getProducersWithInconsistentState(){return this.producersWithInconsistentState}getPeersWithInconsistentAppData(){return this.peersWithInconsistentAppData}findLocalPeerById(e){return this.localState.peers.find((t=>t.id===e))}findLocalConsumerByProducerId(e,t){var r;return null===(r=e.consumers)||void 0===r?void 0:r.find((e=>e.producerId===t))}findLocalProducerById(e,t){return e.producers.find((e=>e.id===t))}resetPreviousCheckResults(){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[]}}var Va,Wa,Ha,qa,za,Ga,Ya;!function(e){e.MissingPeer="missing-peer",e.MissingProducer="missing-producer",e.IncorrectProducerState="incorrect-producer-state",e.IncorrectConsumerState="incorrect-consumer-state",e.IncorrectAppData="incorrect-app-data"}(Va||(Va={}));let $a=class{constructor(e,t,r,n,i,s,o){var a;this.network=t,this.callState=r,this.socket=n,this.peersStorage=i,this.clientEventEmitter=s,this.webRtcIssueDetector=o,Wa.set(this,void 0),Ha.set(this,void 0),qa.set(this,[]),za.set(this,!1),Ga.set(this,{inbound:4.3,outbound:4.3}),Ya.set(this,(new Date).getTime()-15e3),p(this,Ha,null===(a=this.webRtcIssueDetector)||void 0===a?void 0:a.eventEmitter,"f"),p(this,Wa,e("ChannelStateSyncEventHandler"),"f"),this.debouncedHandleChannelStateEvent=jn(this.handleChannelStateEvent.bind(this),3e3),this.listenNetworkScoresUpdatedEvents()}handleChannelStateShort(e){return u(this,void 0,void 0,(function*(){try{yield this.debouncedHandleChannelStateEvent(e)}catch(e){l(this,Wa,"f").error("handleChannelStateSyncEvent()",{error:mr(e)})}}))}handleChannelStateEvent(e){return u(this,void 0,void 0,(function*(){if(l(this,za,"f"))l(this,Wa,"f").warn("Channel state event is already being handled, skipping new event",{case:"handleChannelStateEvent"});else{p(this,za,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void l(this,Wa,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{p(this,za,!1,"f")}}}))}getLastInconsistencyCheckResult(){return l(this,qa,"f")[l(this,qa,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{peerId:e,peersLoaded:this.network.peersLoaded,sdkInstances:Array.from(window._sdkMarks||[]).length,type:Va.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{producerId:e,type:Va.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{producerId:e,type:Va.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(Ur,{peerId:e,type:Va.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new Ua({missingPeers:this.getConfirmedMissingPeers(e.missingPeers),missingProducers:this.getConfirmedMissingProducers(e.missingProducers),consumersWithInconsistentState:this.getConfirmedConsumersWithInconsistencState(e.consumersWithInconsistentState),producersWithInconsistentState:this.getConfirmedProducersWithInconsistencState(e.producersWithInconsistentState),peersWithInconsistentAppData:this.getConfirmedPeersWithInconsistentAppData(e.missingPeers)})}collectProbableInconsistencyCases(e){return u(this,void 0,void 0,(function*(){const t=new Ba({remoteState:e,localState:this.getLocalState()}).check();if(this.rotateLastProbableInconsistencyCheckResults(t),!t.hasInconsistencyCases())return;if(this.isBadNetworkScore())return void this.resetLastProbableInconsistencyCheckResults();(yield this.getIsConnectionActive())&&this.callState.isJoined&&this.network.isNetworkActive||this.resetLastProbableInconsistencyCheckResults()}))}resetLastProbableInconsistencyCheckResults(){p(this,qa,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===l(this,qa,"f").length&&l(this,qa,"f").shift(),l(this,qa,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return l(this,qa,"f").forEach((r=>{r[e].includes(t)&&(n+=1)})),n>=r}getConfirmedMissingPeers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingPeers",e)))}getConfirmedMissingProducers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingProducers",e)))}getConfirmedConsumersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("consumersWithInconsistentState",e,1)))}getConfirmedProducersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("producersWithInconsistentState",e)))}getConfirmedPeersWithInconsistentAppData(e){return e.filter((e=>this.isReachedMaxCheckRetries("peersWithInconsistentAppData",e)))}getLocalState(){return{peers:this.peersStorage.hosts().map((e=>({id:e.id,appDataHash:ja(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){return u(this,void 0,void 0,(function*(){var e;try{if(this.network.checkSocketConnectionActivity(),!this.network.isNetworkActive)return!1;const{success:t}=yield null===(e=this.socket.connection)||void 0===e?void 0:e.timeout(1e3).emitWithAck(Tr,{});return t}catch(e){return!1}}))}listenNetworkScoresUpdatedEvents(){l(this,Ha,"f")&&l(this,Ha,"f").on(Ct.NetworkScoresUpdated,(e=>{e.inbound&&(l(this,Ga,"f").inbound=e.inbound),e.outbound&&(l(this,Ga,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=l(this,Ga,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new Ua({missingPeers:e.missingPeers.filter((e=>!t.missingPeers.includes(e))),missingProducers:e.missingProducers.filter((e=>!t.missingProducers.includes(e))),consumersWithInconsistentState:e.consumersWithInconsistentState.filter((e=>!t.fixedConsumersState.includes(e))),producersWithInconsistentState:e.producersWithInconsistentState.filter((e=>!t.fixedProducersState.includes(e))),peersWithInconsistentAppData:e.peersWithInconsistentAppData.filter((e=>!t.restoredAppDataPeers.includes(e)))})}isRestoreStateRequestToEarly(){return(new Date).getTime()-l(this,Ya,"f")<=15e3}};Wa=new WeakMap,Ha=new WeakMap,qa=new WeakMap,za=new WeakMap,Ga=new WeakMap,Ya=new WeakMap,$a=a([ut(),c(0,pt(Gn.LoggerFactory)),c(1,pt(Gn.Network)),c(2,pt(Gn.CallState)),c(3,pt(Gn.SocketIO)),c(4,pt(Gn.PeersStorage)),c(5,pt(Gn.ClientEventEmitter)),c(6,pt(Gn.WebRTCIssueDetector)),d("design:paramtypes",[Function,Ma,Qn,fa,wa,It,dr])],$a);var Ja=$a,Ka={},Qa={exports:{}},Za=1e3,Xa=6e4,ec=60*Xa,tc=24*ec,rc=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*tc;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ec;case"minutes":case"minute":case"mins":case"min":case"m":return r*Xa;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=tc)return nc(e,t,tc,"day");if(t>=ec)return nc(e,t,ec,"hour");if(t>=Xa)return nc(e,t,Xa,"minute");if(t>=1e3)return nc(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=tc)return Math.round(e/tc)+"d";if(t>=ec)return Math.round(e/ec)+"h";if(t>=Xa)return Math.round(e/Xa)+"m";if(t>=Za)return Math.round(e/Za)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function nc(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var ic=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=rc,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ic(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Qa,Qa.exports);var sc={};Object.defineProperty(sc,"__esModule",{value:!0});var oc={},ac=Object.defineProperty,cc=Object.getOwnPropertyDescriptor,dc=Object.getOwnPropertyNames,uc=Object.prototype.hasOwnProperty,lc={};((e,t)=>{for(var r in t)ac(e,r,{get:t[r],enumerable:!0})})(lc,{BrowserDetector:()=>vc,KnownBrowsers:()=>hc,KnownPlatforms:()=>fc,default:()=>yc});var pc=(e=>((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of dc(t))!uc.call(e,i)&&i!==r&&ac(e,i,{get:()=>t[i],enumerable:!(n=cc(t,i))||n.enumerable});return e})(ac({},"__esModule",{value:!0}),e))(lc),hc={chrome:"Google Chrome",brave:"Brave",crios:"Google Chrome",edge:"Microsoft Edge",edg:"Microsoft Edge",edgios:"Microsoft Edge",fennec:"Mozilla Firefox",jsdom:"JsDOM",mozilla:"Mozilla Firefox",fxios:"Mozilla Firefox",msie:"Microsoft Internet Explorer",opera:"Opera",opios:"Opera",opr:"Opera",opt:"Opera",rv:"Microsoft Internet Explorer",safari:"Safari",samsungbrowser:"Samsung Browser",electron:"Electron"},fc={android:"Android",androidTablet:"Android Tablet",cros:"Chrome OS",fennec:"Android Tablet",ipad:"IPad",ipod:"IPod",iphone:"IPhone",jsdom:"JsDOM",linux:"Linux",mac:"Macintosh",tablet:"Android Tablet",win:"Windows","windows phone":"Windows Phone",xbox:"Microsoft Xbox"},mc=(e,t=-1)=>{let r=new RegExp(`^-?\\d+(?:.\\d{0,${t}})?`),n=Number(e).toString().match(r);return n?n[0]:null},gc=()=>typeof window<"u"?window.navigator:null,vc=class{userAgent;constructor(e){this.userAgent=e||gc()?.userAgent||null}static get VERSION(){return"4.1.0"}parseUserAgent(e){let t={},r=e||this.userAgent||"",n=r.toLowerCase().replace(/\s\s+/g," "),i=/(edge)\/([\w.]+)/.exec(n)||/(edg)[/]([\w.]+)/.exec(n)||/(opr)[/]([\w.]+)/.exec(n)||/(opt)[/]([\w.]+)/.exec(n)||/(fxios)[/]([\w.]+)/.exec(n)||/(edgios)[/]([\w.]+)/.exec(n)||/(jsdom)[/]([\w.]+)/.exec(n)||/(samsungbrowser)[/]([\w.]+)/.exec(n)||/(electron)[/]([\w.]+)/.exec(n)||/(chrome)[/]([\w.]+)/.exec(n)||/(crios)[/]([\w.]+)/.exec(n)||/(opios)[/]([\w.]+)/.exec(n)||/(version)(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(webkit)[/]([\w.]+).*(version)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(webkit)[/]([\w.]+)/.exec(n)||/(opera)(?:.*version|)[/]([\w.]+)/.exec(n)||/(msie) ([\w.]+)/.exec(n)||/(fennec)[/]([\w.]+)/.exec(n)||n.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(n)||n.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(n)||[],s=/(ipad)/.exec(n)||/(ipod)/.exec(n)||/(iphone)/.exec(n)||/(jsdom)/.exec(n)||/(windows phone)/.exec(n)||/(xbox)/.exec(n)||/(win)/.exec(n)||/(tablet)/.exec(n)||/(android)/.test(n)&&!1===/(mobile)/.test(n)&&["androidTablet"]||/(android)/.exec(n)||/(mac)/.exec(n)||/(linux)/.exec(n)||/(cros)/.exec(n)||[],o=i[5]||i[3]||i[1]||null,a=s[0]||null,c=i[4]||i[2]||null,d=gc();"chrome"===o&&"function"==typeof d?.brave?.isBrave&&(o="brave"),o&&(t[o]=!0),a&&(t[a]=!0);let u=!!(t.tablet||t.android||t.androidTablet),l=!!(t.ipad||t.tablet||t.androidTablet),p=!!(t.android||t.androidTablet||t.tablet||t.ipad||t.ipod||t.iphone||t["windows phone"]),h=!!(t.cros||t.mac||t.linux||t.win),f=!!(t.brave||t.chrome||t.crios||t.opr||t.safari||t.edg||t.electron),m=!(!t.msie&&!t.rv),g=!(!t.chrome&&!t.crios),v=!!(t.fxios||t.fennec||t.mozilla),y=!!t.safari,_=!!(t.opera||t.opios||t.opr||t.opt),b=!!(t.edg||t.edge||t.edgios);return{name:hc[o]??null,platform:fc[a]??null,userAgent:r,version:c,shortVersion:c?mc(parseFloat(c),2):null,isAndroid:u,isTablet:l,isMobile:p,isDesktop:h,isWebkit:f,isIE:m,isChrome:g,isFireFox:v,isSafari:y,isOpera:_,isEdge:b}}getBrowserInfo(){let e=this.parseUserAgent();return{name:e.name,platform:e.platform,userAgent:e.userAgent,version:e.version,shortVersion:e.shortVersion}}},yc=vc,_c={};Object.defineProperty(_c,"__esModule",{value:!0}),_c.Logger=void 0;const bc=Qa.exports,Ec="mediasoup-client";_c.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=(0,bc.default)(`${Ec}:${e}`),this._warn=(0,bc.default)(`${Ec}:WARN:${e}`),this._error=(0,bc.default)(`${Ec}:ERROR:${e}`)):(this._debug=(0,bc.default)(Ec),this._warn=(0,bc.default)(`${Ec}:WARN`),this._error=(0,bc.default)(`${Ec}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};var wc,Sc={},Cc={exports:{}},Pc="object"==typeof Reflect?Reflect:null,Tc=Pc&&"function"==typeof Pc.apply?Pc.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};wc=Pc&&"function"==typeof Pc.ownKeys?Pc.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var kc=Number.isNaN||function(e){return e!=e};function Rc(){Rc.init.call(this)}Cc.exports=Rc,Cc.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}jc(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&jc(e,"error",t,r)}(e,i,{once:!0})}))},Rc.EventEmitter=Rc,Rc.prototype._events=void 0,Rc.prototype._eventsCount=0,Rc.prototype._maxListeners=void 0;var Ic=10;function Dc(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Ac(e){return void 0===e._maxListeners?Rc.defaultMaxListeners:e._maxListeners}function Oc(e,t,r,n){var i,s,o,a;if(Dc(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=Ac(e))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function Nc(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Mc(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Nc.bind(n);return i.listener=r,n.wrapFn=i,i}function Lc(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):Fc(i,i.length)}function xc(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function Fc(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function jc(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){n.once&&e.removeEventListener(t,i),r(s)}))}}Object.defineProperty(Rc,"defaultMaxListeners",{enumerable:!0,get:function(){return Ic},set:function(e){if("number"!=typeof e||e<0||kc(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ic=e}}),Rc.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Rc.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||kc(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Rc.prototype.getMaxListeners=function(){return Ac(this)},Rc.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)Tc(a,this,t);else{var c=a.length,d=Fc(a,c);for(r=0;r<c;++r)Tc(d[r],this,t)}return!0},Rc.prototype.addListener=function(e,t){return Oc(this,e,t,!1)},Rc.prototype.on=Rc.prototype.addListener,Rc.prototype.prependListener=function(e,t){return Oc(this,e,t,!0)},Rc.prototype.once=function(e,t){return Dc(t),this.on(e,Mc(this,e,t)),this},Rc.prototype.prependOnceListener=function(e,t){return Dc(t),this.prependListener(e,Mc(this,e,t)),this},Rc.prototype.removeListener=function(e,t){var r,n,i,s,o;if(Dc(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},Rc.prototype.off=Rc.prototype.removeListener,Rc.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},Rc.prototype.listeners=function(e){return Lc(this,e,!0)},Rc.prototype.rawListeners=function(e){return Lc(this,e,!1)},Rc.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):xc.call(e,t)},Rc.prototype.listenerCount=xc,Rc.prototype.eventNames=function(){return this._eventsCount>0?wc(this._events):[]},Object.defineProperty(Sc,"__esModule",{value:!0}),Sc.EnhancedEventEmitter=void 0;const Uc=Cc.exports,Bc=new _c.Logger("EnhancedEventEmitter");class Vc extends Uc.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}close(){super.removeAllListeners()}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){Bc.error("safeEmit() | event listener threw an error [eventName:%s]:%o",e,t);try{super.emit("listenererror",e,t)}catch(e){}return Boolean(super.listenerCount(e))}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}Sc.EnhancedEventEmitter=Vc;var Wc={};Object.defineProperty(Wc,"__esModule",{value:!0}),Wc.InvalidStateError=Wc.UnsupportedError=void 0;class Hc extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,Hc):this.stack=new Error(e).stack}}Wc.UnsupportedError=Hc;class qc extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,qc):this.stack=new Error(e).stack}}Wc.InvalidStateError=qc;var zc={};Object.defineProperty(zc,"__esModule",{value:!0}),zc.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},zc.generateRandomNumber=function(){return Math.round(1e7*Math.random())},zc.deepFreeze=function e(t){const r=Reflect.ownKeys(t);for(const n of r){const r=t[n];(r&&"object"==typeof r||"function"==typeof r)&&e(r)}return Object.freeze(t)};var Gc={},Yc={},$c={},Jc={exports:{}};var Kc=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=rc,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Kc(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Jc,Jc.exports);var Qc=f&&f.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($c,"__esModule",{value:!0}),$c.Logger=void 0;const Zc=Qc(Jc.exports),Xc="h264-profile-level-id";$c.Logger=class{constructor(e){e?(this._debug=(0,Zc.default)(`${Xc}:${e}`),this._warn=(0,Zc.default)(`${Xc}:WARN:${e}`),this._error=(0,Zc.default)(`${Xc}:ERROR:${e}`)):(this._debug=(0,Zc.default)(Xc),this._warn=(0,Zc.default)(`${Xc}:WARN`),this._error=(0,Zc.default)(`${Xc}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Object.defineProperty(Yc,"__esModule",{value:!0}),Yc.ProfileLevelId=Yc.Level=Yc.Profile=void 0,Yc.parseProfileLevelId=dd,Yc.profileLevelIdToString=ud,Yc.profileToString=function(e){switch(e){case td.ConstrainedBaseline:return"ConstrainedBaseline";case td.Baseline:return"Baseline";case td.Main:return"Main";case td.ConstrainedHigh:return"ConstrainedHigh";case td.High:return"High";case td.PredictiveHigh444:return"PredictiveHigh444";default:return void ed.warn(`profileToString() | unrecognized profile ${e}`)}},Yc.levelToString=function(e){switch(e){case rd.L1_b:return"1b";case rd.L1:return"1";case rd.L1_1:return"1.1";case rd.L1_2:return"1.2";case rd.L1_3:return"1.3";case rd.L2:return"2";case rd.L2_1:return"2.1";case rd.L2_2:return"2.2";case rd.L3:return"3";case rd.L3_1:return"3.1";case rd.L3_2:return"3.2";case rd.L4:return"4";case rd.L4_1:return"4.1";case rd.L4_2:return"4.2";case rd.L5:return"5";case rd.L5_1:return"5.1";case rd.L5_2:return"5.2";default:return void ed.warn(`levelToString() | unrecognized level ${e}`)}},Yc.parseSdpProfileLevelId=ld,Yc.isSameProfile=function(e={},t={}){const r=ld(e),n=ld(t);return Boolean(r&&n&&r.profile===n.profile)},Yc.isSameProfileAndLevel=function(e={},t={}){const r=ld(e),n=ld(t);return Boolean(r&&n&&r.profile===n.profile&&r.level==n.level)},Yc.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void ed.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=ld(e),n=ld(t);if(!r)throw new TypeError("invalid local_profile_level_id");if(!n)throw new TypeError("invalid remote_profile_level_id");if(r.profile!==n.profile)throw new TypeError("H264 Profile mismatch");const i=hd(e)&&hd(t),s=r.level,o=n.level,a=function(e,t){return function(e,t){if(e===rd.L1_b)return t!==rd.L1&&t!==rd.L1_b;if(t===rd.L1_b)return e!==rd.L1;return e<t}(e,t)?e:t}(s,o),c=i?s:a;return ed.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${c}]`),ud(new nd(r.profile,c))},Yc.supportedLevel=function(e,t){for(let r=cd.length-1;r>=0;--r){const n=cd[r];if(256*n.max_macroblock_frame_size<=e&&n.max_macroblocks_per_second<=t*n.max_macroblock_frame_size)return ed.debug(`supportedLevel() | result [max_frame_pixel_count:${e}, max_fps:${t}, level:${n.level}]`),n.level}return void ed.warn(`supportedLevel() | no level supported [max_frame_pixel_count:${e}, max_fps:${t}]`)};const ed=new $c.Logger;var td,rd;!function(e){e[e.ConstrainedBaseline=1]="ConstrainedBaseline",e[e.Baseline=2]="Baseline",e[e.Main=3]="Main",e[e.ConstrainedHigh=4]="ConstrainedHigh",e[e.High=5]="High",e[e.PredictiveHigh444=6]="PredictiveHigh444"}(td||(Yc.Profile=td={})),function(e){e[e.L1_b=0]="L1_b",e[e.L1=10]="L1",e[e.L1_1=11]="L1_1",e[e.L1_2=12]="L1_2",e[e.L1_3=13]="L1_3",e[e.L2=20]="L2",e[e.L2_1=21]="L2_1",e[e.L2_2=22]="L2_2",e[e.L3=30]="L3",e[e.L3_1=31]="L3_1",e[e.L3_2=32]="L3_2",e[e.L4=40]="L4",e[e.L4_1=41]="L4_1",e[e.L4_2=42]="L4_2",e[e.L5=50]="L5",e[e.L5_1=51]="L5_1",e[e.L5_2=52]="L5_2"}(rd||(Yc.Level=rd={}));class nd{constructor(e,t){this.profile=e,this.level=t}}Yc.ProfileLevelId=nd;const id=new nd(td.ConstrainedBaseline,rd.L3_1);class sd{constructor(e){this.mask=~pd("x",e),this.masked_value=pd("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class od{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const ad=[new od(66,new sd("x1xx0000"),td.ConstrainedBaseline),new od(77,new sd("1xxx0000"),td.ConstrainedBaseline),new od(88,new sd("11xx0000"),td.ConstrainedBaseline),new od(66,new sd("x0xx0000"),td.Baseline),new od(88,new sd("10xx0000"),td.Baseline),new od(77,new sd("0x0x0000"),td.Main),new od(100,new sd("00000000"),td.High),new od(100,new sd("00001100"),td.ConstrainedHigh),new od(244,new sd("00000000"),td.PredictiveHigh444)],cd=[{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:rd.L1},{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:rd.L1_b},{max_macroblocks_per_second:3e3,max_macroblock_frame_size:396,level:rd.L1_1},{max_macroblocks_per_second:6e3,max_macroblock_frame_size:396,level:rd.L1_2},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:rd.L1_3},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:rd.L2},{max_macroblocks_per_second:19800,max_macroblock_frame_size:792,level:rd.L2_1},{max_macroblocks_per_second:20250,max_macroblock_frame_size:1620,level:rd.L2_2},{max_macroblocks_per_second:40500,max_macroblock_frame_size:1620,level:rd.L3},{max_macroblocks_per_second:108e3,max_macroblock_frame_size:3600,level:rd.L3_1},{max_macroblocks_per_second:216e3,max_macroblock_frame_size:5120,level:rd.L3_2},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:rd.L4},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:rd.L4_1},{max_macroblocks_per_second:522240,max_macroblock_frame_size:8704,level:rd.L4_2},{max_macroblocks_per_second:589824,max_macroblock_frame_size:22080,level:rd.L5},{max_macroblocks_per_second:983040,max_macroblock_frame_size:36864,level:rd.L5_1},{max_macroblocks_per_second:2073600,max_macroblock_frame_size:36864,level:rd.L5_2}];function dd(e){if("string"!=typeof e||6!==e.length)return;const t=parseInt(e,16);if(0===t)return;const r=255&t,n=t>>8&255,i=t>>16&255;let s;switch(r){case rd.L1_1:s=0!=(16&n)?rd.L1_b:rd.L1_1;break;case rd.L1:case rd.L1_2:case rd.L1_3:case rd.L2:case rd.L2_1:case rd.L2_2:case rd.L3:case rd.L3_1:case rd.L3_2:case rd.L4:case rd.L4_1:case rd.L4_2:case rd.L5:case rd.L5_1:case rd.L5_2:s=r;break;default:return void ed.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const t of ad)if(i===t.profile_idc&&t.profile_iop.isMatch(n))return ed.debug(`parseProfileLevelId() | result [str:${e}, profile:${t.profile}, level:${s}]`),new nd(t.profile,s);ed.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function ud(e){if(e.level==rd.L1_b)switch(e.profile){case td.ConstrainedBaseline:return"42f00b";case td.Baseline:return"42100b";case td.Main:return"4d100b";default:return void ed.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case td.ConstrainedBaseline:t="42e0";break;case td.Baseline:t="4200";break;case td.Main:t="4d00";break;case td.ConstrainedHigh:t="640c";break;case td.High:t="6400";break;case td.PredictiveHigh444:t="f400";break;default:return void ed.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function ld(e={}){const t=e["profile-level-id"];return t?dd(t):id}function pd(e,t){return Number(t[0]===e)<<7|Number(t[1]===e)<<6|Number(t[2]===e)<<5|Number(t[3]===e)<<4|Number(t[4]===e)<<3|Number(t[5]===e)<<2|Number(t[6]===e)<<1|Number(t[7]===e)<<0}function hd(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}Object.defineProperty(Gc,"__esModule",{value:!0}),Gc.validateAndNormalizeRtpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(e.codecs&&!Array.isArray(e.codecs))throw new TypeError("caps.codecs is not an array");e.codecs||(e.codecs=[]);for(const t of e.codecs)vd(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("caps.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)_d(t)},Gc.validateAndNormalizeRtpParameters=gd,Gc.validateAndNormalizeSctpStreamParameters=function(e){if("object"!=typeof e)throw new TypeError("params is not an object");if("number"!=typeof e.streamId)throw new TypeError("missing params.streamId");let t=!1;"boolean"==typeof e.ordered?t=!0:e.ordered=!0;if(e.maxPacketLifeTime&&"number"!=typeof e.maxPacketLifeTime)throw new TypeError("invalid params.maxPacketLifeTime");if(e.maxRetransmits&&"number"!=typeof e.maxRetransmits)throw new TypeError("invalid params.maxRetransmits");if(e.maxPacketLifeTime&&e.maxRetransmits)throw new TypeError("cannot provide both maxPacketLifeTime and maxRetransmits");if(t&&e.ordered&&(e.maxPacketLifeTime||e.maxRetransmits))throw new TypeError("cannot be ordered with maxPacketLifeTime or maxRetransmits");t||!e.maxPacketLifeTime&&!e.maxRetransmits||(e.ordered=!1);if(e.label&&"string"!=typeof e.label)throw new TypeError("invalid params.label");if(e.protocol&&"string"!=typeof e.protocol)throw new TypeError("invalid params.protocol")},Gc.validateSctpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(!e.numStreams||"object"!=typeof e.numStreams)throw new TypeError("missing caps.numStreams");!function(e){if("object"!=typeof e)throw new TypeError("numStreams is not an object");if("number"!=typeof e.OS)throw new TypeError("missing numStreams.OS");if("number"!=typeof e.MIS)throw new TypeError("missing numStreams.MIS")}(e.numStreams)},Gc.getExtendedRtpCapabilities=function(e,t,r){const n={codecs:[],headerExtensions:[]};if(r)for(const r of e.codecs??[]){if(Sd(r))continue;const e=(t.codecs??[]).find((e=>Cd(e,r,{strict:!0,modify:!0})));if(!e)continue;const i={kind:r.kind,mimeType:r.mimeType,clockRate:r.clockRate,channels:r.channels,localPayloadType:r.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:e.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:r.parameters??{},remoteParameters:e.parameters??{},rtcpFeedback:Td(r,e)};n.codecs.push(i)}else for(const r of t.codecs??[]){if(Sd(r))continue;const t=(e.codecs??[]).find((e=>Cd(e,r,{strict:!0,modify:!0})));if(!t)continue;const i={kind:t.kind,mimeType:t.mimeType,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:r.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters??{},remoteParameters:r.parameters??{},rtcpFeedback:Td(t,r)};n.codecs.push(i)}for(const r of n.codecs){const n=e.codecs.find((e=>Sd(e)&&e.parameters?.apt===r.localPayloadType)),i=t.codecs.find((e=>Sd(e)&&e.parameters?.apt===r.remotePayloadType));n&&i&&(r.localRtxPayloadType=n.preferredPayloadType,r.remoteRtxPayloadType=i.preferredPayloadType)}for(const r of t.headerExtensions){const t=e.headerExtensions.find((e=>Pd(e,r)));if(!t)continue;const i={kind:r.kind,uri:r.uri,sendId:t.preferredId,recvId:r.preferredId,encrypt:t.preferredEncrypt??!1,direction:"sendrecv"};switch(r.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}n.headerExtensions.push(i)}return n},Gc.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={kind:r.kind,mimeType:r.mimeType,preferredPayloadType:r.remotePayloadType,clockRate:r.clockRate,channels:r.channels,parameters:r.localParameters,rtcpFeedback:r.rtcpFeedback};if(t.codecs.push(e),!r.remoteRtxPayloadType)continue;const n={kind:r.kind,mimeType:`${r.kind}/rtx`,preferredPayloadType:r.remoteRtxPayloadType,clockRate:r.clockRate,parameters:{apt:r.remotePayloadType},rtcpFeedback:[]};t.codecs.push(n)}for(const r of e.headerExtensions){if("sendrecv"!==r.direction&&"recvonly"!==r.direction)continue;const e={kind:r.kind,uri:r.uri,preferredId:r.recvId,preferredEncrypt:r.encrypt??!1,direction:r.direction};t.headerExtensions.push(e)}return t},Gc.getSendingRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.localParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}return r},Gc.getSendingRemoteRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.remoteParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}if(r.headerExtensions.some((e=>"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"goog-remb"!==e.type));else if(r.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type));else for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type&&"goog-remb"!==e.type));return r},Gc.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(Cd(e[n],t,{strict:!0})){r.push(e[n]),Sd(e[n+1])&&r.push(e[n+1]);break}if(0===r.length)throw new TypeError("no matching codec found")}else r.push(e[0]),Sd(e[1])&&r.push(e[1]);return r},Gc.generateProbatorRtpParameters=function(e){gd(e=md.clone(e));const t={mid:"probator",codecs:[],headerExtensions:[],encodings:[{ssrc:1234}],rtcp:{cname:"probator"}};return t.codecs.push(e.codecs[0]),t.codecs[0].payloadType=127,t.headerExtensions=e.headerExtensions,t},Gc.canSend=function(e,t){return(t.codecs??[]).some((t=>t.kind===e))},Gc.canReceive=function(e,t){if(gd(e),0===e.codecs.length)return!1;const r=e.codecs[0];return(t.codecs??[]).some((e=>e.preferredPayloadType===r.payloadType))};const fd=Yc,md=zc;function gd(e){if("object"!=typeof e)throw new TypeError("params is not an object");if(e.mid&&"string"!=typeof e.mid)throw new TypeError("params.mid is not a string");if(!Array.isArray(e.codecs))throw new TypeError("missing params.codecs");for(const t of e.codecs)bd(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("params.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)Ed(t);if(e.encodings&&!Array.isArray(e.encodings))throw new TypeError("params.encodings is not an array");e.encodings||(e.encodings=[]);for(const t of e.encodings)wd(t);if(e.rtcp&&"object"!=typeof e.rtcp)throw new TypeError("params.rtcp is not an object");e.rtcp||(e.rtcp={}),function(e){if("object"!=typeof e)throw new TypeError("rtcp is not an object");if(e.cname&&"string"!=typeof e.cname)throw new TypeError("invalid rtcp.cname");e.reducedSize&&"boolean"==typeof e.reducedSize||(e.reducedSize=!0)}(e.rtcp)}function vd(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if(e.kind=r[1].toLowerCase(),"number"!=typeof e.preferredPayloadType)throw new TypeError("missing codec.preferredPayloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===e.kind?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)yd(t)}function yd(e){if("object"!=typeof e)throw new TypeError("fb is not an object");if(!e.type||"string"!=typeof e.type)throw new TypeError("missing fb.type");e.parameter&&"string"==typeof e.parameter||(e.parameter="")}function _d(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if("audio"!==e.kind&&"video"!==e.kind)throw new TypeError("invalid ext.kind");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.preferredId)throw new TypeError("missing ext.preferredId");if(e.preferredEncrypt&&"boolean"!=typeof e.preferredEncrypt)throw new TypeError("invalid ext.preferredEncrypt");if(e.preferredEncrypt||(e.preferredEncrypt=!1),e.direction&&"string"!=typeof e.direction)throw new TypeError("invalid ext.direction");e.direction||(e.direction="sendrecv")}function bd(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if("number"!=typeof e.payloadType)throw new TypeError("missing codec.payloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===r[1].toLowerCase()?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)yd(t)}function Ed(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.id)throw new TypeError("missing ext.id");if(e.encrypt&&"boolean"!=typeof e.encrypt)throw new TypeError("invalid ext.encrypt");e.encrypt||(e.encrypt=!1),e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError("invalid header extension parameter")}}function wd(e){if("object"!=typeof e)throw new TypeError("encoding is not an object");if(e.ssrc&&"number"!=typeof e.ssrc)throw new TypeError("invalid encoding.ssrc");if(e.rid&&"string"!=typeof e.rid)throw new TypeError("invalid encoding.rid");if(e.rtx&&"object"!=typeof e.rtx)throw new TypeError("invalid encoding.rtx");if(e.rtx&&"number"!=typeof e.rtx.ssrc)throw new TypeError("missing encoding.rtx.ssrc");if(e.dtx&&"boolean"==typeof e.dtx||(e.dtx=!1),e.scalabilityMode&&"string"!=typeof e.scalabilityMode)throw new TypeError("invalid encoding.scalabilityMode")}function Sd(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function Cd(e,t,{strict:r=!1,modify:n=!1}={}){const i=e.mimeType.toLowerCase();if(i!==t.mimeType.toLowerCase())return!1;if(e.clockRate!==t.clockRate)return!1;if(e.channels!==t.channels)return!1;switch(i){case"video/h264":if(r){if((e.parameters["packetization-mode"]??0)!==(t.parameters["packetization-mode"]??0))return!1;if(!fd.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=fd.generateProfileLevelIdStringForAnswer(e.parameters,t.parameters)}catch(e){return!1}n&&(r?(e.parameters["profile-level-id"]=r,t.parameters["profile-level-id"]=r):(delete e.parameters["profile-level-id"],delete t.parameters["profile-level-id"]))}break;case"video/vp9":if(r){if((e.parameters["profile-id"]??0)!==(t.parameters["profile-id"]??0))return!1}}return!0}function Pd(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function Td(e,t){const r=[];for(const n of e.rtcpFeedback??[]){const e=(t.rtcpFeedback??[]).find((e=>e.type===n.type&&(e.parameter===n.parameter||!e.parameter&&!n.parameter)));e&&r.push(e)}return r}var kd={},Rd={},Id={},Dd={};Object.defineProperty(Dd,"__esModule",{value:!0}),Dd.Logger=void 0;const Ad=Qa.exports,Od="awaitqueue";Dd.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=Ad(`awaitqueue:${e}`),this._warn=Ad(`awaitqueue:WARN:${e}`),this._error=Ad(`awaitqueue:ERROR:${e}`)):(this._debug=Ad(Od),this._warn=Ad("awaitqueue:WARN"),this._error=Ad("awaitqueue:ERROR")),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};var Nd={};Object.defineProperty(Nd,"__esModule",{value:!0}),Nd.AwaitQueueRemovedTaskError=Nd.AwaitQueueStoppedError=void 0;class Md extends Error{constructor(e){super(e??"queue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Md)}}Nd.AwaitQueueStoppedError=Md;class Ld extends Error{constructor(e){super(e??"queue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ld)}}Nd.AwaitQueueRemovedTaskError=Ld,Object.defineProperty(Id,"__esModule",{value:!0}),Id.AwaitQueue=void 0;const xd=Nd,Fd=new Dd.Logger("AwaitQueue");Id.AwaitQueue=class{pendingTasks=new Map;nextTaskId=0;stopping=!1;constructor(){Fd.debug("constructor()")}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,Fd.debug(`push() [name:${t}]`),"function"!=typeof e)throw new TypeError("given task is not a function");if(t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={id:this.nextTaskId++,task:e,name:t,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:e=>{if(i.completed)return;i.completed=!0,this.pendingTasks.delete(i.id),Fd.debug(`resolving task [name:${i.name}]`),r(e);const[t]=this.pendingTasks.values();t&&!t.executedAt&&this.execute(t)},reject:e=>{if(!i.completed&&(i.completed=!0,this.pendingTasks.delete(i.id),Fd.debug(`rejecting task [name:${i.name}]: %s`,String(e)),n(e),!this.stopping)){const[e]=this.pendingTasks.values();e&&!e.executedAt&&this.execute(e)}}};this.pendingTasks.set(i.id,i),1===this.pendingTasks.size&&this.execute(i)}))}stop(){Fd.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Fd.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new xd.AwaitQueueStoppedError);this.stopping=!1}remove(e){Fd.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new xd.AwaitQueueRemovedTaskError):Fd.debug(`stop() | no task with given idx [taskIdx:${e}]`)}dump(){const e=Date.now();let t=0;return Array.from(this.pendingTasks.values()).map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt-r.enqueuedAt:e-r.enqueuedAt,executionTime:r.executedAt?e-r.executedAt:0})))}async execute(e){if(Fd.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const t=await e.task();e.resolve(t)}catch(t){e.reject(t)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AwaitQueueRemovedTaskError=e.AwaitQueueStoppedError=e.AwaitQueue=void 0;var t=Id;Object.defineProperty(e,"AwaitQueue",{enumerable:!0,get:function(){return t.AwaitQueue}});var r=Nd;Object.defineProperty(e,"AwaitQueueStoppedError",{enumerable:!0,get:function(){return r.AwaitQueueStoppedError}}),Object.defineProperty(e,"AwaitQueueRemovedTaskError",{enumerable:!0,get:function(){return r.AwaitQueueRemovedTaskError}})}(Rd);var jd={};Object.defineProperty(jd,"__esModule",{value:!0}),jd.Producer=void 0;const Ud=Sc,Bd=Wc,Vd=new _c.Logger("Producer");class Wd extends Ud.EnhancedEventEmitter{_id;_localId;_closed=!1;_rtpSender;_track;_kind;_rtpParameters;_paused;_maxSpatialLayer;_stopTracks;_disableTrackOnPause;_zeroRtpOnPause;_appData;_observer=new Ud.EnhancedEventEmitter;constructor({id:e,localId:t,rtpSender:r,track:n,rtpParameters:i,stopTracks:s,disableTrackOnPause:o,zeroRtpOnPause:a,appData:c}){super(),Vd.debug("constructor()"),this._id=e,this._localId=t,this._rtpSender=r,this._track=n,this._kind=n.kind,this._rtpParameters=i,this._paused=!!o&&!n.enabled,this._maxSpatialLayer=void 0,this._stopTracks=s,this._disableTrackOnPause=o,this._zeroRtpOnPause=a,this._appData=c??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get closed(){return this._closed}get kind(){return this._kind}get rtpSender(){return this._rtpSender}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get maxSpatialLayer(){return this._maxSpatialLayer}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Vd.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(Vd.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Bd.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Vd.debug("pause()"),this._closed?Vd.error("pause() | Producer closed"):(this._paused=!0,this._track&&this._disableTrackOnPause&&(this._track.enabled=!1),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@pause",e,t)})).catch((()=>{})),this._observer.safeEmit("pause"))}resume(){Vd.debug("resume()"),this._closed?Vd.error("resume() | Producer closed"):(this._paused=!1,this._track&&this._disableTrackOnPause&&(this._track.enabled=!0),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@resume",e,t)})).catch((()=>{})),this._observer.safeEmit("resume"))}async replaceTrack({track:e}){if(Vd.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new Bd.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new Bd.InvalidStateError("track ended");e!==this._track?(await new Promise(((t,r)=>{this.safeEmit("@replacetrack",e,t,r)})),this.destroyTrack(),this._track=e,this._track&&this._disableTrackOnPause&&(this._paused?this._paused&&(this._track.enabled=!1):this._track.enabled=!0),this.handleTrack()):Vd.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new Bd.InvalidStateError("closed");if("video"!==this._kind)throw new Bd.UnsupportedError("not a video Producer");if("number"!=typeof e)throw new TypeError("invalid spatialLayer");e!==this._maxSpatialLayer&&(await new Promise(((t,r)=>{this.safeEmit("@setmaxspatiallayer",e,t,r)})).catch((()=>{})),this._maxSpatialLayer=e)}async setRtpEncodingParameters(e){if(this._closed)throw new Bd.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){Vd.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track&&this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){if(this._track)try{this._track.removeEventListener("ended",this.onTrackEnded),this._stopTracks&&this._track.stop()}catch(e){}}}jd.Producer=Wd;var Hd={};Object.defineProperty(Hd,"__esModule",{value:!0}),Hd.Consumer=void 0;const qd=Sc,zd=Wc,Gd=new _c.Logger("Consumer");class Yd extends qd.EnhancedEventEmitter{_id;_localId;_producerId;_closed=!1;_rtpReceiver;_track;_rtpParameters;_paused;_appData;_observer=new qd.EnhancedEventEmitter;constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),Gd.debug("constructor()"),this._id=e,this._localId=t,this._producerId=r,this._rtpReceiver=n,this._track=i,this._rtpParameters=s,this._paused=!i.enabled,this._appData=o??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get producerId(){return this._producerId}get closed(){return this._closed}get kind(){return this._track.kind}get rtpReceiver(){return this._rtpReceiver}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Gd.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(Gd.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new zd.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Gd.debug("pause()"),this._closed?Gd.error("pause() | Consumer closed"):this._paused?Gd.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){Gd.debug("resume()"),this._closed?Gd.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):Gd.debug("resume() | Consumer is already resumed")}onTrackEnded(){Gd.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){try{this._track.removeEventListener("ended",this.onTrackEnded),this._track.stop()}catch(e){}}}Hd.Consumer=Yd;var $d={};Object.defineProperty($d,"__esModule",{value:!0}),$d.DataProducer=void 0;const Jd=Sc,Kd=Wc,Qd=new _c.Logger("DataProducer");class Zd extends Jd.EnhancedEventEmitter{_id;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new Jd.EnhancedEventEmitter;constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),Qd.debug("constructor()"),this._id=e,this._dataChannel=t,this._sctpStreamParameters=r,this._appData=n??{},this.handleDataChannel()}get id(){return this._id}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get bufferedAmount(){return this._dataChannel.bufferedAmount}get bufferedAmountLowThreshold(){return this._dataChannel.bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._dataChannel.bufferedAmountLowThreshold=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Qd.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(Qd.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(Qd.debug("send()"),this._closed)throw new Kd.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(Qd.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;const t=e.error??new Error("unknown DataChannel error");"sctp-failure"===e.error?.errorDetail?Qd.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",e.error?.sctpCauseCode,e.error.message):Qd.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(Qd.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||Qd.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}$d.DataProducer=Zd;var Xd={};Object.defineProperty(Xd,"__esModule",{value:!0}),Xd.DataConsumer=void 0;const eu=Sc,tu=new _c.Logger("DataConsumer");class ru extends eu.EnhancedEventEmitter{_id;_dataProducerId;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new eu.EnhancedEventEmitter;constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),tu.debug("constructor()"),this._id=e,this._dataProducerId=t,this._dataChannel=r,this._sctpStreamParameters=n,this._appData=i??{},this.handleDataChannel()}get id(){return this._id}get dataProducerId(){return this._dataProducerId}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get binaryType(){return this._dataChannel.binaryType}set binaryType(e){this._dataChannel.binaryType=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(tu.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(tu.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(tu.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;const t=e.error??new Error("unknown DataChannel error");"sctp-failure"===e.error?.errorDetail?tu.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",e.error?.sctpCauseCode,e.error.message):tu.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(tu.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(e=>{this._closed||this.safeEmit("message",e.data)}))}}Xd.DataConsumer=ru,Object.defineProperty(kd,"__esModule",{value:!0}),kd.Transport=void 0;const nu=Rd,iu=Sc,su=Wc,ou=zc,au=Gc,cu=jd,du=Hd,uu=$d,lu=Xd,pu=new _c.Logger("Transport");class hu{consumerOptions;promise;resolve;reject;constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class fu extends iu.EnhancedEventEmitter{_id;_closed=!1;_direction;_getSendExtendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind;_maxSctpMessageSize;_handler;_iceGatheringState="new";_connectionState="new";_appData;_producers=new Map;_consumers=new Map;_dataProducers=new Map;_dataConsumers=new Map;_probatorConsumerCreated=!1;_awaitQueue=new nu.AwaitQueue;_pendingConsumerTasks=[];_consumerCreationInProgress=!1;_pendingPauseConsumers=new Map;_consumerPauseInProgress=!1;_pendingResumeConsumers=new Map;_consumerResumeInProgress=!1;_pendingCloseConsumers=new Map;_consumerCloseInProgress=!1;_observer=new iu.EnhancedEventEmitter;constructor({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d,handlerFactory:u,getSendExtendedRtpCapabilities:l,recvRtpCapabilities:p,canProduceByKind:h}){super(),pu.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._getSendExtendedRtpCapabilities=l,this._recvRtpCapabilities=p,this._canProduceByKind=h,this._maxSctpMessageSize=s?s.maxMessageSize:null;const f=ou.clone(c)??{};delete f.iceServers,delete f.iceTransportPolicy,delete f.bundlePolicy,delete f.rtcpMuxPolicy,this._handler=u.factory({direction:e,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:f,getSendExtendedRtpCapabilities:this._getSendExtendedRtpCapabilities}),this._appData=d??{},this.handleHandler()}get id(){return this._id}get closed(){return this._closed}get direction(){return this._direction}get handler(){return this._handler}get iceGatheringState(){return this._iceGatheringState}get connectionState(){return this._connectionState}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){if(!this._closed){pu.debug("close()"),this._closed=!0,this._awaitQueue.stop(),this._handler.close(),this._connectionState="closed";for(const e of this._producers.values())e.transportClosed();this._producers.clear();for(const e of this._consumers.values())e.transportClosed();this._consumers.clear();for(const e of this._dataProducers.values())e.transportClosed();this._dataProducers.clear();for(const e of this._dataConsumers.values())e.transportClosed();this._dataConsumers.clear(),this._observer.safeEmit("close"),super.close(),this._observer.close()}}async getStats(){if(this._closed)throw new su.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(pu.debug("restartIce()"),this._closed)throw new su.InvalidStateError("closed");if(!e)throw new TypeError("missing iceParameters");return this._awaitQueue.push((async()=>await this._handler.restartIce(e)),"transport.restartIce()")}async updateIceServers({iceServers:e}={}){if(pu.debug("updateIceServers()"),this._closed)throw new su.InvalidStateError("closed");if(!Array.isArray(e))throw new TypeError("missing iceServers");return this._awaitQueue.push((async()=>this._handler.updateIceServers(e)),"transport.updateIceServers()")}async produce({track:e,encodings:t,codecOptions:r,codec:n,stopTracks:i=!0,disableTrackOnPause:s=!0,zeroRtpOnPause:o=!1,onRtpSender:a,appData:c={}}={}){if(pu.debug("produce() [track:%o]",e),this._closed)throw new su.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new su.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new su.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new su.InvalidStateError("track ended");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("produce"))throw new TypeError('no "produce" listener set into this transport');if(c&&"object"!=typeof c)throw new TypeError("if given, appData must be an object");return this._awaitQueue.push((async()=>{let d;if(t&&!Array.isArray(t))throw TypeError("encodings must be an array");t&&0===t.length?d=void 0:t&&(d=t.map((e=>{const t={active:!0};return!1===e.active&&(t.active=!1),"boolean"==typeof e.dtx&&(t.dtx=e.dtx),"string"==typeof e.scalabilityMode&&(t.scalabilityMode=e.scalabilityMode),"number"==typeof e.scaleResolutionDownBy&&(t.scaleResolutionDownBy=e.scaleResolutionDownBy),"number"==typeof e.maxBitrate&&(t.maxBitrate=e.maxBitrate),"number"==typeof e.maxFramerate&&(t.maxFramerate=e.maxFramerate),"boolean"==typeof e.adaptivePtime&&(t.adaptivePtime=e.adaptivePtime),"string"==typeof e.priority&&(t.priority=e.priority),"string"==typeof e.networkPriority&&(t.networkPriority=e.networkPriority),t})));const{localId:u,rtpParameters:l,rtpSender:p}=await this._handler.send({track:e,encodings:d,codecOptions:r,codec:n,onRtpSender:a});try{au.validateAndNormalizeRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new cu.Producer({id:t,localId:u,rtpSender:p,track:e,rtpParameters:l,stopTracks:i,disableTrackOnPause:s,zeroRtpOnPause:o,appData:c});return this._producers.set(r.id,r),this.handleProducer(r),this._observer.safeEmit("newproducer",r),r}catch(e){throw this._handler.stopSending(u).catch((()=>{})),e}}),"transport.produce()").catch((t=>{if(i)try{e.stop()}catch(e){}throw t}))}async consume({id:e,producerId:t,kind:r,rtpParameters:n,streamId:i,onRtpReceiver:s,appData:o={}}){if(pu.debug("consume()"),this._closed)throw new su.InvalidStateError("closed");if("recv"!==this._direction)throw new su.UnsupportedError("not a receiving Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing producerId");if("audio"!==r&&"video"!==r)throw new TypeError(`invalid kind '${r}'`);if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(o&&"object"!=typeof o)throw new TypeError("if given, appData must be an object");const a=ou.clone(n);if(!au.canReceive(a,this._recvRtpCapabilities))throw new su.UnsupportedError("cannot consume this Producer");const c=new hu({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),queueMicrotask((()=>{this._closed||!1===this._consumerCreationInProgress&&this.createPendingConsumers()})),c.promise}async produceData({ordered:e=!0,maxPacketLifeTime:t,maxRetransmits:r,label:n="",protocol:i="",appData:s={}}={}){if(pu.debug("produceData()"),this._closed)throw new su.InvalidStateError("closed");if("send"!==this._direction)throw new su.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new su.UnsupportedError("SCTP not enabled by remote Transport");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("producedata"))throw new TypeError('no "producedata" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");return(t||r)&&(e=!1),this._awaitQueue.push((async()=>{const{dataChannel:o,sctpStreamParameters:a}=await this._handler.sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i});au.validateAndNormalizeSctpStreamParameters(a);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:a,label:n,protocol:i,appData:s},e,t)})),d=new uu.DataProducer({id:c,dataChannel:o,sctpStreamParameters:a,appData:s});return this._dataProducers.set(d.id,d),this.handleDataProducer(d),this._observer.safeEmit("newdataproducer",d),d}),"transport.produceData()")}async consumeData({id:e,dataProducerId:t,sctpStreamParameters:r,label:n="",protocol:i="",appData:s={}}){if(pu.debug("consumeData()"),this._closed)throw new su.InvalidStateError("closed");if("recv"!==this._direction)throw new su.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new su.UnsupportedError("SCTP not enabled by remote Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing dataProducerId");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");const o=ou.clone(r);return au.validateAndNormalizeSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new lu.DataConsumer({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:o,appData:s});return this._dataConsumers.set(a.id,a),this.handleDataConsumer(a),this._observer.safeEmit("newdataconsumer",a),a}),"transport.consumeData()")}createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void pu.debug("createPendingConsumers() | there is no Consumer to be created");const e=[...this._pendingConsumerTasks];let t;this._pendingConsumerTasks=[];const r=[];for(const t of e){const{id:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o}=t.consumerOptions;r.push({trackId:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o})}try{const n=await this._handler.receive(r);for(let r=0;r<n.length;++r){const i=e[r],s=n[r],{id:o,producerId:a,kind:c,rtpParameters:d,appData:u}=i.consumerOptions,{localId:l,rtpReceiver:p,track:h}=s,f=new du.Consumer({id:o,localId:l,producerId:a,rtpReceiver:p,track:h,rtpParameters:d,appData:u});this._consumers.set(f.id,f),this.handleConsumer(f),this._probatorConsumerCreated||t||"video"!==c||(t=f),this._observer.safeEmit("newconsumer",f),i.resolve(f)}}catch(t){for(const r of e)r.reject(t)}if(t)try{const e=au.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),pu.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){pu.error("createPendingConsumers() | failed to create Consumer for RTP probation:%o",e)}}),"transport.createPendingConsumers()").then((()=>{this._consumerCreationInProgress=!1,this._pendingConsumerTasks.length>0&&this.createPendingConsumers()})).catch((()=>{}))}pausePendingConsumers(){this._consumerPauseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingPauseConsumers.size)return void pu.debug("pausePendingConsumers() | there is no Consumer to be paused");const e=Array.from(this._pendingPauseConsumers.values());this._pendingPauseConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.pauseReceiving(t)}catch(e){pu.error("pausePendingConsumers() | failed to pause Consumers:",e)}}),"transport.pausePendingConsumers").then((()=>{this._consumerPauseInProgress=!1,this._pendingPauseConsumers.size>0&&this.pausePendingConsumers()})).catch((()=>{}))}resumePendingConsumers(){this._consumerResumeInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingResumeConsumers.size)return void pu.debug("resumePendingConsumers() | there is no Consumer to be resumed");const e=Array.from(this._pendingResumeConsumers.values());this._pendingResumeConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.resumeReceiving(t)}catch(e){pu.error("resumePendingConsumers() | failed to resume Consumers:",e)}}),"transport.resumePendingConsumers").then((()=>{this._consumerResumeInProgress=!1,this._pendingResumeConsumers.size>0&&this.resumePendingConsumers()})).catch((()=>{}))}closePendingConsumers(){this._consumerCloseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingCloseConsumers.size)return void pu.debug("closePendingConsumers() | there is no Consumer to be closed");const e=Array.from(this._pendingCloseConsumers.values());this._pendingCloseConsumers.clear();try{await this._handler.stopReceiving(e.map((e=>e.localId)))}catch(e){pu.error("closePendingConsumers() | failed to close Consumers:",e)}}),"transport.closePendingConsumers").then((()=>{this._consumerCloseInProgress=!1,this._pendingCloseConsumers.size>0&&this.closePendingConsumers()})).catch((()=>{}))}handleHandler(){const e=this._handler;e.on("@connect",(({dtlsParameters:e},t,r)=>{this._closed?r(new su.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(pu.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@icecandidateerror",(e=>{pu.warn(`ICE candidate error [url:${e.url}, localAddress:${e.address}, localPort:${e.port}]: ${e.errorCode} "${e.errorText}"`),this.safeEmit("icecandidateerror",e)})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(pu.debug("connection state changed to %s",e),this._connectionState=e,this._closed||this.safeEmit("connectionstatechange",e))}))}handleProducer(e){e.on("@close",(()=>{this._producers.delete(e.id),this._closed||this._awaitQueue.push((async()=>await this._handler.stopSending(e.localId)),"producer @close event").catch((e=>pu.warn("producer.close() failed:%o",e)))})),e.on("@pause",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.pauseSending(e.localId)),"producer @pause event").then(t).catch(r)})),e.on("@resume",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.resumeSending(e.localId)),"producer @resume event").then(t).catch(r)})),e.on("@replacetrack",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.replaceTrack(e.localId,t)),"producer @replacetrack event").then(r).catch(n)})),e.on("@setmaxspatiallayer",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setMaxSpatialLayer(e.localId,t)),"producer @setmaxspatiallayer event").then(r).catch(n)})),e.on("@setrtpencodingparameters",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setRtpEncodingParameters(e.localId,t)),"producer @setrtpencodingparameters event").then(r).catch(n)})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new su.InvalidStateError("closed"));this._handler.getSenderStats(e.localId).then(t).catch(r)}))}handleConsumer(e){e.on("@close",(()=>{this._consumers.delete(e.id),this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.delete(e.id),this._closed||(this._pendingCloseConsumers.set(e.id,e),!1===this._consumerCloseInProgress&&this.closePendingConsumers())})),e.on("@pause",(()=>{this._pendingResumeConsumers.has(e.id)&&this._pendingResumeConsumers.delete(e.id),this._pendingPauseConsumers.set(e.id,e),queueMicrotask((()=>{this._closed||!1===this._consumerPauseInProgress&&this.pausePendingConsumers()}))})),e.on("@resume",(()=>{this._pendingPauseConsumers.has(e.id)&&this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.set(e.id,e),queueMicrotask((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new su.InvalidStateError("closed"));this._handler.getReceiverStats(e.localId).then(t).catch(r)}))}handleDataProducer(e){e.on("@close",(()=>{this._dataProducers.delete(e.id)}))}handleDataConsumer(e){e.on("@close",(()=>{this._dataConsumers.delete(e.id)}))}}kd.Transport=fu;var mu={},gu={},vu={},yu={exports:{}},_u=yu.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(_u).forEach((function(e){_u[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var s=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(r[n[s]]=t(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&r[e.push].push(s)},n=yu.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},s=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),o=s[s.length-1]);for(var a=0;a<(n[t]||[]).length;a+=1){var c=n[t][a];if(c.reg.test(i))return r(c,o,i)}})),t.media=s,t};var s=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(s,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(vu);var bu=yu.exports,Eu=/%[sdv%]/g,wu=function(e){var t=1,r=arguments,n=r.length;return e.replace(Eu,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},Su=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var s=t.names[i];t.name?n.push(r[t.name][s]):n.push(r[t.names[i]])}else n.push(r[t.name]);return wu.apply(null,n)},Cu=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Pu=["i","c","b","a"],Tu=vu,ku=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||Cu,n=t.innerOrder||Pu,i=[];return r.forEach((function(t){bu[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Su(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Su(t,r,e))}))}))})),e.media.forEach((function(e){i.push(Su("m",bu.m[0],e)),n.forEach((function(t){bu[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Su(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Su(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},Ru=yu.exports;gu.grammar=Ru,gu.write=ku,gu.parse=Tu.parse,gu.parseParams=Tu.parseParams,gu.parseFmtpConfig=Tu.parseFmtpConfig,gu.parsePayloads=Tu.parsePayloads,gu.parseRemoteCandidates=Tu.parseRemoteCandidates,gu.parseImageAttributes=Tu.parseImageAttributes,gu.parseSimulcastStreamList=Tu.parseSimulcastStreamList;var Iu={};Object.defineProperty(Iu,"__esModule",{value:!0}),Iu.parse=function(e){const t=Du.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const Du=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var Au={};Object.defineProperty(Au,"__esModule",{value:!0}),Au.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=new Map;for(const n of e.media){const e=n.type;switch(e){case"audio":case"video":break;default:continue}for(const r of n.rtp){const n={kind:e,mimeType:`${e}/${r.codec}`,preferredPayloadType:r.payload,clockRate:r.rate,channels:r.encoding,parameters:{},rtcpFeedback:[]};t.set(n.preferredPayloadType,n)}for(const e of n.fmtp??[]){const r=Ou.parseParams(e.config),n=t.get(e.payload);n&&(r?.hasOwnProperty("profile-level-id")&&(r["profile-level-id"]=String(r["profile-level-id"])),n.parameters=r)}for(const r of n.rtcpFb??[]){const n={type:r.type,parameter:r.subtype};if(n.parameter||delete n.parameter,"*"!==r.payload){const e=t.get(Number(r.payload));if(!e)continue;e.rtcpFeedback.push(n)}else for(const r of t.values())r.kind!==e||/.+\/rtx$/i.test(r.mimeType)||r.rtcpFeedback.push(n)}for(const t of n.ext??[]){if(t["encrypt-uri"])continue;const n={kind:e,uri:t.uri,preferredId:t.value};r.set(n.preferredId,n)}}return{codecs:Array.from(t.values()),headerExtensions:Array.from(r.values())}},Au.extractDtlsParameters=function({sdpObject:e}){let t,r=e.setup,n=e.fingerprint;if(!r||!n){const t=(e.media??[]).find((e=>0!==e.port));t&&(r??=t.setup,n??=t.fingerprint)}if(!r)throw new Error("no a=setup found at SDP session or media level");if(!n)throw new Error("no a=fingerprint found at SDP session or media level");switch(r){case"active":t="client";break;case"passive":t="server";break;case"actpass":t="auto"}return{role:t,fingerprints:[{algorithm:n.type,value:n.hash}]}},Au.getCname=function({offerMediaObject:e}){const t=(e.ssrcs??[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},Au.applyCodecParameters=function({offerRtpParameters:e,answerMediaObject:t}){for(const r of e.codecs){const e=r.mimeType.toLowerCase();if("audio/opus"!==e)continue;const n=(t.rtp??[]).find((e=>e.payload===r.payloadType));if(!n)continue;t.fmtp=t.fmtp??[];let i=t.fmtp.find((e=>e.payload===r.payloadType));i||(i={payload:r.payloadType,config:""},t.fmtp.push(i));const s=Ou.parseParams(i.config);switch(e){case"audio/opus":{const e=r.parameters?.["sprop-stereo"];void 0!==e&&(s.stereo=Number(e)?1:0);break}}i.config="";for(const e of Object.keys(s))i.config&&(i.config+=";"),i.config+=`${e}=${s[e]}`}};const Ou=gu;var Nu={};Object.defineProperty(Nu,"__esModule",{value:!0}),Nu.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs??[]){const e=r.id;e&&t.add(e)}if(0===t.size)throw new Error("no a=ssrc lines found");const r=new Map;for(const n of e.ssrcGroups??[]){if("FID"!==n.semantics)continue;const e=n.ssrcs.split(/\s+/),i=Number(e[0]),s=Number(e[1]);t.has(i)&&(t.delete(i),t.delete(s),r.set(i,s))}for(const e of t)r.set(e,void 0);const n=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),n.push(r)}return n},Nu.addLegacySimulcast=function({offerMediaObject:e,numStreams:t}){if(t<=1)throw new TypeError("numStreams must be greater than 1");const r=(e.ssrcs??[]).find((e=>"msid"===e.attribute));if(!r)throw new Error("a=ssrc line with msid information not found");const[n,i]=r.value.split(" "),s=Number(r.id);let o;(e.ssrcGroups??[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===s&&(o=Number(t[1]),!0)}));const a=(e.ssrcs??[]).find((e=>"cname"===e.attribute));if(!a)throw new Error("a=ssrc line with cname information not found");const c=a.value,d=[],u=[];for(let e=0;e<t;++e)d.push(s+e),o&&u.push(o+e);e.ssrcGroups=[],e.ssrcs=[],e.ssrcGroups.push({semantics:"SIM",ssrcs:d.join(" ")});for(const t of d)e.ssrcs.push({id:t,attribute:"cname",value:c}),e.ssrcs.push({id:t,attribute:"msid",value:`${n} ${i}`});for(let t=0;t<u.length;++t){const r=d[t],s=u[t];e.ssrcs.push({id:s,attribute:"cname",value:c}),e.ssrcs.push({id:s,attribute:"msid",value:`${n} ${i}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${r} ${s}`})}};var Mu={};Object.defineProperty(Mu,"__esModule",{value:!0}),Mu.addNackSupportForOpus=function(e){for(const t of e.codecs??[])"audio/opus"!==t.mimeType.toLowerCase()&&"audio/multiopus"!==t.mimeType.toLowerCase()||t.rtcpFeedback?.some((e=>"nack"===e.type&&!e.parameter))||(t.rtcpFeedback||(t.rtcpFeedback=[]),t.rtcpFeedback.push({type:"nack"}))};var Lu={},xu={};Object.defineProperty(xu,"__esModule",{value:!0}),xu.OfferMediaSection=xu.AnswerMediaSection=xu.MediaSection=void 0;const Fu=gu,ju=zc;class Uu{_mediaObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r}){if(this._mediaObject={type:"",port:0,protocol:"",payloads:"",rtp:[],fmtp:[]},e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={foundation:e.foundation,component:1,ip:e.address??e.ip,port:e.port,priority:e.priority,transport:e.protocol,type:e.type};e.tcpType&&(t.tcptype=e.tcpType),this._mediaObject.candidates.push(t)}this._mediaObject.endOfCandidates="end-of-candidates",this._mediaObject.iceOptions="renomination"}r&&this.setDtlsRole(r.role)}get mid(){return String(this._mediaObject.mid)}get closed(){return 0===this._mediaObject.port}getObject(){return this._mediaObject}setIceParameters(e){this._mediaObject.iceUfrag=e.usernameFragment,this._mediaObject.icePwd=e.password}pause(){this._mediaObject.direction="inactive"}disable(){this.pause(),delete this._mediaObject.ext,delete this._mediaObject.ssrcs,delete this._mediaObject.ssrcGroups,delete this._mediaObject.simulcast,delete this._mediaObject.simulcast_03,delete this._mediaObject.rids,delete this._mediaObject.extmapAllowMixed}close(){this.disable(),this._mediaObject.port=0}}xu.MediaSection=Uu;xu.AnswerMediaSection=class extends Uu{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,offerMediaObject:s,offerRtpParameters:o,answerRtpParameters:a,codecOptions:c}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r}),this._mediaObject.mid=String(s.mid),this._mediaObject.type=s.type,this._mediaObject.protocol=s.protocol,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.port=7),s.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of a.codecs){const t={payload:e.payloadType,codec:Bu(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=ju.clone(e.parameters)??{};let n=ju.clone(e.rtcpFeedback)??[];if(c){const{opusStereo:t,opusFec:i,opusDtx:s,opusMaxPlaybackRate:a,opusMaxAverageBitrate:d,opusPtime:u,opusNack:l,videoGoogleStartBitrate:p,videoGoogleMaxBitrate:h,videoGoogleMinBitrate:f}=c,m=o.codecs.find((t=>t.payloadType===e.payloadType));switch(e.mimeType.toLowerCase()){case"audio/opus":case"audio/multiopus":void 0!==t&&(m.parameters["sprop-stereo"]=t?1:0,r.stereo=t?1:0),void 0!==i&&(m.parameters.useinbandfec=i?1:0,r.useinbandfec=i?1:0),void 0!==s&&(m.parameters.usedtx=s?1:0,r.usedtx=s?1:0),void 0!==a&&(r.maxplaybackrate=a),void 0!==d&&(r.maxaveragebitrate=d),void 0!==u&&(m.parameters.ptime=u,r.ptime=u),l||(m.rtcpFeedback=m.rtcpFeedback.filter((e=>"nack"!==e.type||e.parameter)),n=n.filter((e=>"nack"!==e.type||e.parameter)));break;case"video/vp8":case"video/vp9":case"video/h264":case"video/h265":case"video/av1":void 0!==p&&(r["x-google-start-bitrate"]=p),void 0!==h&&(r["x-google-max-bitrate"]=h),void 0!==f&&(r["x-google-min-bitrate"]=f)}}const i={payload:e.payloadType,config:""};for(const e of Object.keys(r))i.config&&(i.config+=";"),i.config+=`${e}=${r[e]}`;i.config&&this._mediaObject.fmtp.push(i);for(const t of n)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=a.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of a.headerExtensions){(s.ext??[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if("extmap-allow-mixed"===s.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),s.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:s.simulcast.list1},this._mediaObject.rids=[];for(const e of s.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(s.simulcast_03){this._mediaObject.simulcast_03={value:s.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of s.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";break;case"application":"number"==typeof s.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize):s.sctpmap&&(this._mediaObject.payloads=String(n.port),this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize})}}setDtlsRole(e){switch(e){case"client":this._mediaObject.setup="active";break;case"server":this._mediaObject.setup="passive";break;case"auto":this._mediaObject.setup="actpass"}}resume(){this._mediaObject.direction="recvonly"}muxSimulcastStreams(e){if(!this._mediaObject.simulcast?.list1)return;const t={};for(const r of e)r.rid&&(t[r.rid]=r);const r=this._mediaObject.simulcast.list1,n=Fu.parseSimulcastStreamList(r);for(const e of n)for(const r of e)r.paused=!t[r.scid]?.active;this._mediaObject.simulcast.list1=n.map((e=>e.map((e=>`${e.paused?"~":""}${e.scid}`)).join(","))).join(";")}};function Bu(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}xu.OfferMediaSection=class extends Uu{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,mid:s,kind:o,offerRtpParameters:a,streamId:c,trackId:d}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r}),this._mediaObject.mid=String(s),this._mediaObject.type=o,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.protocol="RTP/AVP",this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.protocol=n?"UDP/DTLS/SCTP":"UDP/TLS/RTP/SAVPF",this._mediaObject.port=7),this._mediaObject.extmapAllowMixed="extmap-allow-mixed",o){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._mediaObject.msid=`${c??"-"} ${d}`;for(const e of a.codecs){const t={payload:e.payloadType,codec:Bu(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r={payload:e.payloadType,config:""};for(const t of Object.keys(e.parameters??{}))r.config&&(r.config+=";"),r.config+=`${t}=${e.parameters[t]}`;r.config&&this._mediaObject.fmtp.push(r);for(const t of e.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=a.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of a.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=a.encodings[0],t=e.ssrc,r=e.rtx?.ssrc;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],t&&a.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:a.rtcp.cname}),r&&(a.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:a.rtcp.cname}),t&&this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize}}setDtlsRole(e){this._mediaObject.setup="actpass"}resume(){this._mediaObject.direction="sendonly"}},Object.defineProperty(Lu,"__esModule",{value:!0}),Lu.RemoteSdp=void 0;const Vu=gu,Wu=xu,Hu=["av1","h264"],qu=new _c.Logger("RemoteSdp");Lu.RemoteSdp=class{_iceParameters;_iceCandidates;_dtlsParameters;_sctpParameters;_plainRtpParameters;_mediaSections=[];_midToIndex=new Map;_firstMid;_sdpObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i}){if(this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=n,this._plainRtpParameters=i,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"10000",sessionVersion:0,username:"mediasoup-client"},name:"-",timing:{start:0,stop:0},media:[]},e?.iceLite&&(this._sdpObject.icelite="ice-lite"),r){this._sdpObject.msidSemantic={semantic:"WMS",token:"*"};const e=this._dtlsParameters.fingerprints.length;this._sdpObject.fingerprint={type:r.fingerprints[e-1].algorithm,hash:r.fingerprints[e-1].value},this._sdpObject.groups=[{type:"BUNDLE",mids:""}]}i&&(this._sdpObject.origin.address=i.ip,this._sdpObject.origin.ipVer=i.ipVersion)}updateIceParameters(e){qu.debug("updateIceParameters() [iceParameters:%o]",e),this._iceParameters=e,this._sdpObject.icelite=e.iceLite?"ice-lite":void 0;for(const t of this._mediaSections)t.setIceParameters(e)}updateDtlsRole(e){qu.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}setSessionExtmapAllowMixed(){qu.debug("setSessionExtmapAllowMixed()"),this._sdpObject.extmapAllowMixed="extmap-allow-mixed"}getNextMediaSectionIdx(){for(let e=0;e<this._mediaSections.length;++e){const t=this._mediaSections[e];if(t.closed)return{idx:e,reuseMid:t.mid}}return{idx:this._mediaSections.length}}send({offerMediaObject:e,reuseMid:t,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i}){const s=new Wu.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i}),o=s.getObject();o.rtp.find((e=>Hu.includes(e.codec.toLowerCase())))||(o.ext=o.ext?.filter((e=>"https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"!==e.uri))),t?this._replaceMediaSection(s,t):this._midToIndex.has(s.mid)?this._replaceMediaSection(s):this._addMediaSection(s)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}){this.setSessionExtmapAllowMixed();const s=new Wu.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}),o=this._mediaSections.find((e=>e.closed));o?this._replaceMediaSection(s,o.mid):this._addMediaSection(s)}pauseMediaSection(e){this._findMediaSection(e).pause()}resumeSendingMediaSection(e){this._findMediaSection(e).resume()}resumeReceivingMediaSection(e){this._findMediaSection(e).resume()}disableMediaSection(e){this._findMediaSection(e).disable()}closeMediaSection(e){const t=this._findMediaSection(e);return e===this._firstMid?(qu.debug("closeMediaSection() | cannot close first media section, disabling it instead [mid:%s]",e),this.disableMediaSection(e),!1):(t.close(),this._regenerateBundleMids(),!0)}muxMediaSectionSimulcast(e,t){const r=this._findMediaSection(e);r.muxSimulcastStreams(t),this._replaceMediaSection(r)}sendSctpAssociation({offerMediaObject:e}){const t=new Wu.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation(){const e=new Wu.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application"});this._addMediaSection(e)}getSdp(){return this._sdpObject.origin.sessionVersion++,Vu.write(this._sdpObject)}_addMediaSection(e){this._firstMid||(this._firstMid=e.mid),this._mediaSections.push(e),this._midToIndex.set(e.mid,this._mediaSections.length-1),this._sdpObject.media.push(e.getObject()),this._regenerateBundleMids()}_replaceMediaSection(e,t){if("string"==typeof t){const r=this._midToIndex.get(t);if(void 0===r)throw new Error(`no media section found for reuseMid '${t}'`);const n=this._mediaSections[r];this._mediaSections[r]=e,this._midToIndex.delete(n.mid),this._midToIndex.set(e.mid,r),this._sdpObject.media[r]=e.getObject(),this._regenerateBundleMids()}else{const t=this._midToIndex.get(e.mid);if(void 0===t)throw new Error(`no media section found with mid '${e.mid}'`);this._mediaSections[t]=e,this._sdpObject.media[t]=e.getObject()}}_findMediaSection(e){const t=this._midToIndex.get(e);if(void 0===t)throw new Error(`no media section found with mid '${e}'`);return this._mediaSections[t]}_regenerateBundleMids(){this._dtlsParameters&&(this._sdpObject.groups[0].mids=this._mediaSections.filter((e=>!e.closed)).map((e=>e.mid)).join(" "))}},Object.defineProperty(mu,"__esModule",{value:!0}),mu.Chrome111=void 0;const zu=gu,Gu=Sc,Yu=Gc,$u=Wc,Ju=Iu,Ku=Au,Qu=Nu,Zu=Mu,Xu=Lu,el=new _c.Logger("Chrome111"),tl={OS:1024,MIS:1024};class rl extends Gu.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Chrome111",factory:e=>new rl(e),getNativeRtpCapabilities:async()=>{el.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video",{sendEncodings:[{scalabilityMode:"L3T3"}]});const t=await e.createOffer();try{e.close()}catch(e){}e=void 0;const r=zu.parse(t.sdp);return rl.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(el.debug("getNativeSctpCapabilities()"),{numStreams:tl})}}static getLocalRtpCapabilities(e){const t=Ku.extractRtpCapabilities({sdpObject:e});return Yu.validateAndNormalizeRtpCapabilities(t),Zu.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),el.debug("constructor()"),this._direction=e,this._remoteSdp=new Xu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(el.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Chrome111"}close(){if(el.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),el.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),el.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});el.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};el.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();el.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){if(this.assertNotClosed(),this.assertSendDirection(),el.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1){let e=1;for(const r of t){const t=r.scalabilityMode?(0,Ju.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(o.sender);const a=await this._pc.createOffer();let c=zu.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=rl.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=Yu.getSendingRtpParameters(e.kind,u);l.codecs=Yu.reduceCodecs(l.codecs,n);const p=Yu.getSendingRemoteRtpParameters(e.kind,u);p.codecs=Yu.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c}),el.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const h=o.mid;l.mid=h,c=zu.parse(this._pc.localDescription.sdp);const f=c.media[s.idx];if(l.rtcp.cname=Ku.getCname({offerMediaObject:f}),t)if(1===t.length){const e=Qu.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),l.encodings=e}else l.encodings=t;else l.encodings=Qu.getRtpEncodings({offerMediaObject:f});this._remoteSdp.send({offerMediaObject:f,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return el.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),this._mapMidTransceiver.set(h,o),{localId:h,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),el.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();el.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),el.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();el.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),el.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();el.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?el.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):el.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),el.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();el.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),el.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();el.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};el.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%tl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=zu.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),el.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};el.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;el.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};el.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=zu.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ku.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:zu.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),el.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){el.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};el.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();el.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){el.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};el.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();el.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){el.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};el.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();el.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};el.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};el.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=zu.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}el.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=zu.parse(this._pc.localDescription.sdp));const r=Ku.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}};assertNotClosed(){if(this._closed)throw new $u.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}mu.Chrome111=rl;var nl={};Object.defineProperty(nl,"__esModule",{value:!0}),nl.Chrome74=void 0;const il=gu,sl=Sc,ol=Gc,al=Wc,cl=Iu,dl=Au,ul=Nu,ll=Mu,pl=Lu,hl=new _c.Logger("Chrome74"),fl={OS:1024,MIS:1024};class ml extends sl.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Chrome74",factory:e=>new ml(e),getNativeRtpCapabilities:async()=>{hl.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}e=void 0;const r=il.parse(t.sdp);return ml.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(hl.debug("getNativeSctpCapabilities()"),{numStreams:fl})}}static getLocalRtpCapabilities(e){const t=dl.extractRtpCapabilities({sdpObject:e});return ol.validateAndNormalizeRtpCapabilities(t),ll.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),hl.debug("constructor()"),this._direction=e,this._remoteSdp=new pl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(hl.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Chrome74"}close(){if(hl.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),hl.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),hl.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});hl.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};hl.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();hl.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),hl.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const i=this._remoteSdp.getNextMediaSectionIdx(),s=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let o=await this._pc.createOffer(),a=il.parse(o.sdp);a.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const c=ml.getLocalRtpCapabilities(a),d=this._getSendExtendedRtpCapabilities(c),u=ol.getSendingRtpParameters(e.kind,d);u.codecs=ol.reduceCodecs(u.codecs,n);const l=ol.getSendingRemoteRtpParameters(e.kind,d);l.codecs=ol.reduceCodecs(l.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a});let p=!1;const h=(0,cl.parse)((t??[{}])[0].scalabilityMode);let f;t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===u.codecs[0].mimeType.toLowerCase()&&(hl.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,a=il.parse(o.sdp),f=a.media[i.idx],ul.addLegacySimulcast({offerMediaObject:f,numStreams:h.spatialLayers}),o={type:"offer",sdp:il.write(a)}),hl.debug("send() | calling pc.setLocalDescription() [offer:%o]",o),await this._pc.setLocalDescription(o);const m=s.mid;if(u.mid=m,a=il.parse(this._pc.localDescription.sdp),f=a.media[i.idx],u.rtcp.cname=dl.getCname({offerMediaObject:f}),t)if(1===t.length){let e=ul.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),p&&(e=[e[0]]),u.encodings=e}else u.encodings=t;else u.encodings=ul.getRtpEncodings({offerMediaObject:f});if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const e of u.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${h.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:i.reuseMid,offerRtpParameters:u,answerRtpParameters:l,codecOptions:r});const g={type:"answer",sdp:this._remoteSdp.getSdp()};return hl.debug("send() | calling pc.setRemoteDescription() [answer:%o]",g),await this._pc.setRemoteDescription(g),this._mapMidTransceiver.set(m,s),{localId:m,rtpParameters:u,rtpSender:s.sender}}async stopSending(e){if(this.assertSendDirection(),hl.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();hl.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),hl.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();hl.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),hl.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();hl.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?hl.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):hl.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),hl.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();hl.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),hl.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();hl.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};hl.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%fl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=il.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),hl.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};hl.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;hl.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};hl.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=il.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));dl.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:il.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),hl.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){hl.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};hl.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();hl.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){hl.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};hl.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();hl.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){hl.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};hl.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();hl.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};hl.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};hl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=il.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}hl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=il.parse(this._pc.localDescription.sdp));const r=dl.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}};assertNotClosed(){if(this._closed)throw new al.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}nl.Chrome74=ml;var gl={};Object.defineProperty(gl,"__esModule",{value:!0}),gl.Firefox120=void 0;const vl=gu,yl=Sc,_l=Wc,bl=Gc,El=Iu,wl=Au,Sl=Nu,Cl=Lu,Pl=new _c.Logger("Firefox120"),Tl={OS:16,MIS:2048};class kl extends yl.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Firefox120",factory:e=>new kl(e),getNativeRtpCapabilities:async()=>{Pl.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});const t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"}),e.addTransceiver(r,{direction:"sendrecv",sendEncodings:[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}]});const n=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}e=void 0;const i=vl.parse(n.sdp);return kl.getLocalRtpCapabilities(i)}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e?.close()}catch(e){}throw e=void 0,n}},getNativeSctpCapabilities:async()=>(Pl.debug("getNativeSctpCapabilities()"),{numStreams:Tl})}}static getLocalRtpCapabilities(e){const t=wl.extractRtpCapabilities({sdpObject:e});return bl.validateAndNormalizeRtpCapabilities(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),Pl.debug("constructor()"),this._direction=e,this._remoteSdp=new Cl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(Pl.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Firefox120"}close(){if(Pl.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){throw this.assertNotClosed(),new _l.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),Pl.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Pl.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Pl.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Pl.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),Pl.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(s.sender);const o=await this._pc.createOffer();let a=vl.parse(o.sdp);a.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const c=kl.getLocalRtpCapabilities(a),d=this._getSendExtendedRtpCapabilities(c),u=bl.getSendingRtpParameters(e.kind,d);u.codecs=bl.reduceCodecs(u.codecs,n);const l=bl.getSendingRemoteRtpParameters(e.kind,d);l.codecs=bl.reduceCodecs(l.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:a});const p=(0,El.parse)((t??[{}])[0].scalabilityMode);Pl.debug("send() | calling pc.setLocalDescription() [offer:%o]",o),await this._pc.setLocalDescription(o);const h=s.mid;u.mid=h,a=vl.parse(this._pc.localDescription.sdp);const f=a.media[a.media.length-1];if(u.rtcp.cname=wl.getCname({offerMediaObject:f}),t)if(1===t.length){const e=Sl.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),u.encodings=e}else u.encodings=t;else u.encodings=Sl.getRtpEncodings({offerMediaObject:f});if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const e of u.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,offerRtpParameters:u,answerRtpParameters:l,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return Pl.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),this._mapMidTransceiver.set(h,s),{localId:h,rtpParameters:u,rtpSender:s.sender}}async stopSending(e){if(this.assertSendDirection(),Pl.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();Pl.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Pl.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Pl.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Pl.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();Pl.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Pl.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Pl.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Pl.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Pl.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Pl.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Pl.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Pl.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Tl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=vl.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),Pl.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pl.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Pl.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Pl.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=vl.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));wl.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:vl.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),Pl.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Pl.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Pl.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Pl.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Pl.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Pl.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Pl.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Pl.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Pl.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Pl.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Pl.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Pl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=vl.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}Pl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=vl.parse(this._pc.localDescription.sdp));const r=wl.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}};assertNotClosed(){if(this._closed)throw new _l.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}gl.Firefox120=kl;var Rl={};Object.defineProperty(Rl,"__esModule",{value:!0}),Rl.Safari12=void 0;const Il=gu,Dl=Sc,Al=Gc,Ol=Wc,Nl=Iu,Ml=Lu,Ll=Au,xl=Nu,Fl=Mu,jl=new _c.Logger("Safari12"),Ul={OS:1024,MIS:1024};class Bl extends Dl.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Safari12",factory:e=>new Bl(e),getNativeRtpCapabilities:async()=>{jl.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}e=void 0;const r=Il.parse(t.sdp);return Bl.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(jl.debug("getNativeSctpCapabilities()"),{numStreams:Ul})}}static getLocalRtpCapabilities(e){const t=Ll.extractRtpCapabilities({sdpObject:e});return Al.validateAndNormalizeRtpCapabilities(t),Fl.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),jl.debug("constructor()"),this._direction=e,this._remoteSdp=new Ml.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(jl.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Safari12"}close(){if(jl.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),jl.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),jl.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});jl.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};jl.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();jl.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),jl.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});i&&i(o.sender);let a=await this._pc.createOffer(),c=Il.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=Bl.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=Al.getSendingRtpParameters(e.kind,u);l.codecs=Al.reduceCodecs(l.codecs,n);const p=Al.getSendingRemoteRtpParameters(e.kind,u);let h;p.codecs=Al.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c});const f=(0,Nl.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(jl.debug("send() | enabling legacy simulcast"),c=Il.parse(a.sdp),h=c.media[s.idx],xl.addLegacySimulcast({offerMediaObject:h,numStreams:t.length}),a={type:"offer",sdp:Il.write(c)}),jl.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const m=o.mid;if(l.mid=m,c=Il.parse(this._pc.localDescription.sdp),h=c.media[s.idx],l.rtcp.cname=Ll.getCname({offerMediaObject:h}),l.encodings=xl.getRtpEncodings({offerMediaObject:h}),t)for(let e=0;e<l.encodings.length;++e)t[e]&&Object.assign(l.encodings[e],t[e]);if(l.encodings.length>1&&("video/vp8"===l.codecs[0].mimeType.toLowerCase()||"video/h264"===l.codecs[0].mimeType.toLowerCase()))for(const e of l.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${f.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:h,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const g={type:"answer",sdp:this._remoteSdp.getSdp()};return jl.debug("send() | calling pc.setRemoteDescription() [answer:%o]",g),await this._pc.setRemoteDescription(g),this._mapMidTransceiver.set(m,o),{localId:m,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;jl.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();jl.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),jl.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();jl.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),jl.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();jl.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?jl.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):jl.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),jl.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();jl.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),jl.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();jl.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};jl.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ul.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Il.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),jl.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};jl.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;jl.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};jl.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Il.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ll.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Il.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),jl.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){jl.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};jl.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();jl.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){jl.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};jl.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();jl.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){jl.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};jl.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();jl.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};jl.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};jl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Il.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}jl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Il.parse(this._pc.localDescription.sdp));const r=Ll.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}};assertNotClosed(){if(this._closed)throw new Ol.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Rl.Safari12=Bl;var Vl={};Object.defineProperty(Vl,"__esModule",{value:!0}),Vl.ReactNative106=void 0;const Wl=gu,Hl=Sc,ql=Gc,zl=Wc,Gl=Iu,Yl=Lu,$l=Au,Jl=Nu,Kl=Mu,Ql=new _c.Logger("ReactNative106"),Zl={OS:1024,MIS:1024};class Xl extends Hl.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"ReactNative106",factory:e=>new Xl(e),getNativeRtpCapabilities:async()=>{Ql.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}e=void 0;const r=Wl.parse(t.sdp);return Xl.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(Ql.debug("getNativeSctpCapabilities()"),{numStreams:Zl})}}static getLocalRtpCapabilities(e){const t=$l.extractRtpCapabilities({sdpObject:e});return ql.validateAndNormalizeRtpCapabilities(t),Kl.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),Ql.debug("constructor()"),this._direction=e,this._remoteSdp=new Yl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(Ql.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"ReactNative106"}close(){if(Ql.debug("close()"),!this._closed){this._closed=!0,this._sendStream.release(!1);try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),Ql.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Ql.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ql.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ql.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ql.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),Ql.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(o.sender);let a=await this._pc.createOffer(),c=Wl.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=Xl.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=ql.getSendingRtpParameters(e.kind,u);l.codecs=ql.reduceCodecs(l.codecs,n);const p=ql.getSendingRemoteRtpParameters(e.kind,u);p.codecs=ql.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c});let h=!1;const f=(0,Gl.parse)((t??[{}])[0].scalabilityMode);let m;t&&1===t.length&&f.spatialLayers>1&&"video/vp9"===l.codecs[0].mimeType.toLowerCase()&&(Ql.debug("send() | enabling legacy simulcast for VP9 SVC"),h=!0,c=Wl.parse(a.sdp),m=c.media[s.idx],Jl.addLegacySimulcast({offerMediaObject:m,numStreams:f.spatialLayers}),a={type:"offer",sdp:Wl.write(c)}),Ql.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);let g=o.mid??void 0;if(g||Ql.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),l.mid=g,c=Wl.parse(this._pc.localDescription.sdp),m=c.media[s.idx],l.rtcp.cname=$l.getCname({offerMediaObject:m}),t)if(1===t.length){let e=Jl.getRtpEncodings({offerMediaObject:m});Object.assign(e[0],t[0]),h&&(e=[e[0]]),l.encodings=e}else l.encodings=t;else l.encodings=Jl.getRtpEncodings({offerMediaObject:m});if(l.encodings.length>1&&("video/vp8"===l.codecs[0].mimeType.toLowerCase()||"video/h264"===l.codecs[0].mimeType.toLowerCase()))for(const e of l.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${f.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:m,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const v={type:"answer",sdp:this._remoteSdp.getSdp()};return Ql.debug("send() | calling pc.setRemoteDescription() [answer:%o]",v),await this._pc.setRemoteDescription(v),g||(g=o.mid,l.mid=g),this._mapMidTransceiver.set(g,o),{localId:g,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;Ql.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();Ql.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ql.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Ql.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ql.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();Ql.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ql.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ql.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Ql.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Ql.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ql.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Ql.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Ql.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Zl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Wl.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ql.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ql.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Ql.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Ql.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Wl.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));$l.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Wl.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ql.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Ql.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ql.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ql.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Ql.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ql.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ql.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Ql.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ql.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ql.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Ql.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ql.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Wl.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ql.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Wl.parse(this._pc.localDescription.sdp));const r=$l.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}};assertNotClosed(){if(this._closed)throw new zl.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Vl.ReactNative106=Xl,Object.defineProperty(oc,"__esModule",{value:!0}),oc.Device=void 0,oc.detectDevice=pp,oc.detectDeviceAsync=hp;const ep=pc,tp=Sc,rp=Wc,np=zc,ip=Gc,sp=kd,op=mu,ap=nl,cp=gl,dp=Rl,up=Vl,lp=new _c.Logger("Device");function pp(e){lp.debug("detectDevice() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return mp(new ep.default(e))}async function hp(e){lp.debug("detectDeviceAsync() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return mp(new ep.default(e))}class fp{_handlerFactory;_handlerName;_loaded=!1;_getSendExtendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind={audio:!1,video:!1};_sctpCapabilities;_observer=new tp.EnhancedEventEmitter;static async factory({handlerName:e,handlerFactory:t}={}){if(lp.debug("factory()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(!e&&!t&&!(e=await hp()))throw new rp.UnsupportedError("device not supported");return new fp({handlerName:e,handlerFactory:t})}constructor({handlerName:e,handlerFactory:t}={}){if(lp.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)lp.debug("constructor() | handler given: %s",e);else{if(!(e=pp()))throw new rp.UnsupportedError("device not supported");lp.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=op.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=ap.Chrome74.createFactory();break;case"Firefox120":this._handlerFactory=cp.Firefox120.createFactory();break;case"Safari12":this._handlerFactory=dp.Safari12.createFactory();break;case"ReactNative106":this._handlerFactory=up.ReactNative106.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}this._handlerName=this._handlerFactory.name}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new rp.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new rp.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e,preferLocalCodecsOrder:t=!1}){if(lp.debug("load() [routerRtpCapabilities:%o]",e),this._loaded)throw new rp.InvalidStateError("already loaded");const r=np.clone(e);ip.validateAndNormalizeRtpCapabilities(r);const{getNativeRtpCapabilities:n,getNativeSctpCapabilities:i}=this._handlerFactory,s=np.clone(await n());ip.validateAndNormalizeRtpCapabilities(s),lp.debug("load() | got native RTP capabilities:%o",s),this._getSendExtendedRtpCapabilities=e=>np.clone(ip.getExtendedRtpCapabilities(e,r,t));const o=ip.getExtendedRtpCapabilities(s,r,!1);this._recvRtpCapabilities=ip.getRecvRtpCapabilities(o),ip.validateAndNormalizeRtpCapabilities(this._recvRtpCapabilities),lp.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._canProduceByKind.audio=ip.canSend("audio",this._recvRtpCapabilities),this._canProduceByKind.video=ip.canSend("video",this._recvRtpCapabilities),this._sctpCapabilities=await i(),ip.validateSctpCapabilities(this._sctpCapabilities),lp.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),lp.debug("load() succeeded"),this._loaded=!0}canProduce(e){if(!this._loaded)throw new rp.InvalidStateError("not loaded");if("audio"!==e&&"video"!==e)throw new TypeError(`invalid kind "${e}"`);return this._canProduceByKind[e]}createSendTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c}){return lp.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c}){return lp.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d}){if(!this._loaded)throw new rp.InvalidStateError("not loaded");if("string"!=typeof t)throw new TypeError("missing id");if("object"!=typeof r)throw new TypeError("missing iceParameters");if(!Array.isArray(n))throw new TypeError("missing iceCandidates");if("object"!=typeof i)throw new TypeError("missing dtlsParameters");if(s&&"object"!=typeof s)throw new TypeError("wrong sctpParameters");if(d&&"object"!=typeof d)throw new TypeError("if given, appData must be an object");const u=new sp.Transport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d,handlerFactory:this._handlerFactory,getSendExtendedRtpCapabilities:this._getSendExtendedRtpCapabilities,recvRtpCapabilities:this._recvRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",u),u}}function mp(e){if("object"==typeof navigator&&"ReactNative"===navigator.product)return lp.debug("detectDeviceImpl() | React-Native detected"),"undefined"==typeof RTCPeerConnection||"undefined"==typeof RTCRtpTransceiver?void lp.warn("detectDeviceImpl() | unsupported react-native-webrtc without RTCPeerConnection or RTCRtpTransceiver, forgot to call registerGlobals() on it?"):"ReactNative106";{const t=e.parseUserAgent(),r=/^\d+/.exec(t?.shortVersion??"0"),n=parseInt(r?.[0]??"0",10),i=t.platform===ep.KnownPlatforms.iphone||t.platform===ep.KnownPlatforms.ipad||t.platform===ep.KnownPlatforms.mac&&(t.isMobile||t.isTablet||"object"==typeof navigator&&navigator?.maxTouchPoints>=2),s=t.isChrome,o=t.isFireFox,a=t.isSafari,c=t.isEdge,d=t.isDesktop&&t.name===ep.KnownBrowsers.electron,u=t.isWebkit,l={browserMajorVersion:n,isIOS:i,isChrome:s,isFirefox:o,isSafari:a,isElectron:d,isWebkit:u};if(lp.debug("detectDeviceImpl() | detected browser [userAgent:%s, parsed:%o, result:%o]",t.userAgent,t,l),(s||c)&&!i&&n>=111)return"Chrome111";if(s&&!i&&n>=74||c&&!i&&n>=88)return"Chrome74";if(d)return"Chrome111";if(o&&!i&&n>=120)return"Firefox120";if(a&&n>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(i&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(u){const t=e.userAgent?.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){return Number(t[1])>=111?"Chrome111":"Chrome74"}return"Chrome111"}return void lp.warn("detectDeviceImpl() | browser not supported [userAgent:%s, parsed:%o, result:%o]",t.userAgent,t,l)}}oc.Device=fp;var gp={},vp={},yp={},_p={};Object.defineProperty(_p,"__esModule",{value:!0}),_p.default="ffffffff-ffff-ffff-ffff-ffffffffffff";var bp={};Object.defineProperty(bp,"__esModule",{value:!0}),bp.default="00000000-0000-0000-0000-000000000000";var Ep={},wp={},Sp={};Object.defineProperty(Sp,"__esModule",{value:!0}),Sp.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i,Object.defineProperty(wp,"__esModule",{value:!0});const Cp=Sp;wp.default=function(e){return"string"==typeof e&&Cp.default.test(e)},Object.defineProperty(Ep,"__esModule",{value:!0});const Pp=wp;Ep.default=function(e){if(!(0,Pp.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)};var Tp={};Object.defineProperty(Tp,"__esModule",{value:!0}),Tp.unsafeStringify=void 0;const kp=wp,Rp=[];for(let e=0;e<256;++e)Rp.push((e+256).toString(16).slice(1));function Ip(e,t=0){return(Rp[e[t+0]]+Rp[e[t+1]]+Rp[e[t+2]]+Rp[e[t+3]]+"-"+Rp[e[t+4]]+Rp[e[t+5]]+"-"+Rp[e[t+6]]+Rp[e[t+7]]+"-"+Rp[e[t+8]]+Rp[e[t+9]]+"-"+Rp[e[t+10]]+Rp[e[t+11]]+Rp[e[t+12]]+Rp[e[t+13]]+Rp[e[t+14]]+Rp[e[t+15]]).toLowerCase()}Tp.unsafeStringify=Ip,Tp.default=function(e,t=0){const r=Ip(e,t);if(!(0,kp.default)(r))throw TypeError("Stringified UUID is invalid");return r};var Dp={},Ap={};let Op;Object.defineProperty(Ap,"__esModule",{value:!0});const Np=new Uint8Array(16);Ap.default=function(){if(!Op){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Op=crypto.getRandomValues.bind(crypto)}return Op(Np)},Object.defineProperty(Dp,"__esModule",{value:!0}),Dp.updateV1State=void 0;const Mp=Ap,Lp=Tp,xp={};function Fp(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function jp(e,t,r,n,i,s,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(o<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else s=new Uint8Array(16),o=0;t??=Date.now(),r??=0,n??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;s[o++]=a>>>24&255,s[o++]=a>>>16&255,s[o++]=a>>>8&255,s[o++]=255&a;const c=t/4294967296*1e4&268435455;s[o++]=c>>>8&255,s[o++]=255&c,s[o++]=c>>>24&15|16,s[o++]=c>>>16&255,s[o++]=n>>>8|128,s[o++]=255&n;for(let e=0;e<6;++e)s[o++]=i[e];return s}Dp.updateV1State=Fp,Dp.default=function(e,t,r){let n;const i=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)n=jp(e.random??e.rng?.()??(0,Mp.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),s=(0,Mp.default)();Fp(xp,e,s),n=jp(s,xp.msecs,xp.nsecs,i?void 0:xp.clockseq,i?void 0:xp.node,t,r)}return t??(0,Lp.unsafeStringify)(n)};var Up={};Object.defineProperty(Up,"__esModule",{value:!0});const Bp=Ep,Vp=Tp;Up.default=function(e){const t=function(e){return Uint8Array.of((15&e[6])<<4|e[7]>>4&15,(15&e[7])<<4|(240&e[4])>>4,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,(15&e[1])<<4|(240&e[2])>>4,96|15&e[2],e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,Bp.default)(e):e);return"string"==typeof e?(0,Vp.unsafeStringify)(t):t};var Wp={},Hp={};function qp(e){return 14+(e+64>>>9<<4)+1}function zp(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function Gp(e,t,r,n,i,s){return zp((o=zp(zp(t,e),zp(n,s)))<<(a=i)|o>>>32-a,r);var o,a}function Yp(e,t,r,n,i,s,o){return Gp(t&r|~t&n,e,t,i,s,o)}function $p(e,t,r,n,i,s,o){return Gp(t&n|r&~n,e,t,i,s,o)}function Jp(e,t,r,n,i,s,o){return Gp(t^r^n,e,t,i,s,o)}function Kp(e,t,r,n,i,s,o){return Gp(r^(t|~n),e,t,i,s,o)}Object.defineProperty(Hp,"__esModule",{value:!0}),Hp.default=function(e){const t=function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(qp(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),r=function(e,t){const r=new Uint32Array(qp(t)).fill(0);r.set(e),r[t>>5]|=128<<t%32,r[r.length-1]=t,e=r;let n=1732584193,i=-271733879,s=-1732584194,o=271733878;for(let t=0;t<e.length;t+=16){const r=n,a=i,c=s,d=o;n=Yp(n,i,s,o,e[t],7,-680876936),o=Yp(o,n,i,s,e[t+1],12,-389564586),s=Yp(s,o,n,i,e[t+2],17,606105819),i=Yp(i,s,o,n,e[t+3],22,-1044525330),n=Yp(n,i,s,o,e[t+4],7,-176418897),o=Yp(o,n,i,s,e[t+5],12,1200080426),s=Yp(s,o,n,i,e[t+6],17,-1473231341),i=Yp(i,s,o,n,e[t+7],22,-45705983),n=Yp(n,i,s,o,e[t+8],7,1770035416),o=Yp(o,n,i,s,e[t+9],12,-1958414417),s=Yp(s,o,n,i,e[t+10],17,-42063),i=Yp(i,s,o,n,e[t+11],22,-1990404162),n=Yp(n,i,s,o,e[t+12],7,1804603682),o=Yp(o,n,i,s,e[t+13],12,-40341101),s=Yp(s,o,n,i,e[t+14],17,-1502002290),i=Yp(i,s,o,n,e[t+15],22,1236535329),n=$p(n,i,s,o,e[t+1],5,-165796510),o=$p(o,n,i,s,e[t+6],9,-1069501632),s=$p(s,o,n,i,e[t+11],14,643717713),i=$p(i,s,o,n,e[t],20,-373897302),n=$p(n,i,s,o,e[t+5],5,-701558691),o=$p(o,n,i,s,e[t+10],9,38016083),s=$p(s,o,n,i,e[t+15],14,-660478335),i=$p(i,s,o,n,e[t+4],20,-405537848),n=$p(n,i,s,o,e[t+9],5,568446438),o=$p(o,n,i,s,e[t+14],9,-1019803690),s=$p(s,o,n,i,e[t+3],14,-187363961),i=$p(i,s,o,n,e[t+8],20,1163531501),n=$p(n,i,s,o,e[t+13],5,-1444681467),o=$p(o,n,i,s,e[t+2],9,-51403784),s=$p(s,o,n,i,e[t+7],14,1735328473),i=$p(i,s,o,n,e[t+12],20,-1926607734),n=Jp(n,i,s,o,e[t+5],4,-378558),o=Jp(o,n,i,s,e[t+8],11,-2022574463),s=Jp(s,o,n,i,e[t+11],16,1839030562),i=Jp(i,s,o,n,e[t+14],23,-35309556),n=Jp(n,i,s,o,e[t+1],4,-1530992060),o=Jp(o,n,i,s,e[t+4],11,1272893353),s=Jp(s,o,n,i,e[t+7],16,-155497632),i=Jp(i,s,o,n,e[t+10],23,-1094730640),n=Jp(n,i,s,o,e[t+13],4,681279174),o=Jp(o,n,i,s,e[t],11,-358537222),s=Jp(s,o,n,i,e[t+3],16,-722521979),i=Jp(i,s,o,n,e[t+6],23,76029189),n=Jp(n,i,s,o,e[t+9],4,-640364487),o=Jp(o,n,i,s,e[t+12],11,-421815835),s=Jp(s,o,n,i,e[t+15],16,530742520),i=Jp(i,s,o,n,e[t+2],23,-995338651),n=Kp(n,i,s,o,e[t],6,-198630844),o=Kp(o,n,i,s,e[t+7],10,1126891415),s=Kp(s,o,n,i,e[t+14],15,-1416354905),i=Kp(i,s,o,n,e[t+5],21,-57434055),n=Kp(n,i,s,o,e[t+12],6,1700485571),o=Kp(o,n,i,s,e[t+3],10,-1894986606),s=Kp(s,o,n,i,e[t+10],15,-1051523),i=Kp(i,s,o,n,e[t+1],21,-2054922799),n=Kp(n,i,s,o,e[t+8],6,1873313359),o=Kp(o,n,i,s,e[t+15],10,-30611744),s=Kp(s,o,n,i,e[t+6],15,-1560198380),i=Kp(i,s,o,n,e[t+13],21,1309151649),n=Kp(n,i,s,o,e[t+4],6,-145523070),o=Kp(o,n,i,s,e[t+11],10,-1120210379),s=Kp(s,o,n,i,e[t+2],15,718787259),i=Kp(i,s,o,n,e[t+9],21,-343485551),n=zp(n,r),i=zp(i,a),s=zp(s,c),o=zp(o,d)}return Uint32Array.of(n,i,s,o)}(t,8*e.length);return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(r)};var Qp={};Object.defineProperty(Qp,"__esModule",{value:!0}),Qp.URL=Qp.DNS=Qp.stringToBytes=void 0;const Zp=Ep,Xp=Tp;function eh(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}Qp.stringToBytes=eh,Qp.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Qp.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",Qp.default=function(e,t,r,n,i,s){const o="string"==typeof r?eh(r):r,a="string"==typeof n?(0,Zp.default)(n):n;if("string"==typeof n&&(n=(0,Zp.default)(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(a),c.set(o,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){s=s||0;for(let e=0;e<16;++e)i[s+e]=c[e];return i}return(0,Xp.unsafeStringify)(c)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=Hp,r=Qp;var n=Qp;function i(e,n,i,s){return(0,r.default)(48,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(Wp);var th={},rh={};Object.defineProperty(rh,"__esModule",{value:!0});const nh="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);rh.default={randomUUID:nh},Object.defineProperty(th,"__esModule",{value:!0});const ih=rh,sh=Ap,oh=Tp;th.default=function(e,t,r){if(ih.default.randomUUID&&!t&&!e)return ih.default.randomUUID();const n=(e=e||{}).random??e.rng?.()??(0,sh.default)();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return(0,oh.unsafeStringify)(n)};var ah={},ch={};function dh(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function uh(e,t){return e<<t|e>>>32-t}Object.defineProperty(ch,"__esModule",{value:!0}),ch.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,s=Math.ceil(i/16),o=new Array(s);for(let t=0;t<s;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];o[t]=r}o[s-1][14]=8*(e.length-1)/Math.pow(2,32),o[s-1][14]=Math.floor(o[s-1][14]),o[s-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<s;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=o[e][t];for(let e=16;e<80;++e)n[e]=uh(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],s=r[1],a=r[2],c=r[3],d=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),o=uh(i,5)+dh(r,s,a,c)+d+t[r]+n[e]>>>0;d=c,c=a,a=uh(s,30)>>>0,s=i,i=o}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+d>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=ch,r=Qp;var n=Qp;function i(e,n,i,s){return(0,r.default)(80,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(ah);var lh={};Object.defineProperty(lh,"__esModule",{value:!0});const ph=Tp,hh=Dp,fh=Up;lh.default=function(e,t,r){e??={},r??=0;let n=(0,hh.default)({...e,_v6:!0},new Uint8Array(16));if(n=(0,fh.default)(n),t){for(let e=0;e<16;e++)t[r+e]=n[e];return t}return(0,ph.unsafeStringify)(n)};var mh={};Object.defineProperty(mh,"__esModule",{value:!0});const gh=Ep,vh=Tp;mh.default=function(e){const t=function(e){return Uint8Array.of((15&e[3])<<4|e[4]>>4&15,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|15&e[6],e[7],(15&e[1])<<4|(240&e[2])>>4,(15&e[2])<<4|(240&e[3])>>4,16|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,gh.default)(e):e);return"string"==typeof e?(0,vh.unsafeStringify)(t):t};var yh={};Object.defineProperty(yh,"__esModule",{value:!0}),yh.updateV7State=void 0;const _h=Ap,bh=Tp,Eh={};function wh(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function Sh(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else n=new Uint8Array(16),i=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=255&t,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|3&e[10],n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}yh.updateV7State=wh,yh.default=function(e,t,r){let n;if(e)n=Sh(e.random??e.rng?.()??(0,_h.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),i=(0,_h.default)();wh(Eh,e,i),n=Sh(i,Eh.msecs,Eh.seq,t,r)}return t??(0,bh.unsafeStringify)(n)};var Ch={};Object.defineProperty(Ch,"__esModule",{value:!0});const Ph=wp;Ch.default=function(e){if(!(0,Ph.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.validate=e.v7=e.v6ToV1=e.v6=e.v5=e.v4=e.v3=e.v1ToV6=e.v1=e.stringify=e.parse=e.NIL=e.MAX=void 0;var t=_p;Object.defineProperty(e,"MAX",{enumerable:!0,get:function(){return t.default}});var r=bp;Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return r.default}});var n=Ep;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return n.default}});var i=Tp;Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return i.default}});var s=Dp;Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return s.default}});var o=Up;Object.defineProperty(e,"v1ToV6",{enumerable:!0,get:function(){return o.default}});var a=Wp;Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return a.default}});var c=th;Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return c.default}});var d=ah;Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return d.default}});var u=lh;Object.defineProperty(e,"v6",{enumerable:!0,get:function(){return u.default}});var l=mh;Object.defineProperty(e,"v6ToV1",{enumerable:!0,get:function(){return l.default}});var p=yh;Object.defineProperty(e,"v7",{enumerable:!0,get:function(){return p.default}});var h=wp;Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return h.default}});var f=Ch;Object.defineProperty(e,"version",{enumerable:!0,get:function(){return f.default}})}(yp);var Th={};Object.defineProperty(Th,"__esModule",{value:!0}),Th.FakeEventTarget=void 0;Th.FakeEventTarget=class{listeners={};addEventListener(e,t,r){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:"function"==typeof t?t:t.handleEvent,once:"object"==typeof r&&!0===r.once}))}removeEventListener(e,t,r){this.listeners[e]&&t&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==("function"==typeof t?t:t.handleEvent))))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}};var kh={};Object.defineProperty(kh,"__esModule",{value:!0}),kh.FakeEvent=void 0;kh.FakeEvent=class{NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;type;bubbles;cancelable;defaultPrevented=!1;composed=!1;currentTarget=null;eventPhase=f.NONE;isTrusted=!0;target=null;timeStamp=0;cancelBubble=!1;returnValue=!0;srcElement=null;constructor(e,t={}){this.type=e,this.bubbles=t.bubbles??!1,this.cancelable=t.cancelable??!1}preventDefault(){this.cancelable&&(this.defaultPrevented=!0)}stopPropagation(){}stopImmediatePropagation(){}composedPath(){return[]}initEvent(e,t,r){}};var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Object.defineProperty(vp,"__esModule",{value:!0}),vp.FakeMediaStreamTrack=void 0;const Ih=yp,Dh=Th,Ah=kh,Oh=Rh;class Nh extends Dh.FakeEventTarget{#b;#E;#w;#S;#C;#P;#T;#k;#R;#I;#D;#A=null;#O=null;#N=null;#M=null;#L=null;constructor({kind:e,id:t,label:r,contentHint:n,enabled:i,muted:s,readyState:o,capabilities:a,constraints:c,settings:d,data:u}){super(),this.#b=t??(0,Ih.v4)(),this.#E=e,this.#w=r??"",this.#T=n??"",this.#C=i??!0,this.#P=s??!1,this.#S=o??"live",this.#k=a??{},this.#R=c??{},this.#I=d??{},this.#D=u??{}}get id(){return this.#b}get kind(){return this.#E}get label(){return this.#w}get contentHint(){return this.#T}set contentHint(e){this.#T=e}get enabled(){return this.#C}set enabled(e){const t=this.#C!==e;this.#C=e,t&&this.dispatchEvent(new Ah.FakeEvent("enabledchange"))}get muted(){return this.#P}get readyState(){return this.#S}get data(){return this.#D}set data(e){this.#D=e}get onmute(){return this.#A}set onmute(e){this.#A&&this.removeEventListener("mute",this.#A),this.#A=e,e&&this.addEventListener("mute",e)}get onunmute(){return this.#O}set onunmute(e){this.#O&&this.removeEventListener("unmute",this.#O),this.#O=e,e&&this.addEventListener("unmute",e)}get onended(){return this.#N}set onended(e){this.#N&&this.removeEventListener("ended",this.#N),this.#N=e,e&&this.addEventListener("ended",e)}get onenabledchange(){return this.#M}set onenabledchange(e){this.#M&&this.removeEventListener("enabledchange",this.#M),this.#M=e,e&&this.addEventListener("enabledchange",e)}get onstopped(){return this.#L}set onstopped(e){this.#L&&this.removeEventListener("stopped",this.#L),this.#L=e,e&&this.addEventListener("stopped",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}stop(){"ended"!==this.#S&&(this.#S="ended",this.dispatchEvent(new Ah.FakeEvent("stopped")))}clone({id:e,data:t}={}){return new Nh({id:e??(0,Ih.v4)(),kind:this.#E,label:this.#w,contentHint:this.#T,enabled:this.#C,muted:this.#P,readyState:this.#S,capabilities:(0,Oh.clone)(this.#k),constraints:(0,Oh.clone)(this.#R),settings:(0,Oh.clone)(this.#I),data:t??(0,Oh.clone)(this.#D)})}getCapabilities(){return this.#k}getConstraints(){return this.#R}async applyConstraints(e={}){return this.#R=e,Promise.resolve()}getSettings(){return this.#I}remoteStop(){"ended"!==this.#S&&(this.#S="ended",this.dispatchEvent(new Ah.FakeEvent("stopped")),this.dispatchEvent(new Ah.FakeEvent("ended")))}remoteMute(){this.#P||(this.#P=!0,this.dispatchEvent(new Ah.FakeEvent("mute")))}remoteUnmute(){this.#P&&(this.#P=!1,this.dispatchEvent(new Ah.FakeEvent("unmute")))}}vp.FakeMediaStreamTrack=Nh;var Mh={};Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.FakeEventTarget=void 0;Mh.FakeEventTarget=class{listeners={};addEventListener(e,t,r){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:"function"==typeof t?t:t.handleEvent,once:"object"==typeof r&&!0===r.once}))}removeEventListener(e,t,r){this.listeners[e]&&t&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==("function"==typeof t?t:t.handleEvent))))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}},Object.defineProperty(gp,"__esModule",{value:!0}),gp.FakeHandler=void 0;const Lh=vp,xh=Sc,Fh=zc,jh=Gc,Uh=Wc,Bh=Mh,Vh=new _c.Logger("FakeHandler");class Wh extends xh.EnhancedEventEmitter{_closed=!1;_fakeParameters;_getSendExtendedRtpCapabilities;_cname=`CNAME-${Fh.generateRandomNumber()}`;_transportReady=!1;_nextLocalId=1;_tracks=new Map;_nextSctpStreamId=0;static createFactory(e){return{name:"FakeHandler",factory:t=>new Wh(t,e),getNativeRtpCapabilities:async()=>(Vh.debug("getNativeRtpCapabilities()"),Wh.getLocalRtpCapabilities(e)),getNativeSctpCapabilities:async()=>(Vh.debug("getNativeSctpCapabilities()"),e.generateNativeSctpCapabilities())}}static getLocalRtpCapabilities(e){const t=e.generateNativeRtpCapabilities();return jh.validateAndNormalizeRtpCapabilities(t),t}constructor({getSendExtendedRtpCapabilities:e},t){super(),Vh.debug("constructor()"),this._getSendExtendedRtpCapabilities=e,this._fakeParameters=t}get name(){return"FakeHandler"}close(){Vh.debug("close()"),this._closed||(this._closed=!0,super.close())}setIceGatheringState(e){this.emit("@icegatheringstatechange",e)}setConnectionState(e){this.emit("@connectionstatechange",e)}async updateIceServers(e){this.assertNotClosed(),Vh.debug("updateIceServers()")}async restartIce(e){this.assertNotClosed(),Vh.debug("restartIce()")}async getTransportStats(){return this.assertNotClosed(),new Map}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),Vh.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"});const i=Wh.getLocalRtpCapabilities(this._fakeParameters),s=this._getSendExtendedRtpCapabilities(i),o=jh.getSendingRtpParameters(e.kind,s);o.codecs=jh.reduceCodecs(o.codecs,n);const a=o.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));o.mid=`mid-${Fh.generateRandomNumber()}`,t||(t=[{}]);for(const e of t)e.ssrc=Fh.generateRandomNumber(),a&&(e.rtx={ssrc:Fh.generateRandomNumber()});o.encodings=t,o.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const c=this._nextLocalId++;return this._tracks.set(c,e),{localId:String(c),rtpParameters:o}}async stopSending(e){if(Vh.debug("stopSending() [localId:%s]",e),!this._closed){if(!this._tracks.has(Number(e)))throw new Error("local track not found");this._tracks.delete(Number(e))}}async pauseSending(e){this.assertNotClosed()}async resumeSending(e){this.assertNotClosed()}async replaceTrack(e,t){this.assertNotClosed(),t?Vh.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Vh.debug("replaceTrack() [localId:%s, no track]",e),this._tracks.delete(Number(e)),this._tracks.set(Number(e),t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),Vh.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),Vh.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t)}async getSenderStats(e){return this.assertNotClosed(),new Map}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),Vh.debug("sendDataChannel()");return{dataChannel:new Hh({id:this._nextSctpStreamId++,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}),sctpStreamParameters:{streamId:this._nextSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r}}}async receive(e){this.assertNotClosed();const t=[];for(const r of e){const{trackId:e,kind:n}=r;this._transportReady||await this.setupTransport({localDtlsRole:"client"}),Vh.debug("receive() [trackId:%s, kind:%s]",e,n);const i=this._nextLocalId++,s=new Lh.FakeMediaStreamTrack({kind:n});this._tracks.set(i,s),t.push({localId:String(i),track:s})}return t}async stopReceiving(e){if(!this._closed)for(const t of e)Vh.debug("stopReceiving() [localId:%s]",t),this._tracks.delete(Number(t))}async pauseReceiving(e){this.assertNotClosed()}async resumeReceiving(e){this.assertNotClosed()}async getReceiverStats(e){return this.assertNotClosed(),new Map}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"client"}),Vh.debug("receiveDataChannel()");return{dataChannel:new Hh({id:e.streamId,ordered:e.ordered,maxPacketLifeTime:e.maxPacketLifeTime,maxRetransmits:e.maxRetransmits,label:t,protocol:r})}}async setupTransport({localDtlsRole:e,localSdpObject:t}){const r=Fh.clone(this._fakeParameters.generateLocalDtlsParameters());e&&(r.role=e),this.emit("@connectionstatechange","connecting"),await new Promise(((e,t)=>this.emit("@connect",{dtlsParameters:r},e,t))),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Uh.InvalidStateError("method called in a closed handler")}}gp.FakeHandler=Wh;class Hh extends Bh.FakeEventTarget{_id;_negotiated=!0;_ordered;_maxPacketLifeTime;_maxRetransmits;_label;_protocol;_readyState="connecting";_bufferedAmount=0;_bufferedAmountLowThreshold=0;_binaryType="arraybuffer";_onopen=null;_onclosing=null;_onclose=null;_onmessage=null;_onbufferedamountlow=null;_onerror=null;constructor({id:e,ordered:t=!0,maxPacketLifeTime:r=null,maxRetransmits:n=null,label:i="",protocol:s=""}){super(),Vh.debug(`constructor() [id:${e}, ordered:${t}, maxPacketLifeTime:${r}, maxRetransmits:${n}, label:${i}, protocol:${s}`),this._id=e,this._ordered=t,this._maxPacketLifeTime=r,this._maxRetransmits=n,this._label=i,this._protocol=s}get id(){return this._id}get negotiated(){return this._negotiated}get ordered(){return this._ordered}get maxPacketLifeTime(){return this._maxPacketLifeTime}get maxRetransmits(){return this._maxRetransmits}get label(){return this._label}get protocol(){return this._protocol}get readyState(){return this._readyState}get bufferedAmount(){return this._bufferedAmount}get bufferedAmountLowThreshold(){return this._bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._bufferedAmountLowThreshold=e}get binaryType(){return this._binaryType}set binaryType(e){this._binaryType=e}get onopen(){return this._onopen}set onopen(e){this._onopen&&this.removeEventListener("open",this._onopen),this._onopen=e,e&&this.addEventListener("open",e)}get onclosing(){return this._onclosing}set onclosing(e){this._onclosing&&this.removeEventListener("closing",this._onclosing),this._onclosing=e,e&&this.addEventListener("closing",e)}get onclose(){return this._onclose}set onclose(e){this._onclose&&this.removeEventListener("close",this._onclose),this._onclose=e,e&&this.addEventListener("close",e)}get onmessage(){return this._onmessage}set onmessage(e){this._onmessage&&this.removeEventListener("message",this._onmessage),this._onmessage=e,e&&this.addEventListener("message",e)}get onbufferedamountlow(){return this._onbufferedamountlow}set onbufferedamountlow(e){this._onbufferedamountlow&&this.removeEventListener("bufferedamountlow",this._onbufferedamountlow),this._onbufferedamountlow=e,e&&this.addEventListener("bufferedamountlow",e)}get onerror(){return this._onerror}set onerror(e){this._onerror&&this.removeEventListener("error",this._onerror),this._onerror=e,e&&this.addEventListener("error",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}close(){["closing","closed"].includes(this._readyState)||(this._readyState="closed")}send(e){if("open"!==this._readyState)throw new Uh.InvalidStateError("not open")}}var qh={};Object.defineProperty(qh,"__esModule",{value:!0}),qh.generateRouterRtpCapabilities=function(){return zh.deepFreeze({codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}},{mimeType:"video/H264",kind:"video",preferredPayloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:105,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"profile-id":0,"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:106,clockRate:9e4,rtcpFeedback:[],parameters:{apt:105}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",preferredId:2,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",preferredId:3,preferredEncrypt:!1,direction:"recvonly"},{kind:"audio",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:11,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:12,preferredEncrypt:!1,direction:"sendrecv"}]})},qh.generateNativeRtpCapabilities=function(){return{codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:111,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{minptime:10,useinbandfec:1}},{mimeType:"audio/ISAC",kind:"audio",preferredPayloadType:103,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/CN",kind:"audio",preferredPayloadType:106,clockRate:32e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/foo",kind:"audio",preferredPayloadType:107,clockRate:9e4,channels:4,rtcpFeedback:[{type:"foo-qwe-qwe"}],parameters:{foo:"lalala"}},{mimeType:"video/BAZCODEC",kind:"video",preferredPayloadType:100,clockRate:9e4,rtcpFeedback:[{type:"foo"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[],parameters:{apt:100}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:96,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:97,clockRate:9e4,rtcpFeedback:[],parameters:{apt:96}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:98,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{"profile-id":0}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:99,clockRate:9e4,rtcpFeedback:[],parameters:{apt:98}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:2},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:3},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:4},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",preferredId:6},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-content-type",preferredId:7},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-timing",preferredId:8},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10}]}},qh.generateNativeSctpCapabilities=function(){return zh.deepFreeze({numStreams:{OS:2048,MIS:2048}})},qh.generateLocalDtlsParameters=function(){return zh.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"82:5A:68:3D:36:C3:0A:DE:AF:E7:32:43:D2:88:83:57:AC:2D:65:E5:80:C4:B6:FB:AF:1A:A0:21:9F:6D:0C:AD"}],role:"auto"})},qh.generateTransportRemoteParameters=function(){return{id:Gh(),iceParameters:zh.deepFreeze({iceLite:!0,password:"yku5ej8nvfaor28lvtrabcx0wkrpkztz",usernameFragment:"h3hk1iz6qqlnqlne"}),iceCandidates:zh.deepFreeze([{foundation:"udpcandidate",address:"9.9.9.9",ip:"9.9.9.9",port:40533,priority:1078862079,protocol:"udp",type:"host",tcpType:"passive"},{foundation:"udpcandidate",address:"9.9.9.9",ip:"9:9:9:9:9:9",port:41333,priority:1078862089,protocol:"udp",type:"host",tcpType:"passive"}]),dtlsParameters:zh.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"A9:F4:E0:D2:74:D3:0F:D9:CA:A5:2F:9F:7F:47:FA:F0:C4:72:DD:73:49:D0:3B:14:90:20:51:30:1B:90:8E:71"},{algorithm:"sha-384",value:"03:D9:0B:87:13:98:F6:6D:BC:FC:92:2E:39:D4:E1:97:32:61:30:56:84:70:81:6E:D1:82:97:EA:D9:C1:21:0F:6B:C5:E7:7F:E1:97:0C:17:97:6E:CF:B3:EF:2E:74:B0"},{algorithm:"sha-512",value:"84:27:A4:28:A4:73:AF:43:02:2A:44:68:FF:2F:29:5C:3B:11:9A:60:F4:A8:F0:F5:AC:A0:E3:49:3E:B1:34:53:A9:85:CE:51:9B:ED:87:5E:B8:F4:8E:3D:FA:20:51:B8:96:EE:DA:56:DC:2F:5C:62:79:15:23:E0:21:82:2B:2C"}],role:"auto"}),sctpParameters:zh.deepFreeze({port:5e3,OS:2048,MIS:2048,maxMessageSize:2e6})}},qh.generateProducerRemoteParameters=function(){return zh.deepFreeze({id:Gh()})},qh.generateConsumerRemoteParameters=function({id:e,codecMimeType:t}={}){switch(t){case"audio/opus":return{id:e??Gh(),producerId:Gh(),kind:"audio",rtpParameters:zh.deepFreeze({codecs:[{mimeType:"audio/opus",payloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}}],encodings:[{ssrc:46687003}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",id:10}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"audio/ISAC":return{id:e??Gh(),producerId:Gh(),kind:"audio",rtpParameters:zh.deepFreeze({codecs:[{mimeType:"audio/ISAC",payloadType:111,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}}],encodings:[{ssrc:46687004}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/VP8":return{id:e??Gh(),producerId:Gh(),kind:"video",rtpParameters:zh.deepFreeze({codecs:[{mimeType:"video/VP8",payloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",payloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}}],encodings:[{ssrc:99991111,rtx:{ssrc:99991112}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/H264":return{id:e??Gh(),producerId:Gh(),kind:"video",rtpParameters:zh.deepFreeze({codecs:[{mimeType:"video/H264",payloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",payloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}}],encodings:[{ssrc:99991113,rtx:{ssrc:99991114}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};default:throw new TypeError(`unknown codecMimeType '${t}'`)}},qh.generateDataProducerRemoteParameters=function(){return zh.deepFreeze({id:Gh()})},qh.generateDataConsumerRemoteParameters=function({id:e}={}){return{id:e??Gh(),dataProducerId:Gh(),sctpStreamParameters:zh.deepFreeze({streamId:666,maxPacketLifeTime:5e3,maxRetransmits:void 0})}};const zh=zc;function Gh(){return String(zh.generateRandomNumber())}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.testFakeParameters=e.FakeHandler=e.enhancedEvents=e.ortc=e.parseScalabilityMode=e.detectDeviceAsync=e.detectDevice=e.Device=e.version=e.types=void 0;const t=Qa.exports;e.debug=t.default,e.types=sc,e.version="3.15.6";var r=oc;Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return r.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return r.detectDevice}}),Object.defineProperty(e,"detectDeviceAsync",{enumerable:!0,get:function(){return r.detectDeviceAsync}});var n=Iu;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return n.parse}}),e.ortc=Gc,e.enhancedEvents=Sc;var i=gp;Object.defineProperty(e,"FakeHandler",{enumerable:!0,get:function(){return i.FakeHandler}}),e.testFakeParameters=qh}(Ka);const Yh=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],$h=[{maxBitrate:1e6,dtx:!0}],Jh=[{maxBitrate:4e4,dtx:!0}],Kh={width:1280,height:720},Qh=0,Zh=2,Xh=0;function ef(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function tf(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}const rf=new Hn,nf=e=>u(void 0,void 0,void 0,(function*(){return yield new Promise(((t,r)=>{!function(e,t,r){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");"function"==typeof t&&(r=t,t={}),t=t||{},r=r||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async=!("async"in t)||!!t.async,i.src=e,t.attrs&&function(e,t){for(var r in t)e.setAttribute(r,t[r])}(i,t.attrs),t.text&&(i.text=""+t.text),("onload"in i?ef:tf)(i,r),i.onload||ef(i,r),n.appendChild(i)}(e,((e,n)=>{e?r(e):t(n)}))}))})),sf=(e,...t)=>u(void 0,[e,...t],void 0,(function*(e,t=3,r=500){let n=0;for(;n<t;)try{return void(yield nf(e))}catch(e){if(n+=1,!(n<t))throw e;yield rf.sleepMs(r)}}));var of;let af=class{constructor(){of.set(this,new Map)}add(e,t,r){const n=this.getKey(e,t);if(l(this,of,"f").has(n))throw new Error("Attempt to rewrite cached track processor");l(this,of,"f").set(n,r)}get(e,t){return l(this,of,"f").get(this.getKey(e,t))}has(e,t){return l(this,of,"f").has(this.getKey(e,t))}getKey(e,t){return`${e}:${t}`}reset(){for(const e of l(this,of,"f").values())e.stopProcessing();l(this,of,"f").clear()}};var cf,df;of=new WeakMap,af=a([ut()],af);let uf=class{constructor(e,t,r,n){this.config=e,this.processorsCache=t,this.audioTrackProcessorFactory=r,cf.set(this,new Map),df.set(this,void 0),p(this,df,n("IntegrationsService"),"f")}init(){const e=this.config.get("denoiser");if("asdk"===e){l(this,df,"f").info("Start integration of ASDK",{denoiser:e});const t={integrated:!1,initPromise:this.integrateASDK()};l(this,cf,"f").set("asdk",t)}else{l(this,df,"f").info("Start integration of RNNoise",{denoiser:e});const t={integrated:!1,initPromise:this.integrateRNNoise()};l(this,cf,"f").set("rnnoise",t)}}integrateASDK(){return u(this,void 0,void 0,(function*(){const e=this.config.get("asdk"),t=this.config.get("staticFilesPath");if(!window.atsvb){const s=`https://effectssdk.ai/sdk/audio/dev/${e.version}/atsvb-web.js`;let o=s;if(e.localDir){const n=`${e.localDir}/${e.version}/atsvb-web.js`;o=new r.URL(n,t).href}yield(n=o,i=s,u(void 0,void 0,void 0,(function*(){try{yield sf(n)}catch(e){if(!i)throw e;yield sf(i)}})))}var n,i;if(!window.atsvb)throw l(this,df,"f").info("Audio Effects SDK is not loaded, skipping initialization",{case:"initAudioSDK"}),new Error("windows.atsvb is still missing");const s=this.audioTrackProcessorFactory({trackLabel:$n.Microphone});yield s.init(),this.processorsCache.add("asdk",$n.Microphone,s);const o=l(this,cf,"f").get("asdk");if(!o)throw Error("IntegrationContext is missing for ASDK");o.integrated=!0}))}get audio(){return"asdk"===this.config.get("denoiser")?this.getASDKState():this.getRNNoiseState()}getASDKState(){var e,t;const r=l(this,cf,"f").get("asdk");return{type:"asdk",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}getRNNoiseState(){var e,t;const r=l(this,cf,"f").get("rnnoise");return{type:"rnnoise",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}integrateRNNoise(){return u(this,void 0,void 0,(function*(){const e=yield function(e){return u(this,void 0,void 0,(function*(){if(!window.WebAssembly)throw new Error("Webassembly not supported");const t=yield fetch(`${e}/rnnoise-processor.wasm`);return yield WebAssembly.instantiate(yield t.arrayBuffer())}))}(this.config.get("staticFilesPath")),t=this.audioTrackProcessorFactory({trackLabel:$n.Microphone,noiseSuppressor:e});this.processorsCache.add("rnnoise",$n.Microphone,t);const r=l(this,cf,"f").get("rnnoise");if(!r)throw Error("IntegrationContext is missing for RNNoise");r.integrated=!0}))}reset(){l(this,cf,"f").clear()}};var lf,pf,hf,ff,mf,gf,vf,yf,_f;cf=new WeakMap,df=new WeakMap,uf=a([ut(),c(0,pt(Gn.Config)),c(1,pt(Gn.ProcessorsCache)),c(2,pt(Gn.AudioTrackProcessorFactory)),c(3,pt(Gn.LoggerFactory)),d("design:paramtypes",[Rt,af,Function,Function])],uf),function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(yf||(yf={})),function(e){e.TSVB="tsvb",e.COMPONENTS_SYSTEM="components_system",e.SRTEAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.PRESET_INIT="preset_init",e.RENDERER="renderer",e.RECORDER="recorder",e.EFFECT_VIRTUAL_BACKGROUND="effect_virtual_background",e.EFFECT_COLOR_CORRECTION="effect_color_correction",e.EFFECT_COLOR_FILTER="effect_color_filter",e.EFFECT_SMART_ZOOM="effect_smart_zoom",e.EFFECT_LOW_LIGHT="effect_low_light"}(_f||(_f={}));class bf{constructor(e){lf.set(this,void 0),pf.set(this,void 0),hf.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),ff.set(this,null),mf.set(this,void 0),gf.set(this,!1),vf.set(this,void 0);const{loggerFactory:t}=e;if(p(this,pf,t("EffectsSDKTrackProcessor"),"f"),p(this,vf,e.onModelsLoaded,"f"),!e.customerId)throw new Error("Customer ID must be provided");p(this,lf,new window.tsvb(e.customerId),"f"),l(this,lf,"f").onError(this.tsvbErrorHandler.bind(this)),l(this,lf,"f").onReady=this.onReady.bind(this);const r=e.config.get("staticFilesPath"),{localDir:n,version:i}=e.config.get("effectsSDKParams"),s=n&&i?`${r}/esdk/${null!=i?i:"3.5.5"}`:`https://effectssdk.ai/sdk/web/${null!=i?i:"3.5.5"}`,o={preset:"balanced",provider:"webgpu",sdk_url:e.sdk_url,api_url:e.api_url,wasmPaths:{"ort-wasm.wasm":`${s}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${s}/ort-wasm-simd.wasm`,"ort-wasm-simd.jsep.wasm":`${s}/ort-wasm-simd.jsep.wasm`}};l(this,lf,"f").config(o)}init(){return u(this,void 0,void 0,(function*(){yield l(this,lf,"f").preload(),yield l(this,lf,"f").cache(),p(this,gf,!0,"f")}))}awaitReady(){return u(this,void 0,void 0,(function*(){yield new Promise(((e,t)=>{const r=Date.now(),n=setInterval((()=>{if(this.isModelsLoaded)return clearInterval(n),void e();Date.now()-r>6e4&&(clearInterval(n),t(new Error("ESDK init timeout")))}),100)}))}))}tsvbErrorHandler(e){var t;const{emitter:r,type:n}=e,i=o(e,["emitter","type"]),s=null!=r?r:"N/A emitter";n===yf.ERROR&&l(this,pf,"f").error(s,Object.assign({error:mr(e)},i)),n===yf.WARNING&&l(this,pf,"f").warn(s,Object.assign({},i)),n===yf.INFO&&l(this,pf,"f").info(s,Object.assign({},i)),r===_f.ML_INFERENCE&&(i.message.toLocaleLowerCase().includes("init lowlighter")&&(l(this,hf,"f").lowLighter=!0),i.message.toLocaleLowerCase().includes("init colorcorrector")&&(l(this,hf,"f").colorCorrector=!0),i.message.toLocaleLowerCase().includes("init facedetector")&&(l(this,hf,"f").faceDetector=!0),i.message.toLocaleLowerCase().includes("init segmentation")&&(l(this,hf,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=l(this,vf,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return l(this,hf,"f").colorCorrector&&l(this,hf,"f").faceDetector&&l(this,hf,"f").lowLighter&&l(this,hf,"f").segmentation}get modelsLoadProgress(){return Object.values(l(this,hf,"f")).filter(Boolean).length/Object.keys(l(this,hf,"f")).length}get isReady(){return l(this,gf,"f")}setOnLoadModels(e){p(this,vf,e,"f"),this.isModelsLoaded&&l(this,vf,"f").call(this)}onReady(){p(this,gf,!0,"f"),l(this,pf,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(l(this,mf,"f"))}processTrack(e){var t,r,n;if(l(this,ff,"f")===e||"ended"===e.readyState)return null!==(r=null===(t=l(this,lf,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])&&void 0!==r?r:e;this.stopProcessing();try{l(this,lf,"f").useStream(new MediaStream([e]));const t=null===(n=l(this,lf,"f").getStream())||void 0===n?void 0:n.getVideoTracks()[0];return t?(p(this,ff,e,"f"),t):e}catch(t){throw l(this,pf,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}stopProcessing(){try{l(this,lf,"f").clear(),l(this,lf,"f").stop()}catch(e){l(this,pf,"f").error("stopProcessing()",{error:e})}finally{p(this,ff,null,"f")}}updateEffects(e){var t,r,n,i,s,o,a,c,d,u,h,f,m,g,v,y,_,b,E,w,S,C;if(p(this,mf,e,"f"),!l(this,gf,"f"))return void l(this,pf,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!l(this,mf,"f")||0===Object.keys(l(this,mf,"f")).length)return void l(this,lf,"f").stop();let P=0;if((null===(t=l(this,mf,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=l(this,mf,"f"))||void 0===r?void 0:r.backgroundColor)?(l(this,lf,"f").setBlur(l(this,mf,"f").blur),P+=1):l(this,lf,"f").clearBlur(),void 0!==(null===(n=l(this,mf,"f"))||void 0===n?void 0:n.background)?(l(this,lf,"f").setBackground(l(this,mf,"f").background),P+=1):void 0!==(null===(i=l(this,mf,"f"))||void 0===i?void 0:i.backgroundColor)?(l(this,lf,"f").setBackgroundColor(null===(s=l(this,mf,"f"))||void 0===s?void 0:s.backgroundColor),l(this,lf,"f").setBackground("color"),P+=1):l(this,lf,"f").clearBackground(),(null===(o=l(this,mf,"f"))||void 0===o?void 0:o.beautification)?(l(this,lf,"f").enableBeautification(),l(this,lf,"f").setBeautificationLevel(l(this,mf,"f").beautification),P+=1):l(this,lf,"f").disableBeautification(),(null===(a=l(this,mf,"f"))||void 0===a?void 0:a.lowLightEffect)?(l(this,lf,"f").enableLowLightEffect(),l(this,lf,"f").setLowLightEffectPower(l(this,mf,"f").lowLightEffect),P+=1):l(this,lf,"f").disableLowLightEffect(),(null===(c=l(this,mf,"f"))||void 0===c?void 0:c.colorCorrector)?(l(this,lf,"f").enableColorCorrector(),l(this,lf,"f").setColorCorrectorPower(l(this,mf,"f").colorCorrector),P+=1):l(this,lf,"f").disableColorCorrector(),(null===(d=l(this,mf,"f"))||void 0===d?void 0:d.smartZoom)?(l(this,lf,"f").enableSmartZoom(),l(this,lf,"f").setFaceArea(l(this,mf,"f").smartZoom),P+=1):l(this,lf,"f").disableSmartZoom(),(null===(u=l(this,mf,"f"))||void 0===u?void 0:u.layout)?(l(this,lf,"f").setLayout(l(this,mf,"f").layout),P+=1):l(this,lf,"f").setLayout("center"),(null===(h=l(this,mf,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=l(this,mf,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=l(this,mf,"f"))||void 0===m?void 0:m.colorFilter.url)?(l(this,lf,"f").setColorFilterConfig({lut:l(this,mf,"f").colorFilter.url,power:l(this,mf,"f").colorFilter.power}),l(this,lf,"f").enableColorFilter(),P+=1):l(this,lf,"f").disableColorFilter(),null===(g=l(this,mf,"f"))||void 0===g?void 0:g.lowerThird){const e=l(this,lf,"f").createComponent({component:l(this,mf,"f").lowerThird.type,options:null!==(v=l(this,mf,"f").lowerThird.options)&&void 0!==v?v:{}});null===(b=null===(_=null===(y=l(this,lf,"f").components)||void 0===y?void 0:y.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===b||b.call(_),l(this,lf,"f").addComponent(e,"lowerThird"),l(this,lf,"f").components.lowerThird.showLowerThird(),P+=1}else null===(S=null===(w=null===(E=l(this,lf,"f").components)||void 0===E?void 0:E.lowerThird)||void 0===w?void 0:w.hideLowerThird)||void 0===S||S.call(w);(null===(C=l(this,mf,"f"))||void 0===C?void 0:C.sharpness)?(l(this,lf,"f").setSharpnessEffectConfig(l(this,mf,"f").sharpness),P+=1):l(this,lf,"f").disableSharpnessEffect(),P>2?l(this,lf,"f").enableFrameSkipping():l(this,lf,"f").disableFrameSkipping(),l(this,lf,"f").run()}}lf=new WeakMap,pf=new WeakMap,hf=new WeakMap,ff=new WeakMap,mf=new WeakMap,gf=new WeakMap,vf=new WeakMap;const Ef=e=>"rtx"!==e.mimeType;var wf,Sf,Cf,Pf,Tf,kf,Rf,If,Df,Af,Of,Nf,Mf,Lf,xf,Ff,jf;class Uf{constructor({track:e,statsHandler:t}){wf.set(this,void 0),Sf.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return l(this,wf,"f")}get audioWebRTCStats(){return l(this,Sf,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addOutboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addOutboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){p(this,wf,e,"f")}setAudioWebRTCStats(e){p(this,Sf,e,"f")}}wf=new WeakMap,Sf=new WeakMap,function(e){e.CloseProducer="CloseProducer",e.Mute="Mute",e.Resume="Resume"}(Cf||(Cf={}));class Bf{constructor(e){Pf.set(this,void 0),Tf.set(this,void 0),this.encoderConfig={},this.label=$n.Unknown,kf.set(this,void 0),Rf.set(this,void 0),If.set(this,void 0),Df.set(this,void 0),Af.set(this,void 0),Of.set(this,void 0),Nf.set(this,void 0),Mf.set(this,void 0),Lf.set(this,!0),xf.set(this,void 0),Ff.set(this,void 0),jf.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,socket:c,mutex:d,loggerFactory:u,loggerNamespace:l,statsHandler:h}=e;p(this,Pf,t,"f"),p(this,Af,r,"f"),p(this,Of,n,"f"),p(this,Nf,i,"f"),p(this,Mf,new It,"f"),this.logger=u(l),p(this,xf,d,"f"),p(this,Rf,s,"f"),p(this,kf,o,"f"),p(this,If,a,"f"),p(this,Df,c,"f"),p(this,jf,h,"f"),p(this,Ff,new Uf({track:t,statsHandler:h}),"f")}get videoWebRTCStats(){return l(this,Ff,"f").videoWebRTCStats}get audioWebRTCStats(){return l(this,Ff,"f").audioWebRTCStats}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished}}get observer(){return l(this,Mf,"f")}get mediaStreamTrack(){return l(this,Pf,"f")}get originalTrack(){return l(this,Tf,"f")}get id(){return this.mediaStreamTrack.id}get kind(){return this.mediaStreamTrack.kind}get producerId(){var e;return null===(e=this.producer)||void 0===e?void 0:e.id}get isPublished(){return!!this.producer&&!this.producer.closed}get isPaused(){var e,t;return null!==(t=null===(e=this.producer)||void 0===e?void 0:e.paused)&&void 0!==t&&t}get internalEventEmitter(){return l(this,Af,"f")}getLabel(){return this.label}setLabel(e){this.label=e}setEncoderConfig(e){this.encoderConfig=e}getEncoderConfig(){return this.encoderConfig}setProducer(e){this.producer=e}setStopTrackOnPause(e){this.isPublished||p(this,Lf,e,"f")}getProducer(){return this.producer}setOriginalTrack(){p(this,Tf,this.mediaStreamTrack,"f")}closeProducer(){return u(this,arguments,void 0,(function*(e=!0){const t=yield l(this,xf,"f").lock(Cf.CloseProducer);if(!this.producer)return void t();const{producerId:r}=this;try{r&&(yield l(this,If,"f").closeRemoteProducer(r),this.logger.info("Remote producer closed",{producerId:r}))}catch(e){this.logger.warn("closeProducer()",{label:this.getLabel(),error:mr(e),producerId:r})}this.producer.close(),this.producer=void 0,e&&this.stopMediaStreamTrack(),t()}))}setPriority(e){return u(this,void 0,void 0,(function*(){this.producer?(yield this.producer.setRtpEncodingParameters({priority:e}),this.logger.debug("setPriority()",{label:this.getLabel(),priority:e})):this.logger.warn("setPriority()",{priority:e,reason:"Not published yet"})}))}stopMediaStreamTrack(){this.mediaStreamTrack.stop(),this.mediaStreamTrack.dispatchEvent(new Event("ended")),this.stopOriginalTrack()}stopOriginalTrack(){l(this,Tf,"f")&&(l(this,Tf,"f").stop(),p(this,Tf,void 0,"f"))}produce(e){return u(this,arguments,void 0,(function*({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s,o,a,c,d;if(!l(this,kf,"f").canPublish)throw this.logger.error("produce()",{message:"Not enough access to produce"}),new Error("Not enough access to produce");if(this.producer)throw new Error("Track already produced");try{yield l(this,Df,"f").request(Tr);const{rtpCapabilities:{codecs:u}}=l(this,Rf,"f").mediasoupDevice,p=null==u?void 0:u.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),h=0,f=this.prepareProducerEncodings({codec:p,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),m={trackTransformParams:n,peerId:String(l(this,kf,"f").id),label:this.getLabel(),maxSpatialLayer:h,encodings:f,codecOptions:t,preferredCodec:r,codec:p,keyFrameRequestDelay:i},g=yield null===(s=l(this,If,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:f,codecOptions:t,codec:p,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:m});if(!g)return;const v=g.rtpSender,y=()=>/Safari/i.test(navigator.userAgent);if(e&&v&&y()){const t=v.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield v.setParameters(t)}this.setProducer(g),(null===(a=null===(o=this.producer)||void 0===o?void 0:o.track)||void 0===a?void 0:a.id)!==l(this,Pf,"f").id&&(this.logger.info("Producer initialized with old track, updating",{oldTrackId:null===(d=null===(c=this.producer)||void 0===c?void 0:c.track)||void 0===d?void 0:d.id,newTrackId:l(this,Pf,"f").id}),yield this.replaceTrack(l(this,Pf,"f"))),"video"===this.kind&&(e&&v&&p&&Wn(p.mimeType)&&!y()?yield v.setParameters(Object.assign(Object.assign({},v.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:p,maxSpatialLayer:h})})):yield g.setMaxSpatialLayer(h),yield l(this,Df,"f").request(mn,{producerId:g.id,maxSpatialLayer:h})),"audio"===this.kind&&(yield this.setPriority("high")),this.logger.debug("produce()",{track:this.logCtx,encodings:e,codecOptions:t})}catch(e){throw this.logger.error("produce()",{error:e,track:this.logCtx}),new Error("Publish track failed")}}))}publish(){return u(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(Qr.trackProduced,this)}))}unpublish(){return u(this,arguments,void 0,(function*(e=!0){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Qr.trackUnproduced,this),this.producer&&(yield this.closeProducer()),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return u(this,void 0,void 0,(function*(){return yield l(this,Df,"f").request(hn,{producerId:e})}))}resumeRemoteProducer(e){return u(this,void 0,void 0,(function*(){return yield l(this,Df,"f").request(fn,{producerId:e})}))}mute(e){return u(this,void 0,void 0,(function*(){const t=yield l(this,xf,"f").lock(Cf.Mute);if(!this.producer)return this.logger.warn("pause()",{message:"Track is not published",track:this.logCtx}),void t();try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),l(this,Lf,"f"))return null==e||e(),l(this,Pf,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Qr.trackClosed,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Qr.trackPaused,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield l(this,Rf,"f").deleteTrack(this),this.internalEventEmitter.emit(Qr.trackFailed,this),new Error("Can`t pause track, removing")}finally{t()}}))}resume(){return u(this,void 0,void 0,(function*(){const e=yield l(this,xf,"f").lock(Cf.Resume);if(!this.producer)return this.logger.warn("resume()",{message:"Track is not published",track:this.logCtx}),void e();try{if(this.logger.debug("resume()",{track:this.logCtx}),l(this,Lf,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Qr.trackReopened,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Qr.trackResumed,this)}catch(e){throw this.logger.error("resume()",{error:e,track:this.logCtx}),new Error("Can`t resume track")}finally{e()}}))}getInfo(){return u(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=l(this,Pf,"f").getSettings();return{trackId:l(this,Pf,"f").id,readyState:l(this,Pf,"f").readyState,kind:this.kind,label:this.label,width:e,height:t,frameRate:r,aspectRatio:n,paused:this.isPaused,trackOutboundStats:yield this.getStats()}}))}getStats(){return u(this,void 0,void 0,(function*(){var e,t,r,n,i;try{return{producerId:null===(e=this.producer)||void 0===e?void 0:e.id,codec:null===(t=this.producer)||void 0===t?void 0:t.rtpParameters.codecs.find((e=>Ef(e))),dtlsState:null===(i=null===(n=null===(r=this.producer)||void 0===r?void 0:r.rtpSender)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.state,rtcStats:yield this.getOutboundRTPStreamStats()}}catch(e){return void this.logger.debug("getStats()",{error:e})}}))}replaceTrack(e){return u(this,void 0,void 0,(function*(){var t;try{p(this,Pf,e,"f"),this.internalEventEmitter.emit(Qr.trackReopened,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),p(this,Ff,new Uf({track:e,statsHandler:l(this,jf,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return u(this,void 0,void 0,(function*(){this.producer?(yield this.resumeRemoteProducer(this.producer.id),this.producer.resume()):this.logger.debug("resumeProducer()",{message:"Track not produced yet",track:this.logCtx})}))}reopenMediaStreamTrack(){return u(this,void 0,void 0,(function*(){var e;const t=yield l(this,Nf,"f").createMediaStreamTrack({label:this.label,constraints:l(this,Of,"f")});p(this,Pf,t,"f"),yield null===(e=this.producer)||void 0===e?void 0:e.replaceTrack({track:t})}))}prepareProducerEncodings(e){const{encodings:t,codec:r,maxSpatialLayer:n}=e;return t&&t.length>1&&r&&Wn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>u(this,[...n],void 0,(function*(n=0){if(!this.producer)throw new Error("Producer is missed");try{const i=yield this.producer.getStats(),s=Array.from(i.values()).find((e=>"outbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>u(this,void 0,void 0,(function*(){return yield r(n+1)}))),150);n>=5&&!s&&t(new Error("OutboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),this.logger.debug("getOutboundRTPStreamStats()",{error:e})}}));r().catch((e=>{this.logger.debug("Error executing getRTCStatsReport",{case:"DefaultBaseTrack",error:mr(e)})}))}))}))}}var Vf,Wf,Hf,qf;Pf=new WeakMap,Tf=new WeakMap,kf=new WeakMap,Rf=new WeakMap,If=new WeakMap,Df=new WeakMap,Af=new WeakMap,Of=new WeakMap,Nf=new WeakMap,Mf=new WeakMap,Lf=new WeakMap,xf=new WeakMap,Ff=new WeakMap,jf=new WeakMap;class zf extends Bf{constructor(e){super(e),this.transformParams={},Vf.set(this,void 0),Wf.set(this,void 0),Hf.set(this,!1),qf.set(this,(()=>{})),p(this,Wf,e,"f")}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished,isEffectsProcessing:this.isEffectsProcessing}}get isEffectsProcessing(){return Boolean(l(this,Vf,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){var e;return{videoGoogleStartBitrate:null!==(e=this.getEncoderConfig().videoGoogleStartBitrate)&&void 0!==e?e:1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===$n.ScreenVideo?"vp8":"h264")}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Yh}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return u(this,void 0,void 0,(function*(){const t=this.getProducer();t?(yield t.setMaxSpatialLayer(e),this.logger.debug("setMaxSpatialLayer()",{label:this.getLabel(),spatialLayer:e})):this.logger.warn("setMaxSpatialLayer()",{message:"Not produced yet"})}))}getMaxSpatialLayer(){const e=this.getProducer();if(e)return e.maxSpatialLayer;this.logger.warn("getMaxSpatialLayer()",{message:"Not produced yet"})}enableEffects(){return u(this,void 0,void 0,(function*(){if(!l(this,Hf,"f")){p(this,Hf,!0,"f");try{if(l(this,Vf,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void p(this,Hf,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=l(this,Wf,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();p(this,Vf,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=l(this,Vf,"f").processTrack(this.mediaStreamTrack),n=Date.now();this.logger.info("enableEffects() time",{time:(n-t)/1e3}),yield this.replaceTrack(r),this.logger.info("enableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("enableEffects()",{track:this.logCtx,error:mr(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:mr(e)})})),l(this,qf,"f").call(this,e)}finally{p(this,Hf,!1,"f")}}}))}disableEffects(){return u(this,void 0,void 0,(function*(){var e;try{if(!l(this,Vf,"f"))return void this.logger.debug("disableEffects()",{description:"Track is not processed"});this.originalTrack?yield this.replaceTrack(this.originalTrack):this.logger.warn("disableEffects()",{description:"Original track missing"}),null===(e=l(this,Vf,"f"))||void 0===e||e.stopProcessing(),p(this,Vf,void 0,"f"),this.logger.info("disableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("disableEffects()",{track:this.logCtx,error:e})}}))}publish(){return u(this,arguments,void 0,(function*(e={}){var t;yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),transformParams:this.transformParams,codecOptions:this.getCodecOptions(),keyFrameRequestDelay:null!==(t=e.keyFrameRequestDelay)&&void 0!==t?t:0}),this.internalEventEmitter.emit(Qr.trackProduced,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return u(this,void 0,void 0,(function*(){var t;if(!Wn(this.getPreferredCodec()))return;const{rtpSender:r}=null!==(t=this.getProducer())&&void 0!==t?t:{};if(!r)return void this.logger.warn("No rtpSender found in producer to change encodings",{maxSpatialLayer:e,trackId:this.id,producerId:this.producerId});const{encodings:n=[]}=this.getEncoderConfig(),i=n[e];if(!i)return void this.logger.warn("Skipping RTPSender params update. No target encoding found",{initialEncodings:n});this.logger.debug("Adjusting encoding parameters to max spatial layer",{targetEncoding:i,maxSpatialLayer:e});const s=r.getParameters();yield r.setParameters(Object.assign(Object.assign({},s),{encodings:[Object.assign(Object.assign({},s.encodings[0]),i)]}))}))}applyEffects(e){return u(this,void 0,void 0,(function*(){var t;try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=l(this,Vf,"f"))||void 0===t||t.updateEffects(e)}catch(e){l(this,qf,"f").call(this,e)}}))}resetEffects(){var e;null===(e=l(this,Vf,"f"))||void 0===e||e.updateEffects({})}setOnLoadModels(e){var t;null===(t=l(this,Vf,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e,t;return null!==(t=null===(e=l(this,Vf,"f"))||void 0===e?void 0:e.modelsLoadProgress)&&void 0!==t?t:0}pause(){return u(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;l(this,Vf,"f")&&(null===(e=l(this,Vf,"f"))||void 0===e||e.stopProcessing(),p(this,Vf,void 0,"f"))}))}))}setOnEffectError(e){p(this,qf,e,"f")}}var Gf,Yf;Vf=new WeakMap,Wf=new WeakMap,Hf=new WeakMap,qf=new WeakMap;let $f=Yf=class{constructor(e){Gf.set(this,void 0),p(this,Gf,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack(e){return u(this,arguments,void 0,(function*({label:e,constraints:t}){if(Yf.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[$n.ScreenVideo,$n.ScreenAudio].includes(e)}createUserMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return l(this,Gf,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return l(this,Gf,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};Gf=new WeakMap,$f=Yf=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],$f);var Jf,Kf,Qf,Zf,Xf,em,tm,rm=$f;let nm=class{constructor(e,t,r,n,i,s,o,a,c){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.clientEventEmitter=n,this.integrationsService=i,this.processorsCache=s,this.videoTrackFactory=o,this.mediaStreamTrackManager=a,this.socket=c,this.isDeviceLoaded=!1,this.tracks=new Map,Jf.set(this,void 0),Kf.set(this,null),Qf.set(this,!1),Zf.set(this,new Map),Xf.set(this,!1),em.set(this,!1),tm.set(this,void 0);const d=this.config.get("effectsSDKParams");p(this,tm,this.config.get("denoiser"),"f"),p(this,Jf,this.loggerFactory("Media"),"f"),p(this,Kf,null!=d?d:null,"f")}get mediasoupDevice(){var e;return null!==(e=this.device)&&void 0!==e||(this.device=this.createDevice()),this.device}get effectsSDKInitialized(){return l(this,Qf,"f")}get effectsSDKParams(){return l(this,Kf,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return u(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));l(this,Jf,"f").error("getTrackCodec()",{label:e.getLabel,rtpCapabilities:t})}createTracks({constraints:e,mediaStreamTracks:t}){return t.map((t=>{const r={mediaStreamTrack:t,constraints:e};let n;return n="audio"===t.kind?this.audioTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),l(this,Jf,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createCustomMediaTrack(e,t){return this.createTracks({constraints:t,mediaStreamTracks:[e]})[0]}deleteTrack(e){return u(this,void 0,void 0,(function*(){const t={trackId:e.id,label:e.getLabel(),producerId:e.producerId};try{"disableNoiseSuppression"in e&&(yield e.disableNoiseSuppression()),"disableEffects"in e&&(yield e.disableEffects())}catch(e){l(this,Jf,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){l(this,Jf,"f").error("deleteTrack()",{error:e})}finally{l(this,Jf,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){try{this.getAllTracks().forEach((e=>e.stopMediaStreamTrack()))}catch(e){l(this,Jf,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}unpublishTracks(){return u(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>u(this,void 0,void 0,(function*(){return yield e.unpublish(!1)})))))}catch(e){l(this,Jf,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){return u(this,void 0,void 0,(function*(){if(l(this,Qf,"f"))return!0;if(!l(this,Kf,"f"))throw l(this,Jf,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const e=(e,t)=>u(this,void 0,void 0,(function*(){if(!window.tsvb)return l(this,Jf,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);l(this,Jf,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{l(this,Zf,"f").set($n.Camera,yield this.createEffectsSDKTrackProcessor($n.Camera)),l(this,Zf,"f").set($n.CameraPreview,yield this.createEffectsSDKTrackProcessor($n.CameraPreview)),p(this,Qf,!0,"f"),l(this,Jf,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){l(this,Jf,"f").error("Failed to initialize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return yield new Promise(((t,r)=>{if(!window.tsvb)return l(this,Jf,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>u(this,void 0,void 0,(function*(){return yield e(t,r)}))));e(t,r).catch((e=>{l(this,Jf,"f").error("Failed to execute init() in initEffectsSDK",{error:mr(e)})}))}))}))}initDenoiser(e,t){return u(this,void 0,void 0,(function*(){if(!l(this,Xf,"f"))try{p(this,Xf,!0,"f"),this.clientEventEmitter.emit(qr,!0);try{yield this.integrationsService.audio.waitForInitialization}catch(e){"asdk"===l(this,tm,"f")&&(p(this,em,!0,"f"),p(this,tm,"rnnoise","f"),this.config.set("denoiser",l(this,tm,"f")),l(this,Jf,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",error:mr(e),type:this.config.get("denoiser")}),this.clientEventEmitter.emit($r),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization)}l(this,Jf,"f").debug("Denoiser initialized, activating",{case:"Denoiser",type:this.integrationsService.audio.type,trackLabel:e.getLabel()});const r=e,n=this.processorsCache.get(l(this,tm,"f"),$n.Microphone);if(!n)return void l(this,Jf,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type});"asdk"===n.type&&n.setOnError(((r,n)=>{this.clientEventEmitter.emit(qr,!0),this.fallbackToRNoise(e,{reason:r,options:t,error:n}).catch((t=>{l(this,Jf,"f").error("Failed to fallback to RNNoise through onError",{case:"Denoiser",type:l(this,tm,"f"),error:mr(t),label:e.getLabel()})})).then((()=>{this.clientEventEmitter.emit(qr,!1)})).catch((()=>{}))})),r.setTrackProcessor(n),l(this,Jf,"f").debug("Denoiser trackProcessor set, check if activation is needed",{case:"Denoiser",type:l(this,tm,"f"),shouldEnableDenoiser:null==t?void 0:t.noiseSuppression,trackLabel:e.getLabel()}),(null==t?void 0:t.noiseSuppression)&&(yield e.enableNoiseSuppression())}catch(r){if(l(this,Jf,"f").warn("Failed to start noise suppression, featured original track",{case:"Denoiser",type:l(this,tm,"f"),error:mr(r),label:e.getLabel()}),"asdk"===l(this,tm,"f"))try{l(this,Jf,"f").warn("Fallback to RNNoise",{error:mr(r)}),yield this.fallbackToRNoise(e,{options:t,reason:"ASDK init error",error:r})}catch(t){l(this,Jf,"f").error("Failed to fallback to RNNoise through catch",{case:"Denoiser",type:l(this,tm,"f"),error:mr(t),label:e.getLabel()})}}finally{this.clientEventEmitter.emit(qr,!1),p(this,Xf,!1,"f")}}))}fallbackToRNoise(e,t){return u(this,void 0,void 0,(function*(){var r;if(l(this,em,"f"))return;if(p(this,em,!0,"f"),"rnnoise"===l(this,tm,"f"))return;this.clientEventEmitter.emit($r),l(this,Jf,"f").info("Fallback to RNNoise",{reason:null==t?void 0:t.reason,error:mr(null==t?void 0:t.error),case:"Denoiser"});const n=e;yield n.disableNoiseSuppression(),n.unsetTrackProcessor(),p(this,tm,"rnnoise","f"),this.config.set("denoiser",l(this,tm,"f")),l(this,Jf,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",type:this.config.get("denoiser")}),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization;const i=this.processorsCache.get(l(this,tm,"f"),$n.Microphone);i?(n.setTrackProcessor(i),(null===(r=null==t?void 0:t.options)||void 0===r?void 0:r.noiseSuppression)&&(yield n.enableNoiseSuppression())):l(this,Jf,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type})}))}createEffectsSDKTrackProcessor(e){return u(this,void 0,void 0,(function*(){var t,r,n;if(e){const t=l(this,Zf,"f").get(e);if(t)return t}if(!l(this,Kf,"f"))throw l(this,Jf,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const i=new bf({loggerFactory:this.loggerFactory,customerId:null===(t=this.config.get("effectsSDKParams"))||void 0===t?void 0:t.customerId,sdk_url:null===(r=this.config.get("effectsSDKParams"))||void 0===r?void 0:r.sdk_url,api_url:null===(n=this.config.get("effectsSDKParams"))||void 0===n?void 0:n.api_url,config:this.config});return yield i.init(),l(this,Jf,"f").info("Track effects processor initialized",{trackLabel:e}),i}))}handleProducerSetMaxSpatialLayer(e){return u(this,arguments,void 0,(function*({producerId:e,spatialLayer:t}){const r=this.getAllTracks().find((t=>{var r;return(null===(r=t.getProducer())||void 0===r?void 0:r.id)===e}));if(!r)return void l(this,Jf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof zf))return void l(this,Jf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Wrong producer kind"});const n=null!=t?t:Qh,i=r.getMaxSpatialLayer();i!==n?(r.getEncodings().length>1&&(yield r.setMaxSpatialLayer(n)),yield this.socket.request(mn,{producerId:e,maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):l(this,Jf,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}static getVideoTrackTransformParams(e){var t,r;const n=e.getSettings();return{width:null!==(t=n.width)&&void 0!==t?t:Kh.width,height:null!==(r=n.height)&&void 0!==r?r:Kh.height}}static getScreenVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:20},width:{max:Kh.width},height:{max:Kh.height}},encoderConfig:null!==(r=null==e?void 0:e.videoEncoderConfig)&&void 0!==r?r:{encodings:$h}}}static getCameraVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:Kh.width},height:{max:Kh.height}},encoderConfig:null!==(r=null==e?void 0:e.encoderConfig)&&void 0!==r?r:{encodings:Yh}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=Bn.getParser(t);return r.satisfies({"yandex browser":">=25"})&&"iOS"===r.getOSName()?void 0:r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":void 0})();return l(this,Jf,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new Ka.Device({handlerName:e})}};Jf=new WeakMap,Kf=new WeakMap,Qf=new WeakMap,Zf=new WeakMap,Xf=new WeakMap,em=new WeakMap,tm=new WeakMap,nm=a([ut(),c(0,pt(Gn.Config)),c(1,pt(Gn.LoggerFactory)),c(2,pt(Gn.AudioTrackFactory)),c(3,pt(Gn.ClientEventEmitter)),c(4,pt(Gn.IntegrationsService)),c(5,pt(Gn.ProcessorsCache)),c(6,pt(Gn.VideoTrackFactory)),c(7,pt(Gn.MediaStreamTrackManager)),c(8,pt(Gn.SocketIO)),d("design:paramtypes",[Rt,Function,Function,It,uf,af,Function,rm,fa])],nm);var im=nm;const sm={[zi.PRODUCER_KIND_VIDEO]:"video",[zi.PRODUCER_KIND_AUDIO]:"audio"},om={[Ji.PEER_ROLE_HOST]:"host",[Ji.PEER_ROLE_AUDIENCE]:"audience"},am={[xi.PRODUCER_LABEL_CAMERA]:$n.Camera,[xi.PRODUCER_LABEL_MICROPHONE]:$n.Microphone,[xi.PRODUCER_LABEL_SCREEN_VIDEO]:$n.ScreenVideo,[xi.PRODUCER_LABEL_SCREEN_AUDIO]:$n.ScreenAudio,[xi.PRODUCER_LABEL_CUSTOM_VIDEO]:$n.CustomVideo,[xi.PRODUCER_LABEL_CUSTOM_AUDIO]:$n.CustomAudio,[xi.PRODUCER_LABEL_UNKNOWN]:$n.Unknown,[xi.PRODUCER_LABEL_UNSPECIFIED]:$n.Unknown},cm={[Li.PEER_GROUP_MODERATOR]:"moderator",[Li.PEER_GROUP_USER]:"user"},dm=e=>{const t=sm[e];if(!t)throw new Error(`Unknown producer kind: ${e}`);return t},um=e=>{const t=cm[e];if(!t)throw new Error(`Unknown peer group: ${e}`);return t},lm=e=>{const t=am[e];if(!t)throw new Error(`Unknown producer label: ${e}`);return t},pm=e=>{const t=om[e];if(!t)throw new Error(`Unknown peer role: ${e}`);return t},hm=e=>({id:e.id,channelIds:e.channelIds,groups:e.groups.map(um),producePermissions:e.producePermissions.map(lm),appId:e.appId,producers:e.producers.map(fm),uid:e.uid,appData:e.appData,role:pm(e.role),loginDate:e.loginDate}),fm=e=>{var t;return{id:e.id,kind:dm(e.kind),label:lm(e.label),peerId:e.peerId,paused:e.paused,encodings:e.encodings,maxSpatialLayer:null!==(t=e.maxSpatialLayer)&&void 0!==t?t:0}},mm=e=>{switch(e){case"moderator":return Li.PEER_GROUP_MODERATOR;case"user":return Li.PEER_GROUP_USER;default:return Li.PEER_GROUP_UNSPECIFIED}};var gm;let vm=class{constructor(e,t,r,n,i,s,o){this.network=e,this.media=t,this.myPeer=r,this.eventsQueue=n,this.clientEventEmitter=i,this.peers=s,gm.set(this,void 0),p(this,gm,o("ChannelStateSyncEventHandler"),"f"),this.debouncedTriggerChannelStateEvent=jn(this.triggerChannelStateEvent.bind(this),3e3),this.watchNetworkState()}handleChannelStateEvent(e){return u(this,void 0,void 0,(function*(){this.network.peersLoaded?yield this.restoreState(e):this.loadChannelState(e),this.clientEventEmitter.emit(zr)}))}watchNetworkState(){this.clientEventEmitter.on(Vr,(()=>{this.debouncedTriggerChannelStateEvent()}))}triggerChannelStateEvent(){return u(this,void 0,void 0,(function*(){const e=()=>u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>u(this,void 0,void 0,(function*(){const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(l(this,gm,"f").info("Channel state event received",{case:"ChannelStateSynchronizer.triggerChannelStateEvent"}),e()):t(new Error("Channel state event not received"))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Br,i),e()};this.clientEventEmitter.on(Br,i)}))))}));try{yield zn(e,{maxRetries:5,actionName:"triggerChannelStateEventWithRetry",logger:l(this,gm,"f")})}catch(e){l(this,gm,"f").warn("Failed to trigger channel state event",{case:"ChannelStateSynchronizer.triggerChannelStateEvent",error:mr(e)})}}))}loadChannelState(e){l(this,gm,"f").info("Loading channel state",{case:"loadChannelState"});try{const t=this.peers.hosts().map((e=>e.shortData)),r=e.peers.filter((e=>e.role===Ji.PEER_ROLE_HOST));this.setMissingPeers(t,r),this.restoreLocalPeersState(r),this.network.peersLoaded=!0}catch(e){l(this,gm,"f").error("Failed to load channel state",{case:"loadState",error:mr(e)})}}restoreState(e){return u(this,void 0,void 0,(function*(){const{peers:t}=e,r={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isSocketConnectionActive)return l(this,gm,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),r;l(this,gm,"f").info("Restoring local state",{case:"restoreLocalState"});const e=this.peers.hosts().map((e=>e.shortData)),n=t.filter((e=>e.role===Ji.PEER_ROLE_HOST)),{removedProducers:i,fixedProducersState:s}=yield this.restoreRemoteProducersState(n);r.removedProducers.push(...s),r.removedProducers.push(...i),r.removedPeers.push(...this.removeUnnecessaryPeers(e,n)),r.missingPeers.push(...this.setMissingPeers(e,n));const o=this.restoreLocalPeersState(n);return r.missingProducers.push(...o.missingProducers),r.removedProducers.push(...o.removedProducers),r.restoredAppDataPeers.push(...o.restoredAppDataPeers),r.fixedProducersState.push(...o.fixedProducersState),r.fixedConsumersState.push(...o.fixedConsumersState),r}catch(e){return l(this,gm,"f").info("Failed to restore local state",{case:"restoreLocalState",error:mr(e)}),r}}))}restoreRemoteProducersState(e){return u(this,void 0,void 0,(function*(){const t={removedProducers:[],fixedProducersState:[]},r=this.myPeer.get(),n=e.find((e=>e.id===this.myPeer.id));if(!r||!n)return t;const i=this.media.getAllTracks(),s=n.producers.filter((e=>!i.map((e=>e.producerId)).some((t=>e.id===t))));yield Promise.all(s.map((e=>u(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),l(this,gm,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const o=n.producers.filter((e=>!!i.find((t=>t.isPaused&&t.isPaused!==e.paused))));return yield Promise.all(o.map((e=>u(this,void 0,void 0,(function*(){yield this.network.pauseRemoteProducer(e.id),t.fixedProducersState.push(e.id),l(this,gm,"f").info("Remote producer state repaired",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})}))))),t}))}removeUnnecessaryPeers(e,t){const r=[];return e.filter((e=>!t.find((t=>t.id===e.id)))).forEach((e=>{this.peers.remove(e.id).catch((e=>{l(this,gm,"f").error("Failed to remove peer",{error:mr(e)})})),r.push(e.id),l(this,gm,"f").info("Unnecessary peer removed",{case:"restoreLocalState",removedPeerId:e.id})})),r}setMissingPeers(e,t){const r=[];return t.forEach((t=>{if(e.find((e=>e.id===t.id)))return;const n=this.peers.add(hm(t));r.push(n.id),l(this,gm,"f").info("Missing peer added to storage",{case:"restoreLocalState",peerId:t.id})})),r}restoreLocalPeersState(e){const t=new Map(e.map((e=>[e.id,e]))),r=this.peers.hosts(),n={removedProducers:[],missingProducers:[],restoredAppDataPeers:[],fixedConsumersState:[],fixedProducersState:[]};return r.forEach((e=>{const r=t.get(e.id);if(!r)return void l(this,gm,"f").warn("Found new local peer, skip restoring state",{case:"restoreLocalState",newPeerId:e.id});n.removedProducers.push(...this.removeUnnecessaryProducers(e,r));this.restoreAppData(e,r)&&n.restoredAppDataPeers.push(e.id);const{fixedProducersState:i,fixedConsumersState:s,missingProducers:o}=this.restoreTracksState(e,r);n.fixedProducersState.push(...i),n.fixedConsumersState.push(...s),n.missingProducers.push(...o)})),l(this,gm,"f").info("Peers state restored",{case:"restoreLocalState"}),n}removeUnnecessaryProducers(e,t){const r=[];return e.getProducers().filter((e=>!t.producers.find((t=>t.id===e.id)))).forEach((t=>{e.observer.safeEmit(pn,t),r.push(t.id),l(this,gm,"f").info("Unnecessary producer removed",{case:"restoreLocalState",removedProducerId:t.id,removedProducerPeerId:t.peerId})})),r}restoreTracksState(e,t){const r={missingProducers:[],fixedProducersState:[],fixedConsumersState:[]};return t.producers.forEach((t=>{var n;const i=e.producers.get(t.id);if(!i)return e.observer.safeEmit(ln,fm(t)),r.missingProducers.push(t.id),void l(this,gm,"f").info("Missing producer added to storage",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId});const{paused:s}=t;if(i.paused!==s){i.paused=s;const n=i.paused?en:tn;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),l(this,gm,"f").info("Producer state fixed",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId})}const o=e.tracks.get(i.label);if((null==o?void 0:o.consumerId)&&(null===(n=o.consumer)||void 0===n?void 0:n.paused)!==t.paused){const{consumerId:n}=o,s=i.paused?bn:En;e.observer.safeEmit(s,n),r.fixedConsumersState.push(n),l(this,gm,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!Fn(e.appData,t.appData)&&(e.observer.emit(br,t.appData),l(this,gm,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};gm=new WeakMap,vm=a([ut(),c(0,pt(Gn.Network)),c(1,pt(Gn.Media)),c(2,pt(Gn.MyPeer)),c(3,pt(Gn.EventsQueue)),c(4,pt(Gn.ClientEventEmitter)),c(5,pt(Gn.Peers)),c(6,pt(Gn.LoggerFactory)),d("design:paramtypes",[Ma,im,Vs,Us,It,La,Function])],vm);var ym,_m=vm;let bm=class{constructor(e,t,r,n,i){this.peers=e,this.clientEventEmitter=t,this.channelStateSyncEventHandler=n,this.channelStateSynchronizer=i,ym.set(this,void 0),p(this,ym,r("ChannelEvents"),"f")}handleChannelEvent(e){return u(this,void 0,void 0,(function*(){switch(e.eventType){case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE:yield this.handleChannelState(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:this.handleChannelStateShort(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:this.handleChannelManagementEvent(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_JOINED:this.handlePeerJoined(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_LEFT:this.handlePeerLeft(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:this.handlePeerAppDataChanged(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:this.handlePeerGroupsChanged(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:this.handleChannelActivityConfirmationAcquired();break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:this.handleChannelActivityConfirmationExpired();break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:this.handleChannelActivityConfirmationRequired(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:this.handleChannelProducePermissionsChanged(e);break;case cs.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:this.handlePeerProducePermissionsChanged(e);break;case cs.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:this.handleChannelProducePermissionsDeleted(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}))}handleChannelManagementEvent(e){if(!e.channelManagementEvent)throw new Error("Missing channelManagementEvent in CHANNEL_MANAGEMENT_EVENT");const t=e.channelManagementEvent.event;this.clientEventEmitter.safeEmit(kr,t),l(this,ym,"f").debug("New channel event",{event:t})}handlePeerJoined(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.add(hm(e.peer));l(this,ym,"f").debug("Peer joined to the channel",{peer:Bs(t)})}handlePeerLeft(e){if(!e.peer)throw new Error("Missing peer in PEER_LEFT event");this.peers.remove(e.peer.id).catch((e=>{l(this,ym,"f").debug("Failed to remove peer",{error:mr(e)})})),l(this,ym,"f").debug("Peer left the channel",{peerId:e.peer.id})}handleChannelState(e){return u(this,void 0,void 0,(function*(){if(!e.channelState)throw new Error("Missing channelState in CHANNEL_STATE event");try{yield this.channelStateSynchronizer.handleChannelStateEvent(e.channelState)}catch(e){l(this,ym,"f").error("Failed to restore channel state",{case:"restoreLocalState",error:mr(e)})}}))}handleChannelStateShort(e){if(!e.channelStateShort)throw new Error("Missing channelStateShort in CHANNEL_STATE_SHORT event");this.channelStateSyncEventHandler.handleChannelStateShort(e.channelStateShort).catch((e=>{l(this,ym,"f").error("Failed to handle channel state short event",{error:mr(e)})}))}handlePeerAppDataChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.get(e.peer.id);t&&t.observer.emit(br,e.peer.appData)}handlePeerGroupsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_GROUP_CHANGED event");const t=this.peers.get(e.peer.id);null==t||t.handleGroupsChange(e.peer.groups.map(um))}handleChannelActivityConfirmationExpired(){this.clientEventEmitter.safeEmit(Or),l(this,ym,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",{})}handleChannelActivityConfirmationAcquired(){this.clientEventEmitter.safeEmit(Ar),l(this,ym,"f").info("Notify the channel that the activity has been acquired.",{})}handleChannelActivityConfirmationRequired(e){if(!e.channelActivityConfirmationTime)throw new Error("Missing channelActivityConfirmationTime in CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED event");const t=e.channelActivityConfirmationTime;this.clientEventEmitter.safeEmit(Dr,t),l(this,ym,"f").info("Notify the channel that activity confirmation is required",{event:e.channelActivityConfirmationTime})}handleChannelProducePermissionsChanged(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_CHANGED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(mm(e)))))),n=e.channelProducePermissions.producePermissions.map(lm),i=e.channelProducePermissions.changedProducePermissions.map(lm);r.forEach((e=>{const t=Array.from(new Set([...e.producePermissions,...i])).filter((e=>!i.includes(e)||n.includes(e)));e.handleProducePermissionsChange(t)})),l(this,ym,"f").info("Peers changed produce permissions",{groups:t,producePermissions:n})}handlePeerProducePermissionsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_PRODUCE_PERMISSIONS_CHANGED event");const t=this.peers.get(e.peer.id);if(!t)return;const r=e.peer.producePermissions.map(lm);t.handleProducePermissionsChange(r)}handleChannelProducePermissionsDeleted(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_DELETED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(mm(e)))))),n=e.channelProducePermissions.producePermissions.map(lm);r.forEach((e=>{const t=e.producePermissions.filter((e=>!n.includes(e)));e.handleProducePermissionsChange(t)})),l(this,ym,"f").info("Peers deleted produce permissions",{groups:t,producePermissions:n})}};ym=new WeakMap,bm=a([ut(),c(0,pt(Gn.Peers)),c(1,pt(Gn.ClientEventEmitter)),c(2,pt(Gn.LoggerFactory)),c(3,pt(Gn.ChannelStateSyncEventHandler)),c(4,pt(Gn.ChannelStateSynchronizer)),d("design:paramtypes",[La,It,Function,Ja,_m])],bm);var Em=bm,wm={},Sm=f&&f.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(wm,"__esModule",{value:!0});var Cm,Pm,Tm=wm.AwaitQueue=class{constructor({ClosedErrorClass:e=Error,StoppedErrorClass:t=Error,RemovedTaskErrorClass:r=Error}={ClosedErrorClass:Error,StoppedErrorClass:Error,RemovedTaskErrorClass:Error}){this.closed=!1,this.pendingTasks=[],this.ClosedErrorClass=Error,this.StoppedErrorClass=Error,this.RemovedTaskErrorClass=Error,this.ClosedErrorClass=e,this.StoppedErrorClass=t,this.RemovedTaskErrorClass=r}get size(){return this.pendingTasks.length}close(){if(!this.closed){this.closed=!0;for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.ClosedErrorClass("AwaitQueue closed"));this.pendingTasks.length=0}}push(e,t){return Sm(this,void 0,void 0,(function*(){if(this.closed)throw new this.ClosedErrorClass("AwaitQueue closed");if("function"!=typeof e)throw new TypeError("given task is not a function");if(!e.name&&t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={task:e,name:t,resolve:r,reject:n,stopped:!1,enqueuedAt:new Date,executedAt:void 0};this.pendingTasks.push(i),1===this.pendingTasks.length&&this.next()}))}))}removeTask(e){if(0===e)throw new TypeError("cannot remove task with index 0");const t=this.pendingTasks[e];t&&(this.pendingTasks.splice(e,1),t.reject(new this.RemovedTaskErrorClass("task removed from the queue")))}stop(){if(!this.closed){for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.StoppedErrorClass("AwaitQueue stopped"));this.pendingTasks.length=0}}dump(){const e=new Date;let t=0;return this.pendingTasks.map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt.getTime()-r.enqueuedAt.getTime():e.getTime()-r.enqueuedAt.getTime(),executingTime:r.executedAt?e.getTime()-r.executedAt.getTime():0})))}next(){return Sm(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return Sm(this,void 0,void 0,(function*(){if(!e.stopped){e.executedAt=new Date;try{const t=yield e.task();if(e.stopped)return;e.resolve(t)}catch(t){if(e.stopped)return;e.reject(t)}}}))}};let km=class{constructor(e,t,r,n,i){this.media=e,this.internalEventEmitter=t,this.peersStorage=r,this.clientEventEmitter=n,Cm.set(this,new Tm),Pm.set(this,void 0),p(this,Pm,i("MediaEvents"),"f")}handleMediaEvent(e){switch(e.eventType){case Ss.MEDIA_EVENT_TYPE_PRODUCER_CREATED:this.handleProducerCreated(e);break;case Ss.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:this.handleProducerClosed(e);break;case Ss.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:this.handleProducerPaused(e);break;case Ss.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:this.handleProducerResumed(e);break;case Ss.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:this.handleProducerMaxSpatialLayerChanged(e);break;case Ss.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:this.handleProducerRequestMaxSpatialLayer(e).catch((e=>{l(this,Pm,"f").error("Failed to handle producer max spatial layer requested event",{error:mr(e)})}));break;case Ss.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:this.handleProducerForciblyClosed(e).catch((e=>{l(this,Pm,"f").error("Failed to handle producer forcibly closed event",{error:mr(e)})}));break;case Ss.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:this.handleConsumerClosed(e);break;case Ss.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:this.handleConsumerResumed(e);break;case Ss.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:this.handleConsumerPaused(e);break;case Ss.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:this.handleConsumerPreferredLayersChanged(e);break;case Ss.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:this.handleTransportConnectionTimeout(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}handleProducerCreated(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CREATED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(ln,fm(e.producer))}handleProducerClosed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CLOSED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(pn,fm(e.producer))}handleProducerPaused(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_PAUSED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t&&r&&(r.paused=!0,t.observer.safeEmit(en,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused}))}handleProducerResumed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_RESUMED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t&&r&&(r.paused=!1,t.observer.safeEmit(tn,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused}))}handleProducerMaxSpatialLayerChanged(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED");if(void 0===e.producer.maxSpatialLayer)return;const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(mn,{peerId:e.producer.peerId,producerId:e.producer.id,spatialLayer:e.producer.maxSpatialLayer})}handleProducerRequestMaxSpatialLayer(e){return u(this,void 0,void 0,(function*(){if(!e.producerSpatialLayerRequest)throw new Error("Missing producerSpatialLayerRequest in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED");const{producerId:t,spatialLayer:r}=e.producerSpatialLayerRequest;yield l(this,Cm,"f").push((()=>u(this,void 0,void 0,(function*(){yield this.media.handleProducerSetMaxSpatialLayer({producerId:t,spatialLayer:r})}))),gn)}))}handleProducerForciblyClosed(e){return u(this,void 0,void 0,(function*(){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED");const t=lm(e.producer.label),r=this.media.getTrack(t);if(!r)return;r.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Qr.trackClosed,r);const n={label:t};this.clientEventEmitter.emit(xr,n),yield this.media.deleteTrack(r)}))}handleConsumerClosed(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_CLOSED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(_n,e.consumer.id)}handleConsumerResumed(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_RESUMED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(En,e.consumer.id)}handleConsumerPaused(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PAUSED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(bn,e.consumer.id)}handleConsumerPreferredLayersChanged(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED");if(void 0===e.consumer.spatialLayer||void 0===e.consumer.temporalLayer)return;const t=this.peersStorage.get(e.consumer.peerId);null==t||t.observer.safeEmit(wn,{consumerId:e.consumer.id,spatialLayer:e.consumer.spatialLayer,temporalLayer:e.consumer.temporalLayer})}handleTransportConnectionTimeout(e){if(!e.transportConnectionTimeout)throw new Error("Missing transportConnectionTimeout in MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT");l(this,Pm,"f").warn("Transport connection timed out",{transportId:e.transportConnectionTimeout.transportId,direction:e.transportConnectionTimeout.direction,timeout:e.transportConnectionTimeout.timeout,reason:e.transportConnectionTimeout.reason})}};Cm=new WeakMap,Pm=new WeakMap,km=a([ut(),c(0,pt(Gn.Media)),c(1,pt(Gn.InternalEventEmitter)),c(2,pt(Gn.PeersStorage)),c(3,pt(Gn.ClientEventEmitter)),c(4,pt(Gn.LoggerFactory)),d("design:paramtypes",[im,It,wa,It,Function])],km);var Rm=km,Im={exports:{}},Dm=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},Am=Dm,Om=Object.prototype.toString;function Nm(e){return"[object Array]"===Om.call(e)}function Mm(e){return void 0===e}function Lm(e){return null!==e&&"object"==typeof e}function xm(e){if("[object Object]"!==Om.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Fm(e){return"[object Function]"===Om.call(e)}function jm(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Nm(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var Um={isArray:Nm,isArrayBuffer:function(e){return"[object ArrayBuffer]"===Om.call(e)},isBuffer:function(e){return null!==e&&!Mm(e)&&null!==e.constructor&&!Mm(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Lm,isPlainObject:xm,isUndefined:Mm,isDate:function(e){return"[object Date]"===Om.call(e)},isFile:function(e){return"[object File]"===Om.call(e)},isBlob:function(e){return"[object Blob]"===Om.call(e)},isFunction:Fm,isStream:function(e){return Lm(e)&&Fm(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:jm,merge:function e(){var t={};function r(r,n){xm(t[n])&&xm(r)?t[n]=e(t[n],r):xm(r)?t[n]=e({},r):Nm(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)jm(arguments[n],r);return t},extend:function(e,t,r){return jm(t,(function(t,n){e[n]=r&&"function"==typeof t?Am(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},Bm=Um;function Vm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Wm=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(Bm.isURLSearchParams(t))n=t.toString();else{var i=[];Bm.forEach(t,(function(e,t){null!=e&&(Bm.isArray(e)?t+="[]":e=[e],Bm.forEach(e,(function(e){Bm.isDate(e)?e=e.toISOString():Bm.isObject(e)&&(e=JSON.stringify(e)),i.push(Vm(t)+"="+Vm(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},Hm=Um;function qm(){this.handlers=[]}qm.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},qm.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},qm.prototype.forEach=function(e){Hm.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var zm=qm,Gm=Um,Ym=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},$m=Ym,Jm=function(e,t,r,n,i){var s=new Error(e);return $m(s,t,r,n,i)},Km=Jm,Qm=Um,Zm=Qm.isStandardBrowserEnv()?{write:function(e,t,r,n,i,s){var o=[];o.push(e+"="+encodeURIComponent(t)),Qm.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Qm.isString(n)&&o.push("path="+n),Qm.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Xm=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},eg=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},tg=Um,rg=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],ng=Um,ig=ng.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=ng.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},sg=Um,og=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(Km("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},ag=Zm,cg=Wm,dg=function(e,t){return e&&!Xm(t)?eg(e,t):t},ug=function(e){var t,r,n,i={};return e?(tg.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=tg.trim(e.substr(0,n)).toLowerCase(),r=tg.trim(e.substr(n+1)),t){if(i[t]&&rg.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i},lg=ig,pg=Jm,hg=function(e){return new Promise((function(t,r){var n=e.data,i=e.headers,s=e.responseType;sg.isFormData(n)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",c=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(a+":"+c)}var d=dg(e.baseURL,e.url);function u(){if(o){var n="getAllResponseHeaders"in o?ug(o.getAllResponseHeaders()):null,i={data:s&&"text"!==s&&"json"!==s?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:n,config:e,request:o};og(t,r,i),o=null}}if(o.open(e.method.toUpperCase(),cg(d,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,"onloadend"in o?o.onloadend=u:o.onreadystatechange=function(){o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))&&setTimeout(u)},o.onabort=function(){o&&(r(pg("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(pg("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(pg(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},sg.isStandardBrowserEnv()){var l=(e.withCredentials||lg(d))&&e.xsrfCookieName?ag.read(e.xsrfCookieName):void 0;l&&(i[e.xsrfHeaderName]=l)}"setRequestHeader"in o&&sg.forEach(i,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),sg.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),s&&"json"!==s&&(o.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),r(e),o=null)})),n||(n=null),o.send(n)}))},fg=Um,mg=function(e,t){Gm.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},gg=Ym,vg={"Content-Type":"application/x-www-form-urlencoded"};function yg(e,t){!fg.isUndefined(e)&&fg.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var _g,bg={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(_g=hg),_g),transformRequest:[function(e,t){return mg(t,"Accept"),mg(t,"Content-Type"),fg.isFormData(e)||fg.isArrayBuffer(e)||fg.isBuffer(e)||fg.isStream(e)||fg.isFile(e)||fg.isBlob(e)?e:fg.isArrayBufferView(e)?e.buffer:fg.isURLSearchParams(e)?(yg(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):fg.isObject(e)||t&&"application/json"===t["Content-Type"]?(yg(t,"application/json"),function(e,t,r){if(fg.isString(e))try{return(t||JSON.parse)(e),fg.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&fg.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw gg(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};bg.headers={common:{Accept:"application/json, text/plain, */*"}},fg.forEach(["delete","get","head"],(function(e){bg.headers[e]={}})),fg.forEach(["post","put","patch"],(function(e){bg.headers[e]=fg.merge(vg)}));var Eg=bg,wg=Um,Sg=Eg,Cg=function(e){return!(!e||!e.__CANCEL__)},Pg=Um,Tg=function(e,t,r){var n=this||Sg;return wg.forEach(r,(function(r){e=r.call(n,e,t)})),e},kg=Cg,Rg=Eg;function Ig(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Dg=Um,Ag=function(e,t){t=t||{};var r={},n=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],o=["validateStatus"];function a(e,t){return Dg.isPlainObject(e)&&Dg.isPlainObject(t)?Dg.merge(e,t):Dg.isPlainObject(t)?Dg.merge({},t):Dg.isArray(t)?t.slice():t}function c(n){Dg.isUndefined(t[n])?Dg.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}Dg.forEach(n,(function(e){Dg.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),Dg.forEach(i,c),Dg.forEach(s,(function(n){Dg.isUndefined(t[n])?Dg.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),Dg.forEach(o,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var d=n.concat(i).concat(s).concat(o),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===d.indexOf(e)}));return Dg.forEach(u,c),r},Og={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},Ng={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Ng[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Mg={},Lg=Og.version.split(".");function xg(e,t){for(var r=t?t.split("."):Lg,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}Ng.transitional=function(e,t,r){var n=t&&xg(t);function i(e,t){return"[Axios v"+Og.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,s,o){if(!1===e)throw new Error(i(s," has been removed in "+t));return n&&!Mg[s]&&(Mg[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,o)}};var Fg={isOlderVersion:xg,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),i=n.length;i-- >0;){var s=n[i],o=t[s];if(o){var a=e[s],c=void 0===a||o(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:Ng},jg=Um,Ug=Wm,Bg=zm,Vg=function(e){return Ig(e),e.headers=e.headers||{},e.data=Tg.call(e,e.data,e.headers,e.transformRequest),e.headers=Pg.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Pg.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Rg.adapter)(e).then((function(t){return Ig(e),t.data=Tg.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return kg(t)||(Ig(e),t&&t.response&&(t.response.data=Tg.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Wg=Ag,Hg=Fg,qg=Hg.validators;function zg(e){this.defaults=e,this.interceptors={request:new Bg,response:new Bg}}zg.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Wg(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&Hg.assertOptions(t,{silentJSONParsing:qg.transitional(qg.boolean,"1.0.0"),forcedJSONParsing:qg.transitional(qg.boolean,"1.0.0"),clarifyTimeoutError:qg.transitional(qg.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var o=[Vg,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(s),i=Promise.resolve(e);o.length;)i=i.then(o.shift(),o.shift());return i}for(var a=e;r.length;){var c=r.shift(),d=r.shift();try{a=c(a)}catch(e){d(e);break}}try{i=Vg(a)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},zg.prototype.getUri=function(e){return e=Wg(this.defaults,e),Ug(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},jg.forEach(["delete","get","head","options"],(function(e){zg.prototype[e]=function(t,r){return this.request(Wg(r||{},{method:e,url:t,data:(r||{}).data}))}})),jg.forEach(["post","put","patch"],(function(e){zg.prototype[e]=function(t,r,n){return this.request(Wg(n||{},{method:e,url:t,data:r}))}}));var Gg=zg;function Yg(e){this.message=e}Yg.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Yg.prototype.__CANCEL__=!0;var $g=Yg,Jg=$g;function Kg(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new Jg(e),t(r.reason))}))}Kg.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Kg.source=function(){var e,t=new Kg((function(t){e=t}));return{token:t,cancel:e}};var Qg=Kg,Zg=Um,Xg=Dm,ev=Gg,tv=Ag;function rv(e){var t=new ev(e),r=Xg(ev.prototype.request,t);return Zg.extend(r,ev.prototype,t),Zg.extend(r,t),r}var nv=rv(Eg);nv.Axios=ev,nv.create=function(e){return rv(tv(nv.defaults,e))},nv.Cancel=$g,nv.CancelToken=Qg,nv.isCancel=Cg,nv.all=function(e){return Promise.all(e)},nv.spread=function(e){return function(t){return e.apply(null,t)}},nv.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},Im.exports=nv,Im.exports.default=nv;var iv=Im.exports,sv="undefined"!=typeof Symbol&&Symbol,ov=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0},av="Function.prototype.bind called on incompatible ",cv=Array.prototype.slice,dv=Object.prototype.toString,uv=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==dv.call(t))throw new TypeError(av+t);for(var r,n=cv.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(cv.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(cv.call(arguments)))},s=Math.max(0,t.length-n.length),o=[],a=0;a<s;a++)o.push("$"+a);if(r=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var c=function(){};c.prototype=t.prototype,r.prototype=new c,c.prototype=null}return r},lv=Function.prototype.bind||uv,pv="Function.prototype.bind called on incompatible ",hv=Array.prototype.slice,fv=Object.prototype.toString,mv=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==fv.call(t))throw new TypeError(pv+t);for(var r,n=hv.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(hv.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(hv.call(arguments)))},s=Math.max(0,t.length-n.length),o=[],a=0;a<s;a++)o.push("$"+a);if(r=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var c=function(){};c.prototype=t.prototype,r.prototype=new c,c.prototype=null}return r},gv=(Function.prototype.bind||mv).call(Function.call,Object.prototype.hasOwnProperty),vv=SyntaxError,yv=Function,_v=TypeError,bv=function(e){try{return yv('"use strict"; return ('+e+").constructor;")()}catch(e){}},Ev=Object.getOwnPropertyDescriptor;if(Ev)try{Ev({},"")}catch(Pt){Ev=null}var wv=function(){throw new _v},Sv=Ev?function(){try{return wv}catch(e){try{return Ev(arguments,"callee").get}catch(e){return wv}}}():wv,Cv="function"==typeof sv&&"function"==typeof Symbol&&"symbol"==typeof sv("foo")&&"symbol"==typeof Symbol("bar")&&ov(),Pv=Object.getPrototypeOf||function(e){return e.__proto__},Tv={},kv="undefined"==typeof Uint8Array?undefined:Pv(Uint8Array),Rv={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":Cv?Pv([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":Tv,"%AsyncGenerator%":Tv,"%AsyncGeneratorFunction%":Tv,"%AsyncIteratorPrototype%":Tv,"%Atomics%":"undefined"==typeof Atomics?undefined:Atomics,"%BigInt%":"undefined"==typeof BigInt?undefined:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?undefined:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?undefined:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?undefined:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?undefined:FinalizationRegistry,"%Function%":yv,"%GeneratorFunction%":Tv,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Cv?Pv(Pv([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&Cv?Pv((new Map)[Symbol.iterator]()):undefined,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?undefined:Promise,"%Proxy%":"undefined"==typeof Proxy?undefined:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?undefined:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?undefined:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&Cv?Pv((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Cv?Pv(""[Symbol.iterator]()):undefined,"%Symbol%":Cv?Symbol:undefined,"%SyntaxError%":vv,"%ThrowTypeError%":Sv,"%TypedArray%":kv,"%TypeError%":_v,"%Uint8Array%":"undefined"==typeof Uint8Array?undefined:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?undefined:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?undefined:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?undefined:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?undefined:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?undefined:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?undefined:WeakSet},Iv=function e(t){var r;if("%AsyncFunction%"===t)r=bv("async function () {}");else if("%GeneratorFunction%"===t)r=bv("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=bv("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=Pv(i.prototype))}return Rv[t]=r,r},Dv={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Av=lv,Ov=gv,Nv=Av.call(Function.call,Array.prototype.concat),Mv=Av.call(Function.apply,Array.prototype.splice),Lv=Av.call(Function.call,String.prototype.replace),xv=Av.call(Function.call,String.prototype.slice),Fv=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,jv=/\\(\\)?/g,Uv=function(e){var t=xv(e,0,1),r=xv(e,-1);if("%"===t&&"%"!==r)throw new vv("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new vv("invalid intrinsic syntax, expected opening `%`");var n=[];return Lv(e,Fv,(function(e,t,r,i){n[n.length]=r?Lv(i,jv,"$1"):t||e})),n},Bv=function(e,t){var r,n=e;if(Ov(Dv,n)&&(n="%"+(r=Dv[n])[0]+"%"),Ov(Rv,n)){var i=Rv[n];if(i===Tv&&(i=Iv(n)),void 0===i&&!t)throw new _v("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new vv("intrinsic "+e+" does not exist!")},Vv=function(e,t){if("string"!=typeof e||0===e.length)throw new _v("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new _v('"allowMissing" argument must be a boolean');var r=Uv(e),n=r.length>0?r[0]:"",i=Bv("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],Mv(r,Nv([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=xv(l,0,1),h=xv(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new vv("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),Ov(Rv,s="%"+(n+="."+l)+"%"))o=Rv[s];else if(null!=o){if(!(l in o)){if(!t)throw new _v("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ev&&d+1>=r.length){var f=Ev(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=Ov(o,l),o=o[l];u&&!a&&(Rv[s]=o)}}return o},Wv={exports:{}};!function(e){var t=lv,r=Vv,n=r("%Function.prototype.apply%"),i=r("%Function.prototype.call%"),s=r("%Reflect.apply%",!0)||t.call(i,n),o=r("%Object.getOwnPropertyDescriptor%",!0),a=r("%Object.defineProperty%",!0),c=r("%Math.max%");if(a)try{a({},"a",{value:1})}catch(e){a=null}e.exports=function(e){var r=s(t,i,arguments);if(o&&a){var n=o(r,"length");n.configurable&&a(r,"length",{value:1+c(0,e.length-(arguments.length-1))})}return r};var d=function(){return s(t,n,arguments)};a?a(e.exports,"apply",{value:d}):e.exports.apply=d}(Wv);var Hv=Vv,qv=Wv.exports,zv=qv(Hv("String.prototype.indexOf")),Gv=g(Object.freeze({__proto__:null,default:{}})),Yv="function"==typeof Map&&Map.prototype,$v=Object.getOwnPropertyDescriptor&&Yv?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Jv=Yv&&$v&&"function"==typeof $v.get?$v.get:null,Kv=Yv&&Map.prototype.forEach,Qv="function"==typeof Set&&Set.prototype,Zv=Object.getOwnPropertyDescriptor&&Qv?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Xv=Qv&&Zv&&"function"==typeof Zv.get?Zv.get:null,ey=Qv&&Set.prototype.forEach,ty="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,ry="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,ny="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,iy=Boolean.prototype.valueOf,sy=Object.prototype.toString,oy=Function.prototype.toString,ay=String.prototype.match,cy="function"==typeof BigInt?BigInt.prototype.valueOf:null,dy=Object.getOwnPropertySymbols,uy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,ly="function"==typeof Symbol&&"object"==typeof Symbol.iterator,py=Object.prototype.propertyIsEnumerable,hy=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),fy=Gv.custom,my=fy&&by(fy)?fy:null,gy="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function vy(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function yy(e){return String(e).replace(/"/g,"&quot;")}function _y(e){return!("[object Array]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}function by(e){if(ly)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!uy)return!1;try{return uy.call(e),!0}catch(e){}return!1}var Ey=Object.prototype.hasOwnProperty||function(e){return e in this};function wy(e,t){return Ey.call(e,t)}function Sy(e){return sy.call(e)}function Cy(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function Py(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return Py(e.slice(0,t.maxStringLength),t)+n}return vy(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,Ty),"single",t)}function Ty(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+t.toString(16).toUpperCase()}function ky(e){return"Object("+e+")"}function Ry(e){return e+" { ? }"}function Iy(e,t,r,n){return e+" ("+t+") {"+(n?Dy(r,n):r.join(", "))+"}"}function Dy(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function Ay(e,t){var r=_y(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=wy(e,i)?t(e[i],e):""}var s,o="function"==typeof dy?dy(e):[];if(ly){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)wy(e,c)&&(r&&String(Number(c))===c&&c<e.length||ly&&s["$"+c]instanceof Symbol||(/[^\w$]/.test(c)?n.push(t(c,e)+": "+t(e[c],e)):n.push(c+": "+t(e[c],e))));if("function"==typeof dy)for(var d=0;d<o.length;d++)py.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var Oy=Vv,Ny=function(e,t){var r=Hv(e,!!t);return"function"==typeof r&&zv(e,".prototype.")>-1?qv(r):r},My=function e(t,r,n,i){var s=r||{};if(wy(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(wy(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=!wy(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(wy(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return Py(t,s);if("number"==typeof t)return 0===t?1/0/t>0?"0":"-0":String(t);if("bigint"==typeof t)return String(t)+"n";var a=void 0===s.depth?5:s.depth;if(void 0===n&&(n=0),n>=a&&a>0&&"object"==typeof t)return _y(t)?"[Array]":"[Object]";var c=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=Array(e.indent+1).join(" ")}return{base:r,prev:Array(t+1).join(r)}}(s,n);if(void 0===i)i=[];else if(Cy(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return wy(s,"quoteStyle")&&(a.quoteStyle=s.quoteStyle),e(t,a,n+1,i)}return e(t,s,n+1,i)}if("function"==typeof t){var u=function(e){if(e.name)return e.name;var t=ay.call(oy.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=Ay(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(by(t)){var p=ly?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):uy.call(t);return"object"!=typeof t||ly?p:ky(p)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var h="<"+String(t.nodeName).toLowerCase(),f=t.attributes||[],m=0;m<f.length;m++)h+=" "+f[m].name+"="+vy(yy(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(_y(t)){if(0===t.length)return"[]";var g=Ay(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(Cy(e[t],"\n")>=0)return!1;return!0}(g)?"["+Dy(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}(t)){var v=Ay(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(my&&"function"==typeof t[my])return t[my]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!Jv||!e||"object"!=typeof e)return!1;try{Jv.call(e);try{Xv.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return Kv.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),Iy("Map",Jv.call(t),y,c)}if(function(e){if(!Xv||!e||"object"!=typeof e)return!1;try{Xv.call(e);try{Jv.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var _=[];return ey.call(t,(function(e){_.push(d(e,t))})),Iy("Set",Xv.call(t),_,c)}if(function(e){if(!ty||!e||"object"!=typeof e)return!1;try{ty.call(e,ty);try{ry.call(e,ry)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Ry("WeakMap");if(function(e){if(!ry||!e||"object"!=typeof e)return!1;try{ry.call(e,ry);try{ty.call(e,ty)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Ry("WeakSet");if(function(e){if(!ny||!e||"object"!=typeof e)return!1;try{return ny.call(e),!0}catch(e){}return!1}(t))return Ry("WeakRef");if(function(e){return!("[object Number]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}(t))return ky(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!cy)return!1;try{return cy.call(e),!0}catch(e){}return!1}(t))return ky(d(cy.call(t)));if(function(e){return!("[object Boolean]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}(t))return ky(iy.call(t));if(function(e){return!("[object String]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}(t))return ky(d(String(t)));if(!function(e){return!("[object Date]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}(t)&&!function(e){return!("[object RegExp]"!==Sy(e)||gy&&"object"==typeof e&&gy in e)}(t)){var b=Ay(t,d),E=hy?hy(t)===Object.prototype:t instanceof Object||t.constructor===Object,w=t instanceof Object?"":"null prototype",S=!E&&gy&&Object(t)===t&&gy in t?Sy(t).slice(8,-1):w?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(S||w?"["+[].concat(S||[],w||[]).join(": ")+"] ":"");return 0===b.length?C+"{}":c?C+"{"+Dy(b,c)+"}":C+"{ "+b.join(", ")+" }"}return String(t)},Ly=Oy("%TypeError%"),xy=Oy("%WeakMap%",!0),Fy=Oy("%Map%",!0),jy=Ny("WeakMap.prototype.get",!0),Uy=Ny("WeakMap.prototype.set",!0),By=Ny("WeakMap.prototype.has",!0),Vy=Ny("Map.prototype.get",!0),Wy=Ny("Map.prototype.set",!0),Hy=Ny("Map.prototype.has",!0),qy=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r,r},zy=String.prototype.replace,Gy=/%20/g,Yy="RFC3986",$y={default:Yy,formatters:{RFC1738:function(e){return zy.call(e,Gy,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:Yy},Jy=$y,Ky=Object.prototype.hasOwnProperty,Qy=Array.isArray,Zy=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Xy=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r},e_={arrayToObject:Xy,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var i=t[n],s=i.obj[i.prop],o=Object.keys(s),a=0;a<o.length;++a){var c=o[a],d=s[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:s,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(Qy(r)){for(var n=[],i=0;i<r.length;++i)void 0!==r[i]&&n.push(r[i]);t.obj[t.prop]=n}}}(t),e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,n,i){if(0===e.length)return e;var s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(e)),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var o="",a=0;a<s.length;++a){var c=s.charCodeAt(a);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||i===Jy.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=Zy[c]:c<2048?o+=Zy[192|c>>6]+Zy[128|63&c]:c<55296||c>=57344?o+=Zy[224|c>>12]+Zy[128|c>>6&63]+Zy[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=Zy[240|c>>18]+Zy[128|c>>12&63]+Zy[128|c>>6&63]+Zy[128|63&c])}return o},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(Qy(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function e(t,r,n){if(!r)return t;if("object"!=typeof r){if(Qy(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!Ky.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return Qy(t)&&!Qy(r)&&(i=Xy(t,n)),Qy(t)&&Qy(r)?(r.forEach((function(r,i){if(Ky.call(t,i)){var s=t[i];s&&"object"==typeof s&&r&&"object"==typeof r?t[i]=e(s,r,n):t.push(r)}else t[i]=r})),t):Object.keys(r).reduce((function(t,i){var s=r[i];return Ky.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},t_=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new Ly("Side channel does not contain "+My(e))},get:function(n){if(xy&&n&&("object"==typeof n||"function"==typeof n)){if(e)return jy(e,n)}else if(Fy){if(t)return Vy(t,n)}else if(r)return function(e,t){var r=qy(e,t);return r&&r.value}(r,n)},has:function(n){if(xy&&n&&("object"==typeof n||"function"==typeof n)){if(e)return By(e,n)}else if(Fy){if(t)return Hy(t,n)}else if(r)return function(e,t){return!!qy(e,t)}(r,n);return!1},set:function(n,i){xy&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new xy),Uy(e,n,i)):Fy?(t||(t=new Fy),Wy(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=qy(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},r_=e_,n_=$y,i_=Object.prototype.hasOwnProperty,s_={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},o_=Array.isArray,a_=String.prototype.split,c_=Array.prototype.push,d_=function(e,t){c_.apply(e,o_(t)?t:[t])},u_=Date.prototype.toISOString,l_=n_.default,p_={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:r_.encode,encodeValuesOnly:!1,format:l_,formatter:n_.formatters[l_],indices:!1,serializeDate:function(e){return u_.call(e)},skipNulls:!1,strictNullHandling:!1},h_={},f_=function e(t,r,n,i,s,o,a,c,d,u,l,p,h,f,m,g){for(var v=t,y=g,_=0,b=!1;void 0!==(y=y.get(h_))&&!b;){var E=y.get(t);if(_+=1,void 0!==E){if(E===_)throw new RangeError("Cyclic object value");b=!0}void 0===y.get(h_)&&(_=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&o_(v)&&(v=r_.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,p_.encoder,m,"key",p):r;v=""}if(function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"symbol"==typeof e||"bigint"==typeof e}(v)||r_.isBuffer(v)){if(a){var w=f?r:a(r,p_.encoder,m,"key",p);if("comma"===n&&f){for(var S=a_.call(String(v),","),C="",P=0;P<S.length;++P)C+=(0===P?"":",")+h(a(S[P],p_.encoder,m,"value",p));return[h(w)+(i&&o_(v)&&1===S.length?"[]":"")+"="+C]}return[h(w)+"="+h(a(v,p_.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var T,k=[];if(void 0===v)return k;if("comma"===n&&o_(v))T=[{value:v.length>0?v.join(",")||null:void 0}];else if(o_(c))T=c;else{var R=Object.keys(v);T=d?R.sort(d):R}for(var I=i&&o_(v)&&1===v.length?r+"[]":r,D=0;D<T.length;++D){var A=T[D],O="object"==typeof A&&void 0!==A.value?A.value:v[A];if(!o||null!==O){var N=o_(v)?"function"==typeof n?n(I,A):I:I+(u?"."+A:"["+A+"]");g.set(t,_);var M=t_();M.set(h_,g),d_(k,e(O,N,n,i,s,o,a,c,d,u,l,p,h,f,m,M))}}return k},m_=e_,g_=Object.prototype.hasOwnProperty,v_=Array.isArray,y_={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:m_.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},__=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},b_=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},E_=function(e,t,r,n){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,o=r.depth>0&&/(\[[^[\]]*])/.exec(i),a=o?i.slice(0,o.index):i,c=[];if(a){if(!r.plainObjects&&g_.call(Object.prototype,a)&&!r.allowPrototypes)return;c.push(a)}for(var d=0;r.depth>0&&null!==(o=s.exec(i))&&d<r.depth;){if(d+=1,!r.plainObjects&&g_.call(Object.prototype,o[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(o[1])}return o&&c.push("["+i.slice(o.index)+"]"),function(e,t,r,n){for(var i=n?t:b_(t,r),s=e.length-1;s>=0;--s){var o,a=e[s];if("[]"===a&&r.parseArrays)o=[].concat(i);else{o=r.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,d=parseInt(c,10);r.parseArrays||""!==c?!isNaN(d)&&a!==c&&String(d)===c&&d>=0&&r.parseArrays&&d<=r.arrayLimit?(o=[])[d]=i:"__proto__"!==c&&(o[c]=i):o={0:i}}i=o}return i}(c,t,r,n)}},w_=function(e,t){var r,n=e,i=function(e){if(!e)return p_;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||p_.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=n_.default;if(void 0!==e.format){if(!i_.call(n_.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=n_.formatters[r],i=p_.filter;return("function"==typeof e.filter||o_(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:p_.addQueryPrefix,allowDots:void 0===e.allowDots?p_.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:p_.charsetSentinel,delimiter:void 0===e.delimiter?p_.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:p_.encode,encoder:"function"==typeof e.encoder?e.encoder:p_.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:p_.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:p_.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:p_.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:p_.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):o_(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in s_?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=s_[s];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c="comma"===a&&t&&t.commaRoundTrip;r||(r=Object.keys(n)),i.sort&&r.sort(i.sort);for(var d=t_(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||d_(o,f_(n[l],l,a,c,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,d))}var p=o.join(i.delimiter),h=!0===i.addQueryPrefix?"?":"";return i.charsetSentinel&&("iso-8859-1"===i.charset?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),p.length>0?h+p:""},S_=function(e,t){var r=function(e){if(!e)return y_;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?y_.charset:e.charset;return{allowDots:void 0===e.allowDots?y_.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:y_.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:y_.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:y_.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:y_.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:y_.comma,decoder:"function"==typeof e.decoder?e.decoder:y_.decoder,delimiter:"string"==typeof e.delimiter||m_.isRegExp(e.delimiter)?e.delimiter:y_.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:y_.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:y_.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:y_.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:y_.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:y_.strictNullHandling}}(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?function(e,t){var r,n={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,s),a=-1,c=t.charset;if(t.charsetSentinel)for(r=0;r<o.length;++r)0===o[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===o[r]?c="utf-8":"utf8=%26%2310003%3B"===o[r]&&(c="iso-8859-1"),a=r,r=o.length);for(r=0;r<o.length;++r)if(r!==a){var d,u,l=o[r],p=l.indexOf("]="),h=-1===p?l.indexOf("="):p+1;-1===h?(d=t.decoder(l,y_.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),y_.decoder,c,"key"),u=m_.maybeMap(b_(l.slice(h+1),t),(function(e){return t.decoder(e,y_.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=__(u)),l.indexOf("[]=")>-1&&(u=v_(u)?[u]:u),g_.call(n,d)?n[d]=m_.combine(n[d],u):n[d]=u}return n}(e,r):e,i=r.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;o<s.length;++o){var a=s[o],c=E_(a,n[a],r,"string"==typeof e);i=m_.merge(i,c,r)}return!0===r.allowSparse?i:m_.compact(i)},C_={formats:$y,parse:S_,stringify:w_};let P_=class{constructor(e){this.config=e;const t=this.config.get("loadbalancer"),{baseURL:r,timeout:n,customNode:i}=t;this.api=iv.create({baseURL:null!=r?r:"https://lb.livedigital.space/v1",timeout:null!=n?n:5e3,withCredentials:!1,paramsSerializer:e=>C_.stringify(e)}),this.customNode=i}getNode(e){return u(this,void 0,void 0,(function*(){if(this.customNode)return this.customNode;const{data:t}=yield this.api.get("/nodes/best",{params:e});return t}))}checkServiceAvailability(){return u(this,arguments,void 0,(function*(e=2e3){try{const{status:t}=yield this.api.options("/nodes/best",{timeout:e});return[vt.OK,vt.NoContent].includes(t)}catch(e){return!1}}))}setBaseUrl(e){try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw new Error("Only http and https protocols are supported.");this.api.defaults.baseURL=t.toString()}catch(e){throw new Error("Invalid URL provided")}}};P_=a([ut(),c(0,pt(Gn.Config)),d("design:paramtypes",[Rt])],P_);var T_,k_=P_;let R_=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],T_.set(this,void 0),p(this,T_,t("System"),"f"),this.deviceChangeHandler=this.deviceChangeHandler.bind(this),this.listenDevices()}setIsEnableVideoDevicesLock(e){this.isEnableVideoDevicesLock=e}setIsEnableAudioDevicesLock(e){this.isEnableAudioDevicesLock=e}setAvailableVideoDevices(e){this.availableVideoDevices=e}setAvailableAudioDevices(e){this.availableAudioDevices=e}requestMediaDevicesAccess(){return u(this,arguments,void 0,(function*(e={video:!0,audio:!0}){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){if(l(this,T_,"f").error("getUserMedia()",{error:t,constraints:e}),"NotAllowedError"===t.name)throw new Error(Jn.NotAllowedError);if("NotReadableError"===t.name)throw new Error(Jn.DeviceIsBusy);if("NotFoundError"===t.name)throw new Error(Jn.NotFoundError);throw new Error(Jn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return u(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices();if(0===e.length)return!0;return e.every((e=>e.deviceId&&e.label))}))}refreshAvailableMediaDevicesList(){return u(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[],r=[];e.forEach((e=>{""!==e.deviceId&&("videoinput"===e.kind&&t.push(e),"audioinput"===e.kind&&r.push(e))})),this.setAvailableVideoDevices(t),this.setAvailableAudioDevices(r);const n=({label:e,kind:t})=>({label:e,kind:t});return l(this,T_,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return u(this,void 0,void 0,(function*(){if(this.isDevicesDetected&&!e)return;(yield this.hasAvailableMediaDevicesList())||(yield this.tryToAccessDevices()),this.isDevicesDetected=!0;const t=yield this.refreshAvailableMediaDevicesList(),r=t.some((e=>"audioinput"===e.kind)),n=t.some((e=>"videoinput"===e.kind));if(!r&&!n)throw new Error(Jn.NoDevices)}))}deviceChangeHandler(){return u(this,void 0,void 0,(function*(){if(!this.isDevicesDetected)return;yield this.refreshAvailableMediaDevicesList();const e={audio:this.availableAudioDevices,video:this.availableVideoDevices};this.clientEventEmitter.safeEmit(Mr,e)}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(){return u(this,arguments,void 0,(function*(e={video:!0,audio:!0}){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return u(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){if(e=t.message,![Jn.NotFoundError,Jn.NotAllowedError,Jn.DeviceIsBusy].includes(e))throw t;t.message!==Jn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};T_=new WeakMap,R_=a([ut(),c(0,pt(Gn.ClientEventEmitter)),c(1,pt(Gn.LoggerFactory)),d("design:paramtypes",[It,Function])],R_);var I_,D_,A_,O_,N_,M_,L_=R_;class x_{constructor({transport:e,statsHandler:t}){I_.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return l(this,I_,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){p(this,I_,e,"f")}}I_=new WeakMap;let F_=class{constructor(){D_.set(this,new Map),A_.set(this,new Map),O_.set(this,new Map),N_.set(this,new Map),M_.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=l(this,D_,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=l(this,A_,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=l(this,O_,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=l(this,N_,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=l(this,M_,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){l(this,D_,"f").set(e,t)}addInboundVideoHandler(e,t){l(this,A_,"f").set(e,t)}addInboundAudioHandler(e,t){l(this,O_,"f").set(e,t)}addOutboundVideoHandler(e,t){l(this,N_,"f").set(e,t)}addOutboundAudioHandler(e,t){l(this,M_,"f").set(e,t)}removeConnectionHandler(e){l(this,D_,"f").delete(e)}removeInboundVideoHandler(e){l(this,A_,"f").delete(e)}removeInboundAudioHandler(e){l(this,N_,"f").delete(e)}removeOutboundVideoHandler(e){l(this,M_,"f").delete(e)}removeOutboundAudioHandler(e){l(this,M_,"f").delete(e)}clear(){l(this,D_,"f").clear(),l(this,A_,"f").clear(),l(this,O_,"f").clear(),l(this,N_,"f").clear(),l(this,M_,"f").clear()}};D_=new WeakMap,A_=new WeakMap,O_=new WeakMap,N_=new WeakMap,M_=new WeakMap,F_=a([ut()],F_);var j_,U_,B_,V_,W_,H_,q_=F_;let z_=class{constructor(e){j_.set(this,!1),U_.set(this,void 0),B_.set(this,void 0),V_.set(this,void 0),W_.set(this,void 0),H_.set(this,void 0),p(this,U_,e("IntegrationsService"),"f")}init({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){p(this,B_,e,"f"),p(this,V_,t,"f"),p(this,W_,r,"f"),p(this,H_,n,"f"),p(this,j_,!0,"f")}getStats(){try{return this.doGetStats()}catch(e){return l(this,U_,"f").error("Failed to get stats",{error:mr(e)}),{}}}clear(){p(this,B_,void 0,"f"),p(this,V_,void 0,"f"),p(this,W_,void 0,"f"),p(this,H_,void 0,"f")}doGetStats(){var e,t,r,n;if(!l(this,j_,"f"))throw new Error("TransportsStatsProvider is not initialized");return Object.assign(Object.assign({},(null===(t=null===(e=l(this,B_,"f"))||void 0===e?void 0:e.connectionStats)||void 0===t?void 0:t.id)?{outbound:Object.assign(Object.assign({},l(this,B_,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(n=null===(r=l(this,V_,"f"))||void 0===r?void 0:r.connectionStats)||void 0===n?void 0:n.id)?{inbound:Object.assign(Object.assign({},l(this,V_,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){if(void 0===l(this,H_,"f"))throw new Error("Peers is undefined");return l(this,H_,"f").hosts().reduce(((e,t)=>{if(t.isMe)return e;return e+Array.from(t.tracks.values()).reduce(((e,t)=>{var r,n;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0)}),0)}calculateOutboundTracksBitrate(){if(void 0===l(this,W_,"f"))throw new Error("Media is undefined");return l(this,W_,"f").getAllTracks().reduce(((e,t)=>{var r,n;if(!t.isPublished)return e;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0)}};j_=new WeakMap,U_=new WeakMap,B_=new WeakMap,V_=new WeakMap,W_=new WeakMap,H_=new WeakMap,z_=a([ut(),c(0,pt(Gn.LoggerFactory)),d("design:paramtypes",[Function])],z_);var G_,Y_,$_,J_,K_=z_;let Q_=class{constructor(e,t,r,n,i,o,a,c,d,u,l,h,f,m,g,v,y,_,b,E){var w;this.state=e,this.myPeer=t,this.integrationsService=n,this.processorsCache=i,this.mediaEventHandler=o,this.channelEventsHandler=a,this.peerTrackFactory=c,this.peers=d,this.system=u,this.media=l,this.network=h,this.loadBalancerClient=f,this.socket=m,this.eventsQueue=g,this.clientEventEmitter=v,this.internalEventEmitter=y,this.statsHandler=_,this.transportsStatsProvider=b,this.webRtcIssueDetector=E,G_.set(this,void 0),Y_.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,$_.set(this,!1),J_.set(this,!1),this.mark=s.default.randomBytes(10).toString("hex"),p(this,G_,r("Engine"),"f"),p(this,Y_,r,"f"),this.watchNetworkState(),this.watchDocumentUnload(),w=this.mark,window._sdkMarks||(window._sdkMarks=new Set),window._sdkMarks.add(w)}get isChannelJoined(){return this.state.isJoined}initialize(){return u(this,void 0,void 0,(function*(){var e,t,r,n;try{const{rtpCapabilities:i}=yield this.socket.request("router.getRtpCapabilities");this.integrationsService.init(),yield this.media.loadDevice(i),l(this,G_,"f").info("Supported capabilities",{codecs:Vn(this.media.mediasoupDevice)});const[s,o]=yield Promise.all([this.network.createSendTransport(this.media.mediasoupDevice),this.network.createRecvTransport(this.media.mediasoupDevice)]);null===(e=this.webRtcIssueDetector)||void 0===e||e.handleNewPeerConnection(s.handler._pc,s.id),null===(t=this.webRtcIssueDetector)||void 0===t||t.handleNewPeerConnection(o.handler._pc,o.id),this.transportsStatsProvider.init({media:this.media,peers:this.peers,receiveTransportConnectionManager:new x_({transport:o,statsHandler:this.statsHandler}),sendTransportConnectionManager:new x_({transport:s,statsHandler:this.statsHandler})}),l(this,G_,"f").debug("initialize()",{sendTransportId:null===(r=this.network.sendTransport)||void 0===r?void 0:r.id,recvTransportId:null===(n=this.network.receiveTransport)||void 0===n?void 0:n.id})}catch(e){l(this,G_,"f").error("initialize()",{error:e});const t=e instanceof Error&&"UnsupportedError"===e.name&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new Mn("Device not supported",Mn.UNSUPPORTED_DEVICE_CODE);throw new Error("Error initialize engine")}}))}release(e){return u(this,void 0,void 0,(function*(){var t;if(!this.isReleasing){this.isReleasing=!0;try{this.state.isJoined=!1,this.network.peersLoaded=!1,this.state.reset(),this.myPeer.delete(),null===(t=this.webRtcIssueDetector)||void 0===t||t.stopWatchingNewPeerConnections(),yield this.peers.reset(),this.network.closeSendTransport(),this.network.closeReceiveTransport(),yield this.network.closeConnectionTransport(),yield this.media.unpublishTracks(),e||this.media.clearTracks(),this.processorsCache.reset(),this.integrationsService.reset(),this.network.closeAllDataChannels(),this.removeClientEventEmitterListeners(),this.network.reset(),this.socket.disconnect(),gr.clear(),this.transportsStatsProvider.clear(),this.statsHandler.clear(),l(this,G_,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw l(this,G_,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}removeClientEventEmitterListeners(){Array.from(Object.values(Qr)).forEach((e=>this.internalEventEmitter.removeAllListeners(e)))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return u(this,void 0,void 0,(function*(){this.network.checkSocketConnectionActivity(),yield this.socket.request(Er)}))}join(e){return u(this,void 0,void 0,(function*(){const t=()=>u(this,void 0,void 0,(function*(){this.watchClientEvents(),yield this.connectToSocketServerWithRetry(e),yield this.performJoin({appData:e.appData})}));try{l(this,G_,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,yield zn(t,{maxRetries:4,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"joinWithRetry",logger:l(this,Y_,"f").call(this,"RetryJoinNode"),onError:()=>u(this,void 0,void 0,(function*(){yield this.release(!0)}))})}catch(e){throw l(this,G_,"f").error("join()",{error:e}),e}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1}}))}loadPeers(e){return u(this,void 0,void 0,(function*(){yield this.peers.load(e)}))}requestChannelStateSync(){zn((()=>u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>u(this,void 0,void 0,(function*(){if(!this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)return e();const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(l(this,G_,"f").info("Channel state event received",{case:"Engine.requestChannelStateSync"}),e()):t(new Error("Channel state event not received"))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Br,i),e()};this.clientEventEmitter.on(Br,i)}))))}))),{minBackoffDelayMs:0,maxBackoffDelayMs:0,maxRetries:10,actionName:"triggerChannelStateEventWithRetry",logger:l(this,G_,"f")}).catch((e=>{l(this,G_,"f").error("Failed to request channel state event",{case:"Engine.requestChannelStateSync",error:mr(e)})}))}setPeer(e,t=!0){return this.peers.add(e,t)}removePeer(e){return u(this,void 0,void 0,(function*(){yield this.peers.remove(e)}))}updateAppData(e){return u(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Error("Need join to channel first");try{Ln(e),yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw l(this,G_,"f").error("updateAppData()",{error:e}),new Error("Can not update peer appData")}}))}createCameraVideoTrack(e){return u(this,void 0,void 0,(function*(){const t=im.getCameraVideoTrackParams(e);try{const[r]=yield this.media.createUserMediaTracks({audio:!1,video:t.videoTrackOptions});return r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof zf&&(r.setLabel((null==e?void 0:e.isPreview)?$n.CameraPreview:$n.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(im.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),l(this,G_,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw l(this,G_,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Error(`Can not create camera track: ${e.message}`)}}))}createMicrophoneAudioTrack(e){return u(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio}),r=(null==e?void 0:e.isPreview)?$n.MicrophonePreview:$n.Microphone;return t.setLabel(r),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"!==t.kind||t.getLabel()!==$n.Microphone||l(this,J_,"f")||this.media.initDenoiser(t,e).catch((t=>{this.clientEventEmitter.emit(Jr,{cause:"Failed to initialize denoiser",error:t}),l(this,G_,"f").error("Failed to execute initDenoiser",{case:"Denoiser",options:e,error:mr(t)})})),this.media.setTrack(t),l(this,G_,"f").debug("createMicrophoneAudioTrack()",{options:e,trackLabel:t.getLabel()}),t}catch(t){throw l(this,G_,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Error(`Can not create microphone track: ${t.message}`)}}))}createScreenMediaTracks(e){return u(this,void 0,void 0,(function*(){const t=im.getScreenVideoTrackParams(e);try{const r=yield this.media.createDisplayMediaTracks({audio:null==e?void 0:e.audio,video:null==e?void 0:e.video});return r.forEach((r=>{if(r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{l(this,G_,"f").error("Failed to unpublish screen track",{error:mr(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof zf){r.setLabel($n.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=im.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void l(this,G_,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel($n.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),l(this,G_,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw l(this,G_,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Error(`Can not create screen media tracks: ${e.message}`)}}))}createCustomAudioTrack(e){if(!e.audioTrack)throw new Error("options.audioTrack is required");try{const t=this.media.createCustomMediaTrack(e.audioTrack,{audio:e.audio});return t.mediaStreamTrack.addEventListener("ended",(()=>{t.unpublish().catch((e=>{l(this,G_,"f").error("Failed to unpublish custom audio track",{track:t,error:mr(e)})}))}),{once:!0}),t.setStopTrackOnPause(Boolean(e.stopTrackOnPause)),t.setLabel($n.CustomAudio),e.audioEncoderConfig&&t.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(t),l(this,G_,"f").debug("createCustomAudioTrack()",{trackParams:e.audio,encoderConfig:e.audioEncoderConfig}),t}catch(t){throw l(this,G_,"f").error("createCustomAudioTrack()",{error:t,trackParams:e.audioTrack}),new Error(`Can not create custom media tracks: ${t.message}`)}}createCustomVideoTrack(e){const t=im.getScreenVideoTrackParams(e);if(!e.videoTrack)throw new Error("options.videoTrack is required");try{const r=this.media.createCustomMediaTrack(e.videoTrack,{video:e.video});r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{l(this,G_,"f").error("Failed to unpublish custom video track",{track:r,error:mr(e)})}))}),{once:!0}),r.mediaStreamTrack.contentHint="customVideo",r.setLabel($n.CustomVideo),r.setEncoderConfig(t.encoderConfig);const n=im.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(n),this.media.setTrack(r),l(this,G_,"f").debug("createCustomVideoTrack()",{trackParams:t,transformParams:n,label:r.logCtx}),r}catch(e){throw l(this,G_,"f").error("createCustomVideoTrack()",{error:e,trackParams:t}),new Error(`Failed to create custom video track: ${e.message}`)}}deleteTrack(e){return u(this,void 0,void 0,(function*(){yield this.media.deleteTrack(e)}))}transportsStats(){return this.transportsStatsProvider.getStats()}setLoadbalancerUrl(e){if(this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)throw new Error("Method not available when joined channel");this.loadBalancerClient.setBaseUrl(e)}connectToSocketServerWithRetry(e){return u(this,void 0,void 0,(function*(){yield zn((()=>u(this,void 0,void 0,(function*(){return yield this.connectToSocketServer(e)}))),{maxRetries:15,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"connectToSocketServer",logger:l(this,Y_,"f").call(this,"RetrySocketConnect"),abortOnError:e=>{var t;return"unauthorized"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.errorCode)}})}))}connectToSocketServer(e){return u(this,void 0,void 0,(function*(){const t=e.isP2pCall?Yn.P2P:Yn.Common,{webSocketUrl:r}=yield this.getAvailableNode({datacenterType:t,channelId:e.channelId,role:e.role});this.socket.connect(r,e.token);try{yield this.waitForSocketConnection()}catch(t){throw l(this,G_,"f").error("Failed to connect to socket server",{error:t,role:e.role,channelId:e.channelId,webSocketUrl:r}),this.socket.disconnect(),t}}))}getAvailableNode(e){return u(this,void 0,void 0,(function*(){try{return{webSocketUrl:(yield this.loadBalancerClient.getNode(e)).webSocketUrl}}catch(e){throw l(this,G_,"f").error("getAvailableNode()",{error:"No available nodes"}),e}}))}waitForSocketConnection(){return u(this,void 0,void 0,(function*(){yield new Promise(((e,t)=>{const r=n=>{const{error:i,state:s}=n,o=()=>this.socket.observer.removeListener(Kn.State,r),a=[Kn.Disconnected,Kn.Reconnecting].includes(s);return i?(o(),void t(i)):this.state.isChannelJoining&&a?(o(),void t(new Error(`Not expected socket state for new connection: ${s}`))):void(this.state.isChannelJoining&&[Kn.Connected,Kn.Reconnected].includes(s)&&(o(),e()))};this.socket.observer.on(Kn.State,r)}))}))}performJoin(e){return u(this,void 0,void 0,(function*(){try{const{appId:t,channelId:r,peerId:n}=yield this.sendJoinChannelRequestWithRetry(e);this.myPeer.id=n,this.state.appId=t,this.state.channelId=r,yield this.initialize(),yield this.network.createAllDataChannels(),this.network.channelMessagesDataConsumer&&(this.eventsQueue.setChannelEventHandler(this.channelEventsHandler.handleChannelEvent.bind(this.channelEventsHandler)),this.eventsQueue.setMediaEventHandler(this.mediaEventHandler.handleMediaEvent.bind(this.mediaEventHandler)),this.eventsQueue.subscribe(this.network.channelMessagesDataConsumer)),gr.setPeerId(n),gr.setChannelId(r),gr.setAppId(t),yield Promise.all([this.network.waitForReceiveTransportConnected(),this.network.waitForChannelMessagesDataConsumerConnected()]),this.state.isJoined=!0,l(this,G_,"f").info("Successfully joined channel",{channelId:r})}catch(e){throw l(this,G_,"f").error("performJoin()",{error:e}),e}}))}sendJoinChannelRequestWithRetry(e){return u(this,void 0,void 0,(function*(){return yield zn((()=>u(this,void 0,void 0,(function*(){return yield this.sendJoinChannelRequest(e)}))),{maxRetries:3,minBackoffDelayMs:300,actionName:"sendJoinChannelRequest",logger:l(this,Y_,"f").call(this,"RetryJoin")})}))}sendJoinChannelRequest(e){return u(this,void 0,void 0,(function*(){return yield this.socket.request(vr,e)}))}watchClientEvents(){this.internalEventEmitter.on(Qr.trackProduced,(e=>u(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Qr.trackUnproduced,(e=>u(this,void 0,void 0,(function*(){var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{l(this,G_,"f").debug("Failed to close peerTrack",{error:mr(e)})})),yield this.media.deleteTrack(e)})))),this.internalEventEmitter.on(Qr.trackPaused,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.pause())||void 0===r||r.catch((e=>{l(this,G_,"f").debug("Failed to pause peerTrack",{error:mr(e)})}))})),this.internalEventEmitter.on(Qr.trackResumed,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.resume())||void 0===r||r.catch((e=>{l(this,G_,"f").debug("Failed to resume peerTrack",{error:mr(e)})}))})),this.internalEventEmitter.on(Qr.trackClosed,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{l(this,G_,"f").debug("Failed to close peerTrack",{error:mr(e)})}))})),this.internalEventEmitter.on(Qr.trackReopened,(e=>u(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Qr.trackFailed,(e=>{this.clientEventEmitter.safeEmit(Fr,{label:e.getLabel()})}))}createSelfPeerTrack(e){return u(this,void 0,void 0,(function*(){var t;if(!this.myPeer.id)return;const r=this.peers.get(this.myPeer.id);if(!r)return;yield null===(t=r.tracks.get(e.getLabel()))||void 0===t?void 0:t.close();const n=this.peerTrackFactory({label:e.getLabel(),mediaStreamTrack:e.mediaStreamTrack,muted:!1,paused:e.isPaused,onClose:()=>{},peerEventEmitter:r.observer});r.tracks.set(n.label,n)}))}triggerRejoinEventIfAppropriate(e){this.rejoinRequested&&!this.state.isChannelJoining||(l(this,G_,"f").debug("Triggering channel rejoin required event",{reason:e}),this.rejoinRequested=!0,this.clientEventEmitter.emit(Nr))}watchNetworkState(){this.network.observer.on(An,(e=>{var t;if(this.isReleasing)return;const{code:r,error:n,state:i}=e,s="unauthorized"===(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.errorCode)&&this.isChannelJoined,o=r===Kn.NeedToJoinFirst&&this.isChannelJoined;if(s&&this.clientEventEmitter.safeEmit(Hr),"server.disconnect"!==r||l(this,$_,"f")){if(o||s){const e=s?"unauthorized error":"invalid channel state";this.triggerRejoinEventIfAppropriate(e)}i===Kn.Disconnected&&this.isChannelJoined&&!l(this,$_,"f")&&l(this,G_,"f").info("connection lost",{channel:"socket"}),i===Kn.Reconnected&&this.isChannelJoined&&l(this,G_,"f").info("connection restored",{channel:"socket"}),i===Kn.BufferingStart&&(p(this,$_,!0,"f"),this.clientEventEmitter.safeEmit(Br),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),[Kn.BufferingEnd,Kn.Reconnected].includes(i)&&this.network.isNetworkActive&&(p(this,$_,!1,"f"),this.clientEventEmitter.safeEmit(Vr))}else this.clientEventEmitter.safeEmit(Wr)})),this.network.observer.on(On,(({state:e,direction:t})=>{if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!l(this,$_,"f")&&(p(this,$_,!0,"f"),l(this,G_,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Br),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),"reconnected"===e&&this.isChannelJoined&&l(this,G_,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&l(this,$_,"f"))){if(![this.network.receiveTransport,this.network.sendTransport].every((e=>"connected"===(null==e?void 0:e.connectionState)||"new"===(null==e?void 0:e.connectionState))))return;p(this,$_,!1,"f"),this.clientEventEmitter.safeEmit(Vr)}}))}watchDocumentUnload(){try{window.addEventListener("unload",(()=>{var e,t;null===(e=this.network.sendTransport)||void 0===e||e.close(),null===(t=this.network.receiveTransport)||void 0===t||t.close()}))}catch(e){l(this,G_,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId,error:mr(e)})}}waitForReconnectOrTriggerRejoinEventIfAppropriate(){l(this,G_,"f").info("Start waiting for seamless reconnect and check loadbalancer availability",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});let e=0;const t=setInterval((()=>u(this,void 0,void 0,(function*(){if(this.isReleasing||!this.state.isJoined)return clearInterval(t),void l(this,G_,"f").info("Stop waiting for seamless reconnect due to call end",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});try{if(!l(this,$_,"f"))return void clearInterval(t);if(!(yield this.loadBalancerClient.checkServiceAvailability(2e3)))return void(e=0);e+=1,e>4&&(clearInterval(t),this.triggerRejoinEventIfAppropriate("loadbalancer available"))}catch(e){l(this,G_,"f").error("Check failed",{error:mr(e),case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"})}}))),3e3)}};G_=new WeakMap,Y_=new WeakMap,$_=new WeakMap,J_=new WeakMap,Q_=a([ut(),c(0,pt(Gn.CallState)),c(1,pt(Gn.MyPeer)),c(2,pt(Gn.LoggerFactory)),c(3,pt(Gn.IntegrationsService)),c(4,pt(Gn.ProcessorsCache)),c(5,pt(Gn.MediaEventHandler)),c(6,pt(Gn.ChannelEventHandler)),c(7,pt(Gn.PeerTrackFactory)),c(8,pt(Gn.Peers)),c(9,pt(Gn.System)),c(10,pt(Gn.Media)),c(11,pt(Gn.Network)),c(12,pt(Gn.LoadBalancerApiClient)),c(13,pt(Gn.SocketIO)),c(14,pt(Gn.EventsQueue)),c(15,pt(Gn.ClientEventEmitter)),c(16,pt(Gn.InternalEventEmitter)),c(17,pt(Gn.StatsHandler)),c(18,pt(Gn.TransportsStatsProvider)),c(19,pt(Gn.WebRTCIssueDetector)),d("design:paramtypes",[Qn,Vs,Function,uf,af,Rm,Em,Function,Object,L_,im,Ma,k_,fa,Us,It,It,q_,K_,dr])],Q_);var Z_=Q_;let X_,eb=!1;const tb=()=>{try{return eb?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:mr(e)}),e instanceof Error&&"SecurityError"===e.name&&(eb=!0),null}};function rb(e){const t=tb();if(!t)return null;try{const r=t.getItem(e);return r?JSON.parse(r):null}catch(e){return null}}const nb=()=>{if(X_)return X_;const e=rb("sdk_clientUniqueId");if(e)return X_=e,e;const t=s.default.randomBytes(12).toString("hex");return X_=t,function(e,t){const r=tb();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},ib=()=>{const e=rb("sdk_clientUniqueId");return e||(null!=X_?X_:nb())},sb=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);function ob(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!sb.has(e&&e.code))(e)))}const ab=["get","head","options"],cb=ab.concat(["put","delete"]);function db(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function ub(e){return!!e.config?.method&&(db(e)&&-1!==cb.indexOf(e.config.method))}function lb(e){return ob(e)||ub(e)}function pb(e){const t=e?.response?.headers["retry-after"];if(!t)return 0;let r=1e3*(Number(t)||0);return 0===r&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}const hb={retries:3,retryCondition:lb,retryDelay:function(e=0,t){return Math.max(0,pb(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function fb(e,t,r=!1){const n=function(e,t){return{...hb,...t,...e["axios-retry"]}}(e,t||{});return n.retryCount=n.retryCount||0,n.lastRequestTime&&!r||(n.lastRequestTime=Date.now()),e["axios-retry"]=n,n}const mb=(e,t)=>{const r=e.interceptors.request.use((e=>(fb(e,t,!0),e["axios-retry"]?.validateResponse&&(e.validateStatus=()=>!1),e))),n=e.interceptors.response.use(null,(async r=>{const{config:n}=r;if(!n)return Promise.reject(r);const i=fb(n,t);return r.response&&i.validateResponse?.(r.response)?r.response:await async function(e,t){const{retries:r,retryCondition:n}=e,i=(e.retryCount||0)<r&&n(t);if("object"==typeof i)try{return!1!==await i}catch(e){return!1}return i}(i,r)?async function(e,t,r,n){t.retryCount+=1;const{retryDelay:i,shouldResetTimeout:s,onRetry:o}=t,a=i(t.retryCount,r);if(function(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}(e,n),!s&&n.timeout&&t.lastRequestTime){const e=Date.now()-t.lastRequestTime,i=n.timeout-e-a;if(i<=0)return Promise.reject(r);n.timeout=i}return n.transformRequest=[e=>e],await o(t.retryCount,r,n),n.signal?.aborted?Promise.resolve(e(n)):new Promise((t=>{const r=()=>{clearTimeout(i),t(e(n))},i=setTimeout((()=>{t(e(n)),n.signal?.removeEventListener&&n.signal.removeEventListener("abort",r)}),a);n.signal?.addEventListener&&n.signal.addEventListener("abort",r,{once:!0})}))}(e,i,r,n):(await async function(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}(i,r),Promise.reject(r))}));return{requestInterceptorId:r,responseInterceptorId:n}};mb.isNetworkError=ob,mb.isSafeRequestError=function(e){return!!e.config?.method&&(db(e)&&-1!==ab.indexOf(e.config.method))},mb.isIdempotentRequestError=ub,mb.isNetworkOrIdempotentRequestError=lb,mb.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,pb(t));return i+.2*i*Math.random()},mb.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,pb(r))}},mb.isRetryableError=db;class gb{constructor(e){this.api=e,mb(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}batch(e){return u(this,void 0,void 0,(function*(){yield this.api.post("/log/batch",e)}))}}class vb{constructor(e){this.api=e,mb(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}sendNetworkMetrics(e){return u(this,void 0,void 0,(function*(){yield this.api.post("/analytics/network-metrics",e)}))}sendWIDMetrics(e){return u(this,void 0,void 0,(function*(){yield this.api.post("/analytics/wid-metrics",Object.assign({},e))}))}}let yb=class{constructor(){this.api=iv.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>C_.stringify(e),headers:{"x-cl-id":ib()}}),this.api.defaults.headers.common["Cache-Control"]="no-cache",this.api.defaults.headers.common.Pragma="no-cache",this.api.defaults.headers.common.Expires="0",this.logApi=new gb(this.api),this.metricsApi=new vb(this.api)}get log(){return this.logApi}get metrics(){return this.metricsApi}};yb=a([ut(),d("design:paramtypes",[])],yb);var _b=yb;const bb=new Error("request for lock canceled");var Eb=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class wb{constructor(e,t=bb){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(((r,n)=>{const i={resolve:r,reject:n,weight:e,priority:t},s=Sb(this._queue,(e=>t<=e.priority));-1===s&&e<=this._value?this._dispatchItem(i):this._queue.splice(s+1,0,i)}))}runExclusive(e){return Eb(this,arguments,void 0,(function*(e,t=1,r=0){const[n,i]=yield this.acquire(t,r);try{return yield e(n)}finally{i()}}))}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise((r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),function(e,t){const r=Sb(e,(e=>t.priority<=e.priority));e.splice(r+1,0,t)}(this._weightedWaiters[e-1],{resolve:r,priority:t})}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(0===this._queue.length)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach((e=>e.resolve())),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const r=this._weightedWaiters[t-1];if(!r)continue;const n=r.findIndex((t=>t.priority<=e));(-1===n?r:r.splice(0,n)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(0===this._queue.length||this._queue[0].priority<t)&&e<=this._value}}function Sb(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1}var Cb,Pb=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class Tb{constructor(e){this._semaphore=new wb(1,e)}acquire(){return Pb(this,arguments,void 0,(function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t}))}runExclusive(e,t=0){return this._semaphore.runExclusive((()=>e()),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}let kb=class{constructor(){Cb.set(this,new Map)}lock(e){return u(this,void 0,void 0,(function*(){let t=l(this,Cb,"f").get(e);return t||(t=new Tb,l(this,Cb,"f").set(e,t)),t.isLocked()&&(yield t.waitForUnlock()),yield t.acquire()}))}isLocked(e){const t=l(this,Cb,"f").get(e);return!!t&&t.isLocked()}waitForUnlock(e){return u(this,void 0,void 0,(function*(){const t=l(this,Cb,"f").get(e);(null==t?void 0:t.isLocked())?yield t.waitForUnlock():yield Promise.resolve()}))}};Cb=new WeakMap,kb=a([ut()],kb);var Rb=kb,Ib={exports:{}},Db=1e3,Ab=60*Db,Ob=60*Ab,Nb=24*Ob,Mb=7*Nb,Lb=365.25*Nb,xb=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*Lb;case"weeks":case"week":case"w":return r*Mb;case"days":case"day":case"d":return r*Nb;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ob;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ab;case"seconds":case"second":case"secs":case"sec":case"s":return r*Db;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=Nb)return Fb(e,t,Nb,"day");if(t>=Ob)return Fb(e,t,Ob,"hour");if(t>=Ab)return Fb(e,t,Ab,"minute");if(t>=Db)return Fb(e,t,Db,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Nb)return Math.round(e/Nb)+"d";if(t>=Ob)return Math.round(e/Ob)+"h";if(t>=Ab)return Math.round(e/Ab)+"m";if(t>=Db)return Math.round(e/Db)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Fb(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var jb=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=xb,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=jb(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ib,Ib.exports);var Ub=Ib.exports,Bb={},Vb={},Wb={},Hb={exports:{}};
31
31
  /**
32
32
  * @license
33
33
  * Lodash <https://lodash.com/>
@@ -36,4 +36,4 @@ and limitations under the License.
36
36
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
37
37
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
38
38
  */
39
- !function(e,t){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,d=128,u=256,l=1/0,p=9007199254740991,h=NaN,m=4294967295,g=[["ary",d],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",u]],v="[object Arguments]",y="[object Array]",_="[object Boolean]",b="[object Date]",w="[object Error]",S="[object Function]",E="[object GeneratorFunction]",C="[object Map]",R="[object Number]",P="[object Object]",T="[object Promise]",k="[object RegExp]",D="[object Set]",I="[object String]",O="[object Symbol]",A="[object WeakMap]",L="[object ArrayBuffer]",M="[object DataView]",N="[object Float32Array]",x="[object Float64Array]",F="[object Int8Array]",j="[object Int16Array]",U="[object Int32Array]",B="[object Uint8Array]",V="[object Uint8ClampedArray]",H="[object Uint16Array]",W="[object Uint32Array]",q=/\b__p \+= '';/g,z=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39);/g,$=/[&<>"']/g,K=RegExp(Y.source),J=RegExp($.source),Q=/<%-([\s\S]+?)%>/g,Z=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,ee=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,te=/^\w*$/,re=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ne=/[\\^$.*+?()[\]{}|]/g,ie=RegExp(ne.source),se=/^\s+/,oe=/\s/,ae=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ce=/\{\n\/\* \[wrapped with (.+)\] \*/,de=/,? & /,ue=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,pe=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,fe=/\w*$/,me=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ve=/^\[object .+?Constructor\]$/,ye=/^0o[0-7]+$/i,_e=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,we=/($^)/,Se=/['\n\r\u2028\u2029\\]/g,Ee="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="\\u2700-\\u27bf",Re="a-z\\xdf-\\xf6\\xf8-\\xff",Pe="A-Z\\xc0-\\xd6\\xd8-\\xde",Te="\\ufe0e\\ufe0f",ke="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",De="['’]",Ie="[\\ud800-\\udfff]",Oe="["+ke+"]",Ae="["+Ee+"]",Le="\\d+",Me="[\\u2700-\\u27bf]",Ne="["+Re+"]",xe="[^\\ud800-\\udfff"+ke+Le+Ce+Re+Pe+"]",Fe="\\ud83c[\\udffb-\\udfff]",je="[^\\ud800-\\udfff]",Ue="(?:\\ud83c[\\udde6-\\uddff]){2}",Be="[\\ud800-\\udbff][\\udc00-\\udfff]",Ve="["+Pe+"]",He="(?:"+Ne+"|"+xe+")",We="(?:"+Ve+"|"+xe+")",qe="(?:['’](?:d|ll|m|re|s|t|ve))?",ze="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ge="(?:"+Ae+"|"+Fe+")"+"?",Ye="[\\ufe0e\\ufe0f]?",$e=Ye+Ge+("(?:\\u200d(?:"+[je,Ue,Be].join("|")+")"+Ye+Ge+")*"),Ke="(?:"+[Me,Ue,Be].join("|")+")"+$e,Je="(?:"+[je+Ae+"?",Ae,Ue,Be,Ie].join("|")+")",Qe=RegExp(De,"g"),Ze=RegExp(Ae,"g"),Xe=RegExp(Fe+"(?="+Fe+")|"+Je+$e,"g"),et=RegExp([Ve+"?"+Ne+"+"+qe+"(?="+[Oe,Ve,"$"].join("|")+")",We+"+"+ze+"(?="+[Oe,Ve+He,"$"].join("|")+")",Ve+"?"+He+"+"+qe,Ve+"+"+ze,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Le,Ke].join("|"),"g"),tt=RegExp("[\\u200d\\ud800-\\udfff"+Ee+Te+"]"),rt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],it=-1,st={};st[N]=st[x]=st[F]=st[j]=st[U]=st[B]=st[V]=st[H]=st[W]=!0,st[v]=st[y]=st[L]=st[_]=st[M]=st[b]=st[w]=st[S]=st[C]=st[R]=st[P]=st[k]=st[D]=st[I]=st[A]=!1;var ot={};ot[v]=ot[y]=ot[L]=ot[M]=ot[_]=ot[b]=ot[N]=ot[x]=ot[F]=ot[j]=ot[U]=ot[C]=ot[R]=ot[P]=ot[k]=ot[D]=ot[I]=ot[O]=ot[B]=ot[V]=ot[H]=ot[W]=!0,ot[w]=ot[S]=ot[A]=!1;var at={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ct=parseFloat,dt=parseInt,ut="object"==typeof f&&f&&f.Object===Object&&f,lt="object"==typeof self&&self&&self.Object===Object&&self,pt=ut||lt||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,mt=ft&&ft.exports===ht,gt=mt&&ut.process,vt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||gt&&gt.binding&&gt.binding("util")}catch(e){}}(),yt=vt&&vt.isArrayBuffer,_t=vt&&vt.isDate,bt=vt&&vt.isMap,wt=vt&&vt.isRegExp,St=vt&&vt.isSet,Et=vt&&vt.isTypedArray;function Ct(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Rt(e,t,r,n){for(var i=-1,s=null==e?0:e.length;++i<s;){var o=e[i];t(n,o,r(o),e)}return n}function Pt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function Tt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function kt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}function Dt(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}function It(e,t){return!!(null==e?0:e.length)&&Bt(e,t,0)>-1}function Ot(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}function At(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function Lt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Mt(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function Nt(e,t,r,n){var i=null==e?0:e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r}function xt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Ft=qt("length");function jt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function Ut(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}function Bt(e,t,r){return t==t?function(e,t,r){var n=r-1,i=e.length;for(;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):Ut(e,Ht,r)}function Vt(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Ht(e){return e!=e}function Wt(e,t){var r=null==e?0:e.length;return r?Yt(e,t)/r:h}function qt(e){return function(t){return null==t?r:t[e]}}function zt(e){return function(t){return null==e?r:e[t]}}function Gt(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function Yt(e,t){for(var n,i=-1,s=e.length;++i<s;){var o=t(e[i]);o!==r&&(n=n===r?o:n+o)}return n}function $t(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Kt(e){return e?e.slice(0,hr(e)+1).replace(se,""):e}function Jt(e){return function(t){return e(t)}}function Qt(e,t){return At(t,(function(t){return e[t]}))}function Zt(e,t){return e.has(t)}function Xt(e,t){for(var r=-1,n=e.length;++r<n&&Bt(t,e[r],0)>-1;);return r}function er(e,t){for(var r=e.length;r--&&Bt(t,e[r],0)>-1;);return r}function tr(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var rr=zt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nr=zt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ir(e){return"\\"+at[e]}function sr(e){return tt.test(e)}function or(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ar(e,t){return function(r){return e(t(r))}}function cr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var a=e[r];a!==t&&a!==s||(e[r]=s,o[i++]=r)}return o}function dr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function ur(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}function lr(e){return sr(e)?function(e){var t=Xe.lastIndex=0;for(;Xe.test(e);)++t;return t}(e):Ft(e)}function pr(e){return sr(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function hr(e){for(var t=e.length;t--&&oe.test(e.charAt(t)););return t}var fr=zt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var mr=function e(t){var f,oe=(t=null==t?pt:mr.defaults(pt.Object(),t,mr.pick(pt,nt))).Array,Ee=t.Date,Ce=t.Error,Re=t.Function,Pe=t.Math,Te=t.Object,ke=t.RegExp,De=t.String,Ie=t.TypeError,Oe=oe.prototype,Ae=Re.prototype,Le=Te.prototype,Me=t["__core-js_shared__"],Ne=Ae.toString,xe=Le.hasOwnProperty,Fe=0,je=(f=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||""))?"Symbol(src)_1."+f:"",Ue=Le.toString,Be=Ne.call(Te),Ve=pt._,He=ke("^"+Ne.call(xe).replace(ne,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),We=mt?t.Buffer:r,qe=t.Symbol,ze=t.Uint8Array,Ge=We?We.allocUnsafe:r,Ye=ar(Te.getPrototypeOf,Te),$e=Te.create,Ke=Le.propertyIsEnumerable,Je=Oe.splice,Xe=qe?qe.isConcatSpreadable:r,tt=qe?qe.iterator:r,at=qe?qe.toStringTag:r,ut=function(){try{var e=hs(Te,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,ht=Ee&&Ee.now!==pt.Date.now&&Ee.now,ft=t.setTimeout!==pt.setTimeout&&t.setTimeout,gt=Pe.ceil,vt=Pe.floor,Ft=Te.getOwnPropertySymbols,zt=We?We.isBuffer:r,gr=t.isFinite,vr=Oe.join,yr=ar(Te.keys,Te),_r=Pe.max,br=Pe.min,wr=Ee.now,Sr=t.parseInt,Er=Pe.random,Cr=Oe.reverse,Rr=hs(t,"DataView"),Pr=hs(t,"Map"),Tr=hs(t,"Promise"),kr=hs(t,"Set"),Dr=hs(t,"WeakMap"),Ir=hs(Te,"create"),Or=Dr&&new Dr,Ar={},Lr=Bs(Rr),Mr=Bs(Pr),Nr=Bs(Tr),xr=Bs(kr),Fr=Bs(Dr),jr=qe?qe.prototype:r,Ur=jr?jr.valueOf:r,Br=jr?jr.toString:r;function Vr(e){if(ia(e)&&!Yo(e)&&!(e instanceof zr)){if(e instanceof qr)return e;if(xe.call(e,"__wrapped__"))return Vs(e)}return new qr(e)}var Hr=function(){function e(){}return function(t){if(!na(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function Wr(){}function qr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function zr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=m,this.__views__=[]}function Gr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Yr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function $r(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Kr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new $r;++t<r;)this.add(e[t])}function Jr(e){var t=this.__data__=new Yr(e);this.size=t.size}function Qr(e,t){var r=Yo(e),n=!r&&Go(e),i=!r&&!n&&Qo(e),s=!r&&!n&&!i&&pa(e),o=r||n||i||s,a=o?$t(e.length,De):[],c=a.length;for(var d in e)!t&&!xe.call(e,d)||o&&("length"==d||i&&("offset"==d||"parent"==d)||s&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||bs(d,c))||a.push(d);return a}function Zr(e){var t=e.length;return t?e[Jn(0,t-1)]:r}function Xr(e,t){return Fs(Oi(e),dn(t,0,e.length))}function en(e){return Fs(Oi(e))}function tn(e,t,n){(n!==r&&!Wo(e[t],n)||n===r&&!(t in e))&&an(e,t,n)}function rn(e,t,n){var i=e[t];xe.call(e,t)&&Wo(i,n)&&(n!==r||t in e)||an(e,t,n)}function nn(e,t){for(var r=e.length;r--;)if(Wo(e[r][0],t))return r;return-1}function sn(e,t,r,n){return fn(e,(function(e,i,s){t(n,e,r(e),s)})),n}function on(e,t){return e&&Ai(t,Ma(t),e)}function an(e,t,r){"__proto__"==t&&ut?ut(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cn(e,t){for(var n=-1,i=t.length,s=oe(i),o=null==e;++n<i;)s[n]=o?r:Da(e,t[n]);return s}function dn(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function un(e,t,n,i,s,o){var a,c=1&t,d=2&t,u=4&t;if(n&&(a=s?n(e,i,s,o):n(e)),a!==r)return a;if(!na(e))return e;var l=Yo(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);t&&"string"==typeof e[0]&&xe.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(e),!c)return Oi(e,a)}else{var p=gs(e),h=p==S||p==E;if(Qo(e))return Ri(e,c);if(p==P||p==v||h&&!s){if(a=d||h?{}:ys(e),!c)return d?function(e,t){return Ai(e,ms(e),t)}(e,function(e,t){return e&&Ai(t,Na(t),e)}(a,e)):function(e,t){return Ai(e,fs(e),t)}(e,on(a,e))}else{if(!ot[p])return s?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case L:return Pi(e);case _:case b:return new n(+e);case M:return function(e,t){var r=t?Pi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case N:case x:case F:case j:case U:case B:case V:case H:case W:return Ti(e,r);case C:case D:return new n;case R:case I:return new n(e);case k:return function(e){var t=new e.constructor(e.source,fe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case O:return function(e){return Ur?Te(Ur.call(e)):{}}(e)}}(e,p,c)}}o||(o=new Jr);var f=o.get(e);if(f)return f;o.set(e,a),da(e)?e.forEach((function(r){a.add(un(r,t,n,r,e,o))})):sa(e)&&e.forEach((function(r,i){a.set(i,un(r,t,n,i,e,o))}));var m=l?r:(u?d?os:ss:d?Na:Ma)(e);return Pt(m||e,(function(r,i){m&&(r=e[i=r]),rn(a,i,un(r,t,n,i,e,o))})),a}function ln(e,t,n){var i=n.length;if(null==e)return!i;for(e=Te(e);i--;){var s=n[i],o=t[s],a=e[s];if(a===r&&!(s in e)||!o(a))return!1}return!0}function pn(e,t,i){if("function"!=typeof e)throw new Ie(n);return Ls((function(){e.apply(r,i)}),t)}function hn(e,t,r,n){var i=-1,s=It,o=!0,a=e.length,c=[],d=t.length;if(!a)return c;r&&(t=At(t,Jt(r))),n?(s=Ot,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Kr(t));e:for(;++i<a;){var u=e[i],l=null==r?u:r(u);if(u=n||0!==u?u:0,o&&l==l){for(var p=d;p--;)if(t[p]===l)continue e;c.push(u)}else s(t,l,n)||c.push(u)}return c}Vr.templateSettings={escape:Q,evaluate:Z,interpolate:X,variable:"",imports:{_:Vr}},Vr.prototype=Wr.prototype,Vr.prototype.constructor=Vr,qr.prototype=Hr(Wr.prototype),qr.prototype.constructor=qr,zr.prototype=Hr(Wr.prototype),zr.prototype.constructor=zr,Gr.prototype.clear=function(){this.__data__=Ir?Ir(null):{},this.size=0},Gr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Gr.prototype.get=function(e){var t=this.__data__;if(Ir){var n=t[e];return n===i?r:n}return xe.call(t,e)?t[e]:r},Gr.prototype.has=function(e){var t=this.__data__;return Ir?t[e]!==r:xe.call(t,e)},Gr.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Ir&&t===r?i:t,this},Yr.prototype.clear=function(){this.__data__=[],this.size=0},Yr.prototype.delete=function(e){var t=this.__data__,r=nn(t,e);return!(r<0)&&(r==t.length-1?t.pop():Je.call(t,r,1),--this.size,!0)},Yr.prototype.get=function(e){var t=this.__data__,n=nn(t,e);return n<0?r:t[n][1]},Yr.prototype.has=function(e){return nn(this.__data__,e)>-1},Yr.prototype.set=function(e,t){var r=this.__data__,n=nn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},$r.prototype.clear=function(){this.size=0,this.__data__={hash:new Gr,map:new(Pr||Yr),string:new Gr}},$r.prototype.delete=function(e){var t=ls(this,e).delete(e);return this.size-=t?1:0,t},$r.prototype.get=function(e){return ls(this,e).get(e)},$r.prototype.has=function(e){return ls(this,e).has(e)},$r.prototype.set=function(e,t){var r=ls(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Kr.prototype.add=Kr.prototype.push=function(e){return this.__data__.set(e,i),this},Kr.prototype.has=function(e){return this.__data__.has(e)},Jr.prototype.clear=function(){this.__data__=new Yr,this.size=0},Jr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Jr.prototype.get=function(e){return this.__data__.get(e)},Jr.prototype.has=function(e){return this.__data__.has(e)},Jr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Yr){var n=r.__data__;if(!Pr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new $r(n)}return r.set(e,t),this.size=r.size,this};var fn=Ni(Sn),mn=Ni(En,!0);function gn(e,t){var r=!0;return fn(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function vn(e,t,n){for(var i=-1,s=e.length;++i<s;){var o=e[i],a=t(o);if(null!=a&&(c===r?a==a&&!la(a):n(a,c)))var c=a,d=o}return d}function yn(e,t){var r=[];return fn(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function _n(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=_s),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?_n(a,t-1,r,n,i):Lt(i,a):n||(i[i.length]=a)}return i}var bn=xi(),wn=xi(!0);function Sn(e,t){return e&&bn(e,t,Ma)}function En(e,t){return e&&wn(e,t,Ma)}function Cn(e,t){return Dt(t,(function(t){return ea(e[t])}))}function Rn(e,t){for(var n=0,i=(t=wi(t,e)).length;null!=e&&n<i;)e=e[Us(t[n++])];return n&&n==i?e:r}function Pn(e,t,r){var n=t(e);return Yo(e)?n:Lt(n,r(e))}function Tn(e){return null==e?e===r?"[object Undefined]":"[object Null]":at&&at in Te(e)?function(e){var t=xe.call(e,at),n=e[at];try{e[at]=r;var i=!0}catch(e){}var s=Ue.call(e);i&&(t?e[at]=n:delete e[at]);return s}(e):function(e){return Ue.call(e)}(e)}function kn(e,t){return e>t}function Dn(e,t){return null!=e&&xe.call(e,t)}function In(e,t){return null!=e&&t in Te(e)}function On(e,t,n){for(var i=n?Ot:It,s=e[0].length,o=e.length,a=o,c=oe(o),d=1/0,u=[];a--;){var l=e[a];a&&t&&(l=At(l,Jt(t))),d=br(l.length,d),c[a]=!n&&(t||s>=120&&l.length>=120)?new Kr(a&&l):r}l=e[0];var p=-1,h=c[0];e:for(;++p<s&&u.length<d;){var f=l[p],m=t?t(f):f;if(f=n||0!==f?f:0,!(h?Zt(h,m):i(u,m,n))){for(a=o;--a;){var g=c[a];if(!(g?Zt(g,m):i(e[a],m,n)))continue e}h&&h.push(m),u.push(f)}}return u}function An(e,t,n){var i=null==(e=Ds(e,t=wi(t,e)))?e:e[Us(Zs(t))];return null==i?r:Ct(i,e,n)}function Ln(e){return ia(e)&&Tn(e)==v}function Mn(e,t,n,i,s){return e===t||(null==e||null==t||!ia(e)&&!ia(t)?e!=e&&t!=t:function(e,t,n,i,s,o){var a=Yo(e),c=Yo(t),d=a?y:gs(e),u=c?y:gs(t),l=(d=d==v?P:d)==P,p=(u=u==v?P:u)==P,h=d==u;if(h&&Qo(e)){if(!Qo(t))return!1;a=!0,l=!1}if(h&&!l)return o||(o=new Jr),a||pa(e)?ns(e,t,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case M:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case L:return!(e.byteLength!=t.byteLength||!s(new ze(e),new ze(t)));case _:case b:case R:return Wo(+e,+t);case w:return e.name==t.name&&e.message==t.message;case k:case I:return e==t+"";case C:var a=or;case D:var c=1&n;if(a||(a=dr),e.size!=t.size&&!c)return!1;var d=o.get(e);if(d)return d==t;n|=2,o.set(e,t);var u=ns(a(e),a(t),n,i,s,o);return o.delete(e),u;case O:if(Ur)return Ur.call(e)==Ur.call(t)}return!1}(e,t,d,n,i,s,o);if(!(1&n)){var f=l&&xe.call(e,"__wrapped__"),m=p&&xe.call(t,"__wrapped__");if(f||m){var g=f?e.value():e,S=m?t.value():t;return o||(o=new Jr),s(g,S,n,i,o)}}if(!h)return!1;return o||(o=new Jr),function(e,t,n,i,s,o){var a=1&n,c=ss(e),d=c.length,u=ss(t).length;if(d!=u&&!a)return!1;var l=d;for(;l--;){var p=c[l];if(!(a?p in t:xe.call(t,p)))return!1}var h=o.get(e),f=o.get(t);if(h&&f)return h==t&&f==e;var m=!0;o.set(e,t),o.set(t,e);var g=a;for(;++l<d;){var v=e[p=c[l]],y=t[p];if(i)var _=a?i(y,v,p,t,e,o):i(v,y,p,e,t,o);if(!(_===r?v===y||s(v,y,n,i,o):_)){m=!1;break}g||(g="constructor"==p)}if(m&&!g){var b=e.constructor,w=t.constructor;b==w||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof w&&w instanceof w||(m=!1)}return o.delete(e),o.delete(t),m}(e,t,n,i,s,o)}(e,t,n,i,Mn,s))}function Nn(e,t,n,i){var s=n.length,o=s,a=!i;if(null==e)return!o;for(e=Te(e);s--;){var c=n[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var d=(c=n[s])[0],u=e[d],l=c[1];if(a&&c[2]){if(u===r&&!(d in e))return!1}else{var p=new Jr;if(i)var h=i(u,l,d,e,t,p);if(!(h===r?Mn(l,u,3,i,p):h))return!1}}return!0}function xn(e){return!(!na(e)||(t=e,je&&je in t))&&(ea(e)?He:ve).test(Bs(e));var t}function Fn(e){return"function"==typeof e?e:null==e?oc:"object"==typeof e?Yo(e)?Wn(e[0],e[1]):Hn(e):mc(e)}function jn(e){if(!Rs(e))return yr(e);var t=[];for(var r in Te(e))xe.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Un(e){if(!na(e))return function(e){var t=[];if(null!=e)for(var r in Te(e))t.push(r);return t}(e);var t=Rs(e),r=[];for(var n in e)("constructor"!=n||!t&&xe.call(e,n))&&r.push(n);return r}function Bn(e,t){return e<t}function Vn(e,t){var r=-1,n=Ko(e)?oe(e.length):[];return fn(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Hn(e){var t=ps(e);return 1==t.length&&t[0][2]?Ts(t[0][0],t[0][1]):function(r){return r===e||Nn(r,e,t)}}function Wn(e,t){return Ss(e)&&Ps(t)?Ts(Us(e),t):function(n){var i=Da(n,e);return i===r&&i===t?Ia(n,e):Mn(t,i,3)}}function qn(e,t,n,i,s){e!==t&&bn(t,(function(o,a){if(s||(s=new Jr),na(o))!function(e,t,n,i,s,o,a){var c=Os(e,n),d=Os(t,n),u=a.get(d);if(u)return void tn(e,n,u);var l=o?o(c,d,n+"",e,t,a):r,p=l===r;if(p){var h=Yo(d),f=!h&&Qo(d),m=!h&&!f&&pa(d);l=d,h||f||m?Yo(c)?l=c:Jo(c)?l=Oi(c):f?(p=!1,l=Ri(d,!0)):m?(p=!1,l=Ti(d,!0)):l=[]:aa(d)||Go(d)?(l=c,Go(c)?l=ba(c):na(c)&&!ea(c)||(l=ys(d))):p=!1}p&&(a.set(d,l),s(l,d,i,o,a),a.delete(d));tn(e,n,l)}(e,t,a,n,qn,i,s);else{var c=i?i(Os(e,a),o,a+"",e,t,s):r;c===r&&(c=o),tn(e,a,c)}}),Na)}function zn(e,t){var n=e.length;if(n)return bs(t+=t<0?n:0,n)?e[t]:r}function Gn(e,t,r){t=t.length?At(t,(function(e){return Yo(e)?function(t){return Rn(t,1===e.length?e[0]:e)}:e})):[oc];var n=-1;t=At(t,Jt(us()));var i=Vn(e,(function(e,r,i){var s=At(t,(function(t){return t(e)}));return{criteria:s,index:++n,value:e}}));return function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(i,(function(e,t){return function(e,t,r){var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;for(;++n<o;){var c=ki(i[n],s[n]);if(c)return n>=a?c:c*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)}))}function Yn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Rn(e,o);r(a,o)&&ti(s,wi(o,e),a)}return s}function $n(e,t,r,n){var i=n?Vt:Bt,s=-1,o=t.length,a=e;for(e===t&&(t=Oi(t)),r&&(a=At(e,Jt(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Je.call(a,c,1),Je.call(e,c,1);return e}function Kn(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==s){var s=i;bs(i)?Je.call(e,i,1):hi(e,i)}}return e}function Jn(e,t){return e+vt(Er()*(t-e+1))}function Qn(e,t){var r="";if(!e||t<1||t>p)return r;do{t%2&&(r+=e),(t=vt(t/2))&&(e+=e)}while(t);return r}function Zn(e,t){return Ms(ks(e,t,oc),e+"")}function Xn(e){return Zr(Wa(e))}function ei(e,t){var r=Wa(e);return Fs(r,dn(t,0,r.length))}function ti(e,t,n,i){if(!na(e))return e;for(var s=-1,o=(t=wi(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var d=Us(t[s]),u=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return e;if(s!=a){var l=c[d];(u=i?i(l,d,c):r)===r&&(u=na(l)?l:bs(t[s+1])?[]:{})}rn(c,d,u),c=c[d]}return e}var ri=Or?function(e,t){return Or.set(e,t),e}:oc,ni=ut?function(e,t){return ut(e,"toString",{configurable:!0,enumerable:!1,value:nc(t),writable:!0})}:oc;function ii(e){return Fs(Wa(e))}function si(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=oe(i);++n<i;)s[n]=e[n+t];return s}function oi(e,t){var r;return fn(e,(function(e,n,i){return!(r=t(e,n,i))})),!!r}function ai(e,t,r){var n=0,i=null==e?n:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;n<i;){var s=n+i>>>1,o=e[s];null!==o&&!la(o)&&(r?o<=t:o<t)?n=s+1:i=s}return i}return ci(e,t,oc,r)}function ci(e,t,n,i){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=n(t))!=t,c=null===t,d=la(t),u=t===r;s<o;){var l=vt((s+o)/2),p=n(e[l]),h=p!==r,f=null===p,m=p==p,g=la(p);if(a)var v=i||m;else v=u?m&&(i||h):c?m&&h&&(i||!f):d?m&&h&&!f&&(i||!g):!f&&!g&&(i?p<=t:p<t);v?s=l+1:o=l}return br(o,4294967294)}function di(e,t){for(var r=-1,n=e.length,i=0,s=[];++r<n;){var o=e[r],a=t?t(o):o;if(!r||!Wo(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ui(e){return"number"==typeof e?e:la(e)?h:+e}function li(e){if("string"==typeof e)return e;if(Yo(e))return At(e,li)+"";if(la(e))return Br?Br.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function pi(e,t,r){var n=-1,i=It,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=Ot;else if(s>=200){var d=t?null:Qi(e);if(d)return dr(d);o=!1,i=Zt,c=new Kr}else c=t?[]:a;e:for(;++n<s;){var u=e[n],l=t?t(u):u;if(u=r||0!==u?u:0,o&&l==l){for(var p=c.length;p--;)if(c[p]===l)continue e;t&&c.push(l),a.push(u)}else i(c,l,r)||(c!==a&&c.push(l),a.push(u))}return a}function hi(e,t){return null==(e=Ds(e,t=wi(t,e)))||delete e[Us(Zs(t))]}function fi(e,t,r,n){return ti(e,t,r(Rn(e,t)),n)}function mi(e,t,r,n){for(var i=e.length,s=n?i:-1;(n?s--:++s<i)&&t(e[s],s,e););return r?si(e,n?0:s,n?s+1:i):si(e,n?s+1:0,n?i:s)}function gi(e,t){var r=e;return r instanceof zr&&(r=r.value()),Mt(t,(function(e,t){return t.func.apply(t.thisArg,Lt([e],t.args))}),r)}function vi(e,t,r){var n=e.length;if(n<2)return n?pi(e[0]):[];for(var i=-1,s=oe(n);++i<n;)for(var o=e[i],a=-1;++a<n;)a!=i&&(s[i]=hn(s[i]||o,e[a],t,r));return pi(_n(s,1),t,r)}function yi(e,t,n){for(var i=-1,s=e.length,o=t.length,a={};++i<s;){var c=i<o?t[i]:r;n(a,e[i],c)}return a}function _i(e){return Jo(e)?e:[]}function bi(e){return"function"==typeof e?e:oc}function wi(e,t){return Yo(e)?e:Ss(e,t)?[e]:js(wa(e))}var Si=Zn;function Ei(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:si(e,t,n)}var Ci=lt||function(e){return pt.clearTimeout(e)};function Ri(e,t){if(t)return e.slice();var r=e.length,n=Ge?Ge(r):new e.constructor(r);return e.copy(n),n}function Pi(e){var t=new e.constructor(e.byteLength);return new ze(t).set(new ze(e)),t}function Ti(e,t){var r=t?Pi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function ki(e,t){if(e!==t){var n=e!==r,i=null===e,s=e==e,o=la(e),a=t!==r,c=null===t,d=t==t,u=la(t);if(!c&&!u&&!o&&e>t||o&&a&&d&&!c&&!u||i&&a&&d||!n&&d||!s)return 1;if(!i&&!o&&!u&&e<t||u&&n&&s&&!i&&!o||c&&n&&s||!a&&s||!d)return-1}return 0}function Di(e,t,r,n){for(var i=-1,s=e.length,o=r.length,a=-1,c=t.length,d=_r(s-o,0),u=oe(c+d),l=!n;++a<c;)u[a]=t[a];for(;++i<o;)(l||i<s)&&(u[r[i]]=e[i]);for(;d--;)u[a++]=e[i++];return u}function Ii(e,t,r,n){for(var i=-1,s=e.length,o=-1,a=r.length,c=-1,d=t.length,u=_r(s-a,0),l=oe(u+d),p=!n;++i<u;)l[i]=e[i];for(var h=i;++c<d;)l[h+c]=t[c];for(;++o<a;)(p||i<s)&&(l[h+r[o]]=e[i++]);return l}function Oi(e,t){var r=-1,n=e.length;for(t||(t=oe(n));++r<n;)t[r]=e[r];return t}function Ai(e,t,n,i){var s=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var c=t[o],d=i?i(n[c],e[c],c,n,e):r;d===r&&(d=e[c]),s?an(n,c,d):rn(n,c,d)}return n}function Li(e,t){return function(r,n){var i=Yo(r)?Rt:sn,s=t?t():{};return i(r,e,us(n,2),s)}}function Mi(e){return Zn((function(t,n){var i=-1,s=n.length,o=s>1?n[s-1]:r,a=s>2?n[2]:r;for(o=e.length>3&&"function"==typeof o?(s--,o):r,a&&ws(n[0],n[1],a)&&(o=s<3?r:o,s=1),t=Te(t);++i<s;){var c=n[i];c&&e(t,c,i,o)}return t}))}function Ni(e,t){return function(r,n){if(null==r)return r;if(!Ko(r))return e(r,n);for(var i=r.length,s=t?i:-1,o=Te(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function xi(e){return function(t,r,n){for(var i=-1,s=Te(t),o=n(t),a=o.length;a--;){var c=o[e?a:++i];if(!1===r(s[c],c,s))break}return t}}function Fi(e){return function(t){var n=sr(t=wa(t))?pr(t):r,i=n?n[0]:t.charAt(0),s=n?Ei(n,1).join(""):t.slice(1);return i[e]()+s}}function ji(e){return function(t){return Mt(ec(Ga(t).replace(Qe,"")),e,"")}}function Ui(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=Hr(e.prototype),n=e.apply(r,t);return na(n)?n:r}}function Bi(e){return function(t,n,i){var s=Te(t);if(!Ko(t)){var o=us(n,3);t=Ma(t),n=function(e){return o(s[e],e,s)}}var a=e(t,n,i);return a>-1?s[o?t[a]:a]:r}}function Vi(e){return is((function(t){var i=t.length,s=i,o=qr.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new Ie(n);if(o&&!c&&"wrapper"==cs(a))var c=new qr([],!0)}for(s=c?s:i;++s<i;){var d=cs(a=t[s]),u="wrapper"==d?as(a):r;c=u&&Es(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[cs(u[0])].apply(c,u[3]):1==a.length&&Es(a)?c[d]():c.thru(a)}return function(){var e=arguments,r=e[0];if(c&&1==e.length&&Yo(r))return c.plant(r).value();for(var n=0,s=i?t[n].apply(this,e):r;++n<i;)s=t[n].call(this,s);return s}}))}function Hi(e,t,n,i,s,o,a,c,u,l){var p=t&d,h=1&t,f=2&t,m=24&t,g=512&t,v=f?r:Ui(e);return function r(){for(var d=arguments.length,y=oe(d),_=d;_--;)y[_]=arguments[_];if(m)var b=ds(r),w=tr(y,b);if(i&&(y=Di(y,i,s,m)),o&&(y=Ii(y,o,a,m)),d-=w,m&&d<l){var S=cr(y,b);return Ki(e,t,Hi,r.placeholder,n,y,S,c,u,l-d)}var E=h?n:this,C=f?E[e]:e;return d=y.length,c?y=Is(y,c):g&&d>1&&y.reverse(),p&&u<d&&(y.length=u),this&&this!==pt&&this instanceof r&&(C=v||Ui(C)),C.apply(E,y)}}function Wi(e,t){return function(r,n){return function(e,t,r,n){return Sn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function qi(e,t){return function(n,i){var s;if(n===r&&i===r)return t;if(n!==r&&(s=n),i!==r){if(s===r)return i;"string"==typeof n||"string"==typeof i?(n=li(n),i=li(i)):(n=ui(n),i=ui(i)),s=e(n,i)}return s}}function zi(e){return is((function(t){return t=At(t,Jt(us())),Zn((function(r){var n=this;return e(t,(function(e){return Ct(e,n,r)}))}))}))}function Gi(e,t){var n=(t=t===r?" ":li(t)).length;if(n<2)return n?Qn(t,e):t;var i=Qn(t,gt(e/lr(t)));return sr(t)?Ei(pr(i),0,e).join(""):i.slice(0,e)}function Yi(e){return function(t,n,i){return i&&"number"!=typeof i&&ws(t,n,i)&&(n=i=r),t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r,n){for(var i=-1,s=_r(gt((t-e)/(r||1)),0),o=oe(s);s--;)o[n?s:++i]=e,e+=r;return o}(t,n,i=i===r?t<n?1:-1:ga(i),e)}}function $i(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=_a(t),r=_a(r)),e(t,r)}}function Ki(e,t,n,i,s,o,d,u,l,p){var h=8&t;t|=h?a:c,4&(t&=~(h?c:a))||(t&=-4);var f=[e,t,s,h?o:r,h?d:r,h?r:o,h?r:d,u,l,p],m=n.apply(r,f);return Es(e)&&As(m,f),m.placeholder=i,Ns(m,e,t)}function Ji(e){var t=Pe[e];return function(e,r){if(e=_a(e),(r=null==r?0:br(va(r),292))&&gr(e)){var n=(wa(e)+"e").split("e");return+((n=(wa(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Qi=kr&&1/dr(new kr([,-0]))[1]==l?function(e){return new kr(e)}:lc;function Zi(e){return function(t){var r=gs(t);return r==C?or(t):r==D?ur(t):function(e,t){return At(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(e,t,i,l,p,h,f,m){var g=2&t;if(!g&&"function"!=typeof e)throw new Ie(n);var v=l?l.length:0;if(v||(t&=-97,l=p=r),f=f===r?f:_r(va(f),0),m=m===r?m:va(m),v-=p?p.length:0,t&c){var y=l,_=p;l=p=r}var b=g?r:as(e),w=[e,t,i,l,p,y,_,h,f,m];if(b&&function(e,t){var r=e[1],n=t[1],i=r|n,o=i<131,a=n==d&&8==r||n==d&&r==u&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==r;if(!o&&!a)return e;1&n&&(e[2]=t[2],i|=1&r?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Di(l,c,t[4]):c,e[4]=l?cr(e[3],s):t[4]}(c=t[5])&&(l=e[5],e[5]=l?Ii(l,c,t[6]):c,e[6]=l?cr(e[5],s):t[6]);(c=t[7])&&(e[7]=c);n&d&&(e[8]=null==e[8]?t[8]:br(e[8],t[8]));null==e[9]&&(e[9]=t[9]);e[0]=t[0],e[1]=i}(w,b),e=w[0],t=w[1],i=w[2],l=w[3],p=w[4],!(m=w[9]=w[9]===r?g?0:e.length:_r(w[9]-v,0))&&24&t&&(t&=-25),t&&1!=t)S=8==t||t==o?function(e,t,n){var i=Ui(e);return function s(){for(var o=arguments.length,a=oe(o),c=o,d=ds(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:cr(a,d);return(o-=u.length)<n?Ki(e,t,Hi,s.placeholder,r,a,u,r,r,n-o):Ct(this&&this!==pt&&this instanceof s?i:e,this,a)}}(e,t,m):t!=a&&33!=t||p.length?Hi.apply(r,w):function(e,t,r,n){var i=1&t,s=Ui(e);return function t(){for(var o=-1,a=arguments.length,c=-1,d=n.length,u=oe(d+a),l=this&&this!==pt&&this instanceof t?s:e;++c<d;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return Ct(l,i?r:this,u)}}(e,t,i,l);else var S=function(e,t,r){var n=1&t,i=Ui(e);return function t(){return(this&&this!==pt&&this instanceof t?i:e).apply(n?r:this,arguments)}}(e,t,i);return Ns((b?ri:As)(S,w),e,t)}function es(e,t,n,i){return e===r||Wo(e,Le[n])&&!xe.call(i,n)?t:e}function ts(e,t,n,i,s,o){return na(e)&&na(t)&&(o.set(t,e),qn(e,t,r,ts,o),o.delete(t)),e}function rs(e){return aa(e)?r:e}function ns(e,t,n,i,s,o){var a=1&n,c=e.length,d=t.length;if(c!=d&&!(a&&d>c))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var p=-1,h=!0,f=2&n?new Kr:r;for(o.set(e,t),o.set(t,e);++p<c;){var m=e[p],g=t[p];if(i)var v=a?i(g,m,p,t,e,o):i(m,g,p,e,t,o);if(v!==r){if(v)continue;h=!1;break}if(f){if(!xt(t,(function(e,t){if(!Zt(f,t)&&(m===e||s(m,e,n,i,o)))return f.push(t)}))){h=!1;break}}else if(m!==g&&!s(m,g,n,i,o)){h=!1;break}}return o.delete(e),o.delete(t),h}function is(e){return Ms(ks(e,r,Ys),e+"")}function ss(e){return Pn(e,Ma,fs)}function os(e){return Pn(e,Na,ms)}var as=Or?function(e){return Or.get(e)}:lc;function cs(e){for(var t=e.name+"",r=Ar[t],n=xe.call(Ar,t)?r.length:0;n--;){var i=r[n],s=i.func;if(null==s||s==e)return i.name}return t}function ds(e){return(xe.call(Vr,"placeholder")?Vr:e).placeholder}function us(){var e=Vr.iteratee||ac;return e=e===ac?Fn:e,arguments.length?e(arguments[0],arguments[1]):e}function ls(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function ps(e){for(var t=Ma(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ps(i)]}return t}function hs(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return xn(n)?n:r}var fs=Ft?function(e){return null==e?[]:(e=Te(e),Dt(Ft(e),(function(t){return Ke.call(e,t)})))}:yc,ms=Ft?function(e){for(var t=[];e;)Lt(t,fs(e)),e=Ye(e);return t}:yc,gs=Tn;function vs(e,t,r){for(var n=-1,i=(t=wi(t,e)).length,s=!1;++n<i;){var o=Us(t[n]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++n!=i?s:!!(i=null==e?0:e.length)&&ra(i)&&bs(o,i)&&(Yo(e)||Go(e))}function ys(e){return"function"!=typeof e.constructor||Rs(e)?{}:Hr(Ye(e))}function _s(e){return Yo(e)||Go(e)||!!(Xe&&e&&e[Xe])}function bs(e,t){var r=typeof e;return!!(t=null==t?p:t)&&("number"==r||"symbol"!=r&&_e.test(e))&&e>-1&&e%1==0&&e<t}function ws(e,t,r){if(!na(r))return!1;var n=typeof t;return!!("number"==n?Ko(r)&&bs(t,r.length):"string"==n&&t in r)&&Wo(r[t],e)}function Ss(e,t){if(Yo(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!la(e))||(te.test(e)||!ee.test(e)||null!=t&&e in Te(t))}function Es(e){var t=cs(e),r=Vr[t];if("function"!=typeof r||!(t in zr.prototype))return!1;if(e===r)return!0;var n=as(r);return!!n&&e===n[0]}(Rr&&gs(new Rr(new ArrayBuffer(1)))!=M||Pr&&gs(new Pr)!=C||Tr&&gs(Tr.resolve())!=T||kr&&gs(new kr)!=D||Dr&&gs(new Dr)!=A)&&(gs=function(e){var t=Tn(e),n=t==P?e.constructor:r,i=n?Bs(n):"";if(i)switch(i){case Lr:return M;case Mr:return C;case Nr:return T;case xr:return D;case Fr:return A}return t});var Cs=Me?ea:_c;function Rs(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Le)}function Ps(e){return e==e&&!na(e)}function Ts(e,t){return function(n){return null!=n&&(n[e]===t&&(t!==r||e in Te(n)))}}function ks(e,t,n){return t=_r(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=_r(r.length-t,0),o=oe(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=oe(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),Ct(e,this,a)}}function Ds(e,t){return t.length<2?e:Rn(e,si(t,0,-1))}function Is(e,t){for(var n=e.length,i=br(t.length,n),s=Oi(e);i--;){var o=t[i];e[i]=bs(o,n)?s[o]:r}return e}function Os(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var As=xs(ri),Ls=ft||function(e,t){return pt.setTimeout(e,t)},Ms=xs(ni);function Ns(e,t,r){var n=t+"";return Ms(e,function(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(ae,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Pt(g,(function(r){var n="_."+r[0];t&r[1]&&!It(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(ce);return t?t[1].split(de):[]}(n),r)))}function xs(e){var t=0,n=0;return function(){var i=wr(),s=16-(i-n);if(n=i,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Fs(e,t){var n=-1,i=e.length,s=i-1;for(t=t===r?i:t;++n<t;){var o=Jn(n,s),a=e[o];e[o]=e[n],e[n]=a}return e.length=t,e}var js=function(e){var t=Fo(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(re,(function(e,r,n,i){t.push(n?i.replace(pe,"$1"):r||e)})),t}));function Us(e){if("string"==typeof e||la(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Bs(e){if(null!=e){try{return Ne.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Vs(e){if(e instanceof zr)return e.clone();var t=new qr(e.__wrapped__,e.__chain__);return t.__actions__=Oi(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Hs=Zn((function(e,t){return Jo(e)?hn(e,_n(t,1,Jo,!0)):[]})),Ws=Zn((function(e,t){var n=Zs(t);return Jo(n)&&(n=r),Jo(e)?hn(e,_n(t,1,Jo,!0),us(n,2)):[]})),qs=Zn((function(e,t){var n=Zs(t);return Jo(n)&&(n=r),Jo(e)?hn(e,_n(t,1,Jo,!0),r,n):[]}));function zs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=_r(n+i,0)),Ut(e,us(t,3),i)}function Gs(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i-1;return n!==r&&(s=va(n),s=n<0?_r(i+s,0):br(s,i-1)),Ut(e,us(t,3),s,!0)}function Ys(e){return(null==e?0:e.length)?_n(e,1):[]}function $s(e){return e&&e.length?e[0]:r}var Ks=Zn((function(e){var t=At(e,_i);return t.length&&t[0]===e[0]?On(t):[]})),Js=Zn((function(e){var t=Zs(e),n=At(e,_i);return t===Zs(n)?t=r:n.pop(),n.length&&n[0]===e[0]?On(n,us(t,2)):[]})),Qs=Zn((function(e){var t=Zs(e),n=At(e,_i);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?On(n,r,t):[]}));function Zs(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Xs=Zn(eo);function eo(e,t){return e&&e.length&&t&&t.length?$n(e,t):e}var to=is((function(e,t){var r=null==e?0:e.length,n=cn(e,t);return Kn(e,At(t,(function(e){return bs(e,r)?+e:e})).sort(ki)),n}));function ro(e){return null==e?e:Cr.call(e)}var no=Zn((function(e){return pi(_n(e,1,Jo,!0))})),io=Zn((function(e){var t=Zs(e);return Jo(t)&&(t=r),pi(_n(e,1,Jo,!0),us(t,2))})),so=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,pi(_n(e,1,Jo,!0),r,t)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Dt(e,(function(e){if(Jo(e))return t=_r(e.length,t),!0})),$t(t,(function(t){return At(e,qt(t))}))}function ao(e,t){if(!e||!e.length)return[];var n=oo(e);return null==t?n:At(n,(function(e){return Ct(t,r,e)}))}var co=Zn((function(e,t){return Jo(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Dt(e,Jo))})),lo=Zn((function(e){var t=Zs(e);return Jo(t)&&(t=r),vi(Dt(e,Jo),us(t,2))})),po=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,vi(Dt(e,Jo),r,t)})),ho=Zn(oo);var fo=Zn((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,ao(e,n)}));function mo(e){var t=Vr(e);return t.__chain__=!0,t}function go(e,t){return t(e)}var vo=is((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,s=function(t){return cn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof zr&&bs(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:go,args:[s],thisArg:r}),new qr(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(s)}));var yo=Li((function(e,t,r){xe.call(e,r)?++e[r]:an(e,r,1)}));var _o=Bi(zs),bo=Bi(Gs);function wo(e,t){return(Yo(e)?Pt:fn)(e,us(t,3))}function So(e,t){return(Yo(e)?Tt:mn)(e,us(t,3))}var Eo=Li((function(e,t,r){xe.call(e,r)?e[r].push(t):an(e,r,[t])}));var Co=Zn((function(e,t,r){var n=-1,i="function"==typeof t,s=Ko(e)?oe(e.length):[];return fn(e,(function(e){s[++n]=i?Ct(t,e,r):An(e,t,r)})),s})),Ro=Li((function(e,t,r){an(e,r,t)}));function Po(e,t){return(Yo(e)?At:Vn)(e,us(t,3))}var To=Li((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var ko=Zn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&ws(e,t[0],t[1])?t=[]:r>2&&ws(t[0],t[1],t[2])&&(t=[t[0]]),Gn(e,_n(t,1),[])})),Do=ht||function(){return pt.Date.now()};function Io(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Xi(e,d,r,r,r,r,t)}function Oo(e,t){var i;if("function"!=typeof t)throw new Ie(n);return e=va(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var Ao=Zn((function(e,t,r){var n=1;if(r.length){var i=cr(r,ds(Ao));n|=a}return Xi(e,n,t,r,i)})),Lo=Zn((function(e,t,r){var n=3;if(r.length){var i=cr(r,ds(Lo));n|=a}return Xi(t,n,e,r,i)}));function Mo(e,t,i){var s,o,a,c,d,u,l=0,p=!1,h=!1,f=!0;if("function"!=typeof e)throw new Ie(n);function m(t){var n=s,i=o;return s=o=r,l=t,c=e.apply(i,n)}function g(e){return l=e,d=Ls(y,t),p?m(e):c}function v(e){var n=e-u;return u===r||n>=t||n<0||h&&e-l>=a}function y(){var e=Do();if(v(e))return _(e);d=Ls(y,function(e){var r=t-(e-u);return h?br(r,a-(e-l)):r}(e))}function _(e){return d=r,f&&s?m(e):(s=o=r,c)}function b(){var e=Do(),n=v(e);if(s=arguments,o=this,u=e,n){if(d===r)return g(u);if(h)return Ci(d),d=Ls(y,t),m(u)}return d===r&&(d=Ls(y,t)),c}return t=_a(t)||0,na(i)&&(p=!!i.leading,a=(h="maxWait"in i)?_r(_a(i.maxWait)||0,t):a,f="trailing"in i?!!i.trailing:f),b.cancel=function(){d!==r&&Ci(d),l=0,s=u=o=d=r},b.flush=function(){return d===r?c:_(Do())},b}var No=Zn((function(e,t){return pn(e,1,t)})),xo=Zn((function(e,t,r){return pn(e,_a(t)||0,r)}));function Fo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ie(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(Fo.Cache||$r),r}function jo(e){if("function"!=typeof e)throw new Ie(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Fo.Cache=$r;var Uo=Si((function(e,t){var r=(t=1==t.length&&Yo(t[0])?At(t[0],Jt(us())):At(_n(t,1),Jt(us()))).length;return Zn((function(n){for(var i=-1,s=br(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return Ct(e,this,n)}))})),Bo=Zn((function(e,t){var n=cr(t,ds(Bo));return Xi(e,a,r,t,n)})),Vo=Zn((function(e,t){var n=cr(t,ds(Vo));return Xi(e,c,r,t,n)})),Ho=is((function(e,t){return Xi(e,u,r,r,r,t)}));function Wo(e,t){return e===t||e!=e&&t!=t}var qo=$i(kn),zo=$i((function(e,t){return e>=t})),Go=Ln(function(){return arguments}())?Ln:function(e){return ia(e)&&xe.call(e,"callee")&&!Ke.call(e,"callee")},Yo=oe.isArray,$o=yt?Jt(yt):function(e){return ia(e)&&Tn(e)==L};function Ko(e){return null!=e&&ra(e.length)&&!ea(e)}function Jo(e){return ia(e)&&Ko(e)}var Qo=zt||_c,Zo=_t?Jt(_t):function(e){return ia(e)&&Tn(e)==b};function Xo(e){if(!ia(e))return!1;var t=Tn(e);return t==w||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!aa(e)}function ea(e){if(!na(e))return!1;var t=Tn(e);return t==S||t==E||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ta(e){return"number"==typeof e&&e==va(e)}function ra(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=p}function na(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ia(e){return null!=e&&"object"==typeof e}var sa=bt?Jt(bt):function(e){return ia(e)&&gs(e)==C};function oa(e){return"number"==typeof e||ia(e)&&Tn(e)==R}function aa(e){if(!ia(e)||Tn(e)!=P)return!1;var t=Ye(e);if(null===t)return!0;var r=xe.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Ne.call(r)==Be}var ca=wt?Jt(wt):function(e){return ia(e)&&Tn(e)==k};var da=St?Jt(St):function(e){return ia(e)&&gs(e)==D};function ua(e){return"string"==typeof e||!Yo(e)&&ia(e)&&Tn(e)==I}function la(e){return"symbol"==typeof e||ia(e)&&Tn(e)==O}var pa=Et?Jt(Et):function(e){return ia(e)&&ra(e.length)&&!!st[Tn(e)]};var ha=$i(Bn),fa=$i((function(e,t){return e<=t}));function ma(e){if(!e)return[];if(Ko(e))return ua(e)?pr(e):Oi(e);if(tt&&e[tt])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[tt]());var t=gs(e);return(t==C?or:t==D?dr:Wa)(e)}function ga(e){return e?(e=_a(e))===l||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function va(e){var t=ga(e),r=t%1;return t==t?r?t-r:t:0}function ya(e){return e?dn(va(e),0,m):0}function _a(e){if("number"==typeof e)return e;if(la(e))return h;if(na(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=na(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Kt(e);var r=ge.test(e);return r||ye.test(e)?dt(e.slice(2),r?2:8):me.test(e)?h:+e}function ba(e){return Ai(e,Na(e))}function wa(e){return null==e?"":li(e)}var Sa=Mi((function(e,t){if(Rs(t)||Ko(t))Ai(t,Ma(t),e);else for(var r in t)xe.call(t,r)&&rn(e,r,t[r])})),Ea=Mi((function(e,t){Ai(t,Na(t),e)})),Ca=Mi((function(e,t,r,n){Ai(t,Na(t),e,n)})),Ra=Mi((function(e,t,r,n){Ai(t,Ma(t),e,n)})),Pa=is(cn);var Ta=Zn((function(e,t){e=Te(e);var n=-1,i=t.length,s=i>2?t[2]:r;for(s&&ws(t[0],t[1],s)&&(i=1);++n<i;)for(var o=t[n],a=Na(o),c=-1,d=a.length;++c<d;){var u=a[c],l=e[u];(l===r||Wo(l,Le[u])&&!xe.call(e,u))&&(e[u]=o[u])}return e})),ka=Zn((function(e){return e.push(r,ts),Ct(Fa,r,e)}));function Da(e,t,n){var i=null==e?r:Rn(e,t);return i===r?n:i}function Ia(e,t){return null!=e&&vs(e,t,In)}var Oa=Wi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),e[t]=r}),nc(oc)),Aa=Wi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),xe.call(e,t)?e[t].push(r):e[t]=[r]}),us),La=Zn(An);function Ma(e){return Ko(e)?Qr(e):jn(e)}function Na(e){return Ko(e)?Qr(e,!0):Un(e)}var xa=Mi((function(e,t,r){qn(e,t,r)})),Fa=Mi((function(e,t,r,n){qn(e,t,r,n)})),ja=is((function(e,t){var r={};if(null==e)return r;var n=!1;t=At(t,(function(t){return t=wi(t,e),n||(n=t.length>1),t})),Ai(e,os(e),r),n&&(r=un(r,7,rs));for(var i=t.length;i--;)hi(r,t[i]);return r}));var Ua=is((function(e,t){return null==e?{}:function(e,t){return Yn(e,t,(function(t,r){return Ia(e,r)}))}(e,t)}));function Ba(e,t){if(null==e)return{};var r=At(os(e),(function(e){return[e]}));return t=us(t),Yn(e,r,(function(e,r){return t(e,r[0])}))}var Va=Zi(Ma),Ha=Zi(Na);function Wa(e){return null==e?[]:Qt(e,Ma(e))}var qa=ji((function(e,t,r){return t=t.toLowerCase(),e+(r?za(t):t)}));function za(e){return Xa(wa(e).toLowerCase())}function Ga(e){return(e=wa(e))&&e.replace(be,rr).replace(Ze,"")}var Ya=ji((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),$a=ji((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Ka=Fi("toLowerCase");var Ja=ji((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}));var Qa=ji((function(e,t,r){return e+(r?" ":"")+Xa(t)}));var Za=ji((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Xa=Fi("toUpperCase");function ec(e,t,n){return e=wa(e),(t=n?r:t)===r?function(e){return rt.test(e)}(e)?function(e){return e.match(et)||[]}(e):function(e){return e.match(ue)||[]}(e):e.match(t)||[]}var tc=Zn((function(e,t){try{return Ct(e,r,t)}catch(e){return Xo(e)?e:new Ce(e)}})),rc=is((function(e,t){return Pt(t,(function(t){t=Us(t),an(e,t,Ao(e[t],e))})),e}));function nc(e){return function(){return e}}var ic=Vi(),sc=Vi(!0);function oc(e){return e}function ac(e){return Fn("function"==typeof e?e:un(e,1))}var cc=Zn((function(e,t){return function(r){return An(r,e,t)}})),dc=Zn((function(e,t){return function(r){return An(e,r,t)}}));function uc(e,t,r){var n=Ma(t),i=Cn(t,n);null!=r||na(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Cn(t,Ma(t)));var s=!(na(r)&&"chain"in r&&!r.chain),o=ea(e);return Pt(i,(function(r){var n=t[r];e[r]=n,o&&(e.prototype[r]=function(){var t=this.__chain__;if(s||t){var r=e(this.__wrapped__),i=r.__actions__=Oi(this.__actions__);return i.push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Lt([this.value()],arguments))})})),e}function lc(){}var pc=zi(At),hc=zi(kt),fc=zi(xt);function mc(e){return Ss(e)?qt(Us(e)):function(e){return function(t){return Rn(t,e)}}(e)}var gc=Yi(),vc=Yi(!0);function yc(){return[]}function _c(){return!1}var bc=qi((function(e,t){return e+t}),0),wc=Ji("ceil"),Sc=qi((function(e,t){return e/t}),1),Ec=Ji("floor");var Cc,Rc=qi((function(e,t){return e*t}),1),Pc=Ji("round"),Tc=qi((function(e,t){return e-t}),0);return Vr.after=function(e,t){if("function"!=typeof t)throw new Ie(n);return e=va(e),function(){if(--e<1)return t.apply(this,arguments)}},Vr.ary=Io,Vr.assign=Sa,Vr.assignIn=Ea,Vr.assignInWith=Ca,Vr.assignWith=Ra,Vr.at=Pa,Vr.before=Oo,Vr.bind=Ao,Vr.bindAll=rc,Vr.bindKey=Lo,Vr.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Yo(e)?e:[e]},Vr.chain=mo,Vr.chunk=function(e,t,n){t=(n?ws(e,t,n):t===r)?1:_r(va(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,o=0,a=oe(gt(i/t));s<i;)a[o++]=si(e,s,s+=t);return a},Vr.compact=function(e){for(var t=-1,r=null==e?0:e.length,n=0,i=[];++t<r;){var s=e[t];s&&(i[n++]=s)}return i},Vr.concat=function(){var e=arguments.length;if(!e)return[];for(var t=oe(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Lt(Yo(r)?Oi(r):[r],_n(t,1))},Vr.cond=function(e){var t=null==e?0:e.length,r=us();return e=t?At(e,(function(e){if("function"!=typeof e[1])throw new Ie(n);return[r(e[0]),e[1]]})):[],Zn((function(r){for(var n=-1;++n<t;){var i=e[n];if(Ct(i[0],this,r))return Ct(i[1],this,r)}}))},Vr.conforms=function(e){return function(e){var t=Ma(e);return function(r){return ln(r,e,t)}}(un(e,1))},Vr.constant=nc,Vr.countBy=yo,Vr.create=function(e,t){var r=Hr(e);return null==t?r:on(r,t)},Vr.curry=function e(t,n,i){var s=Xi(t,8,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},Vr.curryRight=function e(t,n,i){var s=Xi(t,o,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},Vr.debounce=Mo,Vr.defaults=Ta,Vr.defaultsDeep=ka,Vr.defer=No,Vr.delay=xo,Vr.difference=Hs,Vr.differenceBy=Ws,Vr.differenceWith=qs,Vr.drop=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=n||t===r?1:va(t))<0?0:t,i):[]},Vr.dropRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,0,(t=i-(t=n||t===r?1:va(t)))<0?0:t):[]},Vr.dropRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0,!0):[]},Vr.dropWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0):[]},Vr.fill=function(e,t,n,i){var s=null==e?0:e.length;return s?(n&&"number"!=typeof n&&ws(e,t,n)&&(n=0,i=s),function(e,t,n,i){var s=e.length;for((n=va(n))<0&&(n=-n>s?0:s+n),(i=i===r||i>s?s:va(i))<0&&(i+=s),i=n>i?0:ya(i);n<i;)e[n++]=t;return e}(e,t,n,i)):[]},Vr.filter=function(e,t){return(Yo(e)?Dt:yn)(e,us(t,3))},Vr.flatMap=function(e,t){return _n(Po(e,t),1)},Vr.flatMapDeep=function(e,t){return _n(Po(e,t),l)},Vr.flatMapDepth=function(e,t,n){return n=n===r?1:va(n),_n(Po(e,t),n)},Vr.flatten=Ys,Vr.flattenDeep=function(e){return(null==e?0:e.length)?_n(e,l):[]},Vr.flattenDepth=function(e,t){return(null==e?0:e.length)?_n(e,t=t===r?1:va(t)):[]},Vr.flip=function(e){return Xi(e,512)},Vr.flow=ic,Vr.flowRight=sc,Vr.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={};++t<r;){var i=e[t];n[i[0]]=i[1]}return n},Vr.functions=function(e){return null==e?[]:Cn(e,Ma(e))},Vr.functionsIn=function(e){return null==e?[]:Cn(e,Na(e))},Vr.groupBy=Eo,Vr.initial=function(e){return(null==e?0:e.length)?si(e,0,-1):[]},Vr.intersection=Ks,Vr.intersectionBy=Js,Vr.intersectionWith=Qs,Vr.invert=Oa,Vr.invertBy=Aa,Vr.invokeMap=Co,Vr.iteratee=ac,Vr.keyBy=Ro,Vr.keys=Ma,Vr.keysIn=Na,Vr.map=Po,Vr.mapKeys=function(e,t){var r={};return t=us(t,3),Sn(e,(function(e,n,i){an(r,t(e,n,i),e)})),r},Vr.mapValues=function(e,t){var r={};return t=us(t,3),Sn(e,(function(e,n,i){an(r,n,t(e,n,i))})),r},Vr.matches=function(e){return Hn(un(e,1))},Vr.matchesProperty=function(e,t){return Wn(e,un(t,1))},Vr.memoize=Fo,Vr.merge=xa,Vr.mergeWith=Fa,Vr.method=cc,Vr.methodOf=dc,Vr.mixin=uc,Vr.negate=jo,Vr.nthArg=function(e){return e=va(e),Zn((function(t){return zn(t,e)}))},Vr.omit=ja,Vr.omitBy=function(e,t){return Ba(e,jo(us(t)))},Vr.once=function(e){return Oo(2,e)},Vr.orderBy=function(e,t,n,i){return null==e?[]:(Yo(t)||(t=null==t?[]:[t]),Yo(n=i?r:n)||(n=null==n?[]:[n]),Gn(e,t,n))},Vr.over=pc,Vr.overArgs=Uo,Vr.overEvery=hc,Vr.overSome=fc,Vr.partial=Bo,Vr.partialRight=Vo,Vr.partition=To,Vr.pick=Ua,Vr.pickBy=Ba,Vr.property=mc,Vr.propertyOf=function(e){return function(t){return null==e?r:Rn(e,t)}},Vr.pull=Xs,Vr.pullAll=eo,Vr.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?$n(e,t,us(r,2)):e},Vr.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?$n(e,t,r,n):e},Vr.pullAt=to,Vr.range=gc,Vr.rangeRight=vc,Vr.rearg=Ho,Vr.reject=function(e,t){return(Yo(e)?Dt:yn)(e,jo(us(t,3)))},Vr.remove=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],s=e.length;for(t=us(t,3);++n<s;){var o=e[n];t(o,n,e)&&(r.push(o),i.push(n))}return Kn(e,i),r},Vr.rest=function(e,t){if("function"!=typeof e)throw new Ie(n);return Zn(e,t=t===r?t:va(t))},Vr.reverse=ro,Vr.sampleSize=function(e,t,n){return t=(n?ws(e,t,n):t===r)?1:va(t),(Yo(e)?Xr:ei)(e,t)},Vr.set=function(e,t,r){return null==e?e:ti(e,t,r)},Vr.setWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:ti(e,t,n,i)},Vr.shuffle=function(e){return(Yo(e)?en:ii)(e)},Vr.slice=function(e,t,n){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&ws(e,t,n)?(t=0,n=i):(t=null==t?0:va(t),n=n===r?i:va(n)),si(e,t,n)):[]},Vr.sortBy=ko,Vr.sortedUniq=function(e){return e&&e.length?di(e):[]},Vr.sortedUniqBy=function(e,t){return e&&e.length?di(e,us(t,2)):[]},Vr.split=function(e,t,n){return n&&"number"!=typeof n&&ws(e,t,n)&&(t=n=r),(n=n===r?m:n>>>0)?(e=wa(e))&&("string"==typeof t||null!=t&&!ca(t))&&!(t=li(t))&&sr(e)?Ei(pr(e),0,n):e.split(t,n):[]},Vr.spread=function(e,t){if("function"!=typeof e)throw new Ie(n);return t=null==t?0:_r(va(t),0),Zn((function(r){var n=r[t],i=Ei(r,0,t);return n&&Lt(i,n),Ct(e,this,i)}))},Vr.tail=function(e){var t=null==e?0:e.length;return t?si(e,1,t):[]},Vr.take=function(e,t,n){return e&&e.length?si(e,0,(t=n||t===r?1:va(t))<0?0:t):[]},Vr.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=i-(t=n||t===r?1:va(t)))<0?0:t,i):[]},Vr.takeRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!1,!0):[]},Vr.takeWhile=function(e,t){return e&&e.length?mi(e,us(t,3)):[]},Vr.tap=function(e,t){return t(e),e},Vr.throttle=function(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new Ie(n);return na(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),Mo(e,t,{leading:i,maxWait:t,trailing:s})},Vr.thru=go,Vr.toArray=ma,Vr.toPairs=Va,Vr.toPairsIn=Ha,Vr.toPath=function(e){return Yo(e)?At(e,Us):la(e)?[e]:Oi(js(wa(e)))},Vr.toPlainObject=ba,Vr.transform=function(e,t,r){var n=Yo(e),i=n||Qo(e)||pa(e);if(t=us(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:na(e)&&ea(s)?Hr(Ye(e)):{}}return(i?Pt:Sn)(e,(function(e,n,i){return t(r,e,n,i)})),r},Vr.unary=function(e){return Io(e,1)},Vr.union=no,Vr.unionBy=io,Vr.unionWith=so,Vr.uniq=function(e){return e&&e.length?pi(e):[]},Vr.uniqBy=function(e,t){return e&&e.length?pi(e,us(t,2)):[]},Vr.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?pi(e,r,t):[]},Vr.unset=function(e,t){return null==e||hi(e,t)},Vr.unzip=oo,Vr.unzipWith=ao,Vr.update=function(e,t,r){return null==e?e:fi(e,t,bi(r))},Vr.updateWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:fi(e,t,bi(n),i)},Vr.values=Wa,Vr.valuesIn=function(e){return null==e?[]:Qt(e,Na(e))},Vr.without=co,Vr.words=ec,Vr.wrap=function(e,t){return Bo(bi(t),e)},Vr.xor=uo,Vr.xorBy=lo,Vr.xorWith=po,Vr.zip=ho,Vr.zipObject=function(e,t){return yi(e||[],t||[],rn)},Vr.zipObjectDeep=function(e,t){return yi(e||[],t||[],ti)},Vr.zipWith=fo,Vr.entries=Va,Vr.entriesIn=Ha,Vr.extend=Ea,Vr.extendWith=Ca,uc(Vr,Vr),Vr.add=bc,Vr.attempt=tc,Vr.camelCase=qa,Vr.capitalize=za,Vr.ceil=wc,Vr.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=_a(n))==n?n:0),t!==r&&(t=(t=_a(t))==t?t:0),dn(_a(e),t,n)},Vr.clone=function(e){return un(e,4)},Vr.cloneDeep=function(e){return un(e,5)},Vr.cloneDeepWith=function(e,t){return un(e,5,t="function"==typeof t?t:r)},Vr.cloneWith=function(e,t){return un(e,4,t="function"==typeof t?t:r)},Vr.conformsTo=function(e,t){return null==t||ln(e,t,Ma(t))},Vr.deburr=Ga,Vr.defaultTo=function(e,t){return null==e||e!=e?t:e},Vr.divide=Sc,Vr.endsWith=function(e,t,n){e=wa(e),t=li(t);var i=e.length,s=n=n===r?i:dn(va(n),0,i);return(n-=t.length)>=0&&e.slice(n,s)==t},Vr.eq=Wo,Vr.escape=function(e){return(e=wa(e))&&J.test(e)?e.replace($,nr):e},Vr.escapeRegExp=function(e){return(e=wa(e))&&ie.test(e)?e.replace(ne,"\\$&"):e},Vr.every=function(e,t,n){var i=Yo(e)?kt:gn;return n&&ws(e,t,n)&&(t=r),i(e,us(t,3))},Vr.find=_o,Vr.findIndex=zs,Vr.findKey=function(e,t){return jt(e,us(t,3),Sn)},Vr.findLast=bo,Vr.findLastIndex=Gs,Vr.findLastKey=function(e,t){return jt(e,us(t,3),En)},Vr.floor=Ec,Vr.forEach=wo,Vr.forEachRight=So,Vr.forIn=function(e,t){return null==e?e:bn(e,us(t,3),Na)},Vr.forInRight=function(e,t){return null==e?e:wn(e,us(t,3),Na)},Vr.forOwn=function(e,t){return e&&Sn(e,us(t,3))},Vr.forOwnRight=function(e,t){return e&&En(e,us(t,3))},Vr.get=Da,Vr.gt=qo,Vr.gte=zo,Vr.has=function(e,t){return null!=e&&vs(e,t,Dn)},Vr.hasIn=Ia,Vr.head=$s,Vr.identity=oc,Vr.includes=function(e,t,r,n){e=Ko(e)?e:Wa(e),r=r&&!n?va(r):0;var i=e.length;return r<0&&(r=_r(i+r,0)),ua(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Bt(e,t,r)>-1},Vr.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=_r(n+i,0)),Bt(e,t,i)},Vr.inRange=function(e,t,n){return t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r){return e>=br(t,r)&&e<_r(t,r)}(e=_a(e),t,n)},Vr.invoke=La,Vr.isArguments=Go,Vr.isArray=Yo,Vr.isArrayBuffer=$o,Vr.isArrayLike=Ko,Vr.isArrayLikeObject=Jo,Vr.isBoolean=function(e){return!0===e||!1===e||ia(e)&&Tn(e)==_},Vr.isBuffer=Qo,Vr.isDate=Zo,Vr.isElement=function(e){return ia(e)&&1===e.nodeType&&!aa(e)},Vr.isEmpty=function(e){if(null==e)return!0;if(Ko(e)&&(Yo(e)||"string"==typeof e||"function"==typeof e.splice||Qo(e)||pa(e)||Go(e)))return!e.length;var t=gs(e);if(t==C||t==D)return!e.size;if(Rs(e))return!jn(e).length;for(var r in e)if(xe.call(e,r))return!1;return!0},Vr.isEqual=function(e,t){return Mn(e,t)},Vr.isEqualWith=function(e,t,n){var i=(n="function"==typeof n?n:r)?n(e,t):r;return i===r?Mn(e,t,r,n):!!i},Vr.isError=Xo,Vr.isFinite=function(e){return"number"==typeof e&&gr(e)},Vr.isFunction=ea,Vr.isInteger=ta,Vr.isLength=ra,Vr.isMap=sa,Vr.isMatch=function(e,t){return e===t||Nn(e,t,ps(t))},Vr.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,Nn(e,t,ps(t),n)},Vr.isNaN=function(e){return oa(e)&&e!=+e},Vr.isNative=function(e){if(Cs(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return xn(e)},Vr.isNil=function(e){return null==e},Vr.isNull=function(e){return null===e},Vr.isNumber=oa,Vr.isObject=na,Vr.isObjectLike=ia,Vr.isPlainObject=aa,Vr.isRegExp=ca,Vr.isSafeInteger=function(e){return ta(e)&&e>=-9007199254740991&&e<=p},Vr.isSet=da,Vr.isString=ua,Vr.isSymbol=la,Vr.isTypedArray=pa,Vr.isUndefined=function(e){return e===r},Vr.isWeakMap=function(e){return ia(e)&&gs(e)==A},Vr.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==Tn(e)},Vr.join=function(e,t){return null==e?"":vr.call(e,t)},Vr.kebabCase=Ya,Vr.last=Zs,Vr.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=va(n))<0?_r(i+s,0):br(s,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,s):Ut(e,Ht,s,!0)},Vr.lowerCase=$a,Vr.lowerFirst=Ka,Vr.lt=ha,Vr.lte=fa,Vr.max=function(e){return e&&e.length?vn(e,oc,kn):r},Vr.maxBy=function(e,t){return e&&e.length?vn(e,us(t,2),kn):r},Vr.mean=function(e){return Wt(e,oc)},Vr.meanBy=function(e,t){return Wt(e,us(t,2))},Vr.min=function(e){return e&&e.length?vn(e,oc,Bn):r},Vr.minBy=function(e,t){return e&&e.length?vn(e,us(t,2),Bn):r},Vr.stubArray=yc,Vr.stubFalse=_c,Vr.stubObject=function(){return{}},Vr.stubString=function(){return""},Vr.stubTrue=function(){return!0},Vr.multiply=Rc,Vr.nth=function(e,t){return e&&e.length?zn(e,va(t)):r},Vr.noConflict=function(){return pt._===this&&(pt._=Ve),this},Vr.noop=lc,Vr.now=Do,Vr.pad=function(e,t,r){e=wa(e);var n=(t=va(t))?lr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return Gi(vt(i),r)+e+Gi(gt(i),r)},Vr.padEnd=function(e,t,r){e=wa(e);var n=(t=va(t))?lr(e):0;return t&&n<t?e+Gi(t-n,r):e},Vr.padStart=function(e,t,r){e=wa(e);var n=(t=va(t))?lr(e):0;return t&&n<t?Gi(t-n,r)+e:e},Vr.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),Sr(wa(e).replace(se,""),t||0)},Vr.random=function(e,t,n){if(n&&"boolean"!=typeof n&&ws(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=ga(e),t===r?(t=e,e=0):t=ga(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var s=Er();return br(e+s*(t-e+ct("1e-"+((s+"").length-1))),t)}return Jn(e,t)},Vr.reduce=function(e,t,r){var n=Yo(e)?Mt:Gt,i=arguments.length<3;return n(e,us(t,4),r,i,fn)},Vr.reduceRight=function(e,t,r){var n=Yo(e)?Nt:Gt,i=arguments.length<3;return n(e,us(t,4),r,i,mn)},Vr.repeat=function(e,t,n){return t=(n?ws(e,t,n):t===r)?1:va(t),Qn(wa(e),t)},Vr.replace=function(){var e=arguments,t=wa(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Vr.result=function(e,t,n){var i=-1,s=(t=wi(t,e)).length;for(s||(s=1,e=r);++i<s;){var o=null==e?r:e[Us(t[i])];o===r&&(i=s,o=n),e=ea(o)?o.call(e):o}return e},Vr.round=Pc,Vr.runInContext=e,Vr.sample=function(e){return(Yo(e)?Zr:Xn)(e)},Vr.size=function(e){if(null==e)return 0;if(Ko(e))return ua(e)?lr(e):e.length;var t=gs(e);return t==C||t==D?e.size:jn(e).length},Vr.snakeCase=Ja,Vr.some=function(e,t,n){var i=Yo(e)?xt:oi;return n&&ws(e,t,n)&&(t=r),i(e,us(t,3))},Vr.sortedIndex=function(e,t){return ai(e,t)},Vr.sortedIndexBy=function(e,t,r){return ci(e,t,us(r,2))},Vr.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ai(e,t);if(n<r&&Wo(e[n],t))return n}return-1},Vr.sortedLastIndex=function(e,t){return ai(e,t,!0)},Vr.sortedLastIndexBy=function(e,t,r){return ci(e,t,us(r,2),!0)},Vr.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var r=ai(e,t,!0)-1;if(Wo(e[r],t))return r}return-1},Vr.startCase=Qa,Vr.startsWith=function(e,t,r){return e=wa(e),r=null==r?0:dn(va(r),0,e.length),t=li(t),e.slice(r,r+t.length)==t},Vr.subtract=Tc,Vr.sum=function(e){return e&&e.length?Yt(e,oc):0},Vr.sumBy=function(e,t){return e&&e.length?Yt(e,us(t,2)):0},Vr.template=function(e,t,n){var i=Vr.templateSettings;n&&ws(e,t,n)&&(t=r),e=wa(e),t=Ca({},t,i,es);var s,o,a=Ca({},t.imports,i.imports,es),c=Ma(a),d=Qt(a,c),u=0,l=t.interpolate||we,p="__p += '",h=ke((t.escape||we).source+"|"+l.source+"|"+(l===X?he:we).source+"|"+(t.evaluate||we).source+"|$","g"),f="//# sourceURL="+(xe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++it+"]")+"\n";e.replace(h,(function(t,r,n,i,a,c){return n||(n=i),p+=e.slice(u,c).replace(Se,ir),r&&(s=!0,p+="' +\n__e("+r+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),p+="';\n";var m=xe.call(t,"variable")&&t.variable;if(m){if(le.test(m))throw new Ce("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(q,""):p).replace(z,"$1").replace(G,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var g=tc((function(){return Re(c,f+"return "+p).apply(r,d)}));if(g.source=p,Xo(g))throw g;return g},Vr.times=function(e,t){if((e=va(e))<1||e>p)return[];var r=m,n=br(e,m);t=us(t),e-=m;for(var i=$t(n,t);++r<e;)t(r);return i},Vr.toFinite=ga,Vr.toInteger=va,Vr.toLength=ya,Vr.toLower=function(e){return wa(e).toLowerCase()},Vr.toNumber=_a,Vr.toSafeInteger=function(e){return e?dn(va(e),-9007199254740991,p):0===e?e:0},Vr.toString=wa,Vr.toUpper=function(e){return wa(e).toUpperCase()},Vr.trim=function(e,t,n){if((e=wa(e))&&(n||t===r))return Kt(e);if(!e||!(t=li(t)))return e;var i=pr(e),s=pr(t);return Ei(i,Xt(i,s),er(i,s)+1).join("")},Vr.trimEnd=function(e,t,n){if((e=wa(e))&&(n||t===r))return e.slice(0,hr(e)+1);if(!e||!(t=li(t)))return e;var i=pr(e);return Ei(i,0,er(i,pr(t))+1).join("")},Vr.trimStart=function(e,t,n){if((e=wa(e))&&(n||t===r))return e.replace(se,"");if(!e||!(t=li(t)))return e;var i=pr(e);return Ei(i,Xt(i,pr(t))).join("")},Vr.truncate=function(e,t){var n=30,i="...";if(na(t)){var s="separator"in t?t.separator:s;n="length"in t?va(t.length):n,i="omission"in t?li(t.omission):i}var o=(e=wa(e)).length;if(sr(e)){var a=pr(e);o=a.length}if(n>=o)return e;var c=n-lr(i);if(c<1)return i;var d=a?Ei(a,0,c).join(""):e.slice(0,c);if(s===r)return d+i;if(a&&(c+=d.length-c),ca(s)){if(e.slice(c).search(s)){var u,l=d;for(s.global||(s=ke(s.source,wa(fe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;d=d.slice(0,p===r?c:p)}}else if(e.indexOf(li(s),c)!=c){var h=d.lastIndexOf(s);h>-1&&(d=d.slice(0,h))}return d+i},Vr.unescape=function(e){return(e=wa(e))&&K.test(e)?e.replace(Y,fr):e},Vr.uniqueId=function(e){var t=++Fe;return wa(e)+t},Vr.upperCase=Za,Vr.upperFirst=Xa,Vr.each=wo,Vr.eachRight=So,Vr.first=$s,uc(Vr,(Cc={},Sn(Vr,(function(e,t){xe.call(Vr.prototype,t)||(Cc[t]=e)})),Cc),{chain:!1}),Vr.VERSION="4.17.21",Pt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Vr[e].placeholder=Vr})),Pt(["drop","take"],(function(e,t){zr.prototype[e]=function(n){n=n===r?1:_r(va(n),0);var i=this.__filtered__&&!t?new zr(this):this.clone();return i.__filtered__?i.__takeCount__=br(n,i.__takeCount__):i.__views__.push({size:br(n,m),type:e+(i.__dir__<0?"Right":"")}),i},zr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Pt(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;zr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:us(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Pt(["head","last"],(function(e,t){var r="take"+(t?"Right":"");zr.prototype[e]=function(){return this[r](1).value()[0]}})),Pt(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");zr.prototype[e]=function(){return this.__filtered__?new zr(this):this[r](1)}})),zr.prototype.compact=function(){return this.filter(oc)},zr.prototype.find=function(e){return this.filter(e).head()},zr.prototype.findLast=function(e){return this.reverse().find(e)},zr.prototype.invokeMap=Zn((function(e,t){return"function"==typeof e?new zr(this):this.map((function(r){return An(r,e,t)}))})),zr.prototype.reject=function(e){return this.filter(jo(us(e)))},zr.prototype.slice=function(e,t){e=va(e);var n=this;return n.__filtered__&&(e>0||t<0)?new zr(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=va(t))<0?n.dropRight(-t):n.take(t-e)),n)},zr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zr.prototype.toArray=function(){return this.take(m)},Sn(zr.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=Vr[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);s&&(Vr.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof zr,d=a[0],u=c||Yo(t),l=function(e){var t=s.apply(Vr,Lt([e],a));return i&&p?t[0]:t};u&&n&&"function"==typeof d&&1!=d.length&&(c=u=!1);var p=this.__chain__,h=!!this.__actions__.length,f=o&&!p,m=c&&!h;if(!o&&u){t=m?t:new zr(this);var g=e.apply(t,a);return g.__actions__.push({func:go,args:[l],thisArg:r}),new qr(g,p)}return f&&m?e.apply(this,a):(g=this.thru(l),f?i?g.value()[0]:g.value():g)})})),Pt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Oe[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);Vr.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Yo(i)?i:[],e)}return this[r]((function(r){return t.apply(Yo(r)?r:[],e)}))}})),Sn(zr.prototype,(function(e,t){var r=Vr[t];if(r){var n=r.name+"";xe.call(Ar,n)||(Ar[n]=[]),Ar[n].push({name:t,func:r})}})),Ar[Hi(r,2).name]=[{name:"wrapper",func:r}],zr.prototype.clone=function(){var e=new zr(this.__wrapped__);return e.__actions__=Oi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Oi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Oi(this.__views__),e},zr.prototype.reverse=function(){if(this.__filtered__){var e=new zr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Yo(e),n=t<0,i=r?e.length:0,s=function(e,t,r){var n=-1,i=r.length;for(;++n<i;){var s=r[n],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=br(t,e+o);break;case"takeRight":e=_r(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=s.start,a=s.end,c=a-o,d=n?a:o-1,u=this.__iteratees__,l=u.length,p=0,h=br(c,this.__takeCount__);if(!r||!n&&i==c&&h==c)return gi(e,this.__actions__);var f=[];e:for(;c--&&p<h;){for(var m=-1,g=e[d+=t];++m<l;){var v=u[m],y=v.iteratee,_=v.type,b=y(g);if(2==_)g=b;else if(!b){if(1==_)continue e;break e}}f[p++]=g}return f},Vr.prototype.at=vo,Vr.prototype.chain=function(){return mo(this)},Vr.prototype.commit=function(){return new qr(this.value(),this.__chain__)},Vr.prototype.next=function(){this.__values__===r&&(this.__values__=ma(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},Vr.prototype.plant=function(e){for(var t,n=this;n instanceof Wr;){var i=Vs(n);i.__index__=0,i.__values__=r,t?s.__wrapped__=i:t=i;var s=i;n=n.__wrapped__}return s.__wrapped__=e,t},Vr.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof zr){var t=e;return this.__actions__.length&&(t=new zr(this)),(t=t.reverse()).__actions__.push({func:go,args:[ro],thisArg:r}),new qr(t,this.__chain__)}return this.thru(ro)},Vr.prototype.toJSON=Vr.prototype.valueOf=Vr.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},Vr.prototype.first=Vr.prototype.head,tt&&(Vr.prototype[tt]=function(){return this}),Vr}();ft?((ft.exports=mr)._=mr,ht._=mr):pt._=mr}).call(f)}(CS,CS.exports);var RS,PS=f&&f.__extends||(RS=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}RS(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(ES,"__esModule",{value:!0});var TS,kS,DS,IS,OS,AS,LS,MS,NS=i.default,xS=CS.exports,FS=["MaxBatchSize","MaxDelay","MinDelay"],jS=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(FS.forEach((function(t){if(!e.hasOwnProperty(t))throw new Error("Missing required MessageBatcher option: "+t)})),isNaN(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a number");if(!isFinite(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a finite number");if(e.MaxBatchSize<1)throw new Error("MessageBatcher MaxBatchSize option cannot be less than 1");if(isNaN(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a number");if(!isFinite(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a finite number");if(e.MaxDelay<0)throw new Error("MessageBatcher MaxDelay option cannot be less than 0");if(isNaN(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a number");if(!isFinite(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a finite number");if(e.MinDelay<0)throw new Error("MessageBatcher MinDelay option cannot be less than 0");if(e.MinDelay>e.MaxDelay)throw new Error("MessageBatcher MinDelay option cannot be greater than MaxDelay")}(t),r.options=t,r.releaseBatchDebouncedMax=xS.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=xS.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return PS(t,e),t.prototype.Queue=function(e){var t=this;(e=[].concat(e)).forEach((function(e){t.fifo.push(e),t.debounce(t.fifo,t.options.MaxBatchSize)}),this)},t.prototype.debounce=function(e,t){e.length>0&&(e.length>=t?this.firstBatch?(this.firstBatch=!1,this.releaseBatchDebouncedMax.flush()):(this.releaseBatchDebouncedMax.cancel(),this.releaseBatchDebouncedMin(e,t)):(this.releaseBatchDebouncedMin.cancel(),this.releaseBatchDebouncedMax(e,t)))},t.prototype.releaseBatch=function(e,t){var r=this.drainFIFO(e,t);r&&r.length&&(this.emit("batch",r),this.debounce(e,t))},t.prototype.drainFIFO=function(e,t){return e.length>0?e.splice(0,t):e},t}(NS.EventEmitter);ES.MessageBatcher=jS,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(ES)}(SS),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(SS)}(wS);class US{constructor(e){TS.add(this),kS.set(this,void 0),DS.set(this,void 0),IS.set(this,void 0),OS.set(this,void 0),AS.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;p(this,kS,r,"f"),p(this,DS,t,"f"),this.onLogMessage=n,p(this,OS,new eS,"f"),p(this,IS,new wS.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),p(this,AS,e.sendAnalytics,"f"),l(this,IS,"f").on("batch",(e=>{this.logToApi(e).catch((e=>{this.error("Failed to log to api",{case:"Logger",error:mr(e)})}))})),this._debug=bS("LiveDigital").extend("debug").extend(l(this,kS,"f")),this._info=bS("LiveDigital").extend("info").extend(l(this,kS,"f")),this._warn=bS("LiveDigital").extend("warn").extend(l(this,kS,"f")),this._error=bS("LiveDigital").extend("error").extend(l(this,kS,"f")),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}debug(e,t){this._debug(e,t),l(this,AS,"f")&&l(this,IS,"f").Queue({level:"debug",message:e,meta:t}),l(this,DS,"f")>=gt&&l(this,TS,"m",LS).call(this,"debug",e,t)}info(e,t){this._info(e,t),l(this,AS,"f")&&l(this,IS,"f").Queue({level:"info",message:e,meta:t}),l(this,DS,"f")>=mt&&l(this,TS,"m",LS).call(this,"info",e,t)}warn(e,t){this._warn(e,t),l(this,AS,"f")&&l(this,IS,"f").Queue({level:"warn",message:e,meta:t}),l(this,DS,"f")>=ft&&l(this,TS,"m",LS).call(this,"warn",e,t)}error(e,t){this._error(e,t),l(this,AS,"f")&&l(this,IS,"f").Queue({level:"error",message:e,meta:t}),l(this,DS,"f")>=ht&&l(this,TS,"m",LS).call(this,"error",e,t)}logToApi(e){return u(this,void 0,void 0,(function*(){try{yield l(this,OS,"f").log.batch({logs:e.map((e=>l(this,TS,"m",MS).call(this,Object.assign(Object.assign({},e),{meta:this.prepareRecordMeta(e.meta)})))),clientMeta:this.getClientMeta()})}catch(e){this._debug("Log request was not successful",{error:e})}}))}getClientMeta(){return Object.assign(Object.assign({},gr.meta),{clUId:Uw()})}prepareRecordMeta(e){const t=null!=e?e:{},{error:r}=t;return Object.assign(Object.assign(Object.assign({},t),{clientTimestamp:(new Date).toISOString(),from_sdk:!0}),r&&"object"==typeof r?{error:mr(r)}:{})}}kS=new WeakMap,DS=new WeakMap,IS=new WeakMap,OS=new WeakMap,AS=new WeakMap,TS=new WeakSet,LS=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...l(this,TS,"m",MS).call(this,r),e)},MS=function(e){const t=new WeakMap;return function e(r,n=[]){if(!xn(r))return r;const i=t.get(r);if(i)return`[Circular *${i.join(".")}]`;t.set(r,n);const s=Array.isArray(r)?[]:{};return Object.entries(r).forEach((([t,r])=>{s[t]=e(r,[...n,t])})),t.delete(r),s}(e)};let BS=class{constructor(e){this.peerTrackFactory=e,this.tracksByConsumerId=new Map}register(e,t){this.tracksByConsumerId.set(e,t)}get(e){return this.tracksByConsumerId.get(e)}delete(e){return this.tracksByConsumerId.delete(e)}reset(){this.tracksByConsumerId.clear()}create(e){const{consumer:t,label:r,muted:n=!1,mediaStreamTrack:i,paused:s,peerEventEmitter:o}=e,a=this.peerTrackFactory({consumer:t,label:r,mediaStreamTrack:i,paused:s,peerEventEmitter:o,muted:n,onClose:()=>{void 0!==a.consumerId&&this.delete(a.consumerId)}});return void 0!==a.consumerId&&this.register(a.consumerId,a),a}};var VS,HS,WS;BS=a([ut(),c(0,pt(Gn.PeerTrackFactory)),d("design:paramtypes",[Function])],BS);const qS=["frozen-video-track","network-media-sync-failure","encoder-cpu-throttling","decoder-cpu-throttling","missing-video-stream-data","missing-audio-stream-data"];let zS=class{constructor(e,t,r,n,i,s){this.analyticsApiClient=e,this.peers=t,this.socket=r,this.myPeer=n,this.transportsStatsProvider=s,VS.set(this,void 0),HS.set(this,void 0),WS.set(this,void 0),p(this,WS,i("IntegrationsService"),"f"),p(this,HS,new wS.MessageBatcher({MaxBatchSize:50,MaxDelay:6e4,MinDelay:3e4}),"f"),l(this,HS,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendWIDMetrics({reasons:e,clientMeta:this.getClientMeta()}).catch((e=>{l(this,WS,"f").debug("Failed to sendWIDMetrics",{error:mr(e)})}))})),p(this,VS,new wS.MessageBatcher({MaxBatchSize:100,MaxDelay:6e4,MinDelay:3e4}),"f"),l(this,VS,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendNetworkMetrics({metrics:e,clientMeta:this.getClientMeta()}).catch((e=>{l(this,WS,"f").debug("Failed to sendNetworkMetrics",{error:mr(e)})}))}))}handleIssues(e){e.forEach((e=>l(this,WS,"f").info("WebRTCIssue",e)));const t=e.filter((e=>qS.includes(e.reason)));0!==t.length&&t.forEach((e=>l(this,HS,"f").Queue(e.reason)))}handleNetworkScores(e){var t,r,n,i,s;const{inbound:o,outbound:a,statsSamples:{inboundStatsSample:c,outboundStatsSample:d}}=e,u=this.getNodeActiveStreamsStat(),p=null===(t=u.node)||void 0===t?void 0:t.replace(/https:\/\/app-\d+-/,""),h=this.transportsStatsProvider.getStats();if(void 0!==o&&c){const e={jitter:Math.round(1e3*c.avgJitter),packetLoss:c.packetsLoss,rtt:c.rtt,mos:Math.round(10*o)/10,streams:u.inboundActiveStreams,direction:"inbound",node:null!=p?p:"unknown node",bitrate:null!==(n=null===(r=null==h?void 0:h.inbound)||void 0===r?void 0:r.bitrate)&&void 0!==n?n:0,timestamp:(new Date).toISOString()};l(this,VS,"f").Queue(e)}if(void 0!==a&&d){const e={jitter:Math.round(1e3*d.avgJitter),packetLoss:d.packetsLoss,rtt:d.rtt,mos:Math.round(10*a)/10,streams:u.outboundActiveStreams,direction:"outbound",node:null!=p?p:"unknown node",bitrate:null!==(s=null===(i=null==h?void 0:h.outbound)||void 0===i?void 0:i.bitrate)&&void 0!==s?s:0,timestamp:(new Date).toISOString()};l(this,VS,"f").Queue(e)}}getNodeActiveStreamsStat(){var e;const t=this.socket.getServerUrl(),r=this.peers.hosts().filter((e=>{var t;return e.id!==(null===(t=this.myPeer)||void 0===t?void 0:t.id)})).reduce(((e,t)=>e+t.getActiveTracksCount()),0),n=this.myPeer.get();return{node:t,inboundActiveStreams:r,outboundActiveStreams:null!==(e=null==n?void 0:n.getActivePublishersCount())&&void 0!==e?e:0}}getClientMeta(){return Object.assign(Object.assign({},gr.meta),{clientUniqueId:Uw()})}};VS=new WeakMap,HS=new WeakMap,WS=new WeakMap,zS=a([ut(),c(0,pt(Gn.AnalyticsApiClient)),c(1,pt(Gn.Peers)),c(2,pt(Gn.SocketIO)),c(3,pt(Gn.MyPeer)),c(4,pt(Gn.LoggerFactory)),c(5,pt(Gn.TransportsStatsProvider)),d("design:paramtypes",[eS,Object,fa,Vs,Function,Ow])],zS);var GS,YS,$S,KS,JS,QS,ZS,XS,eE,tE=zS;!function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(ZS||(ZS={})),function(e){e[e.PERFORMANCE_STOP=1001]="PERFORMANCE_STOP",e[e.REDUCE_LATENCY=1002]="REDUCE_LATENCY"}(XS||(XS={})),function(e){e.ATSVB="atsvb",e.STREAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.MODEL="model",e.WORKLET="worklet",e.WORKER="worker",e.MODEL_LOADER="model_loader"}(eE||(eE={}));const rE=()=>{};class nE{constructor(e){GS.set(this,void 0),YS.set(this,void 0),$S.set(this,null),KS.set(this,new Map),JS.set(this,void 0),this.type="asdk",QS.set(this,void 0);const{loggerFactory:t}=e;p(this,YS,t("ASDKTrackProcessor"),"f"),p(this,QS,"function"==typeof e.onError?e.onError:rE,"f"),p(this,GS,new window.atsvb(e.asdkCustomerId),"f");const n=e.config.get("staticFilesPath"),{localDir:i,version:s,sdk_url:o,api_url:a}=e.config.get("asdk");let c=`https://effectssdk.ai/sdk/audio/dev/${null!=s?s:"2.4.3"}`;if(i){c=new r.URL(`${i}/${null!=s?s:"2.4.3"}`,n).href}const d={preset:"balanced",sample_rate:48e3,api_url:a,wasmPaths:{"ort-wasm.wasm":`${c}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${c}/ort-wasm-simd.wasm`}},u=!o&&i,h=u?`${c}/`:o;u&&l(this,YS,"f").warn("Using static ASDK path due to missing config",Object.assign(Object.assign({case:"Denoiser",type:"asdk"},e.config.get("asdk")),{sdkUrl:d.sdk_url})),h&&(d.sdk_url=h),l(this,GS,"f").config(d),l(this,GS,"f").onError(this.onError.bind(this))}setOnError(e){p(this,QS,e,"f")}init(){return u(this,void 0,void 0,(function*(){yield l(this,GS,"f").preload()}))}get isProcessing(){return!!l(this,JS,"f")}processTrack(e){return u(this,void 0,void 0,(function*(){var t;if(l(this,$S,"f")===e||"ended"===e.readyState)return(null===(t=l(this,GS,"f").getStream())||void 0===t?void 0:t.getAudioTracks()[0])||e;this.stopProcessing();try{const t=new Promise(((t,r)=>{l(this,GS,"f").onReady=()=>{try{const r=l(this,GS,"f").getStream(),n=null==r?void 0:r.getAudioTracks()[0];if(!n)return void t(e);p(this,$S,e,"f"),p(this,JS,n,"f"),t(n),l(this,GS,"f").run()}catch(e){r(e)}finally{l(this,GS,"f").onReady=void 0}}}));l(this,GS,"f").useStream(new MediaStream([e]));const r=yield t;return l(this,YS,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),r}catch(t){throw l(this,YS,"f").error("processTrack()",{error:mr(t),type:this.type,case:"Denoiser",track:e}),l(this,QS,"f").call(this,"ASDK processTrack() error",t),p(this,QS,rE,"f"),new Error("Can not process this track")}}))}stopProcessing(){try{l(this,GS,"f").stop()}catch(e){l(this,YS,"f").error("stopProcessing()",{type:this.type,case:"Denoiser",error:mr(e)})}finally{p(this,$S,null,"f")}}getUpdatedDebounceCounter(e){var t;let r=null!==(t=l(this,KS,"f").get(e))&&void 0!==t?t:0;return r+=1,l(this,KS,"f").set(e,r),setTimeout((()=>{var t;const r=null!==(t=l(this,KS,"f").get(e))&&void 0!==t?t:0;r<=0?l(this,KS,"f").set(e,0):l(this,KS,"f").set(e,r-1)}),1e4),r}onError(e){const{message:t,type:r,cause:n}=e,i=o(e,["message","type","cause"]);if(r===ZS.ERROR)if(l(this,YS,"f").error(t,Object.assign(Object.assign({error:mr(n),cause:n},i),{type:this.type,case:"Denoiser"})),i.code===XS.REDUCE_LATENCY||i.code===XS.PERFORMANCE_STOP){this.getUpdatedDebounceCounter(i.code)>3&&(l(this,KS,"f").set(i.code,0),l(this,QS,"f").call(this,`ASDK performance issue(${i.code}): ${t}`,n),p(this,QS,rE,"f"))}else l(this,QS,"f").call(this,`ASDK runtime error: ${t}`,n),p(this,QS,rE,"f");r===ZS.WARNING&&l(this,YS,"f").warn(t,Object.assign(Object.assign({},i),{type:this.type,case:"Denoiser"})),r===ZS.INFO&&l(this,YS,"f").info(t,Object.assign(Object.assign({},i),{type:this.type,case:"Denoiser"}))}}GS=new WeakMap,YS=new WeakMap,$S=new WeakMap,KS=new WeakMap,JS=new WeakMap,QS=new WeakMap;class iE extends AudioWorkletNode{constructor(e){super(e.context,"rnnoise",{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{module:e.noiseSuppressor.module}}),this.port.onmessage=({data:e})=>{const t=Object.assign(new Event("status"),e);this.dispatchEvent(t)}}update(e){this.port.postMessage(e)}static register(e){return u(this,void 0,void 0,(function*(){const t=aC.get(Gn.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var sE,oE,aE,cE,dE,uE;class lE{constructor(e){sE.set(this,void 0),oE.set(this,void 0),aE.set(this,void 0),cE.set(this,void 0),dE.set(this,void 0),uE.set(this,!0),p(this,sE,e.noiseSuppressor.instance.exports,"f"),p(this,oE,e.context,"f"),p(this,aE,new Float32Array(l(this,sE,"f").memory.buffer),"f"),p(this,cE,l(this,sE,"f").newState(),"f"),p(this,dE,l(this,oE,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return l(this,dE,"f")}update(e){e||(p(this,uE,!1,"f"),l(this,sE,"f").deleteState(l(this,cE,"f")));const t=Object.assign(new Event("status"),{vadProb:l(this,sE,"f").getVadProb(l(this,cE,"f"))});l(this,dE,"f").dispatchEvent(t)}setOnAudioProcess(){l(this,dE,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!l(this,uE,"f"))return;l(this,aE,"f").set(e.getChannelData(0),l(this,sE,"f").getInput(l(this,cE,"f"))/4);const r=t.getChannelData(0),n=l(this,sE,"f").pipe(l(this,cE,"f"),r.length)/4;n&&r.set(l(this,aE,"f").subarray(n,n+r.length))}))}}sE=new WeakMap,oE=new WeakMap,aE=new WeakMap,cE=new WeakMap,dE=new WeakMap,uE=new WeakMap;var pE,hE,fE,mE,gE,vE,yE,_E,bE,wE,SE,EE,CE,RE,PE,TE,kE,DE,IE,OE,AE,LE,ME,NE,xE,FE,jE,UE,BE,VE,HE,WE,qE,zE,GE,YE,$E,KE,JE,QE,ZE;class XE{constructor({context:e,noiseSuppressor:t}){pE.set(this,void 0),hE.set(this,void 0),fE.set(this,void 0),p(this,pE,e,"f"),p(this,hE,t,"f")}createNoiseSuppressionNode(){return u(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():yield this.createAudioWorkletNode()}))}stop(){var e;null===(e=l(this,fE,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return u(this,void 0,void 0,(function*(){return yield iE.register(l(this,pE,"f")),p(this,fE,new iE({context:l(this,pE,"f"),noiseSuppressor:l(this,hE,"f")}),"f"),l(this,fE,"f")}))}createScriptProcessorNode(){return p(this,fE,new lE({context:l(this,pE,"f"),noiseSuppressor:l(this,hE,"f")}),"f"),l(this,fE,"f").noiseSuppressionScriptProcessorNode}}pE=new WeakMap,hE=new WeakMap,fE=new WeakMap;class eC{constructor(e){mE.set(this,void 0),gE.set(this,void 0),vE.set(this,void 0),yE.set(this,void 0),this.type="rnnoise",p(this,mE,e.noiseSuppressor,"f"),p(this,vE,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!l(this,yE,"f")}processTrack(e){return u(this,void 0,void 0,(function*(){const t=(e=>{const t=window.AudioContext||window.webkitAudioContext||!1;return t?new t(e):null})();if(!t)throw new Error("AudioContext is not available");const r=new MediaStreamAudioDestinationNode(t,{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers"});yield iE.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new XE({context:t,noiseSuppressor:l(this,mE,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return p(this,gE,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),p(this,yE,o,"f"),l(this,vE,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),o}))}stopProcessing(){var e;if(this.isProcessing)if(l(this,gE,"f"))try{l(this,gE,"f").noiseSuppressionProvider.stop(),l(this,gE,"f").noiseSuppressionNode.disconnect(),l(this,gE,"f").streamDestination.disconnect(),l(this,gE,"f").audioContext.close().catch((e=>{l(this,vE,"f").error("stopProcessing()",{success:!1,error:mr(e),case:"Denoiser",type:this.type})})),null===(e=l(this,yE,"f"))||void 0===e||e.stop(),p(this,yE,void 0,"f"),l(this,vE,"f").info("stopProcessing()",{success:!0,case:"Denoiser",type:this.type})}catch(e){l(this,vE,"f").error("stopProcessing()",{success:!1,error:mr(e),case:"Denoiser",type:this.type})}else l(this,vE,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available",case:"Denoiser",type:this.type});else l(this,vE,"f").debug("stopProcessing()",{description:"Track is not processed",case:"Denoiser",type:this.type})}}mE=new WeakMap,gE=new WeakMap,vE=new WeakMap,yE=new WeakMap;class tC extends wg{constructor(e){super(e),_E.set(this,!1),bE.set(this,void 0),wE.set(this,void 0),SE.set(this,void 0),p(this,SE,e.clientEventEmitter,"f")}get isDenoiserRequireActivation(){var e;return!(null===(e=l(this,bE,"f"))||void 0===e?void 0:e.isProcessing)&&l(this,_E,"f")}setTrackProcessor(e){if(!e)throw new Error("trackProcessor must be passed as parameter");this.logger.debug("Setting trackProcessor to AudioTrack",{case:"Denoiser",type:e.type}),p(this,bE,e,"f")}unsetTrackProcessor(){p(this,bE,void 0,"f")}get isEffectsProcessing(){var e;return Boolean(null===(e=l(this,bE,"f"))||void 0===e?void 0:e.isProcessing)}getEncoderConfig(){return this.encoderConfig}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Om}getCodecOptions(){var e,t;return{opusFec:null===(e=this.getEncoderConfig().enableFec)||void 0===e||e,opusDtx:null===(t=this.getEncoderConfig().enableDtx)||void 0===t||t}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||"opus"}enableNoiseSuppression(){return u(this,void 0,void 0,(function*(){var e,t,r;if(p(this,_E,!0,"f"),!l(this,bE,"f"))return this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"}),void l(this,SE,"f").emit(Kr,{cause:"Track suppressor is not defined"});try{const n=yield null===(e=l(this,bE,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);p(this,wE,this.mediaStreamTrack,"f"),yield this.replaceTrack(n),this.logger.debug("Denoiser activated",{case:"Denoiser",type:(null===(t=l(this,bE,"f"))||void 0===t?void 0:t.type)||"none"}),l(this,SE,"f").emit(Gr,{type:null===(r=l(this,bE,"f"))||void 0===r?void 0:r.type})}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:mr(e)}),l(this,SE,"f").emit(Kr,{cause:"Failed to enable noise suppression",error:e}),new Error("Can not enable noise suppression")}}))}disableNoiseSuppression(){return u(this,void 0,void 0,(function*(){var e,t,r,n;p(this,_E,!1,"f");try{if(!(null===(e=l(this,bE,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!l(this,wE,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});yield this.replaceTrack(l(this,wE,"f")),null===(t=l(this,bE,"f"))||void 0===t||t.stopProcessing(),this.logger.debug("Denoiser deactivated",{case:"Denoiser",type:(null===(r=l(this,bE,"f"))||void 0===r?void 0:r.type)||"none"}),l(this,SE,"f").emit(Yr,{type:null===(n=l(this,bE,"f"))||void 0===n?void 0:n.type})}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:mr(e)}),l(this,SE,"f").emit(Kr,{cause:"Failed to disable noise suppression",error:e}),new Error("Can not disable noise suppression")}}))}publish(){return u(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(Qr.trackProduced,this)}))}pause(){return u(this,void 0,void 0,(function*(){yield this.mute()}))}}_E=new WeakMap,bE=new WeakMap,wE=new WeakMap,SE=new WeakMap;class rC{constructor({track:e,statsHandler:t}){EE.set(this,void 0),CE.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return l(this,EE,"f")}get audioWebRTCStats(){return l(this,CE,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addInboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addInboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){p(this,EE,e,"f")}setAudioWebRTCStats(e){p(this,CE,e,"f")}}EE=new WeakMap,CE=new WeakMap;class nC{constructor(e){this.label=$n.Unknown,RE.set(this,void 0),PE.set(this,void 0),TE.set(this,void 0),kE.set(this,void 0),DE.set(this,void 0),IE.set(this,void 0),OE.set(this,void 0),AE.set(this,void 0),LE.set(this,void 0),ME.set(this,void 0),NE.set(this,!1),xE.set(this,void 0),FE.set(this,!1),jE.set(this,new av),UE.set(this,!1),BE.set(this,0),VE.set(this,void 0),this.observer=new Dt,p(this,LE,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,p(this,DE,e.peerConsumerFactory,"f"),p(this,OE,e.loggerFactory("PeerTrack"),"f"),p(this,AE,e.peerEventEmitter,"f"),p(this,UE,e.muted,"f"),p(this,ME,e.paused,"f"),p(this,RE,e.network,"f"),p(this,PE,e.socket,"f"),p(this,TE,e.media,"f"),p(this,IE,e.callState,"f"),p(this,kE,e.onClose,"f"),p(this,VE,new rC({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return l(this,VE,"f").videoWebRTCStats}get audioWebRTCStats(){return l(this,VE,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:l(this,LE,"f").id,label:this.label,consumerId:null===(e=this.consumer)||void 0===e?void 0:e.id,producerId:null===(t=this.consumer)||void 0===t?void 0:t.producerId,muted:l(this,UE,"f"),paused:l(this,ME,"f"),closed:l(this,FE,"f")}}get volume(){return l(this,BE,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return l(this,LE,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return l(this,ME,"f")}get isMuted(){return l(this,UE,"f")}get consumerId(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.id}get currentSpatialLayer(){var e,t;return null!==(t=null===(e=this.consumer)||void 0===e?void 0:e.currentSpatialLayer)&&void 0!==t?t:Lm}close(){return u(this,void 0,void 0,(function*(){l(this,AE,"f").safeEmit(nn,this),p(this,FE,!0,"f"),l(this,kE,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return u(this,void 0,void 0,(function*(){yield l(this,jE,"f").push((()=>u(this,void 0,void 0,(function*(){l(this,OE,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),p(this,UE,!0,"f")}))))}))}unmute(){return u(this,void 0,void 0,(function*(){yield l(this,jE,"f").push((()=>u(this,void 0,void 0,(function*(){l(this,OE,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),p(this,UE,!1,"f")}))))}))}pause(){return u(this,arguments,void 0,(function*(e=!0){yield l(this,jE,"f").push((()=>u(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return p(this,ME,!0,"f"),l(this,AE,"f").safeEmit(sn,this),void l(this,OE,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),p(this,ME,!0,"f"),l(this,AE,"f").safeEmit(sn,this)}))))}))}resume(){return u(this,arguments,void 0,(function*(e=!0){yield l(this,jE,"f").push((()=>u(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return p(this,ME,!1,"f"),l(this,AE,"f").safeEmit(on,this),void l(this,OE,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),p(this,ME,!1,"f"),l(this,AE,"f").safeEmit(on,this)}))))}))}resumeConsumer(){return u(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{this.consumer.resume(),e&&(yield l(this,RE,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{l(this,OE,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:mr(e)})})),l(this,OE,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){l(this,OE,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(){return u(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{this.clearCheckStateTimeout(),e&&(yield l(this,RE,"f").pauseRemoteConsumer(this.consumer.id)),this.consumer.pause(),p(this,NE,!1,"f"),l(this,OE,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){l(this,OE,"f").warn("pauseConsumer()",{error:e})}}))}requestVideoPreferredLayers(e){return u(this,arguments,void 0,(function*({spatialLayer:e,temporalLayer:t}){if(this.consumer)try{if(this.consumer.isAudio)return void l(this,OE,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void l(this,OE,"f").warn("Invalid spatial layer",{spatialLayer:e,consumerSpatialLayers:this.consumer.spatialLayers,case:"requestVideoPreferredLayers"});if(e>this.consumer.currentMaxSpatialLayer)return void(yield this.requestMaxSpatialLayer(this.consumer.id,e));yield l(this,PE,"f").request(Sn,{consumerId:this.consumer.id,spatialLayer:e,temporalLayer:t}),l(this,OE,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw l(this,OE,"f").error("Failed to request preferred layers",{case:"requestVideoPreferredLayers",track:{id:this.mediaStreamTrack.id,kind:this.mediaStreamTrack.kind,label:this.mediaStreamTrack.label},consumerId:this.consumer.id,spatialLayers:this.consumer.spatialLayers,temporalLayers:this.consumer.temporalLayers,error:e}),new Error("Error request preferred layers")}}))}requestKeyFrame(){return u(this,void 0,void 0,(function*(){if(this.consumerId){l(this,OE,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield l(this,PE,"f").request(En,{consumerId:this.consumerId})}catch(e){throw l(this,OE,"f").error("requestKeyFrame()",{error:e,track:this.logCtx,consumerId:this.consumerId}),new Error("Failed to request key frame")}}}))}getVideoAvailableLayers(){if(this.consumer){if(!this.consumer.isAudio)return this.consumer.availableSpatialLayers;l(this,OE,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){return u(this,void 0,void 0,(function*(){var e;const{width:t,height:r,frameRate:n,aspectRatio:i}=l(this,LE,"f").getSettings();return{trackId:l(this,LE,"f").id,readyState:l(this,LE,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:l(this,ME,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return u(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=l(this,TE,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?yield e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return u(this,void 0,void 0,(function*(){try{if(!this.consumer)return;if(this.consumer.isAudio||0===this.consumer.spatialLayers||this.consumer.currentMaxSpatialLayer===t||t<this.consumer.currentMaxSpatialLayer)return void l(this,OE,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield l(this,PE,"f").request(gn,{producerId:this.consumer.producerId,spatialLayer:t}),l(this,OE,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){l(this,OE,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return u(this,void 0,void 0,(function*(){try{if(l(this,FE,"f")||"audio"===this.kind)return;l(this,OE,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||l(this,FE,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||l(this,FE,"f"))return;if(l(this,NE,"f"))return l(this,AE,"f").emit(an,this),void l(this,OE,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){l(this,OE,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){l(this,BE,"f")!==e&&(p(this,BE,e,"f"),this.observer.safeEmit(Jr,{value:e}))}closeConsumer(){return u(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield l(this,RE,"f").closeRemoteConsumer(this.consumer.id)}catch(e){l(this,OE,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return u(this,void 0,void 0,(function*(){try{if(!this.consumer||l(this,FE,"f"))return;l(this,OE,"f").debug("restartConsumer()",{track:this.logCtx}),l(this,AE,"f").emit(nn,this),p(this,ME,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield l(this,RE,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:l(this,TE,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:l(this,IE,"f").appId,channelId:l(this,IE,"f").channelId});p(this,NE,!0,"f"),this.consumer=l(this,DE,"f").call(this,{consumer:e}),p(this,LE,e.track,"f"),yield this.resume(),l(this,AE,"f").emit(rn,this)}catch(e){p(this,NE,!0,"f"),l(this,OE,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return u(this,void 0,void 0,(function*(){if(!this.consumer||l(this,FE,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return yield new Promise((t=>{p(this,xE,setTimeout((()=>u(this,void 0,void 0,(function*(){try{if(!this.consumer)return void t(!1);const{framesDecoded:r}=yield this.consumer.getInboundRTPStreamStats();if(e===r&&!this.isPaused)return void t(!1);t(!0)}catch(e){l(this,OE,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){l(this,xE,"f")||clearTimeout(l(this,xE,"f"))}}RE=new WeakMap,PE=new WeakMap,TE=new WeakMap,kE=new WeakMap,DE=new WeakMap,IE=new WeakMap,OE=new WeakMap,AE=new WeakMap,LE=new WeakMap,ME=new WeakMap,NE=new WeakMap,xE=new WeakMap,FE=new WeakMap,jE=new WeakMap,UE=new WeakMap,BE=new WeakMap,VE=new WeakMap;class iC{constructor(e){this.encodings=[],HE.set(this,void 0);const{id:t,kind:r,peerId:n,label:i,paused:s}=e;this.id=t,this.kind=r,this.peerId=n,this.label=i,this.paused=s,this.encodings=e.encodings,this.trackTransformParams=e.trackTransformParams,this.maxSpatialLayer=e.maxSpatialLayer,p(this,HE,Date.now(),"f")}setPaused(e){this.paused=e,p(this,HE,Date.now(),"f")}getStateChangedAt(){return l(this,HE,"f")}}HE=new WeakMap;class sC{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:c,role:d,loggerFactory:u,myPeer:l,callState:h,peers:f,remotePeerTracks:m,media:g,network:v,socket:y,peerConsumerFactory:_}){this.producers=new Map,this.tracks=new Map,WE.set(this,void 0),qE.set(this,void 0),zE.set(this,void 0),GE.set(this,void 0),YE.set(this,void 0),$E.set(this,void 0),KE.set(this,void 0),JE.set(this,void 0),QE.set(this,void 0),this._observer=new Dt,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=null!=a?a:{},this.uid=c,this.role=d,p(this,$E,l,"f"),p(this,KE,h,"f"),p(this,WE,f,"f"),p(this,qE,m,"f"),p(this,GE,y,"f"),p(this,JE,_,"f"),p(this,zE,v,"f"),p(this,YE,g,"f"),p(this,QE,u("Peer"),"f"),o.forEach(this.handleNewProducer.bind(this)),this.handlePeerEvents()}get appData(){return this.applicationData}get observer(){return this._observer}get isMe(){return this.id===l(this,$E,"f").id}get isModerator(){return this.groups.includes("moderator")}get isUser(){return this.groups.includes("user")}get publishedMedia(){return Array.from(this.producers.values()).map((e=>({producerId:e.id,kind:e.kind,label:e.label,paused:e.paused})))}get shortData(){return{id:this.id,producers:Array.from(this.producers.values()).map((e=>({id:e.id,paused:e.paused}))),appData:this.appData}}hasPermission(e){return this.producePermissions.includes(e)}hasGroup(e){return this.groups.includes(e)}subscribe(e){return u(this,arguments,void 0,(function*({producerId:e,muted:t=!1}){try{const r=this.producers.get(e);if(!r)return void l(this,QE,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:Bs(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void l(this,QE,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:Bs(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield l(this,zE,"f").createConsumer({producerId:r.id,rtpCapabilities:l(this,YE,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:l(this,KE,"f").appId,channelId:l(this,KE,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values($n).includes(r.label))return void l(this,QE,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:Bs(this),producerId:e});const s=l(this,qE,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:l(this,JE,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),l(this,QE,"f").debug(`Subscribed for ${r.kind}`,{peer:Bs(this)})}catch(t){throw l(this,QE,"f").error("subscribe()",{producerId:e,error:t,peer:Bs(this)}),new Error("Error subscribe media")}}))}unsubscribe(e){return u(this,void 0,void 0,(function*(){try{const t=this.getConsumerByProducerId(e);if(!t)return;const r=this.getTrackByConsumerId(t.id);if(!r)return;yield r.close(),this.tracks.delete(r.label),l(this,QE,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:Bs(this)})}catch(t){throw l(this,QE,"f").error("unsubscribe()",{producerId:e,error:t}),new Error("Error unsubscribe media")}}))}setProducePermissions(e){return u(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield l(this,GE,"f").request(Er,{peerId:this.id,producePermissions:e}),l(this,QE,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return u(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield l(this,GE,"f").request(Cr,{peerId:this.id,label:e}),l(this,QE,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return u(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield l(this,GE,"f").request(Rr,{peerId:this.id,label:e}),l(this,QE,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return u(this,void 0,void 0,(function*(){try{return{id:this.id,appData:this.appData,role:this.role,channelIds:this.channelIds,appId:this.appId,uid:this.uid,loginDate:this.loginDate,tracks:yield Promise.all(Array.from(this.tracks.values()).map((e=>u(this,void 0,void 0,(function*(){return yield e.getInfo()})))))}}catch(e){throw l(this,QE,"f").error("getInfo()",{peer:Bs(this),error:e}),new Error("Error get info")}}))}getProducers(){return Array.from(this.producers.values())}getConsumersState(){return this.getAllConsumers().map((e=>({id:e.id,paused:e.paused,producerId:e.producerId})))}handleNewProducer(e){if(this.producers.get(e.id))return;const t=new iC(e);this.producers.set(t.id,t),l(this,QE,"f").debug("Peer published media:",{peer:Bs(this),producer:t});const r={producerId:t.id,kind:t.kind,label:t.label,paused:t.paused};this.observer.safeEmit(Zr,r)}handlePeerEvents(){this.observer.on(ln,this.handleNewProducer.bind(this)),this.observer.on(pn,(e=>u(this,void 0,void 0,(function*(){this.producers.delete(e.id),l(this,QE,"f").debug("Peer unpublished media:",{peer:Bs(this),producer:e}),this.observer.safeEmit(Xr,{producerId:e.id,kind:e.kind,label:e.label,paused:e.paused});const t=this.tracks.get(e.label);if(t)try{yield t.close()}catch(e){l(this,QE,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id,error:mr(e)})}})))),this.observer.on(_n,(e=>u(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),l(this,QE,"f").debug("Peer video track was ended:",{peer:Bs(this),track:t.logCtx}))})))),this.observer.on(bn,(e=>u(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(wn,(e=>u(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(Sn,(e=>{const t=this.getConsumerById(e.consumerId);(null==t?void 0:t.isVideo)&&(t.setCurrentTemporalLayer(e.temporalLayer),t.setCurrentSpatialLayer(e.spatialLayer),e.spatialLayer===t.requestedSpatialLayer&&t.setRequestedSpatialLayer(void 0),l(this,QE,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(mn,(e=>u(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),l(this,QE,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield l(this,GE,"f").request(Sn,{consumerId:n.id,spatialLayer:r}),l(this,QE,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):l(this,QE,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):l(this,QE,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(br,(e=>{try{Nn(e),this.setAppData(e),this.observer.emit(cn,e),l(this,QE,"f").debug("updatePeerAppData",{peer:Bs(this),appData:e})}catch(t){l(this,QE,"f").error("updatePeerAppData",{peer:Bs(this),appData:e,error:t})}}))}reset(){return u(this,void 0,void 0,(function*(){this.producers.clear(),yield Promise.all(Array.from(this.tracks.values()).map((e=>u(this,void 0,void 0,(function*(){return yield e.close()}))))),this.tracks.clear();[ln,pn,_n,bn,wn,Sn,mn,br].forEach((e=>this.observer.removeAllListeners(e)))}))}getActiveTracksCount(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!(null==e?void 0:e.paused))).length}getActivePublishersCount(){return Array.from(this.producers.values()).filter((e=>!e.paused)).length}handleProducePermissionsChange(e){this.producePermissions=e,Object.values($n).filter((e=>!this.producePermissions.includes(e))).forEach((e=>{const t=this.tracks.get(e);t&&(this.tracks.delete(t.label),t.close().catch((e=>{l(this,QE,"f").error("Failed to close track",{case:"Peer",error:mr(e)})})))})),this.observer.safeEmit(dn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(un,{groups:e})}getAllConsumers(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!!e))}getConsumerByProducerId(e){return this.getAllConsumers().find((t=>t.producerId===e))}getConsumerById(e){return this.getAllConsumers().find((t=>t.id===e))}getTrackByConsumerId(e){return Array.from(this.tracks.values()).find((t=>t.consumerId===e))}setAppData(e){this.applicationData=e}throwIfIamNotModerator(){if(!l(this,WE,"f").isModerator(l(this,$E,"f").id))throw new Error("Not enough access")}}WE=new WeakMap,qE=new WeakMap,zE=new WeakMap,GE=new WeakMap,YE=new WeakMap,$E=new WeakMap,KE=new WeakMap,JE=new WeakMap,QE=new WeakMap;class oC{constructor(e){this.spatialLayers=Lm,this.temporalLayers=Nm,this.currentSpatialLayer=Lm,this.currentTemporalLayer=Nm,this.availableSpatialLayers=[],ZE.set(this,void 0);const{consumer:t,loggerFactory:r}=e;this.id=t.id,this.kind=t.kind,this.producerId=t.producerId,this.appData=t.appData,this.consumer=t,p(this,ZE,r("PeerConsumer"),"f"),this.currentMaxSpatialLayer=this.appData.producerData.maxSpatialLayer,this.parseScalabilityMode(),this.initAvailableSpatialLayers(),this.setCurrentSpatialLayerParams()}get paused(){return this.consumer.paused}pause(){this.consumer.pause()}resume(){this.consumer.resume()}close(){this.consumer.close()}get isVideo(){return"video"===this.kind}get isAudio(){return"audio"===this.kind}parseScalabilityMode(){if(this.consumer.rtpParameters.encodings){const{scalabilityMode:e}=this.consumer.rtpParameters.encodings[0],{spatialLayers:t,temporalLayers:r}=Ja.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,l(this,ZE,"f").debug("parseScalabilityMode()",{scalabilityMode:e,spatialLayers:t,temporalLayers:r})}}initAvailableSpatialLayers(){const{encodings:e,trackTransformParams:t}=this.appData.producerData;if(!Array.isArray(e))return;if(this.availableSpatialLayers=e.map((e=>this.tryPrepareSpatialLayerParams(e))),!t||this.availableSpatialLayers.length>1||this.spatialLayers<Mm)return void l(this,ZE,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});l(this,ZE,"f").debug("Pre-generating encodings with spatial layer params",{case:"initAvailableSpatialLayers"});const r=[],n=e[e.length-1];for(let e=this.spatialLayers-1;e>=0;e-=1)r.push(this.tryPrepareSpatialLayerParams(Object.assign(Object.assign({},n),{scaleResolutionDownBy:Math.pow(2,e)})));this.availableSpatialLayers=r}setCurrentSpatialLayerParams(){const{encodings:e}=this.appData.producerData;(null==e?void 0:e[this.currentSpatialLayer])&&(this.currentSpatialLayerParams=this.tryPrepareSpatialLayerParams(e[this.currentSpatialLayer]),l(this,ZE,"f").debug("setCurrentSpatialLayerParams()",{currentSpatialLayerParams:this.currentSpatialLayerParams}))}tryPrepareSpatialLayerParams(e){var t;const{trackTransformParams:r}=this.appData.producerData;if(!r)return e;const{width:n,height:i}=r,s=null!==(t=e.scaleResolutionDownBy)&&void 0!==t?t:1;return n&&i?Object.assign({width:n/s,height:i/s},e):e}setCurrentSpatialLayer(e){if(!this.isVideo)throw new Error("setCurrentSpatialLayer applies to video consumers only");this.currentSpatialLayer=e,l(this,ZE,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,l(this,ZE,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){return u(this,void 0,void 0,(function*(){var e,t;try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>rg(e))),dtlsState:null===(t=null===(e=this.consumer.rtpReceiver)||void 0===e?void 0:e.transport)||void 0===t?void 0:t.state,availableSpatialLayers:this.availableSpatialLayers,currentSpatialLayerParams:this.currentSpatialLayerParams,requestedSpatialLayer:this.requestedSpatialLayer,rtcStats:yield this.getInboundRTPStreamStats()}}catch(e){return void l(this,ZE,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>u(this,[...n],void 0,(function*(n=0){try{const i=yield this.consumer.getStats(),s=Array.from(i.values()).find((e=>"inbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>{r(n+1).catch((e=>{l(this,ZE,"f").debug("Error getting RTCStatsReport",{attempt:n,error:mr(e)})}))}),150);n>=5&&!s&&t(new Error("InboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),l(this,ZE,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r().catch((e=>{l(this,ZE,"f").debug("Error executing getRTCStatsReport",{case:"PeerConsumer",error:mr(e)})}))}))}))}}ZE=new WeakMap;const aC=new st({autoBindInjectable:!0});var cC;aC.bind(Gn.LocalMutex).to(dS).inSingletonScope(),aC.bind(Gn.CallState).to(Qn).inSingletonScope(),aC.bind(Gn.MyPeer).to(Vs).inSingletonScope(),aC.bind(Gn.LoggerFactory).toFactory((e=>{const t=e.container.get(Gn.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new US({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),aC.bind(Gn.System).to(gw).inSingletonScope(),aC.bind(Gn.ProcessorsCache).to(Hm).inSingletonScope(),aC.bind(Gn.IntegrationsService).to(zm).inSingletonScope(),aC.bind(Gn.MediaStreamTrackManager).to(Fg).inSingletonScope(),aC.bind(Gn.Media).to(Ug).inSingletonScope(),aC.bind(Gn.SocketIO).to(fa).inSingletonScope(),aC.bind(Gn.LoadBalancerApiClient).to(cw).inSingletonScope(),aC.bind(Gn.Network).to(Ma).inSingletonScope(),aC.bind(Gn.RemotePeerTracks).to(BS).inSingletonScope(),aC.bind(Gn.Peers).to(Na).inSingletonScope(),aC.bind(Gn.MediaEventHandler).to(dv).inSingletonScope(),aC.bind(Gn.ChannelEventHandler).to(rv).inSingletonScope(),aC.bind(Gn.ChannelAudioObserverEventHandler).to(Ta).inSingletonScope(),aC.bind(Gn.EventsQueue).to(Us).inSingletonScope(),aC.bind(Gn.ChannelStateSynchronizer).to(ev).inSingletonScope(),aC.bind(Gn.ChannelStateSyncEventHandler).to(Ka).inSingletonScope(),aC.bind(Gn.StatsHandler).to(Rw).inSingletonScope(),aC.bind(Gn.WIDHandler).to(tE).inSingletonScope(),aC.bind(Gn.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(Gn.Config),r=e.container.get(Gn.WIDHandler);if(t.get("disableWid"))return;const n=e.container.get(Gn.StatsHandler),i=[1234],s=e.container.get(Gn.LoggerFactory)("WID"),o=new or({statsParser:new ar({ignoreSSRCList:i,logger:s})});return new dr({onIssues:e=>{var n;r.handleIssues(e),null===(n=t.get("onIssues"))||void 0===n||n(e)},issueEmitter:new Ht,networkScoresCalculator:new zt,detectors:[new Qt,new $t,new Jt,new Kt,new Yt,new Zt,new rr({minMosQuality:Tt.GOOD,avgFreezeDurationThresholdMs:2e3,frozenDurationThresholdPct:50}),new nr({minMosQuality:Tt.GOOD,volatilityThreshold:10,affectedStreamsPercentThreshold:60})],statsReporter:new Wt({compositeStatsParser:o,getStatsInterval:5e3}),onNetworkScoresUpdated:e=>{var n;r.handleNetworkScores(e),null===(n=t.get("onNetworkScoresUpdated"))||void 0===n||n(e)},onStats:n.handle.bind(n),ignoreSSRCList:i,compositeStatsParser:o,logger:s,autoAddPeerConnections:!1})})).inSingletonScope(),aC.bind(Gn.Engine).to(Lw).inSingletonScope(),aC.bind(Gn.PeerTrackFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.CallState),n=e.container.get(Gn.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(Gn.Media),network:e.container.get(Gn.Network),peerConsumerFactory:e.container.get(Gn.PeerConsumerFactory),socket:e.container.get(Gn.SocketIO)},{peerEventEmitter:o}=i,a=new nC(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(rn,a),a}})),aC.bind(Gn.PeerFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(Gn.Media),myPeer:e.container.get(Gn.MyPeer),network:e.container.get(Gn.Network),peers:e.container.get(Gn.Peers),remotePeerTracks:e.container.get(Gn.RemotePeerTracks),socket:e.container.get(Gn.SocketIO),peerConsumerFactory:e.container.get(Gn.PeerConsumerFactory)};return new sC(Object.assign(Object.assign({},i),n))}})),aC.bind(Gn.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory);return e=>{const r={loggerFactory:t};return new oC(Object.assign(Object.assign({},r),e))}})),aC.bind(Gn.AudioTrackFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Gn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Gn.Media),mediaStreamTrackManager:e.container.get(Gn.MediaStreamTrackManager),myPeer:e.container.get(Gn.MyPeer),network:e.container.get(Gn.Network),socket:e.container.get(Gn.SocketIO),mutex:e.container.get(Gn.LocalMutex),processorFactory:e.container.get(Gn.AudioTrackProcessorFactory),clientEventEmitter:e.container.get(Gn.ClientEventEmitter),statsHandler:r};return new tC(Object.assign(Object.assign({},i),n))}})),aC.bind(Gn.VideoTrackFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Gn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Gn.Media),mediaStreamTrackManager:e.container.get(Gn.MediaStreamTrackManager),myPeer:e.container.get(Gn.MyPeer),network:e.container.get(Gn.Network),socket:e.container.get(Gn.SocketIO),mutex:e.container.get(Gn.LocalMutex),statsHandler:r};return new Pg(Object.assign(Object.assign({},i),n))}})),aC.bind(Gn.AudioTrackProcessorFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.Config),n=e.container.get(Gn.ProcessorsCache),i=r.get("asdk");return e=>{const s=r.get("denoiser");let o=n.get(s,e.trackLabel);if(o)return o;if("rnnoise"===s&&e.noiseSuppressor&&(o=new eC({noiseSuppressor:e.noiseSuppressor,loggerFactory:t})),"asdk"===s&&(null==i?void 0:i.customerId)&&(o=new nE({asdkCustomerId:i.customerId,loggerFactory:t,config:r})),!o)throw new TypeError("Incorrect parameters passed to AudioTrackProcessorFactory");return o}})),aC.bind(Gn.DataChannelsManager).to(Aa).inSingletonScope(),aC.bind(Gn.AnalyticsApiClient).to(eS).inSingletonScope(),aC.bind(Gn.PeersStorage).to(Sa).inSingletonScope(),aC.bind(Gn.TransportsStatsProvider).to(Ow).inSingletonScope();cC=new WeakMap,module.exports=class{constructor(e){cC.set(this,void 0),this.canUseNoiseSuppression=!0;const{clientEventEmitter:t,internalEventEmitter:r}=e;aC.bind(Gn.Config).toDynamicValue((()=>new kt(e))).inSingletonScope(),aC.bind(Gn.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new Dt)).inSingletonScope(),aC.bind(Gn.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new Dt)).inSingletonScope(),aC.get(Gn.IntegrationsService),this.clientEventEmitter=aC.get(Gn.ClientEventEmitter),p(this,cC,aC.get(Gn.Engine),"f")}get observer(){return this.clientEventEmitter}get id(){return l(this,cC,"f").myPeerId}get peers(){return l(this,cC,"f").getPeers()}get availableVideoDevices(){return l(this,cC,"f").system.availableVideoDevices}get availableAudioDevices(){return l(this,cC,"f").system.availableAudioDevices}get effectsSDKInitialized(){return l(this,cC,"f").media.effectsSDKInitialized}detectDevices(e){return u(this,void 0,void 0,(function*(){return yield l(this,cC,"f").system.detectDevices(e),{video:l(this,cC,"f").system.availableVideoDevices,audio:l(this,cC,"f").system.availableAudioDevices}}))}initEffectsSDK(){return u(this,void 0,void 0,(function*(){return yield l(this,cC,"f").media.initEffectsSDK()}))}join(e){return u(this,void 0,void 0,(function*(){yield l(this,cC,"f").join(e)}))}leave(e){return u(this,void 0,void 0,(function*(){yield l(this,cC,"f").release(e)}))}confirmActivity(){return u(this,void 0,void 0,(function*(){yield l(this,cC,"f").confirmActivity()}))}createCameraVideoTrack(e){return u(this,void 0,void 0,(function*(){return yield l(this,cC,"f").createCameraVideoTrack(e)}))}createMicrophoneAudioTrack(e){return u(this,void 0,void 0,(function*(){return yield l(this,cC,"f").createMicrophoneAudioTrack(e)}))}createScreenMediaTracks(e){return u(this,void 0,void 0,(function*(){return yield l(this,cC,"f").createScreenMediaTracks(e)}))}createCustomAudioTrack(e){return l(this,cC,"f").createCustomAudioTrack(e)}createCustomVideoTrack(e){return l(this,cC,"f").createCustomVideoTrack(e)}deleteTrack(e){return u(this,void 0,void 0,(function*(){yield l(this,cC,"f").deleteTrack(e)}))}loadPeers(e){return u(this,void 0,void 0,(function*(){yield l(this,cC,"f").loadPeers(e)}))}requestChannelStateSync(){l(this,cC,"f").requestChannelStateSync()}updateAppData(e){return u(this,void 0,void 0,(function*(){yield l(this,cC,"f").updateAppData(e)}))}getTransportsInfo(){return u(this,void 0,void 0,(function*(){return yield l(this,cC,"f").network.getTransportsStateInfo()}))}setPreferRelay(e){l(this,cC,"f").network.setPreferRelay(e)}getPreferRelay(){return l(this,cC,"f").network.getPreferRelay()}transportsStats(){return l(this,cC,"f").transportsStats()}setLoadbalancerUrl(e){l(this,cC,"f").setLoadbalancerUrl(e)}};
39
+ !function(e,t){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,d=128,u=256,l=1/0,p=9007199254740991,h=NaN,m=4294967295,g=[["ary",d],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",u]],v="[object Arguments]",y="[object Array]",_="[object Boolean]",b="[object Date]",E="[object Error]",w="[object Function]",S="[object GeneratorFunction]",C="[object Map]",P="[object Number]",T="[object Object]",k="[object Promise]",R="[object RegExp]",I="[object Set]",D="[object String]",A="[object Symbol]",O="[object WeakMap]",N="[object ArrayBuffer]",M="[object DataView]",L="[object Float32Array]",x="[object Float64Array]",F="[object Int8Array]",j="[object Int16Array]",U="[object Int32Array]",B="[object Uint8Array]",V="[object Uint8ClampedArray]",W="[object Uint16Array]",H="[object Uint32Array]",q=/\b__p \+= '';/g,z=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39);/g,$=/[&<>"']/g,J=RegExp(Y.source),K=RegExp($.source),Q=/<%-([\s\S]+?)%>/g,Z=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,ee=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,te=/^\w*$/,re=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ne=/[\\^$.*+?()[\]{}|]/g,ie=RegExp(ne.source),se=/^\s+/,oe=/\s/,ae=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ce=/\{\n\/\* \[wrapped with (.+)\] \*/,de=/,? & /,ue=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,pe=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,fe=/\w*$/,me=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ve=/^\[object .+?Constructor\]$/,ye=/^0o[0-7]+$/i,_e=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ee=/($^)/,we=/['\n\r\u2028\u2029\\]/g,Se="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="\\u2700-\\u27bf",Pe="a-z\\xdf-\\xf6\\xf8-\\xff",Te="A-Z\\xc0-\\xd6\\xd8-\\xde",ke="\\ufe0e\\ufe0f",Re="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ie="['’]",De="[\\ud800-\\udfff]",Ae="["+Re+"]",Oe="["+Se+"]",Ne="\\d+",Me="[\\u2700-\\u27bf]",Le="["+Pe+"]",xe="[^\\ud800-\\udfff"+Re+Ne+Ce+Pe+Te+"]",Fe="\\ud83c[\\udffb-\\udfff]",je="[^\\ud800-\\udfff]",Ue="(?:\\ud83c[\\udde6-\\uddff]){2}",Be="[\\ud800-\\udbff][\\udc00-\\udfff]",Ve="["+Te+"]",We="(?:"+Le+"|"+xe+")",He="(?:"+Ve+"|"+xe+")",qe="(?:['’](?:d|ll|m|re|s|t|ve))?",ze="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ge="(?:"+Oe+"|"+Fe+")"+"?",Ye="[\\ufe0e\\ufe0f]?",$e=Ye+Ge+("(?:\\u200d(?:"+[je,Ue,Be].join("|")+")"+Ye+Ge+")*"),Je="(?:"+[Me,Ue,Be].join("|")+")"+$e,Ke="(?:"+[je+Oe+"?",Oe,Ue,Be,De].join("|")+")",Qe=RegExp(Ie,"g"),Ze=RegExp(Oe,"g"),Xe=RegExp(Fe+"(?="+Fe+")|"+Ke+$e,"g"),et=RegExp([Ve+"?"+Le+"+"+qe+"(?="+[Ae,Ve,"$"].join("|")+")",He+"+"+ze+"(?="+[Ae,Ve+We,"$"].join("|")+")",Ve+"?"+We+"+"+qe,Ve+"+"+ze,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ne,Je].join("|"),"g"),tt=RegExp("[\\u200d\\ud800-\\udfff"+Se+ke+"]"),rt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],it=-1,st={};st[L]=st[x]=st[F]=st[j]=st[U]=st[B]=st[V]=st[W]=st[H]=!0,st[v]=st[y]=st[N]=st[_]=st[M]=st[b]=st[E]=st[w]=st[C]=st[P]=st[T]=st[R]=st[I]=st[D]=st[O]=!1;var ot={};ot[v]=ot[y]=ot[N]=ot[M]=ot[_]=ot[b]=ot[L]=ot[x]=ot[F]=ot[j]=ot[U]=ot[C]=ot[P]=ot[T]=ot[R]=ot[I]=ot[D]=ot[A]=ot[B]=ot[V]=ot[W]=ot[H]=!0,ot[E]=ot[w]=ot[O]=!1;var at={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ct=parseFloat,dt=parseInt,ut="object"==typeof f&&f&&f.Object===Object&&f,lt="object"==typeof self&&self&&self.Object===Object&&self,pt=ut||lt||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,mt=ft&&ft.exports===ht,gt=mt&&ut.process,vt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||gt&&gt.binding&&gt.binding("util")}catch(e){}}(),yt=vt&&vt.isArrayBuffer,_t=vt&&vt.isDate,bt=vt&&vt.isMap,Et=vt&&vt.isRegExp,wt=vt&&vt.isSet,St=vt&&vt.isTypedArray;function Ct(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Pt(e,t,r,n){for(var i=-1,s=null==e?0:e.length;++i<s;){var o=e[i];t(n,o,r(o),e)}return n}function Tt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function kt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function Rt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}function It(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}function Dt(e,t){return!!(null==e?0:e.length)&&Bt(e,t,0)>-1}function At(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}function Ot(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function Nt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Mt(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function Lt(e,t,r,n){var i=null==e?0:e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r}function xt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Ft=qt("length");function jt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function Ut(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}function Bt(e,t,r){return t==t?function(e,t,r){var n=r-1,i=e.length;for(;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):Ut(e,Wt,r)}function Vt(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Wt(e){return e!=e}function Ht(e,t){var r=null==e?0:e.length;return r?Yt(e,t)/r:h}function qt(e){return function(t){return null==t?r:t[e]}}function zt(e){return function(t){return null==e?r:e[t]}}function Gt(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function Yt(e,t){for(var n,i=-1,s=e.length;++i<s;){var o=t(e[i]);o!==r&&(n=n===r?o:n+o)}return n}function $t(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Jt(e){return e?e.slice(0,hr(e)+1).replace(se,""):e}function Kt(e){return function(t){return e(t)}}function Qt(e,t){return Ot(t,(function(t){return e[t]}))}function Zt(e,t){return e.has(t)}function Xt(e,t){for(var r=-1,n=e.length;++r<n&&Bt(t,e[r],0)>-1;);return r}function er(e,t){for(var r=e.length;r--&&Bt(t,e[r],0)>-1;);return r}function tr(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var rr=zt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nr=zt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ir(e){return"\\"+at[e]}function sr(e){return tt.test(e)}function or(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ar(e,t){return function(r){return e(t(r))}}function cr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var a=e[r];a!==t&&a!==s||(e[r]=s,o[i++]=r)}return o}function dr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function ur(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}function lr(e){return sr(e)?function(e){var t=Xe.lastIndex=0;for(;Xe.test(e);)++t;return t}(e):Ft(e)}function pr(e){return sr(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function hr(e){for(var t=e.length;t--&&oe.test(e.charAt(t)););return t}var fr=zt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var mr=function e(t){var f,oe=(t=null==t?pt:mr.defaults(pt.Object(),t,mr.pick(pt,nt))).Array,Se=t.Date,Ce=t.Error,Pe=t.Function,Te=t.Math,ke=t.Object,Re=t.RegExp,Ie=t.String,De=t.TypeError,Ae=oe.prototype,Oe=Pe.prototype,Ne=ke.prototype,Me=t["__core-js_shared__"],Le=Oe.toString,xe=Ne.hasOwnProperty,Fe=0,je=(f=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||""))?"Symbol(src)_1."+f:"",Ue=Ne.toString,Be=Le.call(ke),Ve=pt._,We=Re("^"+Le.call(xe).replace(ne,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=mt?t.Buffer:r,qe=t.Symbol,ze=t.Uint8Array,Ge=He?He.allocUnsafe:r,Ye=ar(ke.getPrototypeOf,ke),$e=ke.create,Je=Ne.propertyIsEnumerable,Ke=Ae.splice,Xe=qe?qe.isConcatSpreadable:r,tt=qe?qe.iterator:r,at=qe?qe.toStringTag:r,ut=function(){try{var e=hs(ke,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,ht=Se&&Se.now!==pt.Date.now&&Se.now,ft=t.setTimeout!==pt.setTimeout&&t.setTimeout,gt=Te.ceil,vt=Te.floor,Ft=ke.getOwnPropertySymbols,zt=He?He.isBuffer:r,gr=t.isFinite,vr=Ae.join,yr=ar(ke.keys,ke),_r=Te.max,br=Te.min,Er=Se.now,wr=t.parseInt,Sr=Te.random,Cr=Ae.reverse,Pr=hs(t,"DataView"),Tr=hs(t,"Map"),kr=hs(t,"Promise"),Rr=hs(t,"Set"),Ir=hs(t,"WeakMap"),Dr=hs(ke,"create"),Ar=Ir&&new Ir,Or={},Nr=Bs(Pr),Mr=Bs(Tr),Lr=Bs(kr),xr=Bs(Rr),Fr=Bs(Ir),jr=qe?qe.prototype:r,Ur=jr?jr.valueOf:r,Br=jr?jr.toString:r;function Vr(e){if(ia(e)&&!Yo(e)&&!(e instanceof zr)){if(e instanceof qr)return e;if(xe.call(e,"__wrapped__"))return Vs(e)}return new qr(e)}var Wr=function(){function e(){}return function(t){if(!na(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function Hr(){}function qr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function zr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=m,this.__views__=[]}function Gr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Yr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function $r(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Jr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new $r;++t<r;)this.add(e[t])}function Kr(e){var t=this.__data__=new Yr(e);this.size=t.size}function Qr(e,t){var r=Yo(e),n=!r&&Go(e),i=!r&&!n&&Qo(e),s=!r&&!n&&!i&&pa(e),o=r||n||i||s,a=o?$t(e.length,Ie):[],c=a.length;for(var d in e)!t&&!xe.call(e,d)||o&&("length"==d||i&&("offset"==d||"parent"==d)||s&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||bs(d,c))||a.push(d);return a}function Zr(e){var t=e.length;return t?e[Kn(0,t-1)]:r}function Xr(e,t){return Fs(Ai(e),dn(t,0,e.length))}function en(e){return Fs(Ai(e))}function tn(e,t,n){(n!==r&&!Ho(e[t],n)||n===r&&!(t in e))&&an(e,t,n)}function rn(e,t,n){var i=e[t];xe.call(e,t)&&Ho(i,n)&&(n!==r||t in e)||an(e,t,n)}function nn(e,t){for(var r=e.length;r--;)if(Ho(e[r][0],t))return r;return-1}function sn(e,t,r,n){return fn(e,(function(e,i,s){t(n,e,r(e),s)})),n}function on(e,t){return e&&Oi(t,Ma(t),e)}function an(e,t,r){"__proto__"==t&&ut?ut(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cn(e,t){for(var n=-1,i=t.length,s=oe(i),o=null==e;++n<i;)s[n]=o?r:Ia(e,t[n]);return s}function dn(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function un(e,t,n,i,s,o){var a,c=1&t,d=2&t,u=4&t;if(n&&(a=s?n(e,i,s,o):n(e)),a!==r)return a;if(!na(e))return e;var l=Yo(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);t&&"string"==typeof e[0]&&xe.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(e),!c)return Ai(e,a)}else{var p=gs(e),h=p==w||p==S;if(Qo(e))return Pi(e,c);if(p==T||p==v||h&&!s){if(a=d||h?{}:ys(e),!c)return d?function(e,t){return Oi(e,ms(e),t)}(e,function(e,t){return e&&Oi(t,La(t),e)}(a,e)):function(e,t){return Oi(e,fs(e),t)}(e,on(a,e))}else{if(!ot[p])return s?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case N:return Ti(e);case _:case b:return new n(+e);case M:return function(e,t){var r=t?Ti(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case L:case x:case F:case j:case U:case B:case V:case W:case H:return ki(e,r);case C:case I:return new n;case P:case D:return new n(e);case R:return function(e){var t=new e.constructor(e.source,fe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return function(e){return Ur?ke(Ur.call(e)):{}}(e)}}(e,p,c)}}o||(o=new Kr);var f=o.get(e);if(f)return f;o.set(e,a),da(e)?e.forEach((function(r){a.add(un(r,t,n,r,e,o))})):sa(e)&&e.forEach((function(r,i){a.set(i,un(r,t,n,i,e,o))}));var m=l?r:(u?d?os:ss:d?La:Ma)(e);return Tt(m||e,(function(r,i){m&&(r=e[i=r]),rn(a,i,un(r,t,n,i,e,o))})),a}function ln(e,t,n){var i=n.length;if(null==e)return!i;for(e=ke(e);i--;){var s=n[i],o=t[s],a=e[s];if(a===r&&!(s in e)||!o(a))return!1}return!0}function pn(e,t,i){if("function"!=typeof e)throw new De(n);return Ns((function(){e.apply(r,i)}),t)}function hn(e,t,r,n){var i=-1,s=Dt,o=!0,a=e.length,c=[],d=t.length;if(!a)return c;r&&(t=Ot(t,Kt(r))),n?(s=At,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Jr(t));e:for(;++i<a;){var u=e[i],l=null==r?u:r(u);if(u=n||0!==u?u:0,o&&l==l){for(var p=d;p--;)if(t[p]===l)continue e;c.push(u)}else s(t,l,n)||c.push(u)}return c}Vr.templateSettings={escape:Q,evaluate:Z,interpolate:X,variable:"",imports:{_:Vr}},Vr.prototype=Hr.prototype,Vr.prototype.constructor=Vr,qr.prototype=Wr(Hr.prototype),qr.prototype.constructor=qr,zr.prototype=Wr(Hr.prototype),zr.prototype.constructor=zr,Gr.prototype.clear=function(){this.__data__=Dr?Dr(null):{},this.size=0},Gr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Gr.prototype.get=function(e){var t=this.__data__;if(Dr){var n=t[e];return n===i?r:n}return xe.call(t,e)?t[e]:r},Gr.prototype.has=function(e){var t=this.__data__;return Dr?t[e]!==r:xe.call(t,e)},Gr.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Dr&&t===r?i:t,this},Yr.prototype.clear=function(){this.__data__=[],this.size=0},Yr.prototype.delete=function(e){var t=this.__data__,r=nn(t,e);return!(r<0)&&(r==t.length-1?t.pop():Ke.call(t,r,1),--this.size,!0)},Yr.prototype.get=function(e){var t=this.__data__,n=nn(t,e);return n<0?r:t[n][1]},Yr.prototype.has=function(e){return nn(this.__data__,e)>-1},Yr.prototype.set=function(e,t){var r=this.__data__,n=nn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},$r.prototype.clear=function(){this.size=0,this.__data__={hash:new Gr,map:new(Tr||Yr),string:new Gr}},$r.prototype.delete=function(e){var t=ls(this,e).delete(e);return this.size-=t?1:0,t},$r.prototype.get=function(e){return ls(this,e).get(e)},$r.prototype.has=function(e){return ls(this,e).has(e)},$r.prototype.set=function(e,t){var r=ls(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Jr.prototype.add=Jr.prototype.push=function(e){return this.__data__.set(e,i),this},Jr.prototype.has=function(e){return this.__data__.has(e)},Kr.prototype.clear=function(){this.__data__=new Yr,this.size=0},Kr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Kr.prototype.get=function(e){return this.__data__.get(e)},Kr.prototype.has=function(e){return this.__data__.has(e)},Kr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Yr){var n=r.__data__;if(!Tr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new $r(n)}return r.set(e,t),this.size=r.size,this};var fn=Li(wn),mn=Li(Sn,!0);function gn(e,t){var r=!0;return fn(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function vn(e,t,n){for(var i=-1,s=e.length;++i<s;){var o=e[i],a=t(o);if(null!=a&&(c===r?a==a&&!la(a):n(a,c)))var c=a,d=o}return d}function yn(e,t){var r=[];return fn(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function _n(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=_s),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?_n(a,t-1,r,n,i):Nt(i,a):n||(i[i.length]=a)}return i}var bn=xi(),En=xi(!0);function wn(e,t){return e&&bn(e,t,Ma)}function Sn(e,t){return e&&En(e,t,Ma)}function Cn(e,t){return It(t,(function(t){return ea(e[t])}))}function Pn(e,t){for(var n=0,i=(t=Ei(t,e)).length;null!=e&&n<i;)e=e[Us(t[n++])];return n&&n==i?e:r}function Tn(e,t,r){var n=t(e);return Yo(e)?n:Nt(n,r(e))}function kn(e){return null==e?e===r?"[object Undefined]":"[object Null]":at&&at in ke(e)?function(e){var t=xe.call(e,at),n=e[at];try{e[at]=r;var i=!0}catch(e){}var s=Ue.call(e);i&&(t?e[at]=n:delete e[at]);return s}(e):function(e){return Ue.call(e)}(e)}function Rn(e,t){return e>t}function In(e,t){return null!=e&&xe.call(e,t)}function Dn(e,t){return null!=e&&t in ke(e)}function An(e,t,n){for(var i=n?At:Dt,s=e[0].length,o=e.length,a=o,c=oe(o),d=1/0,u=[];a--;){var l=e[a];a&&t&&(l=Ot(l,Kt(t))),d=br(l.length,d),c[a]=!n&&(t||s>=120&&l.length>=120)?new Jr(a&&l):r}l=e[0];var p=-1,h=c[0];e:for(;++p<s&&u.length<d;){var f=l[p],m=t?t(f):f;if(f=n||0!==f?f:0,!(h?Zt(h,m):i(u,m,n))){for(a=o;--a;){var g=c[a];if(!(g?Zt(g,m):i(e[a],m,n)))continue e}h&&h.push(m),u.push(f)}}return u}function On(e,t,n){var i=null==(e=Is(e,t=Ei(t,e)))?e:e[Us(Zs(t))];return null==i?r:Ct(i,e,n)}function Nn(e){return ia(e)&&kn(e)==v}function Mn(e,t,n,i,s){return e===t||(null==e||null==t||!ia(e)&&!ia(t)?e!=e&&t!=t:function(e,t,n,i,s,o){var a=Yo(e),c=Yo(t),d=a?y:gs(e),u=c?y:gs(t),l=(d=d==v?T:d)==T,p=(u=u==v?T:u)==T,h=d==u;if(h&&Qo(e)){if(!Qo(t))return!1;a=!0,l=!1}if(h&&!l)return o||(o=new Kr),a||pa(e)?ns(e,t,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case M:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case N:return!(e.byteLength!=t.byteLength||!s(new ze(e),new ze(t)));case _:case b:case P:return Ho(+e,+t);case E:return e.name==t.name&&e.message==t.message;case R:case D:return e==t+"";case C:var a=or;case I:var c=1&n;if(a||(a=dr),e.size!=t.size&&!c)return!1;var d=o.get(e);if(d)return d==t;n|=2,o.set(e,t);var u=ns(a(e),a(t),n,i,s,o);return o.delete(e),u;case A:if(Ur)return Ur.call(e)==Ur.call(t)}return!1}(e,t,d,n,i,s,o);if(!(1&n)){var f=l&&xe.call(e,"__wrapped__"),m=p&&xe.call(t,"__wrapped__");if(f||m){var g=f?e.value():e,w=m?t.value():t;return o||(o=new Kr),s(g,w,n,i,o)}}if(!h)return!1;return o||(o=new Kr),function(e,t,n,i,s,o){var a=1&n,c=ss(e),d=c.length,u=ss(t).length;if(d!=u&&!a)return!1;var l=d;for(;l--;){var p=c[l];if(!(a?p in t:xe.call(t,p)))return!1}var h=o.get(e),f=o.get(t);if(h&&f)return h==t&&f==e;var m=!0;o.set(e,t),o.set(t,e);var g=a;for(;++l<d;){var v=e[p=c[l]],y=t[p];if(i)var _=a?i(y,v,p,t,e,o):i(v,y,p,e,t,o);if(!(_===r?v===y||s(v,y,n,i,o):_)){m=!1;break}g||(g="constructor"==p)}if(m&&!g){var b=e.constructor,E=t.constructor;b==E||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof E&&E instanceof E||(m=!1)}return o.delete(e),o.delete(t),m}(e,t,n,i,s,o)}(e,t,n,i,Mn,s))}function Ln(e,t,n,i){var s=n.length,o=s,a=!i;if(null==e)return!o;for(e=ke(e);s--;){var c=n[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var d=(c=n[s])[0],u=e[d],l=c[1];if(a&&c[2]){if(u===r&&!(d in e))return!1}else{var p=new Kr;if(i)var h=i(u,l,d,e,t,p);if(!(h===r?Mn(l,u,3,i,p):h))return!1}}return!0}function xn(e){return!(!na(e)||(t=e,je&&je in t))&&(ea(e)?We:ve).test(Bs(e));var t}function Fn(e){return"function"==typeof e?e:null==e?oc:"object"==typeof e?Yo(e)?Hn(e[0],e[1]):Wn(e):mc(e)}function jn(e){if(!Ps(e))return yr(e);var t=[];for(var r in ke(e))xe.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Un(e){if(!na(e))return function(e){var t=[];if(null!=e)for(var r in ke(e))t.push(r);return t}(e);var t=Ps(e),r=[];for(var n in e)("constructor"!=n||!t&&xe.call(e,n))&&r.push(n);return r}function Bn(e,t){return e<t}function Vn(e,t){var r=-1,n=Jo(e)?oe(e.length):[];return fn(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Wn(e){var t=ps(e);return 1==t.length&&t[0][2]?ks(t[0][0],t[0][1]):function(r){return r===e||Ln(r,e,t)}}function Hn(e,t){return ws(e)&&Ts(t)?ks(Us(e),t):function(n){var i=Ia(n,e);return i===r&&i===t?Da(n,e):Mn(t,i,3)}}function qn(e,t,n,i,s){e!==t&&bn(t,(function(o,a){if(s||(s=new Kr),na(o))!function(e,t,n,i,s,o,a){var c=As(e,n),d=As(t,n),u=a.get(d);if(u)return void tn(e,n,u);var l=o?o(c,d,n+"",e,t,a):r,p=l===r;if(p){var h=Yo(d),f=!h&&Qo(d),m=!h&&!f&&pa(d);l=d,h||f||m?Yo(c)?l=c:Ko(c)?l=Ai(c):f?(p=!1,l=Pi(d,!0)):m?(p=!1,l=ki(d,!0)):l=[]:aa(d)||Go(d)?(l=c,Go(c)?l=ba(c):na(c)&&!ea(c)||(l=ys(d))):p=!1}p&&(a.set(d,l),s(l,d,i,o,a),a.delete(d));tn(e,n,l)}(e,t,a,n,qn,i,s);else{var c=i?i(As(e,a),o,a+"",e,t,s):r;c===r&&(c=o),tn(e,a,c)}}),La)}function zn(e,t){var n=e.length;if(n)return bs(t+=t<0?n:0,n)?e[t]:r}function Gn(e,t,r){t=t.length?Ot(t,(function(e){return Yo(e)?function(t){return Pn(t,1===e.length?e[0]:e)}:e})):[oc];var n=-1;t=Ot(t,Kt(us()));var i=Vn(e,(function(e,r,i){var s=Ot(t,(function(t){return t(e)}));return{criteria:s,index:++n,value:e}}));return function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(i,(function(e,t){return function(e,t,r){var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;for(;++n<o;){var c=Ri(i[n],s[n]);if(c)return n>=a?c:c*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)}))}function Yn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Pn(e,o);r(a,o)&&ti(s,Ei(o,e),a)}return s}function $n(e,t,r,n){var i=n?Vt:Bt,s=-1,o=t.length,a=e;for(e===t&&(t=Ai(t)),r&&(a=Ot(e,Kt(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Ke.call(a,c,1),Ke.call(e,c,1);return e}function Jn(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==s){var s=i;bs(i)?Ke.call(e,i,1):hi(e,i)}}return e}function Kn(e,t){return e+vt(Sr()*(t-e+1))}function Qn(e,t){var r="";if(!e||t<1||t>p)return r;do{t%2&&(r+=e),(t=vt(t/2))&&(e+=e)}while(t);return r}function Zn(e,t){return Ms(Rs(e,t,oc),e+"")}function Xn(e){return Zr(Ha(e))}function ei(e,t){var r=Ha(e);return Fs(r,dn(t,0,r.length))}function ti(e,t,n,i){if(!na(e))return e;for(var s=-1,o=(t=Ei(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var d=Us(t[s]),u=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return e;if(s!=a){var l=c[d];(u=i?i(l,d,c):r)===r&&(u=na(l)?l:bs(t[s+1])?[]:{})}rn(c,d,u),c=c[d]}return e}var ri=Ar?function(e,t){return Ar.set(e,t),e}:oc,ni=ut?function(e,t){return ut(e,"toString",{configurable:!0,enumerable:!1,value:nc(t),writable:!0})}:oc;function ii(e){return Fs(Ha(e))}function si(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=oe(i);++n<i;)s[n]=e[n+t];return s}function oi(e,t){var r;return fn(e,(function(e,n,i){return!(r=t(e,n,i))})),!!r}function ai(e,t,r){var n=0,i=null==e?n:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;n<i;){var s=n+i>>>1,o=e[s];null!==o&&!la(o)&&(r?o<=t:o<t)?n=s+1:i=s}return i}return ci(e,t,oc,r)}function ci(e,t,n,i){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=n(t))!=t,c=null===t,d=la(t),u=t===r;s<o;){var l=vt((s+o)/2),p=n(e[l]),h=p!==r,f=null===p,m=p==p,g=la(p);if(a)var v=i||m;else v=u?m&&(i||h):c?m&&h&&(i||!f):d?m&&h&&!f&&(i||!g):!f&&!g&&(i?p<=t:p<t);v?s=l+1:o=l}return br(o,4294967294)}function di(e,t){for(var r=-1,n=e.length,i=0,s=[];++r<n;){var o=e[r],a=t?t(o):o;if(!r||!Ho(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ui(e){return"number"==typeof e?e:la(e)?h:+e}function li(e){if("string"==typeof e)return e;if(Yo(e))return Ot(e,li)+"";if(la(e))return Br?Br.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function pi(e,t,r){var n=-1,i=Dt,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=At;else if(s>=200){var d=t?null:Qi(e);if(d)return dr(d);o=!1,i=Zt,c=new Jr}else c=t?[]:a;e:for(;++n<s;){var u=e[n],l=t?t(u):u;if(u=r||0!==u?u:0,o&&l==l){for(var p=c.length;p--;)if(c[p]===l)continue e;t&&c.push(l),a.push(u)}else i(c,l,r)||(c!==a&&c.push(l),a.push(u))}return a}function hi(e,t){return null==(e=Is(e,t=Ei(t,e)))||delete e[Us(Zs(t))]}function fi(e,t,r,n){return ti(e,t,r(Pn(e,t)),n)}function mi(e,t,r,n){for(var i=e.length,s=n?i:-1;(n?s--:++s<i)&&t(e[s],s,e););return r?si(e,n?0:s,n?s+1:i):si(e,n?s+1:0,n?i:s)}function gi(e,t){var r=e;return r instanceof zr&&(r=r.value()),Mt(t,(function(e,t){return t.func.apply(t.thisArg,Nt([e],t.args))}),r)}function vi(e,t,r){var n=e.length;if(n<2)return n?pi(e[0]):[];for(var i=-1,s=oe(n);++i<n;)for(var o=e[i],a=-1;++a<n;)a!=i&&(s[i]=hn(s[i]||o,e[a],t,r));return pi(_n(s,1),t,r)}function yi(e,t,n){for(var i=-1,s=e.length,o=t.length,a={};++i<s;){var c=i<o?t[i]:r;n(a,e[i],c)}return a}function _i(e){return Ko(e)?e:[]}function bi(e){return"function"==typeof e?e:oc}function Ei(e,t){return Yo(e)?e:ws(e,t)?[e]:js(Ea(e))}var wi=Zn;function Si(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:si(e,t,n)}var Ci=lt||function(e){return pt.clearTimeout(e)};function Pi(e,t){if(t)return e.slice();var r=e.length,n=Ge?Ge(r):new e.constructor(r);return e.copy(n),n}function Ti(e){var t=new e.constructor(e.byteLength);return new ze(t).set(new ze(e)),t}function ki(e,t){var r=t?Ti(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Ri(e,t){if(e!==t){var n=e!==r,i=null===e,s=e==e,o=la(e),a=t!==r,c=null===t,d=t==t,u=la(t);if(!c&&!u&&!o&&e>t||o&&a&&d&&!c&&!u||i&&a&&d||!n&&d||!s)return 1;if(!i&&!o&&!u&&e<t||u&&n&&s&&!i&&!o||c&&n&&s||!a&&s||!d)return-1}return 0}function Ii(e,t,r,n){for(var i=-1,s=e.length,o=r.length,a=-1,c=t.length,d=_r(s-o,0),u=oe(c+d),l=!n;++a<c;)u[a]=t[a];for(;++i<o;)(l||i<s)&&(u[r[i]]=e[i]);for(;d--;)u[a++]=e[i++];return u}function Di(e,t,r,n){for(var i=-1,s=e.length,o=-1,a=r.length,c=-1,d=t.length,u=_r(s-a,0),l=oe(u+d),p=!n;++i<u;)l[i]=e[i];for(var h=i;++c<d;)l[h+c]=t[c];for(;++o<a;)(p||i<s)&&(l[h+r[o]]=e[i++]);return l}function Ai(e,t){var r=-1,n=e.length;for(t||(t=oe(n));++r<n;)t[r]=e[r];return t}function Oi(e,t,n,i){var s=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var c=t[o],d=i?i(n[c],e[c],c,n,e):r;d===r&&(d=e[c]),s?an(n,c,d):rn(n,c,d)}return n}function Ni(e,t){return function(r,n){var i=Yo(r)?Pt:sn,s=t?t():{};return i(r,e,us(n,2),s)}}function Mi(e){return Zn((function(t,n){var i=-1,s=n.length,o=s>1?n[s-1]:r,a=s>2?n[2]:r;for(o=e.length>3&&"function"==typeof o?(s--,o):r,a&&Es(n[0],n[1],a)&&(o=s<3?r:o,s=1),t=ke(t);++i<s;){var c=n[i];c&&e(t,c,i,o)}return t}))}function Li(e,t){return function(r,n){if(null==r)return r;if(!Jo(r))return e(r,n);for(var i=r.length,s=t?i:-1,o=ke(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function xi(e){return function(t,r,n){for(var i=-1,s=ke(t),o=n(t),a=o.length;a--;){var c=o[e?a:++i];if(!1===r(s[c],c,s))break}return t}}function Fi(e){return function(t){var n=sr(t=Ea(t))?pr(t):r,i=n?n[0]:t.charAt(0),s=n?Si(n,1).join(""):t.slice(1);return i[e]()+s}}function ji(e){return function(t){return Mt(ec(Ga(t).replace(Qe,"")),e,"")}}function Ui(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=Wr(e.prototype),n=e.apply(r,t);return na(n)?n:r}}function Bi(e){return function(t,n,i){var s=ke(t);if(!Jo(t)){var o=us(n,3);t=Ma(t),n=function(e){return o(s[e],e,s)}}var a=e(t,n,i);return a>-1?s[o?t[a]:a]:r}}function Vi(e){return is((function(t){var i=t.length,s=i,o=qr.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new De(n);if(o&&!c&&"wrapper"==cs(a))var c=new qr([],!0)}for(s=c?s:i;++s<i;){var d=cs(a=t[s]),u="wrapper"==d?as(a):r;c=u&&Ss(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[cs(u[0])].apply(c,u[3]):1==a.length&&Ss(a)?c[d]():c.thru(a)}return function(){var e=arguments,r=e[0];if(c&&1==e.length&&Yo(r))return c.plant(r).value();for(var n=0,s=i?t[n].apply(this,e):r;++n<i;)s=t[n].call(this,s);return s}}))}function Wi(e,t,n,i,s,o,a,c,u,l){var p=t&d,h=1&t,f=2&t,m=24&t,g=512&t,v=f?r:Ui(e);return function r(){for(var d=arguments.length,y=oe(d),_=d;_--;)y[_]=arguments[_];if(m)var b=ds(r),E=tr(y,b);if(i&&(y=Ii(y,i,s,m)),o&&(y=Di(y,o,a,m)),d-=E,m&&d<l){var w=cr(y,b);return Ji(e,t,Wi,r.placeholder,n,y,w,c,u,l-d)}var S=h?n:this,C=f?S[e]:e;return d=y.length,c?y=Ds(y,c):g&&d>1&&y.reverse(),p&&u<d&&(y.length=u),this&&this!==pt&&this instanceof r&&(C=v||Ui(C)),C.apply(S,y)}}function Hi(e,t){return function(r,n){return function(e,t,r,n){return wn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function qi(e,t){return function(n,i){var s;if(n===r&&i===r)return t;if(n!==r&&(s=n),i!==r){if(s===r)return i;"string"==typeof n||"string"==typeof i?(n=li(n),i=li(i)):(n=ui(n),i=ui(i)),s=e(n,i)}return s}}function zi(e){return is((function(t){return t=Ot(t,Kt(us())),Zn((function(r){var n=this;return e(t,(function(e){return Ct(e,n,r)}))}))}))}function Gi(e,t){var n=(t=t===r?" ":li(t)).length;if(n<2)return n?Qn(t,e):t;var i=Qn(t,gt(e/lr(t)));return sr(t)?Si(pr(i),0,e).join(""):i.slice(0,e)}function Yi(e){return function(t,n,i){return i&&"number"!=typeof i&&Es(t,n,i)&&(n=i=r),t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r,n){for(var i=-1,s=_r(gt((t-e)/(r||1)),0),o=oe(s);s--;)o[n?s:++i]=e,e+=r;return o}(t,n,i=i===r?t<n?1:-1:ga(i),e)}}function $i(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=_a(t),r=_a(r)),e(t,r)}}function Ji(e,t,n,i,s,o,d,u,l,p){var h=8&t;t|=h?a:c,4&(t&=~(h?c:a))||(t&=-4);var f=[e,t,s,h?o:r,h?d:r,h?r:o,h?r:d,u,l,p],m=n.apply(r,f);return Ss(e)&&Os(m,f),m.placeholder=i,Ls(m,e,t)}function Ki(e){var t=Te[e];return function(e,r){if(e=_a(e),(r=null==r?0:br(va(r),292))&&gr(e)){var n=(Ea(e)+"e").split("e");return+((n=(Ea(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Qi=Rr&&1/dr(new Rr([,-0]))[1]==l?function(e){return new Rr(e)}:lc;function Zi(e){return function(t){var r=gs(t);return r==C?or(t):r==I?ur(t):function(e,t){return Ot(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(e,t,i,l,p,h,f,m){var g=2&t;if(!g&&"function"!=typeof e)throw new De(n);var v=l?l.length:0;if(v||(t&=-97,l=p=r),f=f===r?f:_r(va(f),0),m=m===r?m:va(m),v-=p?p.length:0,t&c){var y=l,_=p;l=p=r}var b=g?r:as(e),E=[e,t,i,l,p,y,_,h,f,m];if(b&&function(e,t){var r=e[1],n=t[1],i=r|n,o=i<131,a=n==d&&8==r||n==d&&r==u&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==r;if(!o&&!a)return e;1&n&&(e[2]=t[2],i|=1&r?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Ii(l,c,t[4]):c,e[4]=l?cr(e[3],s):t[4]}(c=t[5])&&(l=e[5],e[5]=l?Di(l,c,t[6]):c,e[6]=l?cr(e[5],s):t[6]);(c=t[7])&&(e[7]=c);n&d&&(e[8]=null==e[8]?t[8]:br(e[8],t[8]));null==e[9]&&(e[9]=t[9]);e[0]=t[0],e[1]=i}(E,b),e=E[0],t=E[1],i=E[2],l=E[3],p=E[4],!(m=E[9]=E[9]===r?g?0:e.length:_r(E[9]-v,0))&&24&t&&(t&=-25),t&&1!=t)w=8==t||t==o?function(e,t,n){var i=Ui(e);return function s(){for(var o=arguments.length,a=oe(o),c=o,d=ds(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:cr(a,d);return(o-=u.length)<n?Ji(e,t,Wi,s.placeholder,r,a,u,r,r,n-o):Ct(this&&this!==pt&&this instanceof s?i:e,this,a)}}(e,t,m):t!=a&&33!=t||p.length?Wi.apply(r,E):function(e,t,r,n){var i=1&t,s=Ui(e);return function t(){for(var o=-1,a=arguments.length,c=-1,d=n.length,u=oe(d+a),l=this&&this!==pt&&this instanceof t?s:e;++c<d;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return Ct(l,i?r:this,u)}}(e,t,i,l);else var w=function(e,t,r){var n=1&t,i=Ui(e);return function t(){return(this&&this!==pt&&this instanceof t?i:e).apply(n?r:this,arguments)}}(e,t,i);return Ls((b?ri:Os)(w,E),e,t)}function es(e,t,n,i){return e===r||Ho(e,Ne[n])&&!xe.call(i,n)?t:e}function ts(e,t,n,i,s,o){return na(e)&&na(t)&&(o.set(t,e),qn(e,t,r,ts,o),o.delete(t)),e}function rs(e){return aa(e)?r:e}function ns(e,t,n,i,s,o){var a=1&n,c=e.length,d=t.length;if(c!=d&&!(a&&d>c))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var p=-1,h=!0,f=2&n?new Jr:r;for(o.set(e,t),o.set(t,e);++p<c;){var m=e[p],g=t[p];if(i)var v=a?i(g,m,p,t,e,o):i(m,g,p,e,t,o);if(v!==r){if(v)continue;h=!1;break}if(f){if(!xt(t,(function(e,t){if(!Zt(f,t)&&(m===e||s(m,e,n,i,o)))return f.push(t)}))){h=!1;break}}else if(m!==g&&!s(m,g,n,i,o)){h=!1;break}}return o.delete(e),o.delete(t),h}function is(e){return Ms(Rs(e,r,Ys),e+"")}function ss(e){return Tn(e,Ma,fs)}function os(e){return Tn(e,La,ms)}var as=Ar?function(e){return Ar.get(e)}:lc;function cs(e){for(var t=e.name+"",r=Or[t],n=xe.call(Or,t)?r.length:0;n--;){var i=r[n],s=i.func;if(null==s||s==e)return i.name}return t}function ds(e){return(xe.call(Vr,"placeholder")?Vr:e).placeholder}function us(){var e=Vr.iteratee||ac;return e=e===ac?Fn:e,arguments.length?e(arguments[0],arguments[1]):e}function ls(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function ps(e){for(var t=Ma(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ts(i)]}return t}function hs(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return xn(n)?n:r}var fs=Ft?function(e){return null==e?[]:(e=ke(e),It(Ft(e),(function(t){return Je.call(e,t)})))}:yc,ms=Ft?function(e){for(var t=[];e;)Nt(t,fs(e)),e=Ye(e);return t}:yc,gs=kn;function vs(e,t,r){for(var n=-1,i=(t=Ei(t,e)).length,s=!1;++n<i;){var o=Us(t[n]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++n!=i?s:!!(i=null==e?0:e.length)&&ra(i)&&bs(o,i)&&(Yo(e)||Go(e))}function ys(e){return"function"!=typeof e.constructor||Ps(e)?{}:Wr(Ye(e))}function _s(e){return Yo(e)||Go(e)||!!(Xe&&e&&e[Xe])}function bs(e,t){var r=typeof e;return!!(t=null==t?p:t)&&("number"==r||"symbol"!=r&&_e.test(e))&&e>-1&&e%1==0&&e<t}function Es(e,t,r){if(!na(r))return!1;var n=typeof t;return!!("number"==n?Jo(r)&&bs(t,r.length):"string"==n&&t in r)&&Ho(r[t],e)}function ws(e,t){if(Yo(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!la(e))||(te.test(e)||!ee.test(e)||null!=t&&e in ke(t))}function Ss(e){var t=cs(e),r=Vr[t];if("function"!=typeof r||!(t in zr.prototype))return!1;if(e===r)return!0;var n=as(r);return!!n&&e===n[0]}(Pr&&gs(new Pr(new ArrayBuffer(1)))!=M||Tr&&gs(new Tr)!=C||kr&&gs(kr.resolve())!=k||Rr&&gs(new Rr)!=I||Ir&&gs(new Ir)!=O)&&(gs=function(e){var t=kn(e),n=t==T?e.constructor:r,i=n?Bs(n):"";if(i)switch(i){case Nr:return M;case Mr:return C;case Lr:return k;case xr:return I;case Fr:return O}return t});var Cs=Me?ea:_c;function Ps(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ne)}function Ts(e){return e==e&&!na(e)}function ks(e,t){return function(n){return null!=n&&(n[e]===t&&(t!==r||e in ke(n)))}}function Rs(e,t,n){return t=_r(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=_r(r.length-t,0),o=oe(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=oe(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),Ct(e,this,a)}}function Is(e,t){return t.length<2?e:Pn(e,si(t,0,-1))}function Ds(e,t){for(var n=e.length,i=br(t.length,n),s=Ai(e);i--;){var o=t[i];e[i]=bs(o,n)?s[o]:r}return e}function As(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Os=xs(ri),Ns=ft||function(e,t){return pt.setTimeout(e,t)},Ms=xs(ni);function Ls(e,t,r){var n=t+"";return Ms(e,function(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(ae,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Tt(g,(function(r){var n="_."+r[0];t&r[1]&&!Dt(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(ce);return t?t[1].split(de):[]}(n),r)))}function xs(e){var t=0,n=0;return function(){var i=Er(),s=16-(i-n);if(n=i,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Fs(e,t){var n=-1,i=e.length,s=i-1;for(t=t===r?i:t;++n<t;){var o=Kn(n,s),a=e[o];e[o]=e[n],e[n]=a}return e.length=t,e}var js=function(e){var t=Fo(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(re,(function(e,r,n,i){t.push(n?i.replace(pe,"$1"):r||e)})),t}));function Us(e){if("string"==typeof e||la(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Bs(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Vs(e){if(e instanceof zr)return e.clone();var t=new qr(e.__wrapped__,e.__chain__);return t.__actions__=Ai(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Ws=Zn((function(e,t){return Ko(e)?hn(e,_n(t,1,Ko,!0)):[]})),Hs=Zn((function(e,t){var n=Zs(t);return Ko(n)&&(n=r),Ko(e)?hn(e,_n(t,1,Ko,!0),us(n,2)):[]})),qs=Zn((function(e,t){var n=Zs(t);return Ko(n)&&(n=r),Ko(e)?hn(e,_n(t,1,Ko,!0),r,n):[]}));function zs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=_r(n+i,0)),Ut(e,us(t,3),i)}function Gs(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i-1;return n!==r&&(s=va(n),s=n<0?_r(i+s,0):br(s,i-1)),Ut(e,us(t,3),s,!0)}function Ys(e){return(null==e?0:e.length)?_n(e,1):[]}function $s(e){return e&&e.length?e[0]:r}var Js=Zn((function(e){var t=Ot(e,_i);return t.length&&t[0]===e[0]?An(t):[]})),Ks=Zn((function(e){var t=Zs(e),n=Ot(e,_i);return t===Zs(n)?t=r:n.pop(),n.length&&n[0]===e[0]?An(n,us(t,2)):[]})),Qs=Zn((function(e){var t=Zs(e),n=Ot(e,_i);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?An(n,r,t):[]}));function Zs(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Xs=Zn(eo);function eo(e,t){return e&&e.length&&t&&t.length?$n(e,t):e}var to=is((function(e,t){var r=null==e?0:e.length,n=cn(e,t);return Jn(e,Ot(t,(function(e){return bs(e,r)?+e:e})).sort(Ri)),n}));function ro(e){return null==e?e:Cr.call(e)}var no=Zn((function(e){return pi(_n(e,1,Ko,!0))})),io=Zn((function(e){var t=Zs(e);return Ko(t)&&(t=r),pi(_n(e,1,Ko,!0),us(t,2))})),so=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,pi(_n(e,1,Ko,!0),r,t)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=It(e,(function(e){if(Ko(e))return t=_r(e.length,t),!0})),$t(t,(function(t){return Ot(e,qt(t))}))}function ao(e,t){if(!e||!e.length)return[];var n=oo(e);return null==t?n:Ot(n,(function(e){return Ct(t,r,e)}))}var co=Zn((function(e,t){return Ko(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(It(e,Ko))})),lo=Zn((function(e){var t=Zs(e);return Ko(t)&&(t=r),vi(It(e,Ko),us(t,2))})),po=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,vi(It(e,Ko),r,t)})),ho=Zn(oo);var fo=Zn((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,ao(e,n)}));function mo(e){var t=Vr(e);return t.__chain__=!0,t}function go(e,t){return t(e)}var vo=is((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,s=function(t){return cn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof zr&&bs(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:go,args:[s],thisArg:r}),new qr(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(s)}));var yo=Ni((function(e,t,r){xe.call(e,r)?++e[r]:an(e,r,1)}));var _o=Bi(zs),bo=Bi(Gs);function Eo(e,t){return(Yo(e)?Tt:fn)(e,us(t,3))}function wo(e,t){return(Yo(e)?kt:mn)(e,us(t,3))}var So=Ni((function(e,t,r){xe.call(e,r)?e[r].push(t):an(e,r,[t])}));var Co=Zn((function(e,t,r){var n=-1,i="function"==typeof t,s=Jo(e)?oe(e.length):[];return fn(e,(function(e){s[++n]=i?Ct(t,e,r):On(e,t,r)})),s})),Po=Ni((function(e,t,r){an(e,r,t)}));function To(e,t){return(Yo(e)?Ot:Vn)(e,us(t,3))}var ko=Ni((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var Ro=Zn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&Es(e,t[0],t[1])?t=[]:r>2&&Es(t[0],t[1],t[2])&&(t=[t[0]]),Gn(e,_n(t,1),[])})),Io=ht||function(){return pt.Date.now()};function Do(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Xi(e,d,r,r,r,r,t)}function Ao(e,t){var i;if("function"!=typeof t)throw new De(n);return e=va(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var Oo=Zn((function(e,t,r){var n=1;if(r.length){var i=cr(r,ds(Oo));n|=a}return Xi(e,n,t,r,i)})),No=Zn((function(e,t,r){var n=3;if(r.length){var i=cr(r,ds(No));n|=a}return Xi(t,n,e,r,i)}));function Mo(e,t,i){var s,o,a,c,d,u,l=0,p=!1,h=!1,f=!0;if("function"!=typeof e)throw new De(n);function m(t){var n=s,i=o;return s=o=r,l=t,c=e.apply(i,n)}function g(e){return l=e,d=Ns(y,t),p?m(e):c}function v(e){var n=e-u;return u===r||n>=t||n<0||h&&e-l>=a}function y(){var e=Io();if(v(e))return _(e);d=Ns(y,function(e){var r=t-(e-u);return h?br(r,a-(e-l)):r}(e))}function _(e){return d=r,f&&s?m(e):(s=o=r,c)}function b(){var e=Io(),n=v(e);if(s=arguments,o=this,u=e,n){if(d===r)return g(u);if(h)return Ci(d),d=Ns(y,t),m(u)}return d===r&&(d=Ns(y,t)),c}return t=_a(t)||0,na(i)&&(p=!!i.leading,a=(h="maxWait"in i)?_r(_a(i.maxWait)||0,t):a,f="trailing"in i?!!i.trailing:f),b.cancel=function(){d!==r&&Ci(d),l=0,s=u=o=d=r},b.flush=function(){return d===r?c:_(Io())},b}var Lo=Zn((function(e,t){return pn(e,1,t)})),xo=Zn((function(e,t,r){return pn(e,_a(t)||0,r)}));function Fo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new De(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(Fo.Cache||$r),r}function jo(e){if("function"!=typeof e)throw new De(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Fo.Cache=$r;var Uo=wi((function(e,t){var r=(t=1==t.length&&Yo(t[0])?Ot(t[0],Kt(us())):Ot(_n(t,1),Kt(us()))).length;return Zn((function(n){for(var i=-1,s=br(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return Ct(e,this,n)}))})),Bo=Zn((function(e,t){var n=cr(t,ds(Bo));return Xi(e,a,r,t,n)})),Vo=Zn((function(e,t){var n=cr(t,ds(Vo));return Xi(e,c,r,t,n)})),Wo=is((function(e,t){return Xi(e,u,r,r,r,t)}));function Ho(e,t){return e===t||e!=e&&t!=t}var qo=$i(Rn),zo=$i((function(e,t){return e>=t})),Go=Nn(function(){return arguments}())?Nn:function(e){return ia(e)&&xe.call(e,"callee")&&!Je.call(e,"callee")},Yo=oe.isArray,$o=yt?Kt(yt):function(e){return ia(e)&&kn(e)==N};function Jo(e){return null!=e&&ra(e.length)&&!ea(e)}function Ko(e){return ia(e)&&Jo(e)}var Qo=zt||_c,Zo=_t?Kt(_t):function(e){return ia(e)&&kn(e)==b};function Xo(e){if(!ia(e))return!1;var t=kn(e);return t==E||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!aa(e)}function ea(e){if(!na(e))return!1;var t=kn(e);return t==w||t==S||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ta(e){return"number"==typeof e&&e==va(e)}function ra(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=p}function na(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ia(e){return null!=e&&"object"==typeof e}var sa=bt?Kt(bt):function(e){return ia(e)&&gs(e)==C};function oa(e){return"number"==typeof e||ia(e)&&kn(e)==P}function aa(e){if(!ia(e)||kn(e)!=T)return!1;var t=Ye(e);if(null===t)return!0;var r=xe.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Le.call(r)==Be}var ca=Et?Kt(Et):function(e){return ia(e)&&kn(e)==R};var da=wt?Kt(wt):function(e){return ia(e)&&gs(e)==I};function ua(e){return"string"==typeof e||!Yo(e)&&ia(e)&&kn(e)==D}function la(e){return"symbol"==typeof e||ia(e)&&kn(e)==A}var pa=St?Kt(St):function(e){return ia(e)&&ra(e.length)&&!!st[kn(e)]};var ha=$i(Bn),fa=$i((function(e,t){return e<=t}));function ma(e){if(!e)return[];if(Jo(e))return ua(e)?pr(e):Ai(e);if(tt&&e[tt])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[tt]());var t=gs(e);return(t==C?or:t==I?dr:Ha)(e)}function ga(e){return e?(e=_a(e))===l||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function va(e){var t=ga(e),r=t%1;return t==t?r?t-r:t:0}function ya(e){return e?dn(va(e),0,m):0}function _a(e){if("number"==typeof e)return e;if(la(e))return h;if(na(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=na(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Jt(e);var r=ge.test(e);return r||ye.test(e)?dt(e.slice(2),r?2:8):me.test(e)?h:+e}function ba(e){return Oi(e,La(e))}function Ea(e){return null==e?"":li(e)}var wa=Mi((function(e,t){if(Ps(t)||Jo(t))Oi(t,Ma(t),e);else for(var r in t)xe.call(t,r)&&rn(e,r,t[r])})),Sa=Mi((function(e,t){Oi(t,La(t),e)})),Ca=Mi((function(e,t,r,n){Oi(t,La(t),e,n)})),Pa=Mi((function(e,t,r,n){Oi(t,Ma(t),e,n)})),Ta=is(cn);var ka=Zn((function(e,t){e=ke(e);var n=-1,i=t.length,s=i>2?t[2]:r;for(s&&Es(t[0],t[1],s)&&(i=1);++n<i;)for(var o=t[n],a=La(o),c=-1,d=a.length;++c<d;){var u=a[c],l=e[u];(l===r||Ho(l,Ne[u])&&!xe.call(e,u))&&(e[u]=o[u])}return e})),Ra=Zn((function(e){return e.push(r,ts),Ct(Fa,r,e)}));function Ia(e,t,n){var i=null==e?r:Pn(e,t);return i===r?n:i}function Da(e,t){return null!=e&&vs(e,t,Dn)}var Aa=Hi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),e[t]=r}),nc(oc)),Oa=Hi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),xe.call(e,t)?e[t].push(r):e[t]=[r]}),us),Na=Zn(On);function Ma(e){return Jo(e)?Qr(e):jn(e)}function La(e){return Jo(e)?Qr(e,!0):Un(e)}var xa=Mi((function(e,t,r){qn(e,t,r)})),Fa=Mi((function(e,t,r,n){qn(e,t,r,n)})),ja=is((function(e,t){var r={};if(null==e)return r;var n=!1;t=Ot(t,(function(t){return t=Ei(t,e),n||(n=t.length>1),t})),Oi(e,os(e),r),n&&(r=un(r,7,rs));for(var i=t.length;i--;)hi(r,t[i]);return r}));var Ua=is((function(e,t){return null==e?{}:function(e,t){return Yn(e,t,(function(t,r){return Da(e,r)}))}(e,t)}));function Ba(e,t){if(null==e)return{};var r=Ot(os(e),(function(e){return[e]}));return t=us(t),Yn(e,r,(function(e,r){return t(e,r[0])}))}var Va=Zi(Ma),Wa=Zi(La);function Ha(e){return null==e?[]:Qt(e,Ma(e))}var qa=ji((function(e,t,r){return t=t.toLowerCase(),e+(r?za(t):t)}));function za(e){return Xa(Ea(e).toLowerCase())}function Ga(e){return(e=Ea(e))&&e.replace(be,rr).replace(Ze,"")}var Ya=ji((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),$a=ji((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Ja=Fi("toLowerCase");var Ka=ji((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}));var Qa=ji((function(e,t,r){return e+(r?" ":"")+Xa(t)}));var Za=ji((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Xa=Fi("toUpperCase");function ec(e,t,n){return e=Ea(e),(t=n?r:t)===r?function(e){return rt.test(e)}(e)?function(e){return e.match(et)||[]}(e):function(e){return e.match(ue)||[]}(e):e.match(t)||[]}var tc=Zn((function(e,t){try{return Ct(e,r,t)}catch(e){return Xo(e)?e:new Ce(e)}})),rc=is((function(e,t){return Tt(t,(function(t){t=Us(t),an(e,t,Oo(e[t],e))})),e}));function nc(e){return function(){return e}}var ic=Vi(),sc=Vi(!0);function oc(e){return e}function ac(e){return Fn("function"==typeof e?e:un(e,1))}var cc=Zn((function(e,t){return function(r){return On(r,e,t)}})),dc=Zn((function(e,t){return function(r){return On(e,r,t)}}));function uc(e,t,r){var n=Ma(t),i=Cn(t,n);null!=r||na(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Cn(t,Ma(t)));var s=!(na(r)&&"chain"in r&&!r.chain),o=ea(e);return Tt(i,(function(r){var n=t[r];e[r]=n,o&&(e.prototype[r]=function(){var t=this.__chain__;if(s||t){var r=e(this.__wrapped__),i=r.__actions__=Ai(this.__actions__);return i.push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Nt([this.value()],arguments))})})),e}function lc(){}var pc=zi(Ot),hc=zi(Rt),fc=zi(xt);function mc(e){return ws(e)?qt(Us(e)):function(e){return function(t){return Pn(t,e)}}(e)}var gc=Yi(),vc=Yi(!0);function yc(){return[]}function _c(){return!1}var bc=qi((function(e,t){return e+t}),0),Ec=Ki("ceil"),wc=qi((function(e,t){return e/t}),1),Sc=Ki("floor");var Cc,Pc=qi((function(e,t){return e*t}),1),Tc=Ki("round"),kc=qi((function(e,t){return e-t}),0);return Vr.after=function(e,t){if("function"!=typeof t)throw new De(n);return e=va(e),function(){if(--e<1)return t.apply(this,arguments)}},Vr.ary=Do,Vr.assign=wa,Vr.assignIn=Sa,Vr.assignInWith=Ca,Vr.assignWith=Pa,Vr.at=Ta,Vr.before=Ao,Vr.bind=Oo,Vr.bindAll=rc,Vr.bindKey=No,Vr.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Yo(e)?e:[e]},Vr.chain=mo,Vr.chunk=function(e,t,n){t=(n?Es(e,t,n):t===r)?1:_r(va(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,o=0,a=oe(gt(i/t));s<i;)a[o++]=si(e,s,s+=t);return a},Vr.compact=function(e){for(var t=-1,r=null==e?0:e.length,n=0,i=[];++t<r;){var s=e[t];s&&(i[n++]=s)}return i},Vr.concat=function(){var e=arguments.length;if(!e)return[];for(var t=oe(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Nt(Yo(r)?Ai(r):[r],_n(t,1))},Vr.cond=function(e){var t=null==e?0:e.length,r=us();return e=t?Ot(e,(function(e){if("function"!=typeof e[1])throw new De(n);return[r(e[0]),e[1]]})):[],Zn((function(r){for(var n=-1;++n<t;){var i=e[n];if(Ct(i[0],this,r))return Ct(i[1],this,r)}}))},Vr.conforms=function(e){return function(e){var t=Ma(e);return function(r){return ln(r,e,t)}}(un(e,1))},Vr.constant=nc,Vr.countBy=yo,Vr.create=function(e,t){var r=Wr(e);return null==t?r:on(r,t)},Vr.curry=function e(t,n,i){var s=Xi(t,8,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},Vr.curryRight=function e(t,n,i){var s=Xi(t,o,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},Vr.debounce=Mo,Vr.defaults=ka,Vr.defaultsDeep=Ra,Vr.defer=Lo,Vr.delay=xo,Vr.difference=Ws,Vr.differenceBy=Hs,Vr.differenceWith=qs,Vr.drop=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=n||t===r?1:va(t))<0?0:t,i):[]},Vr.dropRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,0,(t=i-(t=n||t===r?1:va(t)))<0?0:t):[]},Vr.dropRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0,!0):[]},Vr.dropWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0):[]},Vr.fill=function(e,t,n,i){var s=null==e?0:e.length;return s?(n&&"number"!=typeof n&&Es(e,t,n)&&(n=0,i=s),function(e,t,n,i){var s=e.length;for((n=va(n))<0&&(n=-n>s?0:s+n),(i=i===r||i>s?s:va(i))<0&&(i+=s),i=n>i?0:ya(i);n<i;)e[n++]=t;return e}(e,t,n,i)):[]},Vr.filter=function(e,t){return(Yo(e)?It:yn)(e,us(t,3))},Vr.flatMap=function(e,t){return _n(To(e,t),1)},Vr.flatMapDeep=function(e,t){return _n(To(e,t),l)},Vr.flatMapDepth=function(e,t,n){return n=n===r?1:va(n),_n(To(e,t),n)},Vr.flatten=Ys,Vr.flattenDeep=function(e){return(null==e?0:e.length)?_n(e,l):[]},Vr.flattenDepth=function(e,t){return(null==e?0:e.length)?_n(e,t=t===r?1:va(t)):[]},Vr.flip=function(e){return Xi(e,512)},Vr.flow=ic,Vr.flowRight=sc,Vr.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={};++t<r;){var i=e[t];n[i[0]]=i[1]}return n},Vr.functions=function(e){return null==e?[]:Cn(e,Ma(e))},Vr.functionsIn=function(e){return null==e?[]:Cn(e,La(e))},Vr.groupBy=So,Vr.initial=function(e){return(null==e?0:e.length)?si(e,0,-1):[]},Vr.intersection=Js,Vr.intersectionBy=Ks,Vr.intersectionWith=Qs,Vr.invert=Aa,Vr.invertBy=Oa,Vr.invokeMap=Co,Vr.iteratee=ac,Vr.keyBy=Po,Vr.keys=Ma,Vr.keysIn=La,Vr.map=To,Vr.mapKeys=function(e,t){var r={};return t=us(t,3),wn(e,(function(e,n,i){an(r,t(e,n,i),e)})),r},Vr.mapValues=function(e,t){var r={};return t=us(t,3),wn(e,(function(e,n,i){an(r,n,t(e,n,i))})),r},Vr.matches=function(e){return Wn(un(e,1))},Vr.matchesProperty=function(e,t){return Hn(e,un(t,1))},Vr.memoize=Fo,Vr.merge=xa,Vr.mergeWith=Fa,Vr.method=cc,Vr.methodOf=dc,Vr.mixin=uc,Vr.negate=jo,Vr.nthArg=function(e){return e=va(e),Zn((function(t){return zn(t,e)}))},Vr.omit=ja,Vr.omitBy=function(e,t){return Ba(e,jo(us(t)))},Vr.once=function(e){return Ao(2,e)},Vr.orderBy=function(e,t,n,i){return null==e?[]:(Yo(t)||(t=null==t?[]:[t]),Yo(n=i?r:n)||(n=null==n?[]:[n]),Gn(e,t,n))},Vr.over=pc,Vr.overArgs=Uo,Vr.overEvery=hc,Vr.overSome=fc,Vr.partial=Bo,Vr.partialRight=Vo,Vr.partition=ko,Vr.pick=Ua,Vr.pickBy=Ba,Vr.property=mc,Vr.propertyOf=function(e){return function(t){return null==e?r:Pn(e,t)}},Vr.pull=Xs,Vr.pullAll=eo,Vr.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?$n(e,t,us(r,2)):e},Vr.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?$n(e,t,r,n):e},Vr.pullAt=to,Vr.range=gc,Vr.rangeRight=vc,Vr.rearg=Wo,Vr.reject=function(e,t){return(Yo(e)?It:yn)(e,jo(us(t,3)))},Vr.remove=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],s=e.length;for(t=us(t,3);++n<s;){var o=e[n];t(o,n,e)&&(r.push(o),i.push(n))}return Jn(e,i),r},Vr.rest=function(e,t){if("function"!=typeof e)throw new De(n);return Zn(e,t=t===r?t:va(t))},Vr.reverse=ro,Vr.sampleSize=function(e,t,n){return t=(n?Es(e,t,n):t===r)?1:va(t),(Yo(e)?Xr:ei)(e,t)},Vr.set=function(e,t,r){return null==e?e:ti(e,t,r)},Vr.setWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:ti(e,t,n,i)},Vr.shuffle=function(e){return(Yo(e)?en:ii)(e)},Vr.slice=function(e,t,n){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&Es(e,t,n)?(t=0,n=i):(t=null==t?0:va(t),n=n===r?i:va(n)),si(e,t,n)):[]},Vr.sortBy=Ro,Vr.sortedUniq=function(e){return e&&e.length?di(e):[]},Vr.sortedUniqBy=function(e,t){return e&&e.length?di(e,us(t,2)):[]},Vr.split=function(e,t,n){return n&&"number"!=typeof n&&Es(e,t,n)&&(t=n=r),(n=n===r?m:n>>>0)?(e=Ea(e))&&("string"==typeof t||null!=t&&!ca(t))&&!(t=li(t))&&sr(e)?Si(pr(e),0,n):e.split(t,n):[]},Vr.spread=function(e,t){if("function"!=typeof e)throw new De(n);return t=null==t?0:_r(va(t),0),Zn((function(r){var n=r[t],i=Si(r,0,t);return n&&Nt(i,n),Ct(e,this,i)}))},Vr.tail=function(e){var t=null==e?0:e.length;return t?si(e,1,t):[]},Vr.take=function(e,t,n){return e&&e.length?si(e,0,(t=n||t===r?1:va(t))<0?0:t):[]},Vr.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=i-(t=n||t===r?1:va(t)))<0?0:t,i):[]},Vr.takeRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!1,!0):[]},Vr.takeWhile=function(e,t){return e&&e.length?mi(e,us(t,3)):[]},Vr.tap=function(e,t){return t(e),e},Vr.throttle=function(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new De(n);return na(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),Mo(e,t,{leading:i,maxWait:t,trailing:s})},Vr.thru=go,Vr.toArray=ma,Vr.toPairs=Va,Vr.toPairsIn=Wa,Vr.toPath=function(e){return Yo(e)?Ot(e,Us):la(e)?[e]:Ai(js(Ea(e)))},Vr.toPlainObject=ba,Vr.transform=function(e,t,r){var n=Yo(e),i=n||Qo(e)||pa(e);if(t=us(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:na(e)&&ea(s)?Wr(Ye(e)):{}}return(i?Tt:wn)(e,(function(e,n,i){return t(r,e,n,i)})),r},Vr.unary=function(e){return Do(e,1)},Vr.union=no,Vr.unionBy=io,Vr.unionWith=so,Vr.uniq=function(e){return e&&e.length?pi(e):[]},Vr.uniqBy=function(e,t){return e&&e.length?pi(e,us(t,2)):[]},Vr.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?pi(e,r,t):[]},Vr.unset=function(e,t){return null==e||hi(e,t)},Vr.unzip=oo,Vr.unzipWith=ao,Vr.update=function(e,t,r){return null==e?e:fi(e,t,bi(r))},Vr.updateWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:fi(e,t,bi(n),i)},Vr.values=Ha,Vr.valuesIn=function(e){return null==e?[]:Qt(e,La(e))},Vr.without=co,Vr.words=ec,Vr.wrap=function(e,t){return Bo(bi(t),e)},Vr.xor=uo,Vr.xorBy=lo,Vr.xorWith=po,Vr.zip=ho,Vr.zipObject=function(e,t){return yi(e||[],t||[],rn)},Vr.zipObjectDeep=function(e,t){return yi(e||[],t||[],ti)},Vr.zipWith=fo,Vr.entries=Va,Vr.entriesIn=Wa,Vr.extend=Sa,Vr.extendWith=Ca,uc(Vr,Vr),Vr.add=bc,Vr.attempt=tc,Vr.camelCase=qa,Vr.capitalize=za,Vr.ceil=Ec,Vr.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=_a(n))==n?n:0),t!==r&&(t=(t=_a(t))==t?t:0),dn(_a(e),t,n)},Vr.clone=function(e){return un(e,4)},Vr.cloneDeep=function(e){return un(e,5)},Vr.cloneDeepWith=function(e,t){return un(e,5,t="function"==typeof t?t:r)},Vr.cloneWith=function(e,t){return un(e,4,t="function"==typeof t?t:r)},Vr.conformsTo=function(e,t){return null==t||ln(e,t,Ma(t))},Vr.deburr=Ga,Vr.defaultTo=function(e,t){return null==e||e!=e?t:e},Vr.divide=wc,Vr.endsWith=function(e,t,n){e=Ea(e),t=li(t);var i=e.length,s=n=n===r?i:dn(va(n),0,i);return(n-=t.length)>=0&&e.slice(n,s)==t},Vr.eq=Ho,Vr.escape=function(e){return(e=Ea(e))&&K.test(e)?e.replace($,nr):e},Vr.escapeRegExp=function(e){return(e=Ea(e))&&ie.test(e)?e.replace(ne,"\\$&"):e},Vr.every=function(e,t,n){var i=Yo(e)?Rt:gn;return n&&Es(e,t,n)&&(t=r),i(e,us(t,3))},Vr.find=_o,Vr.findIndex=zs,Vr.findKey=function(e,t){return jt(e,us(t,3),wn)},Vr.findLast=bo,Vr.findLastIndex=Gs,Vr.findLastKey=function(e,t){return jt(e,us(t,3),Sn)},Vr.floor=Sc,Vr.forEach=Eo,Vr.forEachRight=wo,Vr.forIn=function(e,t){return null==e?e:bn(e,us(t,3),La)},Vr.forInRight=function(e,t){return null==e?e:En(e,us(t,3),La)},Vr.forOwn=function(e,t){return e&&wn(e,us(t,3))},Vr.forOwnRight=function(e,t){return e&&Sn(e,us(t,3))},Vr.get=Ia,Vr.gt=qo,Vr.gte=zo,Vr.has=function(e,t){return null!=e&&vs(e,t,In)},Vr.hasIn=Da,Vr.head=$s,Vr.identity=oc,Vr.includes=function(e,t,r,n){e=Jo(e)?e:Ha(e),r=r&&!n?va(r):0;var i=e.length;return r<0&&(r=_r(i+r,0)),ua(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Bt(e,t,r)>-1},Vr.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=_r(n+i,0)),Bt(e,t,i)},Vr.inRange=function(e,t,n){return t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r){return e>=br(t,r)&&e<_r(t,r)}(e=_a(e),t,n)},Vr.invoke=Na,Vr.isArguments=Go,Vr.isArray=Yo,Vr.isArrayBuffer=$o,Vr.isArrayLike=Jo,Vr.isArrayLikeObject=Ko,Vr.isBoolean=function(e){return!0===e||!1===e||ia(e)&&kn(e)==_},Vr.isBuffer=Qo,Vr.isDate=Zo,Vr.isElement=function(e){return ia(e)&&1===e.nodeType&&!aa(e)},Vr.isEmpty=function(e){if(null==e)return!0;if(Jo(e)&&(Yo(e)||"string"==typeof e||"function"==typeof e.splice||Qo(e)||pa(e)||Go(e)))return!e.length;var t=gs(e);if(t==C||t==I)return!e.size;if(Ps(e))return!jn(e).length;for(var r in e)if(xe.call(e,r))return!1;return!0},Vr.isEqual=function(e,t){return Mn(e,t)},Vr.isEqualWith=function(e,t,n){var i=(n="function"==typeof n?n:r)?n(e,t):r;return i===r?Mn(e,t,r,n):!!i},Vr.isError=Xo,Vr.isFinite=function(e){return"number"==typeof e&&gr(e)},Vr.isFunction=ea,Vr.isInteger=ta,Vr.isLength=ra,Vr.isMap=sa,Vr.isMatch=function(e,t){return e===t||Ln(e,t,ps(t))},Vr.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,Ln(e,t,ps(t),n)},Vr.isNaN=function(e){return oa(e)&&e!=+e},Vr.isNative=function(e){if(Cs(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return xn(e)},Vr.isNil=function(e){return null==e},Vr.isNull=function(e){return null===e},Vr.isNumber=oa,Vr.isObject=na,Vr.isObjectLike=ia,Vr.isPlainObject=aa,Vr.isRegExp=ca,Vr.isSafeInteger=function(e){return ta(e)&&e>=-9007199254740991&&e<=p},Vr.isSet=da,Vr.isString=ua,Vr.isSymbol=la,Vr.isTypedArray=pa,Vr.isUndefined=function(e){return e===r},Vr.isWeakMap=function(e){return ia(e)&&gs(e)==O},Vr.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==kn(e)},Vr.join=function(e,t){return null==e?"":vr.call(e,t)},Vr.kebabCase=Ya,Vr.last=Zs,Vr.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=va(n))<0?_r(i+s,0):br(s,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,s):Ut(e,Wt,s,!0)},Vr.lowerCase=$a,Vr.lowerFirst=Ja,Vr.lt=ha,Vr.lte=fa,Vr.max=function(e){return e&&e.length?vn(e,oc,Rn):r},Vr.maxBy=function(e,t){return e&&e.length?vn(e,us(t,2),Rn):r},Vr.mean=function(e){return Ht(e,oc)},Vr.meanBy=function(e,t){return Ht(e,us(t,2))},Vr.min=function(e){return e&&e.length?vn(e,oc,Bn):r},Vr.minBy=function(e,t){return e&&e.length?vn(e,us(t,2),Bn):r},Vr.stubArray=yc,Vr.stubFalse=_c,Vr.stubObject=function(){return{}},Vr.stubString=function(){return""},Vr.stubTrue=function(){return!0},Vr.multiply=Pc,Vr.nth=function(e,t){return e&&e.length?zn(e,va(t)):r},Vr.noConflict=function(){return pt._===this&&(pt._=Ve),this},Vr.noop=lc,Vr.now=Io,Vr.pad=function(e,t,r){e=Ea(e);var n=(t=va(t))?lr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return Gi(vt(i),r)+e+Gi(gt(i),r)},Vr.padEnd=function(e,t,r){e=Ea(e);var n=(t=va(t))?lr(e):0;return t&&n<t?e+Gi(t-n,r):e},Vr.padStart=function(e,t,r){e=Ea(e);var n=(t=va(t))?lr(e):0;return t&&n<t?Gi(t-n,r)+e:e},Vr.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),wr(Ea(e).replace(se,""),t||0)},Vr.random=function(e,t,n){if(n&&"boolean"!=typeof n&&Es(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=ga(e),t===r?(t=e,e=0):t=ga(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var s=Sr();return br(e+s*(t-e+ct("1e-"+((s+"").length-1))),t)}return Kn(e,t)},Vr.reduce=function(e,t,r){var n=Yo(e)?Mt:Gt,i=arguments.length<3;return n(e,us(t,4),r,i,fn)},Vr.reduceRight=function(e,t,r){var n=Yo(e)?Lt:Gt,i=arguments.length<3;return n(e,us(t,4),r,i,mn)},Vr.repeat=function(e,t,n){return t=(n?Es(e,t,n):t===r)?1:va(t),Qn(Ea(e),t)},Vr.replace=function(){var e=arguments,t=Ea(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Vr.result=function(e,t,n){var i=-1,s=(t=Ei(t,e)).length;for(s||(s=1,e=r);++i<s;){var o=null==e?r:e[Us(t[i])];o===r&&(i=s,o=n),e=ea(o)?o.call(e):o}return e},Vr.round=Tc,Vr.runInContext=e,Vr.sample=function(e){return(Yo(e)?Zr:Xn)(e)},Vr.size=function(e){if(null==e)return 0;if(Jo(e))return ua(e)?lr(e):e.length;var t=gs(e);return t==C||t==I?e.size:jn(e).length},Vr.snakeCase=Ka,Vr.some=function(e,t,n){var i=Yo(e)?xt:oi;return n&&Es(e,t,n)&&(t=r),i(e,us(t,3))},Vr.sortedIndex=function(e,t){return ai(e,t)},Vr.sortedIndexBy=function(e,t,r){return ci(e,t,us(r,2))},Vr.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ai(e,t);if(n<r&&Ho(e[n],t))return n}return-1},Vr.sortedLastIndex=function(e,t){return ai(e,t,!0)},Vr.sortedLastIndexBy=function(e,t,r){return ci(e,t,us(r,2),!0)},Vr.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var r=ai(e,t,!0)-1;if(Ho(e[r],t))return r}return-1},Vr.startCase=Qa,Vr.startsWith=function(e,t,r){return e=Ea(e),r=null==r?0:dn(va(r),0,e.length),t=li(t),e.slice(r,r+t.length)==t},Vr.subtract=kc,Vr.sum=function(e){return e&&e.length?Yt(e,oc):0},Vr.sumBy=function(e,t){return e&&e.length?Yt(e,us(t,2)):0},Vr.template=function(e,t,n){var i=Vr.templateSettings;n&&Es(e,t,n)&&(t=r),e=Ea(e),t=Ca({},t,i,es);var s,o,a=Ca({},t.imports,i.imports,es),c=Ma(a),d=Qt(a,c),u=0,l=t.interpolate||Ee,p="__p += '",h=Re((t.escape||Ee).source+"|"+l.source+"|"+(l===X?he:Ee).source+"|"+(t.evaluate||Ee).source+"|$","g"),f="//# sourceURL="+(xe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++it+"]")+"\n";e.replace(h,(function(t,r,n,i,a,c){return n||(n=i),p+=e.slice(u,c).replace(we,ir),r&&(s=!0,p+="' +\n__e("+r+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),p+="';\n";var m=xe.call(t,"variable")&&t.variable;if(m){if(le.test(m))throw new Ce("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(q,""):p).replace(z,"$1").replace(G,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var g=tc((function(){return Pe(c,f+"return "+p).apply(r,d)}));if(g.source=p,Xo(g))throw g;return g},Vr.times=function(e,t){if((e=va(e))<1||e>p)return[];var r=m,n=br(e,m);t=us(t),e-=m;for(var i=$t(n,t);++r<e;)t(r);return i},Vr.toFinite=ga,Vr.toInteger=va,Vr.toLength=ya,Vr.toLower=function(e){return Ea(e).toLowerCase()},Vr.toNumber=_a,Vr.toSafeInteger=function(e){return e?dn(va(e),-9007199254740991,p):0===e?e:0},Vr.toString=Ea,Vr.toUpper=function(e){return Ea(e).toUpperCase()},Vr.trim=function(e,t,n){if((e=Ea(e))&&(n||t===r))return Jt(e);if(!e||!(t=li(t)))return e;var i=pr(e),s=pr(t);return Si(i,Xt(i,s),er(i,s)+1).join("")},Vr.trimEnd=function(e,t,n){if((e=Ea(e))&&(n||t===r))return e.slice(0,hr(e)+1);if(!e||!(t=li(t)))return e;var i=pr(e);return Si(i,0,er(i,pr(t))+1).join("")},Vr.trimStart=function(e,t,n){if((e=Ea(e))&&(n||t===r))return e.replace(se,"");if(!e||!(t=li(t)))return e;var i=pr(e);return Si(i,Xt(i,pr(t))).join("")},Vr.truncate=function(e,t){var n=30,i="...";if(na(t)){var s="separator"in t?t.separator:s;n="length"in t?va(t.length):n,i="omission"in t?li(t.omission):i}var o=(e=Ea(e)).length;if(sr(e)){var a=pr(e);o=a.length}if(n>=o)return e;var c=n-lr(i);if(c<1)return i;var d=a?Si(a,0,c).join(""):e.slice(0,c);if(s===r)return d+i;if(a&&(c+=d.length-c),ca(s)){if(e.slice(c).search(s)){var u,l=d;for(s.global||(s=Re(s.source,Ea(fe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;d=d.slice(0,p===r?c:p)}}else if(e.indexOf(li(s),c)!=c){var h=d.lastIndexOf(s);h>-1&&(d=d.slice(0,h))}return d+i},Vr.unescape=function(e){return(e=Ea(e))&&J.test(e)?e.replace(Y,fr):e},Vr.uniqueId=function(e){var t=++Fe;return Ea(e)+t},Vr.upperCase=Za,Vr.upperFirst=Xa,Vr.each=Eo,Vr.eachRight=wo,Vr.first=$s,uc(Vr,(Cc={},wn(Vr,(function(e,t){xe.call(Vr.prototype,t)||(Cc[t]=e)})),Cc),{chain:!1}),Vr.VERSION="4.17.21",Tt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Vr[e].placeholder=Vr})),Tt(["drop","take"],(function(e,t){zr.prototype[e]=function(n){n=n===r?1:_r(va(n),0);var i=this.__filtered__&&!t?new zr(this):this.clone();return i.__filtered__?i.__takeCount__=br(n,i.__takeCount__):i.__views__.push({size:br(n,m),type:e+(i.__dir__<0?"Right":"")}),i},zr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Tt(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;zr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:us(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Tt(["head","last"],(function(e,t){var r="take"+(t?"Right":"");zr.prototype[e]=function(){return this[r](1).value()[0]}})),Tt(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");zr.prototype[e]=function(){return this.__filtered__?new zr(this):this[r](1)}})),zr.prototype.compact=function(){return this.filter(oc)},zr.prototype.find=function(e){return this.filter(e).head()},zr.prototype.findLast=function(e){return this.reverse().find(e)},zr.prototype.invokeMap=Zn((function(e,t){return"function"==typeof e?new zr(this):this.map((function(r){return On(r,e,t)}))})),zr.prototype.reject=function(e){return this.filter(jo(us(e)))},zr.prototype.slice=function(e,t){e=va(e);var n=this;return n.__filtered__&&(e>0||t<0)?new zr(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=va(t))<0?n.dropRight(-t):n.take(t-e)),n)},zr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zr.prototype.toArray=function(){return this.take(m)},wn(zr.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=Vr[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);s&&(Vr.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof zr,d=a[0],u=c||Yo(t),l=function(e){var t=s.apply(Vr,Nt([e],a));return i&&p?t[0]:t};u&&n&&"function"==typeof d&&1!=d.length&&(c=u=!1);var p=this.__chain__,h=!!this.__actions__.length,f=o&&!p,m=c&&!h;if(!o&&u){t=m?t:new zr(this);var g=e.apply(t,a);return g.__actions__.push({func:go,args:[l],thisArg:r}),new qr(g,p)}return f&&m?e.apply(this,a):(g=this.thru(l),f?i?g.value()[0]:g.value():g)})})),Tt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ae[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);Vr.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Yo(i)?i:[],e)}return this[r]((function(r){return t.apply(Yo(r)?r:[],e)}))}})),wn(zr.prototype,(function(e,t){var r=Vr[t];if(r){var n=r.name+"";xe.call(Or,n)||(Or[n]=[]),Or[n].push({name:t,func:r})}})),Or[Wi(r,2).name]=[{name:"wrapper",func:r}],zr.prototype.clone=function(){var e=new zr(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},zr.prototype.reverse=function(){if(this.__filtered__){var e=new zr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Yo(e),n=t<0,i=r?e.length:0,s=function(e,t,r){var n=-1,i=r.length;for(;++n<i;){var s=r[n],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=br(t,e+o);break;case"takeRight":e=_r(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=s.start,a=s.end,c=a-o,d=n?a:o-1,u=this.__iteratees__,l=u.length,p=0,h=br(c,this.__takeCount__);if(!r||!n&&i==c&&h==c)return gi(e,this.__actions__);var f=[];e:for(;c--&&p<h;){for(var m=-1,g=e[d+=t];++m<l;){var v=u[m],y=v.iteratee,_=v.type,b=y(g);if(2==_)g=b;else if(!b){if(1==_)continue e;break e}}f[p++]=g}return f},Vr.prototype.at=vo,Vr.prototype.chain=function(){return mo(this)},Vr.prototype.commit=function(){return new qr(this.value(),this.__chain__)},Vr.prototype.next=function(){this.__values__===r&&(this.__values__=ma(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},Vr.prototype.plant=function(e){for(var t,n=this;n instanceof Hr;){var i=Vs(n);i.__index__=0,i.__values__=r,t?s.__wrapped__=i:t=i;var s=i;n=n.__wrapped__}return s.__wrapped__=e,t},Vr.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof zr){var t=e;return this.__actions__.length&&(t=new zr(this)),(t=t.reverse()).__actions__.push({func:go,args:[ro],thisArg:r}),new qr(t,this.__chain__)}return this.thru(ro)},Vr.prototype.toJSON=Vr.prototype.valueOf=Vr.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},Vr.prototype.first=Vr.prototype.head,tt&&(Vr.prototype[tt]=function(){return this}),Vr}();ft?((ft.exports=mr)._=mr,ht._=mr):pt._=mr}).call(f)}(Hb,Hb.exports);var qb,zb=f&&f.__extends||(qb=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}qb(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(Wb,"__esModule",{value:!0});var Gb,Yb,$b,Jb,Kb,Qb,Zb,Xb,eE,tE=i.default,rE=Hb.exports,nE=["MaxBatchSize","MaxDelay","MinDelay"],iE=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(nE.forEach((function(t){if(!e.hasOwnProperty(t))throw new Error("Missing required MessageBatcher option: "+t)})),isNaN(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a number");if(!isFinite(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a finite number");if(e.MaxBatchSize<1)throw new Error("MessageBatcher MaxBatchSize option cannot be less than 1");if(isNaN(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a number");if(!isFinite(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a finite number");if(e.MaxDelay<0)throw new Error("MessageBatcher MaxDelay option cannot be less than 0");if(isNaN(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a number");if(!isFinite(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a finite number");if(e.MinDelay<0)throw new Error("MessageBatcher MinDelay option cannot be less than 0");if(e.MinDelay>e.MaxDelay)throw new Error("MessageBatcher MinDelay option cannot be greater than MaxDelay")}(t),r.options=t,r.releaseBatchDebouncedMax=rE.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=rE.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return zb(t,e),t.prototype.Queue=function(e){var t=this;(e=[].concat(e)).forEach((function(e){t.fifo.push(e),t.debounce(t.fifo,t.options.MaxBatchSize)}),this)},t.prototype.debounce=function(e,t){e.length>0&&(e.length>=t?this.firstBatch?(this.firstBatch=!1,this.releaseBatchDebouncedMax.flush()):(this.releaseBatchDebouncedMax.cancel(),this.releaseBatchDebouncedMin(e,t)):(this.releaseBatchDebouncedMin.cancel(),this.releaseBatchDebouncedMax(e,t)))},t.prototype.releaseBatch=function(e,t){var r=this.drainFIFO(e,t);r&&r.length&&(this.emit("batch",r),this.debounce(e,t))},t.prototype.drainFIFO=function(e,t){return e.length>0?e.splice(0,t):e},t}(tE.EventEmitter);Wb.MessageBatcher=iE,Gb=Vb,Object.defineProperty(Gb,"__esModule",{value:!0}),function(e){for(var t in e)Gb.hasOwnProperty(t)||(Gb[t]=e[t])}(Wb),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Vb)}(Bb);class sE{constructor(e){Yb.add(this),$b.set(this,void 0),Jb.set(this,void 0),Kb.set(this,void 0),Qb.set(this,void 0),Zb.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;p(this,$b,r,"f"),p(this,Jb,t,"f"),this.onLogMessage=n,p(this,Qb,new _b,"f"),p(this,Kb,new Bb.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),p(this,Zb,e.sendAnalytics,"f"),l(this,Kb,"f").on("batch",(e=>{this.logToApi(e).catch((e=>{this.error("Failed to log to api",{case:"Logger",error:mr(e)})}))})),this._debug=Ub("LiveDigital").extend("debug").extend(l(this,$b,"f")),this._info=Ub("LiveDigital").extend("info").extend(l(this,$b,"f")),this._warn=Ub("LiveDigital").extend("warn").extend(l(this,$b,"f")),this._error=Ub("LiveDigital").extend("error").extend(l(this,$b,"f")),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}debug(e,t){this._debug(e,t),l(this,Zb,"f")&&l(this,Kb,"f").Queue({level:"debug",message:e,meta:t}),l(this,Jb,"f")>=gt&&l(this,Yb,"m",Xb).call(this,"debug",e,t)}info(e,t){this._info(e,t),l(this,Zb,"f")&&l(this,Kb,"f").Queue({level:"info",message:e,meta:t}),l(this,Jb,"f")>=mt&&l(this,Yb,"m",Xb).call(this,"info",e,t)}warn(e,t){this._warn(e,t),l(this,Zb,"f")&&l(this,Kb,"f").Queue({level:"warn",message:e,meta:t}),l(this,Jb,"f")>=ft&&l(this,Yb,"m",Xb).call(this,"warn",e,t)}error(e,t){this._error(e,t),l(this,Zb,"f")&&l(this,Kb,"f").Queue({level:"error",message:e,meta:t}),l(this,Jb,"f")>=ht&&l(this,Yb,"m",Xb).call(this,"error",e,t)}logToApi(e){return u(this,void 0,void 0,(function*(){try{yield l(this,Qb,"f").log.batch({logs:e.map((e=>l(this,Yb,"m",eE).call(this,Object.assign(Object.assign({},e),{meta:this.prepareRecordMeta(e.meta)})))),clientMeta:this.getClientMeta()})}catch(e){this._debug("Log request was not successful",{error:e})}}))}getClientMeta(){return Object.assign(Object.assign({},gr.meta),{clUId:ib()})}prepareRecordMeta(e){const t=null!=e?e:{},{error:r}=t;return Object.assign(Object.assign(Object.assign({},t),{clientTimestamp:(new Date).toISOString(),from_sdk:!0}),r&&"object"==typeof r?{error:mr(r)}:{})}}$b=new WeakMap,Jb=new WeakMap,Kb=new WeakMap,Qb=new WeakMap,Zb=new WeakMap,Yb=new WeakSet,Xb=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...l(this,Yb,"m",eE).call(this,r),e)},eE=function(e){const t=new WeakMap;return function e(r,n=[]){if(!xn(r))return r;const i=t.get(r);if(i)return`[Circular *${i.join(".")}]`;t.set(r,n);const s=Array.isArray(r)?[]:{};return Object.entries(r).forEach((([t,r])=>{s[t]=e(r,[...n,t])})),t.delete(r),s}(e)};let oE=class{constructor(e){this.peerTrackFactory=e,this.tracksByConsumerId=new Map}register(e,t){this.tracksByConsumerId.set(e,t)}get(e){return this.tracksByConsumerId.get(e)}delete(e){return this.tracksByConsumerId.delete(e)}reset(){this.tracksByConsumerId.clear()}create(e){const{consumer:t,label:r,muted:n=!1,mediaStreamTrack:i,paused:s,peerEventEmitter:o}=e,a=this.peerTrackFactory({consumer:t,label:r,mediaStreamTrack:i,paused:s,peerEventEmitter:o,muted:n,onClose:()=>{void 0!==a.consumerId&&this.delete(a.consumerId)}});return void 0!==a.consumerId&&this.register(a.consumerId,a),a}};var aE,cE,dE;oE=a([ut(),c(0,pt(Gn.PeerTrackFactory)),d("design:paramtypes",[Function])],oE);const uE=["frozen-video-track","network-media-sync-failure","encoder-cpu-throttling","decoder-cpu-throttling","missing-video-stream-data","missing-audio-stream-data"];let lE=class{constructor(e,t,r,n,i,s){this.analyticsApiClient=e,this.peers=t,this.socket=r,this.myPeer=n,this.transportsStatsProvider=s,aE.set(this,void 0),cE.set(this,void 0),dE.set(this,void 0),p(this,dE,i("IntegrationsService"),"f"),p(this,cE,new Bb.MessageBatcher({MaxBatchSize:50,MaxDelay:6e4,MinDelay:3e4}),"f"),l(this,cE,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendWIDMetrics({reasons:e,clientMeta:this.getClientMeta()}).catch((e=>{l(this,dE,"f").debug("Failed to sendWIDMetrics",{error:mr(e)})}))})),p(this,aE,new Bb.MessageBatcher({MaxBatchSize:100,MaxDelay:6e4,MinDelay:3e4}),"f"),l(this,aE,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendNetworkMetrics({metrics:e,clientMeta:this.getClientMeta()}).catch((e=>{l(this,dE,"f").debug("Failed to sendNetworkMetrics",{error:mr(e)})}))}))}handleIssues(e){e.forEach((e=>l(this,dE,"f").info("WebRTCIssue",e)));const t=e.filter((e=>uE.includes(e.reason)));0!==t.length&&t.forEach((e=>l(this,cE,"f").Queue(e.reason)))}handleNetworkScores(e){var t,r,n,i,s;const{inbound:o,outbound:a,statsSamples:{inboundStatsSample:c,outboundStatsSample:d}}=e,u=this.getNodeActiveStreamsStat(),p=null===(t=u.node)||void 0===t?void 0:t.replace(/https:\/\/app-\d+-/,""),h=this.transportsStatsProvider.getStats();if(void 0!==o&&c){const e={jitter:Math.round(1e3*c.avgJitter),packetLoss:c.packetsLoss,rtt:c.rtt,mos:Math.round(10*o)/10,streams:u.inboundActiveStreams,direction:"inbound",node:null!=p?p:"unknown node",bitrate:null!==(n=null===(r=null==h?void 0:h.inbound)||void 0===r?void 0:r.bitrate)&&void 0!==n?n:0,timestamp:(new Date).toISOString()};l(this,aE,"f").Queue(e)}if(void 0!==a&&d){const e={jitter:Math.round(1e3*d.avgJitter),packetLoss:d.packetsLoss,rtt:d.rtt,mos:Math.round(10*a)/10,streams:u.outboundActiveStreams,direction:"outbound",node:null!=p?p:"unknown node",bitrate:null!==(s=null===(i=null==h?void 0:h.outbound)||void 0===i?void 0:i.bitrate)&&void 0!==s?s:0,timestamp:(new Date).toISOString()};l(this,aE,"f").Queue(e)}}getNodeActiveStreamsStat(){var e;const t=this.socket.getServerUrl(),r=this.peers.hosts().filter((e=>{var t;return e.id!==(null===(t=this.myPeer)||void 0===t?void 0:t.id)})).reduce(((e,t)=>e+t.getActiveTracksCount()),0),n=this.myPeer.get();return{node:t,inboundActiveStreams:r,outboundActiveStreams:null!==(e=null==n?void 0:n.getActivePublishersCount())&&void 0!==e?e:0}}getClientMeta(){return Object.assign(Object.assign({},gr.meta),{clientUniqueId:ib()})}};aE=new WeakMap,cE=new WeakMap,dE=new WeakMap,lE=a([ut(),c(0,pt(Gn.AnalyticsApiClient)),c(1,pt(Gn.Peers)),c(2,pt(Gn.SocketIO)),c(3,pt(Gn.MyPeer)),c(4,pt(Gn.LoggerFactory)),c(5,pt(Gn.TransportsStatsProvider)),d("design:paramtypes",[_b,Object,fa,Vs,Function,K_])],lE);var pE,hE,fE,mE,gE,vE,yE,_E,bE,EE=lE;!function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(yE||(yE={})),function(e){e[e.PERFORMANCE_STOP=1001]="PERFORMANCE_STOP",e[e.REDUCE_LATENCY=1002]="REDUCE_LATENCY"}(_E||(_E={})),function(e){e.ATSVB="atsvb",e.STREAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.MODEL="model",e.WORKLET="worklet",e.WORKER="worker",e.MODEL_LOADER="model_loader"}(bE||(bE={}));const wE=()=>{};class SE{constructor(e){pE.set(this,void 0),hE.set(this,void 0),fE.set(this,null),mE.set(this,new Map),gE.set(this,void 0),this.type="asdk",vE.set(this,void 0);const{loggerFactory:t}=e;p(this,hE,t("ASDKTrackProcessor"),"f"),p(this,vE,"function"==typeof e.onError?e.onError:wE,"f"),p(this,pE,new window.atsvb(e.asdkCustomerId),"f");const n=e.config.get("staticFilesPath"),{localDir:i,version:s,sdk_url:o,api_url:a}=e.config.get("asdk");let c=`https://effectssdk.ai/sdk/audio/dev/${null!=s?s:"2.4.3"}`;if(i){c=new r.URL(`${i}/${null!=s?s:"2.4.3"}`,n).href}const d={preset:"balanced",sample_rate:48e3,api_url:a,wasmPaths:{"ort-wasm.wasm":`${c}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${c}/ort-wasm-simd.wasm`}},u=!o&&i,h=u?`${c}/`:o;u&&l(this,hE,"f").warn("Using static ASDK path due to missing config",Object.assign(Object.assign({case:"Denoiser",type:"asdk"},e.config.get("asdk")),{sdkUrl:d.sdk_url})),h&&(d.sdk_url=h),l(this,pE,"f").config(d),l(this,pE,"f").onError(this.onError.bind(this))}setOnError(e){p(this,vE,e,"f")}init(){return u(this,void 0,void 0,(function*(){yield l(this,pE,"f").preload()}))}get isProcessing(){return!!l(this,gE,"f")}processTrack(e){return u(this,void 0,void 0,(function*(){var t;if(l(this,fE,"f")===e||"ended"===e.readyState)return(null===(t=l(this,pE,"f").getStream())||void 0===t?void 0:t.getAudioTracks()[0])||e;this.stopProcessing();try{const t=new Promise(((t,r)=>{l(this,pE,"f").onReady=()=>{try{const r=l(this,pE,"f").getStream(),n=null==r?void 0:r.getAudioTracks()[0];if(!n)return void t(e);p(this,fE,e,"f"),p(this,gE,n,"f"),t(n),l(this,pE,"f").run()}catch(e){r(e)}finally{l(this,pE,"f").onReady=void 0}}}));l(this,pE,"f").useStream(new MediaStream([e]));const r=yield t;return l(this,hE,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),r}catch(t){throw l(this,hE,"f").error("processTrack()",{error:mr(t),type:this.type,case:"Denoiser",track:e}),l(this,vE,"f").call(this,"ASDK processTrack() error",t),p(this,vE,wE,"f"),new Error("Can not process this track")}}))}stopProcessing(){try{l(this,pE,"f").stop()}catch(e){l(this,hE,"f").error("stopProcessing()",{type:this.type,case:"Denoiser",error:mr(e)})}finally{p(this,fE,null,"f")}}getUpdatedDebounceCounter(e){var t;let r=null!==(t=l(this,mE,"f").get(e))&&void 0!==t?t:0;return r+=1,l(this,mE,"f").set(e,r),setTimeout((()=>{var t;const r=null!==(t=l(this,mE,"f").get(e))&&void 0!==t?t:0;r<=0?l(this,mE,"f").set(e,0):l(this,mE,"f").set(e,r-1)}),1e4),r}onError(e){const{message:t,type:r,cause:n}=e,i=o(e,["message","type","cause"]);if(r===yE.ERROR)if(l(this,hE,"f").error(t,Object.assign(Object.assign({error:mr(n),cause:n},i),{type:this.type,case:"Denoiser"})),i.code===_E.REDUCE_LATENCY||i.code===_E.PERFORMANCE_STOP){this.getUpdatedDebounceCounter(i.code)>3&&(l(this,mE,"f").set(i.code,0),l(this,vE,"f").call(this,`ASDK performance issue(${i.code}): ${t}`,n),p(this,vE,wE,"f"))}else l(this,vE,"f").call(this,`ASDK runtime error: ${t}`,n),p(this,vE,wE,"f");r===yE.WARNING&&l(this,hE,"f").warn(t,Object.assign(Object.assign({},i),{type:this.type,case:"Denoiser"})),r===yE.INFO&&l(this,hE,"f").info(t,Object.assign(Object.assign({},i),{type:this.type,case:"Denoiser"}))}}pE=new WeakMap,hE=new WeakMap,fE=new WeakMap,mE=new WeakMap,gE=new WeakMap,vE=new WeakMap;class CE extends AudioWorkletNode{constructor(e){super(e.context,"rnnoise",{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{module:e.noiseSuppressor.module}}),this.port.onmessage=({data:e})=>{const t=Object.assign(new Event("status"),e);this.dispatchEvent(t)}}update(e){this.port.postMessage(e)}static register(e){return u(this,void 0,void 0,(function*(){const t=Tw.get(Gn.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var PE,TE,kE,RE,IE,DE;class AE{constructor(e){PE.set(this,void 0),TE.set(this,void 0),kE.set(this,void 0),RE.set(this,void 0),IE.set(this,void 0),DE.set(this,!0),p(this,PE,e.noiseSuppressor.instance.exports,"f"),p(this,TE,e.context,"f"),p(this,kE,new Float32Array(l(this,PE,"f").memory.buffer),"f"),p(this,RE,l(this,PE,"f").newState(),"f"),p(this,IE,l(this,TE,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return l(this,IE,"f")}update(e){e||(p(this,DE,!1,"f"),l(this,PE,"f").deleteState(l(this,RE,"f")));const t=Object.assign(new Event("status"),{vadProb:l(this,PE,"f").getVadProb(l(this,RE,"f"))});l(this,IE,"f").dispatchEvent(t)}setOnAudioProcess(){l(this,IE,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!l(this,DE,"f"))return;l(this,kE,"f").set(e.getChannelData(0),l(this,PE,"f").getInput(l(this,RE,"f"))/4);const r=t.getChannelData(0),n=l(this,PE,"f").pipe(l(this,RE,"f"),r.length)/4;n&&r.set(l(this,kE,"f").subarray(n,n+r.length))}))}}PE=new WeakMap,TE=new WeakMap,kE=new WeakMap,RE=new WeakMap,IE=new WeakMap,DE=new WeakMap;var OE,NE,ME,LE,xE,FE,jE,UE,BE,VE,WE,HE,qE,zE,GE,YE,$E,JE,KE,QE,ZE,XE,ew,tw,rw,nw,iw,sw,ow,aw,cw,dw,uw,lw,pw,hw,fw,mw,gw,vw;class yw{constructor({context:e,noiseSuppressor:t}){OE.set(this,void 0),NE.set(this,void 0),ME.set(this,void 0),p(this,OE,e,"f"),p(this,NE,t,"f")}createNoiseSuppressionNode(){return u(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():yield this.createAudioWorkletNode()}))}stop(){var e;null===(e=l(this,ME,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return u(this,void 0,void 0,(function*(){return yield CE.register(l(this,OE,"f")),p(this,ME,new CE({context:l(this,OE,"f"),noiseSuppressor:l(this,NE,"f")}),"f"),l(this,ME,"f")}))}createScriptProcessorNode(){return p(this,ME,new AE({context:l(this,OE,"f"),noiseSuppressor:l(this,NE,"f")}),"f"),l(this,ME,"f").noiseSuppressionScriptProcessorNode}}OE=new WeakMap,NE=new WeakMap,ME=new WeakMap;class _w{constructor(e){LE.set(this,void 0),xE.set(this,void 0),FE.set(this,void 0),jE.set(this,void 0),this.type="rnnoise",p(this,LE,e.noiseSuppressor,"f"),p(this,FE,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!l(this,jE,"f")}processTrack(e){return u(this,void 0,void 0,(function*(){const t=(e=>{const t=window.AudioContext||window.webkitAudioContext||!1;return t?new t(e):null})();if(!t)throw new Error("AudioContext is not available");const r=new MediaStreamAudioDestinationNode(t,{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers"});yield CE.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new yw({context:t,noiseSuppressor:l(this,LE,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return p(this,xE,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),p(this,jE,o,"f"),l(this,FE,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),o}))}stopProcessing(){var e;if(this.isProcessing)if(l(this,xE,"f"))try{l(this,xE,"f").noiseSuppressionProvider.stop(),l(this,xE,"f").noiseSuppressionNode.disconnect(),l(this,xE,"f").streamDestination.disconnect(),l(this,xE,"f").audioContext.close().catch((e=>{l(this,FE,"f").error("stopProcessing()",{success:!1,error:mr(e),case:"Denoiser",type:this.type})})),null===(e=l(this,jE,"f"))||void 0===e||e.stop(),p(this,jE,void 0,"f"),l(this,FE,"f").info("stopProcessing()",{success:!0,case:"Denoiser",type:this.type})}catch(e){l(this,FE,"f").error("stopProcessing()",{success:!1,error:mr(e),case:"Denoiser",type:this.type})}else l(this,FE,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available",case:"Denoiser",type:this.type});else l(this,FE,"f").debug("stopProcessing()",{description:"Track is not processed",case:"Denoiser",type:this.type})}}LE=new WeakMap,xE=new WeakMap,FE=new WeakMap,jE=new WeakMap;class bw extends Bf{constructor(e){super(e),UE.set(this,!1),BE.set(this,void 0),VE.set(this,void 0),WE.set(this,void 0),p(this,WE,e.clientEventEmitter,"f")}get isDenoiserRequireActivation(){var e;return!(null===(e=l(this,BE,"f"))||void 0===e?void 0:e.isProcessing)&&l(this,UE,"f")}setTrackProcessor(e){if(!e)throw new Error("trackProcessor must be passed as parameter");this.logger.debug("Setting trackProcessor to AudioTrack",{case:"Denoiser",type:e.type}),p(this,BE,e,"f")}unsetTrackProcessor(){p(this,BE,void 0,"f")}get isEffectsProcessing(){var e;return Boolean(null===(e=l(this,BE,"f"))||void 0===e?void 0:e.isProcessing)}getEncoderConfig(){return this.encoderConfig}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Jh}getCodecOptions(){var e,t;return{opusFec:null===(e=this.getEncoderConfig().enableFec)||void 0===e||e,opusDtx:null===(t=this.getEncoderConfig().enableDtx)||void 0===t||t}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||"opus"}enableNoiseSuppression(){return u(this,void 0,void 0,(function*(){var e,t,r;if(p(this,UE,!0,"f"),!l(this,BE,"f"))return this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"}),void l(this,WE,"f").emit(Jr,{cause:"Track suppressor is not defined"});try{const n=yield null===(e=l(this,BE,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);p(this,VE,this.mediaStreamTrack,"f"),yield this.replaceTrack(n),this.logger.debug("Denoiser activated",{case:"Denoiser",type:(null===(t=l(this,BE,"f"))||void 0===t?void 0:t.type)||"none"}),l(this,WE,"f").emit(Gr,{type:null===(r=l(this,BE,"f"))||void 0===r?void 0:r.type})}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:mr(e)}),l(this,WE,"f").emit(Jr,{cause:"Failed to enable noise suppression",error:e}),new Error("Can not enable noise suppression")}}))}disableNoiseSuppression(){return u(this,void 0,void 0,(function*(){var e,t,r,n;p(this,UE,!1,"f");try{if(!(null===(e=l(this,BE,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!l(this,VE,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});yield this.replaceTrack(l(this,VE,"f")),null===(t=l(this,BE,"f"))||void 0===t||t.stopProcessing(),this.logger.debug("Denoiser deactivated",{case:"Denoiser",type:(null===(r=l(this,BE,"f"))||void 0===r?void 0:r.type)||"none"}),l(this,WE,"f").emit(Yr,{type:null===(n=l(this,BE,"f"))||void 0===n?void 0:n.type})}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:mr(e)}),l(this,WE,"f").emit(Jr,{cause:"Failed to disable noise suppression",error:e}),new Error("Can not disable noise suppression")}}))}publish(){return u(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(Qr.trackProduced,this)}))}pause(){return u(this,void 0,void 0,(function*(){yield this.mute()}))}}UE=new WeakMap,BE=new WeakMap,VE=new WeakMap,WE=new WeakMap;class Ew{constructor({track:e,statsHandler:t}){HE.set(this,void 0),qE.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return l(this,HE,"f")}get audioWebRTCStats(){return l(this,qE,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addInboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addInboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){p(this,HE,e,"f")}setAudioWebRTCStats(e){p(this,qE,e,"f")}}HE=new WeakMap,qE=new WeakMap;class ww{constructor(e){this.label=$n.Unknown,zE.set(this,void 0),GE.set(this,void 0),YE.set(this,void 0),$E.set(this,void 0),JE.set(this,void 0),KE.set(this,void 0),QE.set(this,void 0),ZE.set(this,void 0),XE.set(this,void 0),ew.set(this,void 0),tw.set(this,!1),rw.set(this,void 0),nw.set(this,!1),iw.set(this,new Tm),sw.set(this,!1),ow.set(this,0),aw.set(this,void 0),this.observer=new It,p(this,XE,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,p(this,JE,e.peerConsumerFactory,"f"),p(this,QE,e.loggerFactory("PeerTrack"),"f"),p(this,ZE,e.peerEventEmitter,"f"),p(this,sw,e.muted,"f"),p(this,ew,e.paused,"f"),p(this,zE,e.network,"f"),p(this,GE,e.socket,"f"),p(this,YE,e.media,"f"),p(this,KE,e.callState,"f"),p(this,$E,e.onClose,"f"),p(this,aw,new Ew({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return l(this,aw,"f").videoWebRTCStats}get audioWebRTCStats(){return l(this,aw,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:l(this,XE,"f").id,label:this.label,consumerId:null===(e=this.consumer)||void 0===e?void 0:e.id,producerId:null===(t=this.consumer)||void 0===t?void 0:t.producerId,muted:l(this,sw,"f"),paused:l(this,ew,"f"),closed:l(this,nw,"f")}}get volume(){return l(this,ow,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return l(this,XE,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return l(this,ew,"f")}get isMuted(){return l(this,sw,"f")}get consumerId(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.id}get currentSpatialLayer(){var e,t;return null!==(t=null===(e=this.consumer)||void 0===e?void 0:e.currentSpatialLayer)&&void 0!==t?t:Qh}close(){return u(this,void 0,void 0,(function*(){l(this,ZE,"f").safeEmit(nn,this),p(this,nw,!0,"f"),l(this,$E,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return u(this,void 0,void 0,(function*(){yield l(this,iw,"f").push((()=>u(this,void 0,void 0,(function*(){l(this,QE,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),p(this,sw,!0,"f")}))))}))}unmute(){return u(this,void 0,void 0,(function*(){yield l(this,iw,"f").push((()=>u(this,void 0,void 0,(function*(){l(this,QE,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),p(this,sw,!1,"f")}))))}))}pause(){return u(this,arguments,void 0,(function*(e=!0){yield l(this,iw,"f").push((()=>u(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return p(this,ew,!0,"f"),l(this,ZE,"f").safeEmit(sn,this),void l(this,QE,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),p(this,ew,!0,"f"),l(this,ZE,"f").safeEmit(sn,this)}))))}))}resume(){return u(this,arguments,void 0,(function*(e=!0){yield l(this,iw,"f").push((()=>u(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return p(this,ew,!1,"f"),l(this,ZE,"f").safeEmit(on,this),void l(this,QE,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),p(this,ew,!1,"f"),l(this,ZE,"f").safeEmit(on,this)}))))}))}resumeConsumer(){return u(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{this.consumer.resume(),e&&(yield l(this,zE,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{l(this,QE,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:mr(e)})})),l(this,QE,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){l(this,QE,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(){return u(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{this.clearCheckStateTimeout(),e&&(yield l(this,zE,"f").pauseRemoteConsumer(this.consumer.id)),this.consumer.pause(),p(this,tw,!1,"f"),l(this,QE,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){l(this,QE,"f").warn("pauseConsumer()",{error:e})}}))}requestVideoPreferredLayers(e){return u(this,arguments,void 0,(function*({spatialLayer:e,temporalLayer:t}){if(this.consumer)try{if(this.consumer.isAudio)return void l(this,QE,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void l(this,QE,"f").warn("Invalid spatial layer",{spatialLayer:e,consumerSpatialLayers:this.consumer.spatialLayers,case:"requestVideoPreferredLayers"});if(e>this.consumer.currentMaxSpatialLayer)return void(yield this.requestMaxSpatialLayer(this.consumer.id,e));yield l(this,GE,"f").request(wn,{consumerId:this.consumer.id,spatialLayer:e,temporalLayer:t}),l(this,QE,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw l(this,QE,"f").error("Failed to request preferred layers",{case:"requestVideoPreferredLayers",track:{id:this.mediaStreamTrack.id,kind:this.mediaStreamTrack.kind,label:this.mediaStreamTrack.label},consumerId:this.consumer.id,spatialLayers:this.consumer.spatialLayers,temporalLayers:this.consumer.temporalLayers,error:e}),new Error("Error request preferred layers")}}))}requestKeyFrame(){return u(this,void 0,void 0,(function*(){if(this.consumerId){l(this,QE,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield l(this,GE,"f").request(Sn,{consumerId:this.consumerId})}catch(e){throw l(this,QE,"f").error("requestKeyFrame()",{error:e,track:this.logCtx,consumerId:this.consumerId}),new Error("Failed to request key frame")}}}))}getVideoAvailableLayers(){if(this.consumer){if(!this.consumer.isAudio)return this.consumer.availableSpatialLayers;l(this,QE,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){return u(this,void 0,void 0,(function*(){var e;const{width:t,height:r,frameRate:n,aspectRatio:i}=l(this,XE,"f").getSettings();return{trackId:l(this,XE,"f").id,readyState:l(this,XE,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:l(this,ew,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return u(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=l(this,YE,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?yield e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return u(this,void 0,void 0,(function*(){try{if(!this.consumer)return;if(this.consumer.isAudio||0===this.consumer.spatialLayers||this.consumer.currentMaxSpatialLayer===t||t<this.consumer.currentMaxSpatialLayer)return void l(this,QE,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield l(this,GE,"f").request(gn,{producerId:this.consumer.producerId,spatialLayer:t}),l(this,QE,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){l(this,QE,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return u(this,void 0,void 0,(function*(){try{if(l(this,nw,"f")||"audio"===this.kind)return;l(this,QE,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||l(this,nw,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||l(this,nw,"f"))return;if(l(this,tw,"f"))return l(this,ZE,"f").emit(an,this),void l(this,QE,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){l(this,QE,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){l(this,ow,"f")!==e&&(p(this,ow,e,"f"),this.observer.safeEmit(Kr,{value:e}))}closeConsumer(){return u(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield l(this,zE,"f").closeRemoteConsumer(this.consumer.id)}catch(e){l(this,QE,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return u(this,void 0,void 0,(function*(){try{if(!this.consumer||l(this,nw,"f"))return;l(this,QE,"f").debug("restartConsumer()",{track:this.logCtx}),l(this,ZE,"f").emit(nn,this),p(this,ew,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield l(this,zE,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:l(this,YE,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:l(this,KE,"f").appId,channelId:l(this,KE,"f").channelId});p(this,tw,!0,"f"),this.consumer=l(this,JE,"f").call(this,{consumer:e}),p(this,XE,e.track,"f"),yield this.resume(),l(this,ZE,"f").emit(rn,this)}catch(e){p(this,tw,!0,"f"),l(this,QE,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return u(this,void 0,void 0,(function*(){if(!this.consumer||l(this,nw,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return yield new Promise((t=>{p(this,rw,setTimeout((()=>u(this,void 0,void 0,(function*(){try{if(!this.consumer)return void t(!1);const{framesDecoded:r}=yield this.consumer.getInboundRTPStreamStats();if(e===r&&!this.isPaused)return void t(!1);t(!0)}catch(e){l(this,QE,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){l(this,rw,"f")||clearTimeout(l(this,rw,"f"))}}zE=new WeakMap,GE=new WeakMap,YE=new WeakMap,$E=new WeakMap,JE=new WeakMap,KE=new WeakMap,QE=new WeakMap,ZE=new WeakMap,XE=new WeakMap,ew=new WeakMap,tw=new WeakMap,rw=new WeakMap,nw=new WeakMap,iw=new WeakMap,sw=new WeakMap,ow=new WeakMap,aw=new WeakMap;class Sw{constructor(e){this.encodings=[];const{id:t,kind:r,peerId:n,label:i,paused:s}=e;this.id=t,this.kind=r,this.peerId=n,this.label=i,this.paused=s,this.encodings=e.encodings,this.trackTransformParams=e.trackTransformParams,this.maxSpatialLayer=e.maxSpatialLayer}}class Cw{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:c,role:d,loggerFactory:u,myPeer:l,callState:h,peers:f,remotePeerTracks:m,media:g,network:v,socket:y,peerConsumerFactory:_}){this.producers=new Map,this.tracks=new Map,cw.set(this,void 0),dw.set(this,void 0),uw.set(this,void 0),lw.set(this,void 0),pw.set(this,void 0),hw.set(this,void 0),fw.set(this,void 0),mw.set(this,void 0),gw.set(this,void 0),this._observer=new It,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=null!=a?a:{},this.uid=c,this.role=d,p(this,hw,l,"f"),p(this,fw,h,"f"),p(this,cw,f,"f"),p(this,dw,m,"f"),p(this,lw,y,"f"),p(this,mw,_,"f"),p(this,uw,v,"f"),p(this,pw,g,"f"),p(this,gw,u("Peer"),"f"),o.forEach(this.handleNewProducer.bind(this)),this.handlePeerEvents()}get appData(){return this.applicationData}get observer(){return this._observer}get isMe(){return this.id===l(this,hw,"f").id}get isModerator(){return this.groups.includes("moderator")}get isUser(){return this.groups.includes("user")}get publishedMedia(){return Array.from(this.producers.values()).map((e=>({producerId:e.id,kind:e.kind,label:e.label,paused:e.paused})))}get shortData(){return{id:this.id,producers:Array.from(this.producers.values()).map((e=>({id:e.id,paused:e.paused}))),appData:this.appData}}hasPermission(e){return this.producePermissions.includes(e)}hasGroup(e){return this.groups.includes(e)}subscribe(e){return u(this,arguments,void 0,(function*({producerId:e,muted:t=!1}){try{const r=this.producers.get(e);if(!r)return void l(this,gw,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:Bs(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void l(this,gw,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:Bs(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield l(this,uw,"f").createConsumer({producerId:r.id,rtpCapabilities:l(this,pw,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:l(this,fw,"f").appId,channelId:l(this,fw,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values($n).includes(r.label))return void l(this,gw,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:Bs(this),producerId:e});const s=l(this,dw,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:l(this,mw,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),l(this,gw,"f").debug(`Subscribed for ${r.kind}`,{peer:Bs(this)})}catch(t){throw l(this,gw,"f").error("subscribe()",{producerId:e,error:t,peer:Bs(this)}),new Error("Error subscribe media")}}))}unsubscribe(e){return u(this,void 0,void 0,(function*(){try{const t=this.getConsumerByProducerId(e);if(!t)return;const r=this.getTrackByConsumerId(t.id);if(!r)return;yield r.close(),this.tracks.delete(r.label),l(this,gw,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:Bs(this)})}catch(t){throw l(this,gw,"f").error("unsubscribe()",{producerId:e,error:t}),new Error("Error unsubscribe media")}}))}setProducePermissions(e){return u(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield l(this,lw,"f").request(Sr,{peerId:this.id,producePermissions:e}),l(this,gw,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return u(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield l(this,lw,"f").request(Cr,{peerId:this.id,label:e}),l(this,gw,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return u(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield l(this,lw,"f").request(Pr,{peerId:this.id,label:e}),l(this,gw,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return u(this,void 0,void 0,(function*(){try{return{id:this.id,appData:this.appData,role:this.role,channelIds:this.channelIds,appId:this.appId,uid:this.uid,loginDate:this.loginDate,tracks:yield Promise.all(Array.from(this.tracks.values()).map((e=>u(this,void 0,void 0,(function*(){return yield e.getInfo()})))))}}catch(e){throw l(this,gw,"f").error("getInfo()",{peer:Bs(this),error:e}),new Error("Error get info")}}))}getProducers(){return Array.from(this.producers.values())}getConsumersState(){return this.getAllConsumers().map((e=>({id:e.id,paused:e.paused,producerId:e.producerId})))}handleNewProducer(e){if(this.producers.get(e.id))return;const t=new Sw(e);this.producers.set(t.id,t),l(this,gw,"f").debug("Peer published media:",{peer:Bs(this),producer:t});const r={producerId:t.id,kind:t.kind,label:t.label,paused:t.paused};this.observer.safeEmit(Zr,r)}handlePeerEvents(){this.observer.on(ln,this.handleNewProducer.bind(this)),this.observer.on(pn,(e=>u(this,void 0,void 0,(function*(){this.producers.delete(e.id),l(this,gw,"f").debug("Peer unpublished media:",{peer:Bs(this),producer:e}),this.observer.safeEmit(Xr,{producerId:e.id,kind:e.kind,label:e.label,paused:e.paused});const t=this.tracks.get(e.label);if(t)try{yield t.close()}catch(e){l(this,gw,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id,error:mr(e)})}})))),this.observer.on(_n,(e=>u(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),l(this,gw,"f").debug("Peer video track was ended:",{peer:Bs(this),track:t.logCtx}))})))),this.observer.on(bn,(e=>u(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(En,(e=>u(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(wn,(e=>{const t=this.getConsumerById(e.consumerId);(null==t?void 0:t.isVideo)&&(t.setCurrentTemporalLayer(e.temporalLayer),t.setCurrentSpatialLayer(e.spatialLayer),e.spatialLayer===t.requestedSpatialLayer&&t.setRequestedSpatialLayer(void 0),l(this,gw,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(mn,(e=>u(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),l(this,gw,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield l(this,lw,"f").request(wn,{consumerId:n.id,spatialLayer:r}),l(this,gw,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):l(this,gw,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):l(this,gw,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(br,(e=>{try{Ln(e),this.setAppData(e),this.observer.emit(cn,e),l(this,gw,"f").debug("updatePeerAppData",{peer:Bs(this),appData:e})}catch(t){l(this,gw,"f").error("updatePeerAppData",{peer:Bs(this),appData:e,error:t})}}))}reset(){return u(this,void 0,void 0,(function*(){this.producers.clear(),yield Promise.all(Array.from(this.tracks.values()).map((e=>u(this,void 0,void 0,(function*(){return yield e.close()}))))),this.tracks.clear();[ln,pn,_n,bn,En,wn,mn,br].forEach((e=>this.observer.removeAllListeners(e)))}))}getActiveTracksCount(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!(null==e?void 0:e.paused))).length}getActivePublishersCount(){return Array.from(this.producers.values()).filter((e=>!e.paused)).length}handleProducePermissionsChange(e){this.producePermissions=e,Object.values($n).filter((e=>!this.producePermissions.includes(e))).forEach((e=>{const t=this.tracks.get(e);t&&(this.tracks.delete(t.label),t.close().catch((e=>{l(this,gw,"f").error("Failed to close track",{case:"Peer",error:mr(e)})})))})),this.observer.safeEmit(dn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(un,{groups:e})}getAllConsumers(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!!e))}getConsumerByProducerId(e){return this.getAllConsumers().find((t=>t.producerId===e))}getConsumerById(e){return this.getAllConsumers().find((t=>t.id===e))}getTrackByConsumerId(e){return Array.from(this.tracks.values()).find((t=>t.consumerId===e))}setAppData(e){this.applicationData=e}throwIfIamNotModerator(){if(!l(this,cw,"f").isModerator(l(this,hw,"f").id))throw new Error("Not enough access")}}cw=new WeakMap,dw=new WeakMap,uw=new WeakMap,lw=new WeakMap,pw=new WeakMap,hw=new WeakMap,fw=new WeakMap,mw=new WeakMap,gw=new WeakMap;class Pw{constructor(e){this.spatialLayers=Qh,this.temporalLayers=Xh,this.currentSpatialLayer=Qh,this.currentTemporalLayer=Xh,this.availableSpatialLayers=[],vw.set(this,void 0);const{consumer:t,loggerFactory:r}=e;this.id=t.id,this.kind=t.kind,this.producerId=t.producerId,this.appData=t.appData,this.consumer=t,p(this,vw,r("PeerConsumer"),"f"),this.currentMaxSpatialLayer=this.appData.producerData.maxSpatialLayer,this.parseScalabilityMode(),this.initAvailableSpatialLayers(),this.setCurrentSpatialLayerParams()}get paused(){return this.consumer.paused}pause(){this.consumer.pause()}resume(){this.consumer.resume()}close(){this.consumer.close()}get isVideo(){return"video"===this.kind}get isAudio(){return"audio"===this.kind}parseScalabilityMode(){if(this.consumer.rtpParameters.encodings){const{scalabilityMode:e}=this.consumer.rtpParameters.encodings[0],{spatialLayers:t,temporalLayers:r}=Ka.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,l(this,vw,"f").debug("parseScalabilityMode()",{scalabilityMode:e,spatialLayers:t,temporalLayers:r})}}initAvailableSpatialLayers(){const{encodings:e,trackTransformParams:t}=this.appData.producerData;if(!Array.isArray(e))return;if(this.availableSpatialLayers=e.map((e=>this.tryPrepareSpatialLayerParams(e))),!t||this.availableSpatialLayers.length>1||this.spatialLayers<Zh)return void l(this,vw,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});l(this,vw,"f").debug("Pre-generating encodings with spatial layer params",{case:"initAvailableSpatialLayers"});const r=[],n=e[e.length-1];for(let e=this.spatialLayers-1;e>=0;e-=1)r.push(this.tryPrepareSpatialLayerParams(Object.assign(Object.assign({},n),{scaleResolutionDownBy:Math.pow(2,e)})));this.availableSpatialLayers=r}setCurrentSpatialLayerParams(){const{encodings:e}=this.appData.producerData;(null==e?void 0:e[this.currentSpatialLayer])&&(this.currentSpatialLayerParams=this.tryPrepareSpatialLayerParams(e[this.currentSpatialLayer]),l(this,vw,"f").debug("setCurrentSpatialLayerParams()",{currentSpatialLayerParams:this.currentSpatialLayerParams}))}tryPrepareSpatialLayerParams(e){var t;const{trackTransformParams:r}=this.appData.producerData;if(!r)return e;const{width:n,height:i}=r,s=null!==(t=e.scaleResolutionDownBy)&&void 0!==t?t:1;return n&&i?Object.assign({width:n/s,height:i/s},e):e}setCurrentSpatialLayer(e){if(!this.isVideo)throw new Error("setCurrentSpatialLayer applies to video consumers only");this.currentSpatialLayer=e,l(this,vw,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,l(this,vw,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){return u(this,void 0,void 0,(function*(){var e,t;try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>Ef(e))),dtlsState:null===(t=null===(e=this.consumer.rtpReceiver)||void 0===e?void 0:e.transport)||void 0===t?void 0:t.state,availableSpatialLayers:this.availableSpatialLayers,currentSpatialLayerParams:this.currentSpatialLayerParams,requestedSpatialLayer:this.requestedSpatialLayer,rtcStats:yield this.getInboundRTPStreamStats()}}catch(e){return void l(this,vw,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return u(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>u(this,[...n],void 0,(function*(n=0){try{const i=yield this.consumer.getStats(),s=Array.from(i.values()).find((e=>"inbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>{r(n+1).catch((e=>{l(this,vw,"f").debug("Error getting RTCStatsReport",{attempt:n,error:mr(e)})}))}),150);n>=5&&!s&&t(new Error("InboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),l(this,vw,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r().catch((e=>{l(this,vw,"f").debug("Error executing getRTCStatsReport",{case:"PeerConsumer",error:mr(e)})}))}))}))}}vw=new WeakMap;const Tw=new st({autoBindInjectable:!0});var kw;Tw.bind(Gn.LocalMutex).to(Rb).inSingletonScope(),Tw.bind(Gn.CallState).to(Qn).inSingletonScope(),Tw.bind(Gn.MyPeer).to(Vs).inSingletonScope(),Tw.bind(Gn.LoggerFactory).toFactory((e=>{const t=e.container.get(Gn.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new sE({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),Tw.bind(Gn.System).to(L_).inSingletonScope(),Tw.bind(Gn.ProcessorsCache).to(af).inSingletonScope(),Tw.bind(Gn.IntegrationsService).to(uf).inSingletonScope(),Tw.bind(Gn.MediaStreamTrackManager).to(rm).inSingletonScope(),Tw.bind(Gn.Media).to(im).inSingletonScope(),Tw.bind(Gn.SocketIO).to(fa).inSingletonScope(),Tw.bind(Gn.LoadBalancerApiClient).to(k_).inSingletonScope(),Tw.bind(Gn.Network).to(Ma).inSingletonScope(),Tw.bind(Gn.RemotePeerTracks).to(oE).inSingletonScope(),Tw.bind(Gn.Peers).to(La).inSingletonScope(),Tw.bind(Gn.MediaEventHandler).to(Rm).inSingletonScope(),Tw.bind(Gn.ChannelEventHandler).to(Em).inSingletonScope(),Tw.bind(Gn.ChannelAudioObserverEventHandler).to(ka).inSingletonScope(),Tw.bind(Gn.EventsQueue).to(Us).inSingletonScope(),Tw.bind(Gn.ChannelStateSynchronizer).to(_m).inSingletonScope(),Tw.bind(Gn.ChannelStateSyncEventHandler).to(Ja).inSingletonScope(),Tw.bind(Gn.StatsHandler).to(q_).inSingletonScope(),Tw.bind(Gn.WIDHandler).to(EE).inSingletonScope(),Tw.bind(Gn.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(Gn.Config),r=e.container.get(Gn.WIDHandler);if(t.get("disableWid"))return;const n=e.container.get(Gn.StatsHandler),i=[1234],s=e.container.get(Gn.LoggerFactory)("WID"),o=new or({statsParser:new ar({ignoreSSRCList:i,logger:s})});return new dr({onIssues:e=>{var n;r.handleIssues(e),null===(n=t.get("onIssues"))||void 0===n||n(e)},issueEmitter:new Wt,networkScoresCalculator:new zt,detectors:[new Qt,new $t,new Kt,new Jt,new Yt,new Zt,new rr({minMosQuality:kt.GOOD,avgFreezeDurationThresholdMs:2e3,frozenDurationThresholdPct:50}),new nr({minMosQuality:kt.GOOD,volatilityThreshold:10,affectedStreamsPercentThreshold:60})],statsReporter:new Ht({compositeStatsParser:o,getStatsInterval:5e3}),onNetworkScoresUpdated:e=>{var n;r.handleNetworkScores(e),null===(n=t.get("onNetworkScoresUpdated"))||void 0===n||n(e)},onStats:n.handle.bind(n),ignoreSSRCList:i,compositeStatsParser:o,logger:s,autoAddPeerConnections:!1})})).inSingletonScope(),Tw.bind(Gn.Engine).to(Z_).inSingletonScope(),Tw.bind(Gn.PeerTrackFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.CallState),n=e.container.get(Gn.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(Gn.Media),network:e.container.get(Gn.Network),peerConsumerFactory:e.container.get(Gn.PeerConsumerFactory),socket:e.container.get(Gn.SocketIO)},{peerEventEmitter:o}=i,a=new ww(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(rn,a),a}})),Tw.bind(Gn.PeerFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(Gn.Media),myPeer:e.container.get(Gn.MyPeer),network:e.container.get(Gn.Network),peers:e.container.get(Gn.Peers),remotePeerTracks:e.container.get(Gn.RemotePeerTracks),socket:e.container.get(Gn.SocketIO),peerConsumerFactory:e.container.get(Gn.PeerConsumerFactory)};return new Cw(Object.assign(Object.assign({},i),n))}})),Tw.bind(Gn.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory);return e=>{const r={loggerFactory:t};return new Pw(Object.assign(Object.assign({},r),e))}})),Tw.bind(Gn.AudioTrackFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Gn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Gn.Media),mediaStreamTrackManager:e.container.get(Gn.MediaStreamTrackManager),myPeer:e.container.get(Gn.MyPeer),network:e.container.get(Gn.Network),socket:e.container.get(Gn.SocketIO),mutex:e.container.get(Gn.LocalMutex),processorFactory:e.container.get(Gn.AudioTrackProcessorFactory),clientEventEmitter:e.container.get(Gn.ClientEventEmitter),statsHandler:r};return new bw(Object.assign(Object.assign({},i),n))}})),Tw.bind(Gn.VideoTrackFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Gn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Gn.Media),mediaStreamTrackManager:e.container.get(Gn.MediaStreamTrackManager),myPeer:e.container.get(Gn.MyPeer),network:e.container.get(Gn.Network),socket:e.container.get(Gn.SocketIO),mutex:e.container.get(Gn.LocalMutex),statsHandler:r};return new zf(Object.assign(Object.assign({},i),n))}})),Tw.bind(Gn.AudioTrackProcessorFactory).toFactory((function(e){const t=e.container.get(Gn.LoggerFactory),r=e.container.get(Gn.Config),n=e.container.get(Gn.ProcessorsCache),i=r.get("asdk");return e=>{const s=r.get("denoiser");let o=n.get(s,e.trackLabel);if(o)return o;if("rnnoise"===s&&e.noiseSuppressor&&(o=new _w({noiseSuppressor:e.noiseSuppressor,loggerFactory:t})),"asdk"===s&&(null==i?void 0:i.customerId)&&(o=new SE({asdkCustomerId:i.customerId,loggerFactory:t,config:r})),!o)throw new TypeError("Incorrect parameters passed to AudioTrackProcessorFactory");return o}})),Tw.bind(Gn.DataChannelsManager).to(Oa).inSingletonScope(),Tw.bind(Gn.AnalyticsApiClient).to(_b).inSingletonScope(),Tw.bind(Gn.PeersStorage).to(wa).inSingletonScope(),Tw.bind(Gn.TransportsStatsProvider).to(K_).inSingletonScope();kw=new WeakMap,module.exports=class{constructor(e){kw.set(this,void 0),this.canUseNoiseSuppression=!0;const{clientEventEmitter:t,internalEventEmitter:r}=e;Tw.bind(Gn.Config).toDynamicValue((()=>new Rt(e))).inSingletonScope(),Tw.bind(Gn.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new It)).inSingletonScope(),Tw.bind(Gn.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new It)).inSingletonScope(),Tw.get(Gn.IntegrationsService),this.clientEventEmitter=Tw.get(Gn.ClientEventEmitter),p(this,kw,Tw.get(Gn.Engine),"f")}get observer(){return this.clientEventEmitter}get id(){return l(this,kw,"f").myPeerId}get peers(){return l(this,kw,"f").getPeers()}get availableVideoDevices(){return l(this,kw,"f").system.availableVideoDevices}get availableAudioDevices(){return l(this,kw,"f").system.availableAudioDevices}get effectsSDKInitialized(){return l(this,kw,"f").media.effectsSDKInitialized}detectDevices(e){return u(this,void 0,void 0,(function*(){return yield l(this,kw,"f").system.detectDevices(e),{video:l(this,kw,"f").system.availableVideoDevices,audio:l(this,kw,"f").system.availableAudioDevices}}))}initEffectsSDK(){return u(this,void 0,void 0,(function*(){return yield l(this,kw,"f").media.initEffectsSDK()}))}join(e){return u(this,void 0,void 0,(function*(){yield l(this,kw,"f").join(e)}))}leave(e){return u(this,void 0,void 0,(function*(){yield l(this,kw,"f").release(e)}))}confirmActivity(){return u(this,void 0,void 0,(function*(){yield l(this,kw,"f").confirmActivity()}))}createCameraVideoTrack(e){return u(this,void 0,void 0,(function*(){return yield l(this,kw,"f").createCameraVideoTrack(e)}))}createMicrophoneAudioTrack(e){return u(this,void 0,void 0,(function*(){return yield l(this,kw,"f").createMicrophoneAudioTrack(e)}))}createScreenMediaTracks(e){return u(this,void 0,void 0,(function*(){return yield l(this,kw,"f").createScreenMediaTracks(e)}))}createCustomAudioTrack(e){return l(this,kw,"f").createCustomAudioTrack(e)}createCustomVideoTrack(e){return l(this,kw,"f").createCustomVideoTrack(e)}deleteTrack(e){return u(this,void 0,void 0,(function*(){yield l(this,kw,"f").deleteTrack(e)}))}loadPeers(e){return u(this,void 0,void 0,(function*(){yield l(this,kw,"f").loadPeers(e)}))}requestChannelStateSync(){l(this,kw,"f").requestChannelStateSync()}updateAppData(e){return u(this,void 0,void 0,(function*(){yield l(this,kw,"f").updateAppData(e)}))}getTransportsInfo(){return u(this,void 0,void 0,(function*(){return yield l(this,kw,"f").network.getTransportsStateInfo()}))}setPreferRelay(e){l(this,kw,"f").network.setPreferRelay(e)}getPreferRelay(){return l(this,kw,"f").network.getPreferRelay()}transportsStats(){return l(this,kw,"f").transportsStats()}setLoadbalancerUrl(e){l(this,kw,"f").setLoadbalancerUrl(e)}};