@phenixrts/sdk 2024.2.8-beta.366 → 2024.2.8-beta.367

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see channels.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(()=>(()=>{var e={787:(e,t,n)=>{"use strict";var r,i=n(383),a=n.n(i),o=n(579),s=n.n(o),u=n(693),c=n.n(u),l=function(){function e(){a()(this,e),c()(this,"_document",void 0),c()(this,"_location",void 0),c()(this,"_navigator",void 0),c()(this,"_window",void 0),this._document=document,this._location=location,this._navigator=navigator,this._window=window}return s()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"getInstance",value:function(){return e._instance}}])}();r=l,c()(l,"_instance",new r),t.A=l.getInstance()},701:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(738),i=n.n(r),a=n(383),o=n.n(a),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=u()((function e(t,n,r){o()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),f=function(){function e(t){if(o()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var a=r.length,o=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return o(t,e)}),n)}r[t]=s,0==--a&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)o(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,a=t.length;i<a;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){d.A.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new h(e,t,n)),n},f.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var p=f},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(701).A;function i(e,t,n,i,a,o,s){try{var u=e[o](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,a)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,a){var o=e.apply(t,n);function s(e){i(o,r,a,s,u,"next",e)}function u(e){i(o,r,a,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var r=n(701).A,i=n(738).default;function a(){"use strict";e.exports=a=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,s=o.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var i=t&&t.prototype instanceof C?t:C,a=Object.create(i.prototype),o=new A(r||[]);return u(a,"_invoke",{value:L(e,n,o)}),a}function m(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=p;var v="suspendedStart",g="suspendedYield",y="executing",_="completed",b={};function C(){}function k(){}function S(){}var x={};f(x,l,(function(){return this}));var w=Object.getPrototypeOf,T=w&&w(w(O([])));T&&T!==o&&s.call(T,l)&&(x=T);var P=S.prototype=C.prototype=Object.create(x);function E(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(r,a,o,u){var c=m(e[r],e,a);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(d)&&s.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,o,u)}),(function(e){n("throw",e,o,u)})):t.resolve(d).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,u)}))}u(c.arg)}var r;u(this,"_invoke",{value:function(e,i){function a(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(a,a):a()}})}function L(e,n,r){var i=v;return function(a,o){if(i===y)throw Error("Generator is already running");if(i===_){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=I(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===v)throw i=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=m(e,n,r);if("normal"===c.type){if(i=r.done?_:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=_,r.method="throw",r.arg=c.arg)}}}function I(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=m(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(i(e)+" is not iterable")}return k.prototype=S,u(P,"constructor",{value:S,configurable:!0}),u(S,"constructor",{value:k,configurable:!0}),k.displayName=f(S,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,f(e,h,"GeneratorFunction")),e.prototype=Object.create(P),e},n.awrap=function(e){return{__await:e}},E(F.prototype),f(F.prototype,d,(function(){return this})),n.AsyncIterator=F,n.async=function(e,t,i,a,o){void 0===o&&(o=r);var s=new F(p(e,t,i,a),o);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(P),f(P,h,"Generator"),f(P,l,(function(){return this})),f(P,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=O,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(R),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return o.type="throw",o.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=s.call(a,"catchLoc"),c=s.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),R(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;R(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},n}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),a=n(122),o=n(752);e.exports=function(e,t){return r(e)||i(e,t)||a(e,t)||o()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),a=n(122),o=n(869);e.exports=function(e){return r(e)||i(e)||a(e)||o()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.u=e=>e+".js",n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="",n.b=document.baseURI||self.location.href;var r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>Se,Channels:()=>Mt,SDK:()=>_e,default:()=>Vt});var e,t,i,a=n(383),o=n.n(a),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=function(){function e(){o()(this,e)}return u()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();e=h,l()(h,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),l()(h,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),l()(h,"_browserName",e.parseBrowserName()),l()(h,"_browserMajorVersion",e.parseBrowserMajorVersion()),l()(h,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(t=navigator)||void 0===t?void 0:t.userAgent)),l()(h,"_isAndroid",/Android/i.test(null===(i=navigator)||void 0===i?void 0:i.userAgent)),l()(h,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),l()(h,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),l()(h,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),l()(h,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),l()(h,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),l()(h,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),l()(h,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),l()(h,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var f=function(){function e(){o()(this,e)}return u()(e,null,[{key:"clientOfferDisabled",get:function(){return h.isChrome74||h.isChrome75||h.isChrome76||h.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return h.isChrome69||h.isChrome70||h.isChrome71||h.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=69||"Firefox"===h.browserName&&h.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=63||"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===h.browserName||"SamsungBrowser"===h.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==h.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){return"Chrome"===h.browserName&&"function"==typeof d.A.documentCreateElement}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion>=71||"Firefox"===h.browserName&&h.browserMajorVersion>=69||"Safari"===h.browserName}},{key:"isMobile",get:function(){return h.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==h.browserName&&"Safari"!==h.browserName}}])}(),p=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),m=function(){return u()((function e(t,n,r){o()(this,e),l()(this,"_category",void 0),l()(this,"_appenders",void 0),l()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?f.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),v=function(){return u()((function e(){o()(this,e),l()(this,"_appenders",[])}),[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}])}(),g=function(){return u()((function e(){o()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();l()(g,"_sendLocalCandidates",void 0),l()(g,"_sendLogs",void 0),l()(g,"_sendMetrics",void 0),l()(g,"_logToConsole",void 0),g.applyFeatures();var y=function(){return u()((function e(){o()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return p[g.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return p[g.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return p.Info}}])}(),_=function(){return u()((function e(){o()(this,e),l()(this,"_threshold",y.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),b=function(){return u()((function e(t){o()(this,e),l()(this,"_threshold",void 0),this._threshold=t}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(p[e],"] ").concat(t);e<p.Warn?console.log(i):console.error(i)}}}])}(),C=n(293),k=n.n(C),S=n(756),x=n.n(S),w=function(){function e(){throw o()(this,e),new Error("Numbers is a static class that may not be instantiated")}return u()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),T=function(){return u()((function e(){o()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2024-12-09T18:00:58.926Z (2024.2.8-beta.366)"}catch(e){return this._defaultVersion}}}])}();l()(T,"_defaultVersion",(new Date).toISOString());var P=function(){return u()((function e(t){o()(this,e),l()(this,"_telemetryConfiguration",void 0),l()(this,"_logs",[]),l()(this,"_isSending",void 0),l()(this,"_domain",d.A.locationHostname),this._telemetryConfiguration=t}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,a={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:p[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:T.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<p.Error?this._logs.push(a):this._logs.unshift(a),this.sendLogsIfAble()}},{key:"sendLogs",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=k()(x().mark((function e(){var t,n,r,i,a,o=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?w.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce((function(e,t){return e+(t?r(t):0)}),0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),a=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(a).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 12:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),E=function(){return u()((function e(t){o()(this,e),l()(this,"_telemetryService",void 0),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new P(t)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),F=function(){return u()((function e(){o()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_pageLoadTime",void 0),l()(this,"_threshold",y.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),L=function(){return u()((function e(){o()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return I[g.sendMetrics]}}])}(),I=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),D=function(){return u()((function e(){o()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_threshold",L.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),R=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},A=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case I.Off:return"Off";case I.Essential:return"Essential";case I.All:return"All";default:R(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return I.Off;case"Essential":return I.Essential;case"All":return I.All;default:R(e)}}}])}(),O=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case p.Off:return"Off";case p.Trace:return"Trace";case p.Debug:return"Debug";case p.Info:return"Trace";case p.Warn:return"Warn";case p.Error:return"Error";case p.Fatal:return"Fatal";case p.All:return"All";default:R(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return p.Off;case"Trace":return p.Trace;case"Debug":return p.Debug;case"Info":return p.Info;case"Warn":return p.Warn;case"Error":return p.Error;case"Fatal":return p.Fatal;case"All":return p.All;default:R(e)}}}])}(),M=function(){return u()((function e(){o()(this,e)}),[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":A.convertTelemetryLevelToTelemetryLevelType(L.defaultTelemetryLevel),"phenix-logging-level":O.convertLoggingLevelToLoggingLevelType(y.defaultLoggingLevel),"phenix-console-logging-level":O.convertLoggingLevelToLoggingLevelType(y.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":O.convertLoggingLevelToLoggingLevelType(y.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}}])}(),V=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new m(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");p[e]&&this._threshold.setThreshold(p[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(p[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new b(e||y.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||y.defaultTelemetryLoggingLevel,this._appenders.add(new E(this._telemetryConfiguration))}}])}();l()(V,"_configurationParameterReader",new M),l()(V,"_loggers",{}),l()(V,"_appenders",new v),l()(V,"_threshold",new _),l()(V,"_telemetryConfiguration",new F),V.applyLoggerConfigFromParameterConfiguration();var U=function(){return u()((function e(){throw o()(this,e),new Error("Strings is a static class that may not be instantiated")}),null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill((function(){return Math.random().toString(16).substring(2,15)})).reduce((function(e,t){return e+t()}),"").substring(0,e)}}])}(),B=n(452),N=n.n(B),j=n(72),H=n.n(j),z=n(511),G=n.n(z),q=function(){return u()((function e(t){o()(this,e),l()(this,"_disposed",void 0),l()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}),[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function W(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(W=function(){return!!e})()}var J=function(e){function t(e,n){return o()(this,t),r=this,i=t,a=[function(){var t=e.indexOf(n);t>=0&&e.splice(t,1)}],i=H()(i),N()(r,W()?Reflect.construct(i,a||[],H()(r).constructor):i.apply(r,a));var r,i,a}return G()(t,e),u()(t)}(q),K=function(){return u()((function e(t){o()(this,e),l()(this,"_listeners",void 0),l()(this,"_value",void 0),this._listeners=[],this._value=t}),[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new J(this._listeners,e)}}])}(),Q=function(){return u()((function e(t){o()(this,e),l()(this,"_subject",void 0),this._subject=t}),[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),Z=function(){return u()((function e(t){var n,r;o()(this,e),l()(this,"_applicationId",void 0),l()(this,"_token",void 0),this._applicationId=(null==t?void 0:t.applicationId)||"",this._token={uri:null!=t&&null!==(n=t.token)&&void 0!==n&&n.uri?new d.A.URL(t.token.uri):null,capabilities:(null==t||null===(r=t.token)||void 0===r?void 0:r.capabilities)||[]}}),[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),$=function(){function e(){o()(this,e)}return u()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new Z(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new Z(r)}catch(t){return e._logger.error("Cannot parse token value",t),new Z(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();l()($,"_logger",V.getLogger("EdgeAuthParser"));var X=function(){return u()((function e(){o()(this,e),l()(this,"_list",[])}),[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach((function(e){return e.dispose()})),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),Y="visibilitychange",ee=function(){return u()((function e(){o()(this,e),l()(this,"_disposables",new X),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new K(!0),this._readOnlyIsForeground=new Q(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!d.A.documentIsHidden},n=!1;d.A.addDocumentEventListener(Y,t,n),this._disposables.add(new q((function(){return d.A.removeDocumentEventListener(Y,t,n)})))}}])}(),te=n(701).A,ne=function(){return u()((function e(t){o()(this,e),l()(this,"_logger",V.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),f.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}),[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"connectionState",get:function(){return this._peerConnection.connectionState}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsGetTransceivers",get:function(){return!f.getTransceiversDisabled&&"function"==typeof this._peerConnection.getTransceivers}},{key:"supportsAddTransceiver",get:function(){return!f.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(r=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAnswer",value:(n=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLocalDescription",value:(t=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(f.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(f.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new te((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){return this._peerConnection.onconnectionstatechange},set:function(e){this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,t,n,r}(),re=function(){return u()((function e(){o()(this,e)}),[{key:"createPeerConnection",value:(e=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ne(t));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ie=function(){function e(){throw o()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return u()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){f.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=k()(x().mark((function t(){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=k()(x().mark((function t(){var n,r,i,a,o=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:"recvonly",r=o.length>1&&void 0!==o[1]&&o[1],!e._cached||e._cached.direction!==n||r){t.next=6;break}return i=e._cached.peerConnection,e._cached=null,t.abrupt("return",i);case 6:return a=f.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=k()(x().mark((function e(t){var r,i,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:n}),r=t.addTransceiver("video",{direction:n}),e.t0=i,e.t1=r,e.t2=t,e.next=9,t.createOffer(void 0);case 9:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 11:return a="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(a);case 15:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]);var t,n}();l()(ie,"_logger",V.getLogger("PeerConnectionService")),l()(ie,"_peerConnectionFactory",new K(new re)),l()(ie,"_cached",void 0),ie.initiateInitialPrecaching();var ae=function(){return u()((function e(){o()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new d.A.URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}])}(),oe=function(){return u()((function e(){o()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new d.A.URL(e).origin}catch(e){return""}}}])}(),se=function(){return u()((function e(){o()(this,e)}),null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();l()(se,"_discoveryParameters",void 0),se.applyParameters();var ue=function(){function e(){throw o()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return u()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new d.A.URL(e.toString()),n=T.sdkVersion,r=se.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();l()(ue,"_discoveryUri",new K("https://pcast.phenixrts.com/pcast/endPoints"));var ce,le=n(132),de=n.n(le),he=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;o()(this,e),l()(this,"_backoffIntervalInMillisecond",void 0),l()(this,"_minBackoffIntervalInMillisecond",void 0),l()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=t,this._minBackoffIntervalInMillisecond=n,this._maxBackoffIntervalInMillisecond=r}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,a=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(a,this._maxBackoffIntervalInMillisecond)}}])}(),fe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(fe||{}),pe=fe,me=function(){return u()((function e(t){o()(this,e),l()(this,"_metrics",void 0),this._metrics=t}),[{key:"getName",value:function(){return pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case pe.TimeToFirstFrame:case pe.ChannelCreationTimeToFirstFrame:return I.Essential;case pe.Stalled:case pe.Buffering:case pe.SetupCompleted:case pe.SetupFailed:case pe.RoundTripTime:case pe.DownlinkThroughputCapacity:case pe.NetworkType:case pe.ResolutionChanged:case pe.ApplicationForeground:case pe.ApplicationBackground:return I.All;default:R(this._metrics)}}}])}(),ve=function(){return u()((function e(t){o()(this,e),l()(this,"_logger",V.getLogger("MetricsService")),l()(this,"_metricsConfiguration",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_metrics",[]),l()(this,"_isSending",void 0),l()(this,"_failureCount",0),l()(this,"_domain",d.A.locationHostname),this._metricsConfiguration=t,this._exponentialBackoff=new he}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,a=e.resource,o=e.kind,s=new me(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:T.sdkVersion,runtime:i,resource:a,kind:o};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void d.A.setTimeout((function(){n._metrics=[].concat(de()(t),de()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()}),n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,t}(),ge=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var r=new D;return r.sessionId=_e.clientSessionId,r.tenancy=_e.tenancy.value,r.url=ae.getTelemetryUrl(t),r.environment=oe.getEnvironmentFromUrl(t),r.threshold=A.convertTelemetryLevelTypeToTelemetryLevel(_e.telemetryLevel),e._metricsServices[t]=new ve(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();l()(ge,"_metricsServices",{});var ye=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),_e=function(){function e(){throw o()(this,e),new Error("SDK is a static class that may not be instantiated")}return u()(e,null,[{key:"pageLoadTime",get:function(){return ye}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return O.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return A.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return h}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=V.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof E}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof E}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ge.getMetricsService(ue.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ge.setTelemetryLevel(I[t]),e._telemetryLevel.subscribe((function(e){ge.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=this._configurationParameterReader.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=this._configurationParameterReader.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=oe.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=$.parseToken(t);return e._tenancy.value=n.tenancy,ue.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return ue.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");if(i){var a=new d.A.URL(i);return a.pathname="/pcast/endPoints",ue.uri.value=a.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new ee),t){if(t.discoveryUri&&(ue.uri.value=t.discoveryUri),t.peerConnectionFactory&&(ie.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&I[t.telemetryLevel]&&(e._telemetryLevel.value=A.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&p[t.loggingLevel]&&this._logger.threshold.setThreshold(O.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&p[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof b}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new b(O.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ae.getTelemetryUrl(e)}}])}();ce=_e,l()(_e,"_automaticallyRetryOnFailure",!0),l()(_e,"_automaticallyReconnectPeerConnection",!0),l()(_e,"_automaticallyPlayMediaStream",!0),l()(_e,"_automaticallyMuteVideoOnPlayFailure",!0),l()(_e,"_forceGarbageCollectionOnRestart",!0),l()(_e,"_skipGarbageCollectionOnMobileDevices",!0),l()(_e,"_webPlayerLoader",null),l()(_e,"_shakaPlayerLoader",null),l()(_e,"_hlsJsLoader",null),l()(_e,"_configurationParameterReader",new M),l()(_e,"_applicationActivityMonitor",void 0),l()(_e,"_environment",new K("")),l()(_e,"_telemetryUrl",new K("https://telemetry.phenixrts.com/telemetry")),l()(_e,"_maximalNumberOfPeerConnectionReconnectAttempts",8),l()(_e,"_telemetryLevel",new K(L.defaultTelemetryLevel)),l()(_e,"_metricsService",void 0),l()(_e,"_metricsConfiguration",void 0),l()(_e,"_sendLocalCandidates",new K(g.sendLocalCandidates)),l()(_e,"_tenancy",new K("")),l()(_e,"_clientSessionId",U.random(32)),l()(_e,"_loadedTimestamp",new Date),l()(_e,"_logger",V.getLogger("SDK")),l()(_e,"_initialized",new K(!1)),l()(_e,"_readOnlyInitialized",new Q(ce._initialized)),l()(_e,"_readOnlyDiscoveryUri",new Q(ue.uri)),l()(_e,"_readOnlyPeerConnectionFactory",new Q(ie.peerConnectionFactory)),d.A.addWindowEventListener("unload",(function(){_e.dispose()})),_e.applyDiscoveryUriDefaultFromParameterConfiguration(),_e.applyMetricsConfiguration(),_e.applyTelemetryConfiguration(),_e.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),_e.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),_e.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),_e.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),_e.init();var be=function(){function e(t,n){o()(this,e),l()(this,"width",void 0),l()(this,"height",void 0),this.width=t,this.height=n}return u()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}],[{key:"empty",get:function(){return new e(0,0)}}])}(),Ce=function(){return u()((function e(){throw o()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}),null,[{key:"forceGarbageCollection",value:function(){f.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){f.isQueueMicrotaskSupported?d.A.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):d.A.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=d.A.documentCreateElement("img");e.src=d.A.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){d.A.URL.revokeObjectURL(this.src),e=null}}}])}(),ke=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.UnsupportedFeature=12]="UnsupportedFeature",e[e.ConfigurationError=13]="ConfigurationError",e[e.TransientConfigurationError=14]="TransientConfigurationError",e[e.ConnectionError=15]="ConnectionError",e[e.ClientStartError=16]="ClientStartError",e[e.Error=17]="Error",e}(ke||{}),Se=ke,xe=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;o()(this,e),l()(this,"_duration",void 0),this._duration=t}),[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,a=(n=Math.floor(n/60))%60,o=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),o&&s.push(o+"H"),a&&s.push(a+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),we=function(){return u()((function e(t,n,r,i){o()(this,e),l()(this,"_pageLoadTime",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_logger",V.getLogger("StreamTelemetry")),l()(this,"_disposables",new X),l()(this,"_streamId",void 0),l()(this,"_metricsService",void 0),l()(this,"_listenToFirstTime",void 0),l()(this,"_listenForStall",void 0),l()(this,"_listenForContinuation",void 0),l()(this,"_timeToFirstFrame",void 0),l()(this,"_channelCreationTimeToFirstFrame",void 0),l()(this,"_startRecordingFirstFrame",void 0),l()(this,"_videoStalled",void 0),l()(this,"_lastProgress",void 0),l()(this,"_videoResolution",void 0),l()(this,"_clearTimeToFirstFrameListener",void 0),l()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=r,this._metricsService=i}),[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new q((function(){e.removeEventListener("loadeddata",t._listenToFirstTime),e.removeEventListener("loadedmetadata",t._listenToFirstTime)})),this._disposables.add(this._clearTimeToFirstFrameListener)}},{key:"setupListenerForRebuffering",value:function(e){var t=this;this._listenForStall=function(){return t.onStall()},this._listenForContinuation=function(n){return t.onContinuation(n,e)},e.addEventListener("stalled",this._listenForStall),e.addEventListener("pause",this._listenForStall),e.addEventListener("suspend",this._listenForStall),e.addEventListener("play",this._listenForContinuation),e.addEventListener("playing",this._listenForContinuation),e.addEventListener("progress",this._listenForContinuation),e.addEventListener("timeupdate",this._listenForContinuation),this._clearRebufferingListener=new q((function(){e.removeEventListener("stalled",t._listenForStall),e.removeEventListener("pause",t._listenForStall),e.removeEventListener("suspend",t._listenForStall),e.removeEventListener("play",t._listenForContinuation),e.removeEventListener("playing",t._listenForContinuation),e.removeEventListener("progress",t._listenForContinuation),e.removeEventListener("timeupdate",t._listenForContinuation)})),this._disposables.add(this._clearRebufferingListener)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"durationSincePageLoad",get:function(){var e=Date.now();return new xe(e-this._pageLoadTime).toIsoString()}},{key:"callTimeToFirstFrame",value:function(){var e=Date.now();this.pushTimeToFirstFrame(e),this.pushChannelCreationTimeToFirstFrame(e),this._clearTimeToFirstFrameListener.dispose()}},{key:"pushTimeToFirstFrame",value:function(e){this._timeToFirstFrame=e-this._startRecordingFirstFrame,this._metricsService.push({metricType:pe.TimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._timeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] First frame [%s]",this.durationSincePageLoad,this._streamId,new xe(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:pe.ChannelCreationTimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._channelCreationTimeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] Channel creation to first frame [%s]",this.durationSincePageLoad,this._streamId,new xe(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:pe.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:pe.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new xe(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:pe.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Te=function(){return u()((function e(t){o()(this,e),l()(this,"_logger",V.getLogger("StreamSetupListener")),l()(this,"metricsService",_e.metricsService),l()(this,"_pageLoadTime",void 0),l()(this,"_startTime",void 0),l()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}),[{key:"success",value:function(e){this.recordStreamMetric(pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new me(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new xe(n-this._pageLoadTime).toIsoString(),t,i,new xe(r).toIsoString())}}}])}(),Pe=function(){return u()((function e(){o()(this,e),l()(this,"_disposables",new X),l()(this,"_isSupported",void 0!==d.A.navigatorConnection),l()(this,"_rtt",new K(void 0)),l()(this,"_effectiveType",new K(void 0)),l()(this,"_downlinkThroughputCapacity",new K(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}),[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=d.A.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=d.A.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=d.A.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=d.A.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new q((function(){var e;return null===(e=d.A.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),Ee=function(){return u()((function e(t,n){var r=this;o()(this,e),l()(this,"_logger",V.getLogger("SessionTelemetry")),l()(this,"_metricsService",void 0),l()(this,"_applicationActivityMonitor",_e.applicationActivityMonitor),l()(this,"_networkMonitor",new Pe),l()(this,"_pageLoadTime",void 0),l()(this,"_disposables",new X),l()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Te(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?pe.ApplicationForeground:pe.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new xe(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:pe.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new xe(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:pe.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new xe(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:pe.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new xe(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Fe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Le=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ie=u()((function e(t){o()(this,e),l()(this,"token",void 0),l()(this,"tokenExpiring",void 0),this.token=new K(t),this.tokenExpiring=new K(!1)})),De=function(){return u()((function e(t){var n;o()(this,e),l()(this,"channelInitialization",void 0),l()(this,"disposables",void 0),l()(this,"channelDisposables",void 0),l()(this,"rendererDisposables",void 0),l()(this,"videoElement",void 0),l()(this,"state",void 0),l()(this,"autoMuted",void 0),l()(this,"autoPaused",void 0),l()(this,"authorized",void 0),l()(this,"online",void 0),l()(this,"loading",void 0),l()(this,"playing",void 0),l()(this,"standby",void 0),l()(this,"stopped",void 0),l()(this,"targetLag",void 0),l()(this,"lag",void 0),l()(this,"bitrateLimit",void 0),l()(this,"resolution",void 0),l()(this,"failureCount",void 0),l()(this,"endPoint",void 0),l()(this,"stream",void 0),l()(this,"rtcStatistics",void 0),l()(this,"videoTelemetry",void 0),l()(this,"rtcAudioStatistic",void 0),l()(this,"rtcVideoStatistic",void 0),l()(this,"clearFailureCountTimeout",void 0),this.disposables=new X,this.channelDisposables=new X,this.rendererDisposables=new X,this.channelInitialization=new Date,this.videoElement=new K(null),this.state=new K(Se.Initializing),this.autoMuted=new K(!1),this.autoPaused=new K(!1),this.authorized=new K(!0),this.online=new K(!0),this.loading=new K(!1),this.playing=new K(!1),this.standby=new K(!1),this.stopped=new K(!1),this.targetLag=new K(null!==(n=null==t?void 0:t.targetLag)&&void 0!==n?n:0),this.lag=new K(0),this.bitrateLimit=new K(0),this.resolution=new K(be.empty),this.failureCount=new K(0),this.endPoint=new K(null),this.stream=new K(null),this.rtcStatistics=new K(null)}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=_e.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"no-stream":case"not-found":return Se.StandBy;case"geo-restricted":return Se.GeoRestricted;case"geo-blocked":return Se.GeoBlocked;case"unauthorized":return Se.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"forbidden-tag":return Se.ConfigurationError;case"port-in-range-not-found":return Se.TransientConfigurationError;case"failed":return Se.Error;default:R(e)}}}])}(),Re=n(738),Ae=n.n(Re),Oe=function(){return u()((function e(){throw o()(this,e),new Error("EncodedStreamSink is a static class that may not be instantiated")}),null,[{key:"validateEncodedStreamSink",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function type. Found [").concat(Ae()(t),"]")}:2!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function parameter length. Expected 2. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),Me=function(){return u()((function e(){o()(this,e)}),null,[{key:"validateMediaStreamTrackTransform",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function type. Found [").concat(Ae()(t),"]")}:3!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function parameter length. Expected 3. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),Ve=u()((function e(t){o()(this,e),l()(this,"hasInsertableStreams",void 0),l()(this,"hasEncodedInsertableStreams",void 0),l()(this,"videoStreamTransformCallback",void 0),l()(this,"audioStreamTransformCallback",void 0),l()(this,"encodedVideoStreamSink",void 0),l()(this,"encodedAudioStreamSink",void 0),this.hasInsertableStreams=new K(t.hasInsertableStreams),this.hasEncodedInsertableStreams=new K(t.hasEncodedInsertableStreams),this.videoStreamTransformCallback=t.videoStreamTransformCallback,this.audioStreamTransformCallback=t.audioStreamTransformCallback,this.encodedVideoStreamSink=t.encodedVideoStreamSink,this.encodedAudioStreamSink=t.encodedAudioStreamSink})),Ue=u()((function e(){o()(this,e),l()(this,"mediaStream",void 0),l()(this,"peerConnection",void 0),l()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new K(null),this.peerConnection=new K(null),this.peerConnectionReconnectAttempts=0})),Be=u()((function e(){o()(this,e),l()(this,"isStarting",void 0),l()(this,"isDisposed",void 0),this.isStarting=new K(!1),this.isDisposed=!1})),Ne=u()((function e(){o()(this,e),l()(this,"shouldExtractTimecode",void 0),l()(this,"shouldExtractTimestamps",void 0),l()(this,"isEnabled",void 0),l()(this,"decodedFrameTimingInformation",void 0),l()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new K(!1),this.shouldExtractTimestamps=new K(!1),this.isEnabled=new K(!1),this.decodedFrameTimingInformation=new K(null),this.renderedFrameTimingInformation=new K(null)})),je=n(715),He=n.n(je),ze=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Le.Normal:return"Normal";case Le.Force:return"Force";case Le.Reset:return"Reset";default:R(e)}}}])}(),Ge=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Fe.Keep:return"Keep";case Fe.Reset:return"Reset";default:R(e)}}}])}(),qe=n(701).A,We=function(){return u()((function e(t,n){if(o()(this,e),l()(this,"_logger",V.getLogger("EndPoint")),l()(this,"_uri",void 0),l()(this,"_timeout",void 0),l()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}),[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(v=k()(x().mark((function e(){var t,n,r,i,a=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,qe.race([d.A.fetch(t,{method:"GET",cache:"no-cache"}),new qe((function(e,n){return d.A.setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),a._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(m=k()(x().mark((function e(t,n,r){var i,a,o,s,u,c,l,h,f,p,m,v,g=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=$.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return a=this.buildUrl([i,"stream","subscribe"]).toString(),o=new d.A.FormData,s=T.sdkVersion,0===r&&n?(u={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}},o.append("jsonBody",JSON.stringify(u))):(c={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},o.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,f=null,e.next=13,qe.race([d.A.fetch(a,{method:"POST",body:o}),new qe((function(e){return f=d.A.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){f&&d.A.clearTimeout(f)}));case 13:h=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(p=this.mapHttpStatusToSubscribeStatus(h))){e.next=23;break}return e.abrupt("return",{status:p});case 23:return m=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(i,h);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,m-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return m.apply(this,arguments)})},{key:"publish",value:(p=k()(x().mark((function e(t,n,r,i){var a,o,s,u,c,l,h,f,p,m,v,g,y=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=$.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([a,"stream","publish"]).toString(),s=new d.A.FormData,u=T.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),h=Date.now(),e.prev=9,p=null,e.next=13,qe.race([d.A.fetch(o,{method:"POST",body:s}),new qe((function(e){return p=d.A.setTimeout((function(){y._logger.error("Failed to publish",new Error("Publish timed out [".concat(o,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&d.A.clearTimeout(p)}));case 13:f=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(m=this.mapHttpStatusToPublishStatus(f))){e.next=23;break}return e.abrupt("return",{status:m});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(a,f);case 26:return g=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-h),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(f=k()(x().mark((function e(t,n){var r,i,a,o,s,u,c,l,h,f=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new d.A.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(a)),o=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(r,{method:"POST",body:i}),new qe((function(e){return u=d.A.setTimeout((function(){f._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 22:return h=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",h,l-o),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return f.apply(this,arguments)})},{key:"limitBitrate",value:(h=k()(x().mark((function e(t,n,r,i,a){var o,s,u,c,l,h,f,p,m=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new d.A.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Ge.convertBitrateStateToBitrateStateType(i),bitrateMode:ze.convertBitrateModeToBitrateModeType(a)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,h=null,e.next=9,qe.race([d.A.fetch(o,{method:"POST",body:s}),new qe((function(e){return h=d.A.setTimeout((function(){m._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(o,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){h&&d.A.clearTimeout(h)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return f=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",f,p-c),e.abrupt("return",{status:f});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(c=k()(x().mark((function e(t,n,r){var i,a,o,s,u,c,l,h,f,p,m=this,v=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],a=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),o=new d.A.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},o.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,qe.race([d.A.fetch(a,{method:"POST",body:o}),new qe((function(e){return l=d.A.setTimeout((function(){m._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(a,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){l&&d.A.clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(h=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:h});case 20:return f=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,f-u),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(s=k()(x().mark((function e(t,n){var r,i,a,o,s,u,c,l,h,f=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new d.A.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(a)),o=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new qe((function(e){return u=d.A.setTimeout((function(){f._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(s);case 22:return h=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",h,l-o),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(a=k()(x().mark((function e(t,n){var r,i,a,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),a=new d.A.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},a.append("jsonBody",JSON.stringify(o)),navigator.sendBeacon(i,a);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new d.A.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,de()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new d.A.URL(this._uri),t=T.sdkVersion,n=se.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(i=k()(x().mark((function e(t,n){var r,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(r=k()(x().mark((function e(t,n){var r,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(n=k()(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(t=k()(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=k()(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,a,s,c,h,f,p,m,v}(),Je=n(701).A,Ke=function(){return u()((function e(t){if(o()(this,e),l()(this,"_logger",V.getLogger("Discovery")),l()(this,"_metricsService",void 0),l()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ge.getMetricsService(t.toString()),this._uri=t}),[{key:"discoverNearbyEndPoints",value:(t=k()(x().mark((function e(t,n){var r,i,a,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new Error("Discovery requires timeout");case 2:return r=t.toString(),e.next=5,Je.race([d.A.fetch(r,{method:"GET",cache:"no-cache"}),new Je((function(e,t){return d.A.setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return a=e.sent,o=a.split(","),e.abrupt("return",o.map((function(e){return new We(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=k()(x().mark((function e(){var t,n,r,i,a,o,s=this,u=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ue.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new d.A.URL(n),t);case 4:return r=e.sent,i=0,a=function(){return new Je((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Je.race(r.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,a()})).then((function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:pe.RoundTripTime,runtime:(n-_e.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 9:return o=e.sent,e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),Qe=function(){function e(){throw o()(this,e),new Error("Discovery is a static class that may not be instantiated")}return u()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=k()(x().mark((function t(){var n;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new d.A.URL(_e.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=k()(x().mark((function t(n){var r,i,a;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new Ke(n),a=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){d.A.setTimeout((function(){e._cache[r]===a&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),t.abrupt("return",a);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();e._cache[n]&&delete e._cache[n]}}]);var t,n}();l()(Qe,"_cache",{}),Qe.precacheClosestEndPointDiscovery();var Ze=function(){return u()((function e(t){o()(this,e),l()(this,"_sdp",void 0),l()(this,"_audioCodec",void 0),l()(this,"_videoCodec",void 0),l()(this,"_isAudioTrackEnabled",void 0),l()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}),[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}])}(),$e=function(){return u()((function e(t,n,r){if(o()(this,e),l()(this,"_estimatedRoundTripTime",void 0),l()(this,"_estimatedVideoCodec",void 0),l()(this,"_estimatedAudioCodec",void 0),l()(this,"_rtcStatistic",new K({})),l()(this,"_peerConnection",void 0),l()(this,"_isMonitorRunning",!0),l()(this,"_updateTimeout",void 0),l()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!f.getCurrentOfferDisabled){var i=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(d.A.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,a=n._estimatedRoundTripTime;e.forEach((function(o){if("candidate-pair"===o.type&&o.currentRoundTripTime&&(a=1e3*o.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=a),r.video&&(r.video.roundTripTime=a)),"candidate-pair"===o.type&&o.lastPacketReceivedTimestamp&&(i=o.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===o.type){var s=o.kind||o.mediaType||t(o),u="";if(e.forEach((function(e){e.id===o.codecId&&(u=e.mimeType)})),s&&n._tracksToMonitor.includes(s)){var c,l,d,h,f,p=(o.bytesReceived||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesReceived)&&void 0!==c?c:0),m=o.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(f=h[s])||void 0===f?void 0:f.timestamp),v=p&&m?Math.floor(8*p/m*1e3):0;if(r[s]={ssrc:o.ssrc,mediaType:s,timestamp:o.timestamp,bitrate:v,bytesReceived:o.bytesReceived,packetsLost:o.packetsLost,packetsReceived:o.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:a},(o.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=o.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[s].framesDecoded=o.framesDecoded;var g=(o.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(r[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeout=d.A.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},r=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i=e.stat("mediaType").toString();n[i]={timestamp:Date.now()},n[i].ssrc=e.stat("ssrc").toString(),n[i].mediaType=i,n[i].bytesReceived=e.stat("bytesReceived"),n[i].packetsLost=e.stat("packetsLost"),n[i].packetsReceived=e.stat("packetsReceived"),n[i].codec=e.stat("googCodecName").toString()||t.getCodecByType(i),n[i].roundTripTime=r,"video"===i&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[i].framesDecoded=e.stat("framesDecoded"),n[i].fps=(n[i].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[i].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeout=d.A.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]);var e,t}(),Xe=function(){return u()((function e(){throw o()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}),null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),Ye=function(e){return e[e.BufferingPeriod=0]="BufferingPeriod",e[e.PictureTiming=1]="PictureTiming",e[e.PanScanRect=2]="PanScanRect",e[e.FillerPayload=3]="FillerPayload",e[e.UserDataRegistered=4]="UserDataRegistered",e[e.UserDataUnregistered=5]="UserDataUnregistered",e[e.RecoveryPoint=6]="RecoveryPoint",e[e.DecRefPicMarkingRepeition=7]="DecRefPicMarkingRepeition",e[e.SparePic=8]="SparePic",e[e.SceneInfo=9]="SceneInfo",e[e.SubSeqInfo=10]="SubSeqInfo",e[e.SubSeqLayerCharacteristics=11]="SubSeqLayerCharacteristics",e[e.SubSeqCharacteristics=12]="SubSeqCharacteristics",e[e.FullFrameFreeze=13]="FullFrameFreeze",e[e.FullFrameFreezeRelease=14]="FullFrameFreezeRelease",e[e.FullFrameSnapshot=15]="FullFrameSnapshot",e[e.ProgressiveRefinementSegmentStart=16]="ProgressiveRefinementSegmentStart",e[e.ProgressiveRefinementSegmentEnd=17]="ProgressiveRefinementSegmentEnd",e[e.MotionConstrainedSliceGroupSet=18]="MotionConstrainedSliceGroupSet",e[e.FilmGrainCharacteristic=19]="FilmGrainCharacteristic",e[e.DeblockingFilterDisplayReference=20]="DeblockingFilterDisplayReference",e[e.StereoVideoInfo=21]="StereoVideoInfo",e[e.PostFilterHint=22]="PostFilterHint",e[e.ToneMappingInfo=23]="ToneMappingInfo",e[e.ScalabilityInfo=24]="ScalabilityInfo",e[e.SubPicScalableLayer=25]="SubPicScalableLayer",e[e.NonRequiredLayerRep=26]="NonRequiredLayerRep",e[e.PariorityLayerInfo=27]="PariorityLayerInfo",e[e.LayersNotPresent=28]="LayersNotPresent",e[e.LayerDependencyChange=29]="LayerDependencyChange",e[e.ScalableNesting=30]="ScalableNesting",e[e.BaseLayerTemporalHrd=31]="BaseLayerTemporalHrd",e[e.QualityLayerIntegrityCheck=32]="QualityLayerIntegrityCheck",e[e.RedundantPicProperty=33]="RedundantPicProperty",e[e.Tl0DepRepIndex=34]="Tl0DepRepIndex",e[e.TlSwitchingPoint=35]="TlSwitchingPoint",e[e.ParallelDecodingInfo=36]="ParallelDecodingInfo",e[e.MvcScalableNesting=37]="MvcScalableNesting",e[e.ViewScalabilityInfo=38]="ViewScalabilityInfo",e[e.MultiviewSceneInfo=39]="MultiviewSceneInfo",e[e.MultiviewAcquisitionInfo=40]="MultiviewAcquisitionInfo",e[e.NonRequiredViewComponent=41]="NonRequiredViewComponent",e[e.ViewDependencyChange=42]="ViewDependencyChange",e[e.OperationPointsNotPresent=43]="OperationPointsNotPresent",e[e.BaseViewTemporalHdr=44]="BaseViewTemporalHdr",e[e.FramePackingArrangement=45]="FramePackingArrangement",e[e.MultiviewViewPosition=46]="MultiviewViewPosition",e[e.DisplayOrientation=47]="DisplayOrientation",e[e.MvcdScalableNesting=48]="MvcdScalableNesting",e[e.MvcdViewScalabilityInfo=49]="MvcdViewScalabilityInfo",e[e.DepthRepresentationInfo=50]="DepthRepresentationInfo",e[e.ThreeDimensionalReferenceDisplaysInfo=51]="ThreeDimensionalReferenceDisplaysInfo",e[e.DepthTiming=52]="DepthTiming",e[e.DepthSamplingInfo=53]="DepthSamplingInfo",e[e.ConstrainedDepthParameterSetIdentifier=54]="ConstrainedDepthParameterSetIdentifier",e[e.GreenMetadata=55]="GreenMetadata",e[e.MasteringDisplayColourVolumev=56]="MasteringDisplayColourVolumev",e[e.ColourRemappingInfo=57]="ColourRemappingInfo",e[e.ContentLightLevelInfo=58]="ContentLightLevelInfo",e[e.AlternativeTransferCharacteristics=59]="AlternativeTransferCharacteristics",e[e.AmbientViewingEnvironment=60]="AmbientViewingEnvironment",e[e.ContentColourVolume=61]="ContentColourVolume",e[e.EquirectangularProjection=62]="EquirectangularProjection",e[e.CubemapProjection=63]="CubemapProjection",e[e.SphereRotation=64]="SphereRotation",e[e.RegionwisePacking=65]="RegionwisePacking",e[e.OmniViewport=66]="OmniViewport",e[e.AlternativeDepthInfo=67]="AlternativeDepthInfo",e[e.SeiManifest=68]="SeiManifest",e[e.SeiPrefixIndication=69]="SeiPrefixIndication",e[e.AnnotatedRegions=70]="AnnotatedRegions",e[e.ShutterIntervalInfo=71]="ShutterIntervalInfo",e}(Ye||{}),et=Ye,tt=function(){return u()((function e(t){o()(this,e),l()(this,"_data",void 0),l()(this,"_bitOffset",void 0),this._data=t,this._bitOffset=0}),[{key:"readBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot read [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));for(var t=0,n=e;n>0;){var r=Math.floor(this._bitOffset/8),i=8-this._bitOffset%8,a=Math.min(n,i),o=(1<<a)-1;t=t<<a|this._data[r]>>i-a&o,n-=a,this._bitOffset+=a}return t}},{key:"skipBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot skip [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));this._bitOffset+=e}},{key:"getRemainingBits",value:function(){return 8*this._data.length-this._bitOffset}}])}(),nt=function(){return u()((function e(){throw o()(this,e),new Error("EmulationPreventionBytes is a static class that may not be instantiated")}),null,[{key:"getOffsetWithExpandedEmulationPreventionBytes",value:function(e,t,n){for(var r=0,i=0,a=n,o=t;o<e.length&&0!==a;o++,i++)2!==r||3!==e[o]?(0===e[o]?r++:r>0&&(r=0),a--):r=0;return i}},{key:"removeEmulationPreventionBytes",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,r=0,i=2;i<e.byteLength;i++)3===e[i]&&0===e[i-1]&&0===e[i-2]&&(t.set(e.subarray(r,i),n),n+=i-r,r=i+1);return r<e.byteLength&&t.set(e.subarray(r),n),t}}])}(),rt=function(e){return e[e.ProgressiveFrame=0]="ProgressiveFrame",e[e.TopField=1]="TopField",e[e.BottomField=2]="BottomField",e[e.TopFieldBottomField=3]="TopFieldBottomField",e[e.BottomFieldTopField=4]="BottomFieldTopField",e[e.TopFieldBottomFieldTopFieldRepeated=5]="TopFieldBottomFieldTopFieldRepeated",e[e.BottomFieldTopFieldBottomFieldRepeated=6]="BottomFieldTopFieldBottomFieldRepeated",e[e.FrameDoubling=7]="FrameDoubling",e[e.FrameTripling=8]="FrameTripling",e}(rt||{}),it=function(){return u()((function e(){o()(this,e)}),[{key:"parse",value:function(e,t){var n=new tt(nt.removeEmulationPreventionBytes(e)),r={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&(n.skipBits(t.cpbRemovalDelayLengthMinus1+1),n.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){var i=this.convertPicStructToNumClockTS(n.readBits(4));r.picStruct={numClockTS:i,clockTimestamps:[]};for(var a=0;a<r.picStruct.numClockTS;a++){var o=1===n.readBits(1);if(o){var s={ctType:n.readBits(2),nuitFieldBasedFlag:1===n.readBits(1),countingType:n.readBits(5),fullTimestampFlag:1===n.readBits(1),discontinuityFlag:1===n.readBits(1),cntDroppedFlag:1===n.readBits(1),nFrames:n.readBits(8)};s.fullTimestampFlag?(s.seconds=n.readBits(6),s.minutes=n.readBits(6),s.hours=n.readBits(5)):1===n.readBits(1)&&(s.seconds=n.readBits(6),1===n.readBits(1)&&(s.minutes=n.readBits(6),1===n.readBits(1)&&(s.hours=n.readBits(5)))),s.timeOffset=n.readBits(24),r.picStruct.clockTimestamps.push({clockTimestampFlag:o,clockTimestamp:s})}else r.picStruct.clockTimestamps.push({clockTimestampFlag:!1})}}return r}},{key:"convertPicStructToNumClockTS",value:function(e){switch(e){case rt.ProgressiveFrame:case rt.TopField:case rt.BottomField:return 1;case rt.TopFieldBottomField:case rt.BottomFieldTopField:case rt.FrameDoubling:return 2;case rt.TopFieldBottomFieldTopFieldRepeated:case rt.BottomFieldTopFieldBottomFieldRepeated:case rt.FrameTripling:return 3;default:return 0}}}])}();function at(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ot=function(){return u()((function e(){o()(this,e),l()(this,"_listeners",new Set)}),[{key:"subscribe",value:function(e){var t=this;return this._listeners.add(e),new q((function(){return t._listeners.delete(e)}))}},{key:"emit",value:function(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return at(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?at(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}(this._listeners);try{for(n.s();!(t=n.n()).done;)(0,t.value)(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._listeners.clear()}}])}(),st=function(){return u()((function e(){o()(this,e),l()(this,"_eventEmitters",new Map),l()(this,"_onEventWithNoSubscriberHandlers",new Set),l()(this,"_disposables",new X)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new q((function(){return t._onEventWithNoSubscriberHandlers.delete(e)}))}},{key:"subscribe",value:function(e,t){var n=(this._eventEmitters.get(e)||this.createEmitter(e)).subscribe(t);return this._disposables.add(n),n}},{key:"publish",value:function(e,t){var n=this._eventEmitters.get(e);n?n.emit(t):this._onEventWithNoSubscriberHandlers.forEach((function(n){return n(e,t)}))}},{key:"dispose",value:function(){this._disposables.dispose(),this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._eventEmitters.clear(),this._onEventWithNoSubscriberHandlers.clear()}},{key:"createEmitter",value:function(e){var t=new ot;return this._eventEmitters.set(e,t),t}}])}(),ut=function(e){return e[e.EncodedVideoStreamChunk=0]="EncodedVideoStreamChunk",e[e.NalUnit=1]="NalUnit",e[e.SeiPayload=2]="SeiPayload",e[e.Payload=3]="Payload",e[e.PayloadSubscription=4]="PayloadSubscription",e[e.EndOfChunk=5]="EndOfChunk",e}({}),ct=function(){return u()((function e(t){o()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_disposables",new X),this._eventPublisher=t}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(ut.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(ut.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(ut.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(ut.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),lt=function(){function e(){throw o()(this,e),new Error("Uint8Arrays is a static class that may not be instantiated")}return u()(e,null,[{key:"isDataAtOffsetTargetByteSequence",value:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]!==t[n+r])return!1;return!0}},{key:"findTargetByteSequenceIndexFromOffset",value:function(t,n,r){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,a=r;a<=n.byteLength;a++)if(e.isDataAtOffsetTargetByteSequence(t,n,a))return a;return i}},{key:"getUuidStringFromUint8Array",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=[],r=0;r<t;r++){var i=e[r].toString(16).padStart(2,"0");n.push(i),3!==r&&5!==r&&7!==r&&9!==r||n.push("-")}return n.join("")}}])}(),dt=function(e){return e[e.Unspecified=0]="Unspecified",e[e.SliceLayerNonIdrData=1]="SliceLayerNonIdrData",e[e.SliceDataPartitionALayer=2]="SliceDataPartitionALayer",e[e.SliceDataPartitionBLayer=3]="SliceDataPartitionBLayer",e[e.SliceDataPartitionCLayer=4]="SliceDataPartitionCLayer",e[e.SliceLayerIdrData=5]="SliceLayerIdrData",e[e.SupplementalEnhancementInformation=6]="SupplementalEnhancementInformation",e[e.SequenceParameterSet=7]="SequenceParameterSet",e[e.PictureParameterSet=8]="PictureParameterSet",e[e.AccessUnitDelimiter=9]="AccessUnitDelimiter",e[e.EndOfSequence=10]="EndOfSequence",e[e.EndOfStream=11]="EndOfStream",e[e.FillerData=12]="FillerData",e[e.SequenceParamterSetExtension=13]="SequenceParamterSetExtension",e[e.PrefixNalUnit=14]="PrefixNalUnit",e[e.SubsetSequenceParamterSet=15]="SubsetSequenceParamterSet",e[e.DepthParamterSet=16]="DepthParamterSet",e[e.Reserved17=17]="Reserved17",e[e.Reserved18=18]="Reserved18",e[e.SliceLayerAuxiliary=19]="SliceLayerAuxiliary",e[e.SliceExtension=20]="SliceExtension",e[e.SliceExtensionDepthViewComponent=21]="SliceExtensionDepthViewComponent",e[e.Reserved22=22]="Reserved22",e[e.Reserverd23=23]="Reserverd23",e[e.Unspecified24=24]="Unspecified24",e[e.Unspecified25=25]="Unspecified25",e[e.Unspecified26=26]="Unspecified26",e[e.Unspecified27=27]="Unspecified27",e[e.Unspecified28=28]="Unspecified28",e[e.Unspecified29=29]="Unspecified29",e[e.Unspecified30=30]="Unspecified30",e[e.Unspecified31=31]="Unspecified31",e}(dt||{}),ht=dt,ft=function(){function e(t,n){o()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_vclExtractionStrategy",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._vclExtractionStrategy=n,this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents())}return u()(e,[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.parseEncodedVideoStreamChunk.bind(this))}},{key:"parseEncodedVideoStreamChunk",value:function(e){for(var t=e.context,n=e.data,r=0;r<n.byteLength;)r+=this.handleExtractedData(t,this.extractNalUnitAtOffset(n,r));this.notifyEndOfChunk(t)}},{key:"handleExtractedData",value:function(e,t){var n=t.annexBStartCodeLength,r=t.nalUnit,i=t.seiPayloads;return this.publishNalUnit(e,r),null==i||i.forEach(this.handleSeiPayload.bind(this,e)),r.data.byteLength+n}},{key:"handleSeiPayload",value:function(e,t){this.publishSeiPayload(e,t),t.type===et.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=lt.getUuidStringFromUint8Array(t.data.subarray(0,16)),r=t.data.subarray(16);this.publishPayload(e,{uuid:n,data:r})}},{key:"publishNalUnit",value:function(e,t){this._eventPublisher.publish(ut.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(ut.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(ut.EndOfChunk,{context:e,data:null})}},{key:"extractNalUnitAtOffset",value:function(e,t){var n,r=1===e[t+2]?3:4,i=t+r,a=31&e[i];switch(a){case ht.SliceLayerNonIdrData:case ht.SliceDataPartitionALayer:case ht.SliceDataPartitionBLayer:case ht.SliceDataPartitionCLayer:case ht.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,i);break;case ht.SupplementalEnhancementInformation:n=this.extractSeiNalUnit(e,i);break;default:n=this.extractNonVclNalUnit(e,i)}return{annexBStartCodeLength:r,nalUnit:{type:a,data:n.nalUnitData},seiPayloads:n.seiPayloads}}},{key:"extractSeiNalUnit",value:function(t,n){for(var r=n+1,i=[];!lt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,r)&&!lt.isDataAtOffsetTargetByteSequence(e._seiPayload3ByteEndCode,t,r)&&r<t.byteLength;){var a=this.extractSeiPayload(t,r);i.push({data:a.payload,type:a.payloadType}),r=a.endIndex}return r++,{nalUnitData:t.subarray(n,r),seiPayloads:i}}},{key:"extractNonVclNalUnit",value:function(t,n){var r=e.findAnnexBStartIndexFromOffset(t,n,t.byteLength);return{nalUnitData:t.subarray(n,r)}}},{key:"extractSeiPayload",value:function(e,t){for(var n=t,r=0;255===e[n];)n++,r++;var i=255*r+e[n];for(n++,r=0;255===e[n];)n++,r++;var a=255*r+e[n],o=++n+nt.getOffsetWithExpandedEmulationPreventionBytes(e,n,a);return{payloadType:i,payload:e.subarray(n,o),endIndex:o}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,r){var i=lt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,r);return i!==r?i:lt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,r)}}])}();l()(ft,"annexB3ByteStartCode",new Uint8Array([0,0,1])),l()(ft,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),l()(ft,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),l()(ft,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var pt=function(){return u()((function e(){o()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=ft.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),mt=function(){function e(){o()(this,e)}return u()(e,[{key:"extractVclNalUnit",value:function(t,n){var r=n+ft.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(lt.isDataAtOffsetTargetByteSequence(ft.annexB4ByteStartCode,t,r))return{nalUnitData:t.subarray(n+ft.annexB4ByteStartCode.byteLength,r)};var i=n+ft.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return lt.isDataAtOffsetTargetByteSequence(ft.annexB3ByteStartCode,t,i)?{nalUnitData:t.subarray(n+ft.annexB3ByteStartCode.byteLength,i)}:{nalUnitData:t.subarray(n)}}}])}();l()(mt,"_truncatedVclNalUnitByteLength",32);var vt=function(){},gt=function(){function e(t){o()(this,e),l()(this,"_logger",V.getLogger("PhenixEmbeddedIsoBmff2023")),l()(this,"_eventPublisher",void 0),l()(this,"_expectedPayloadUuid",new Set),l()(this,"_endOfChunkHandlersByTrackId",new Map),l()(this,"_disposables",new X),l()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new q(this.enableWarningLogWhenVclEmbeddedDataNotFound.bind(this))),this._eventPublisher=t,this._expectedPayloadUuid.add(e._phenixVclEmbeddedDataUuid),this._expectedPayloadUuid.add(e._phenixInitializationSegmentUuid),this._disposables.add(this.subscribeToPayloadEvents()),this._disposables.add(this.subscribeToPayloadSubscriptionEvents()),this._disposables.add(this.subscribeToNalUnitEvents())}return u()(e,[{key:"subscribeToEmbeddedData",value:function(t){return this._enableWarningLogWhenVclEmbeddedDataNotFound.dispose(),this._eventPublisher.subscribe(ut.Payload,(function(n){var r=n.context,i=n.data;switch(i.uuid){case e._phenixInitializationSegmentUuid:t({context:r,data:{type:"Initialization",data:i.data}});break;case e._phenixVclEmbeddedDataUuid:t({context:r,data:{type:"Media",data:i.data}})}}))}},{key:"dispose",value:function(){this._disposables.dispose(),this._endOfChunkHandlersByTrackId.clear(),this._expectedPayloadUuid.clear()}},{key:"enableWarningLogWhenVclEmbeddedDataNotFound",value:function(){this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents()),this._disposables.add(this.subscribeToEndOfChunkEvents())}},{key:"subscribeToPayloadSubscriptionEvents",value:function(){var e=this;return this._eventPublisher.subscribe(ut.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(ut.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,r=t.data;r.type>ht.SliceLayerIdrData||r.data.byteLength<e._truncatedVclNalUnitDataByteLength||(this.publishVclEmbeddedPayload(n,{uuid:e._phenixVclEmbeddedDataUuid,data:this.extractVclEmbeddedData(r)}),this.disarmLoggingNoVclEmbeddedDataFound(n.trackId))}},{key:"extractVclEmbeddedData",value:function(t){return t.data.subarray(e._truncatedVclNalUnitDataByteLength)}},{key:"publishVclEmbeddedPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"armLoggingNoVclEmbeddedDataFound",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.set(t.trackId,this.logWarningVclEmbeddedDataNotFound.bind(this,t.trackId))}},{key:"disarmLoggingNoVclEmbeddedDataFound",value:function(e){this._endOfChunkHandlersByTrackId.set(e,vt)}},{key:"logWarningVclEmbeddedDataNotFound",value:function(e){this._logger.warn("[%s] [%s] No VCL embedded data found in an encoded video stream chunk from track with id [%s]",e.streamId,e.contextId,e.trackId)}},{key:"subscribeToEndOfChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EndOfChunk,this.handleEndOfEncodedVideoStreamChunk.bind(this))}},{key:"handleEndOfEncodedVideoStreamChunk",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.get(t.trackId)()}},{key:"subscribeToPayloadEvents",value:function(){return this._eventPublisher.subscribe(ut.Payload,this.handlePayloadEvent.bind(this))}},{key:"handlePayloadEvent",value:function(e){var t=e.context,n=e.data;this._expectedPayloadUuid.has(n.uuid)||d.A.setTimeout(this.logWarningUnexpectedPayloadUuidReceivedOnce.bind(this,t,n.uuid))}},{key:"logWarningUnexpectedPayloadUuidReceivedOnce",value:function(e,t){this._logger.warn("[%s] [%s] [%s] Received unexpected payload with uuid [%s]",e.streamId,e.contextId,e.trackId,t),this._expectedPayloadUuid.add(t)}}])}();l()(gt,"_truncatedVclNalUnitDataByteLength",32),l()(gt,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),l()(gt,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var yt=function(){return u()((function e(t,n,r){o()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_bitstream",void 0),l()(this,"_parser",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._bitstream=n,this._parser=r,this._disposables.add(this._bitstream),this._disposables.add(this._parser)}),[{key:"bitstream",get:function(){return this._bitstream}},{key:"decode",value:function(e){this._eventPublisher.publish(ut.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),_t=function(){return u()((function e(t,n){o()(this,e),l()(this,"_h264VideoBitstreamDecoder",void 0),l()(this,"_encoding",void 0),l()(this,"_disposables",void 0),this._h264VideoBitstreamDecoder=t,this._encoding=n,this._disposables=new X,this._disposables.add(this._h264VideoBitstreamDecoder),this._disposables.add(this._encoding)}),[{key:"bitstream",get:function(){return this._h264VideoBitstreamDecoder.bitstream}},{key:"decode",value:function(e){this._h264VideoBitstreamDecoder.decode(e)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEmbeddedData",value:function(e,t){return t?this._encoding.subscribeToEmbeddedData((function(n){n.trackId===t&&e(n)})):this._encoding.subscribeToEmbeddedData(e)}}])}(),bt=function(){return u()((function e(){throw o()(this,e),new Error("BitstreamDecoders is a static class that may not be instantiated")}),null,[{key:"createH264VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new ft(e,new pt);return new yt(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new ft(e,new mt),r=new yt(e,t,n),i=new gt(e);return new _t(r,i)}}])}();function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ct(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var xt,wt=function(){function e(t,n){var r=this;o()(this,e),l()(this,"_channelContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_bitstreamDecoder",bt.createH264VideoBitstreamDecoder()),l()(this,"_frameTimingsByRtpTimestamp",new Map),l()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),l()(this,"_pictureTimingParser",new it),l()(this,"_videoElementDisposables",new X),l()(this,"_currentPlaybackState","waiting"),l()(this,"_armedVideoFrameCallbackId",null),l()(this,"_disposables",new X),l()(this,"_disposed",!1),this._channelContext=t,this._frameTimingInformationContext=n,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new q((function(){return r._frameTimingsByRtpTimestamp.clear()}))),this._disposables.add(this._videoElementDisposables),this._channelContext.videoElement.value&&this.setupVideoEventListeners(this._channelContext.videoElement.value),this._disposables.add(this._channelContext.videoElement.subscribe((function(e){r._videoElementDisposables.dispose(),e&&r.setupVideoEventListeners(e)}))),this._frameTimingInformationContext.shouldExtractTimecode.value&&this._disposables.add(this._bitstreamDecoder.bitstream.subscribeToSeiPayloadType(et.PictureTiming,this.onPictureTimingExtracted.bind(this)))}return u()(e,[{key:"processFrame",value:function(e,t,n,r){if(!this._disposed){var i={mid:t,trackId:n,receiveTimestamp:new Date};this.removeFrameTimingsExceedingMaxCapacity();var a=r.timestamp.toString(10);this._frameTimingsByRtpTimestamp.has(a),this._frameTimingsByRtpTimestamp.set(a,i),this._bitstreamDecoder.decode({context:{streamId:e,trackId:n,contextId:a},data:new Uint8Array(r.data)})}}},{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"onPictureTimingExtracted",value:function(e){var t,n,r,i,a,o=e.context,s=o.contextId,u=o.trackId,c=e.data;if(!this._disposed){var l=null===(t=this._pictureTimingParser.parse(c.data,this._picturingTimingParsingConfig).picStruct)||void 0===t||null===(n=t.clockTimestamps.find((function(e){return!0===e.clockTimestampFlag})))||void 0===n?void 0:n.clockTimestamp;if(l){var d=this._frameTimingsByRtpTimestamp.get(s);if(d){var h={mid:d.mid,trackId:u,kind:"video",codec:"H264",timecode:{hours:null!==(r=l.hours)&&void 0!==r?r:null,minutes:null!==(i=l.minutes)&&void 0!==i?i:null,seconds:null!==(a=l.seconds)&&void 0!==a?a:null,frames:l.nFrames,isFrameDrop:l.countingType>1},sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,receiveTimestamp:new Date(d.receiveTimestamp),playbackState:this._currentPlaybackState};d.decodedFrameTimingInformation=h,this._frameTimingInformationContext.decodedFrameTimingInformation.value=h}}}}},{key:"videoFrameCallback",value:function(e,t){if(!this._disposed){this.armVideoFrameCallback();var n=t.rtpTimestamp;if(n){var r,i=[],a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return St(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?St(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}(this._frameTimingsByRtpTimestamp);try{for(a.s();!(r=a.n()).done;){var o=He()(r.value,2),s=o[0],u=o[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=kt(kt({},u.decodedFrameTimingInformation),{},{renderTimestamp:new Date(performance.timeOrigin+e),playbackState:"playing"})),i.push(s)}}catch(e){a.e(e)}finally{a.f()}for(var c=0,l=i;c<l.length;c++){var d=l[c];this._frameTimingsByRtpTimestamp.delete(d)}}}}},{key:"removeFrameTimingsExceedingMaxCapacity",value:function(){var t=this._frameTimingsByRtpTimestamp.size-(e.MAX_FRAME_TIMING_ENTRIES-1);if(!(t<=0))for(var n=this._frameTimingsByRtpTimestamp.keys(),r=0;r<t;r++){var i=n.next().value;this._frameTimingsByRtpTimestamp.delete(i)}}},{key:"setupVideoEventListeners",value:function(e){var t=this,n=function(){return t._currentPlaybackState="playing"};e.addEventListener("playing",n),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("playing",n)})));var r=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",r),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("pause",r)})));var i=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",i),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("stalled",i)})));var a=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",a),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("waiting",a)})));var o=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",o),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("ended",o)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new q((function(){var e;t._armedVideoFrameCallbackId&&(null===(e=t._channelContext.videoElement.value)||void 0===e||e.cancelVideoFrameCallback(t._armedVideoFrameCallbackId))})))}},{key:"armVideoFrameCallback",value:function(){var e;this._armedVideoFrameCallbackId=null===(e=this._channelContext.videoElement.value)||void 0===e?void 0:e.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}}])}();l()(wt,"MAX_FRAME_TIMING_ENTRIES",1800);var Tt=Symbol(),Pt=function(){function e(){throw o()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return u()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){if("OPUS"===t.toUpperCase())return e._dummyAudioSilentPerCodec.OPUS.buffer}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._dummy82x82H264.IFrame.buffer):e._dummy2x2VideoIFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return"H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber&&(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._isAndroidChrome)?Tt:e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?e.getSurrogate82x82PFrameAndUpdateFrameNumber():e._dummy2x2VideoPFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoPFrame",value:function(t){if("H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber){var n=e._surrogate82x82PFrameFrameNumber,r=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return n>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?Tt:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,r)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var t=(14&e._surrogate82x82PFrameFrameNumber)>>1,n=(1&e._surrogate82x82PFrameFrameNumber)<<7,r=e._dummy82x82H264.PFrame.slice().buffer,i=e._dummy82x82H264PFrameFrameNumberIndex;return r[i]|=t,r[i+1]|=n,e._surrogate82x82PFrameFrameNumber++,r}}])}();xt=Pt,l()(Pt,"_isSafari","Safari"===h.browserName),l()(Pt,"_isMobileChrome","Chrome"===h.browserName&&h.isMobile()),l()(Pt,"_isAndroidChrome","Chrome"===h.browserName&&h.isAndroid),l()(Pt,"_singleZeroByte",new Uint8Array([0])),l()(Pt,"_dummyAudioSilentPerCodec",{OPUS:new Uint8Array([104,7,217,171,188,121,135,171,142,74,20,243,167,28,242,154,122,69,167,45,68,37,116,76,173,22,179,14,81,87,234,231,173,42,56,206,51])}),l()(Pt,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203,0,0,0,1,104,235,227,196,72,68,0,0,1,101,136,130,0,63,112,35,134,230,209,128,9,175,10,65,102,107,84,70,251,113,217,127,255,255,249]),VP8:new Uint8Array([176,2,0,157,1,42,1,0,1,0,57,107,0,39,28,36,12,44,44,68,204,36,65,168,0,19,167,163,122,80,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([130,73,131,66,0,0,0,0,6,118,56,36,28,25,160,0,0,32,64,0,17,191,221,119,255,64,127,177,0])}),l()(Pt,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,65,154,104,73,168,65,104,153,76,15,255,146,129]),VP8:new Uint8Array([49,3,0,228,224,168,155,55,175,16,79,79,177,10,47,228,146,192,31,231,79,70,255,238,81,193,93,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([134,0,64,146,156,36,72,0,0,3,112,0,0,75,64])}),l()(Pt,"_dummy82x82H264",{IFrame:new Uint8Array([0,0,0,1,103,66,192,13,218,24,222,34,34,16,0,0,3,0,16,0,0,3,3,200,241,66,170,0,0,0,1,104,206,15,200,0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[95],de()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],de()(new Uint8Array(3).fill(255)),[15,69,0,1,87,159,39,39,39,39,39,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,120])),PFrame:new Uint8Array([0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[164],de()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),l()(Pt,"_dummy82x82H264PFrameFrameNumberIndex",10418),l()(Pt,"_surrogate82x82PFrameFrameNumberReset",1),l()(Pt,"_useUpdateSurrogate82x82PFrameFrameNumber",xt._isMobileChrome||xt._isSafari),l()(Pt,"_surrogate82x82PFrameFrameNumber",xt._surrogate82x82PFrameFrameNumberReset);var Et=function(){return u()((function e(){throw o()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"configureEncodedStreamPipeline",value:function(e,t,r,i,a,o){var s=new X,u=new K(null),c=new K(null);return e.getTracks().forEach((function(e){var l=t.filter((function(t){return t.track===e}))[0],d=e.kind;switch(d){case"video":var h=!!r;if(f.isRTCRtpScriptTransformSupported){var p=new Worker(new URL(n.p+n.u(63),n.b),{type:void 0});p.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=h,!t.t0){t.next=6;break}return t.next=5,r(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}p.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(p,{kind:e.kind,codec:a,mustSink:h}),s.add(new q((function(){p.terminate()})));break}var m=function(){var t=k()(x().mark((function t(n,i){var o;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!h){t.next=12;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=11;break}if((o="key"===n.type?Pt.getInvalidSurrogateVideoIFrame(a):Pt.getInvalidSurrogateVideoPFrame(a))!==Tt){t.next=8;break}return t.abrupt("return");case 8:n.data=o||n.data,t.next=12;break;case 11:"key"===n.type?n.data=Pt.getSurrogateVideoIFramePerCodec(a)||n.data:n.data=Pt.getSurrogateVideoPFramePerCodec(a)||n.data;case 12:i.enqueue(n);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),v=new TransformStream({transform:m}),g=l.createEncodedStreams(),y=g.readable,_=g.writable;y.pipeThrough(v).pipeTo(_);break;case"audio":var b=!!i;if(f.isRTCRtpScriptTransformSupported){var C=new Worker(new URL(n.p+n.u(444),n.b),{type:void 0});C.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n.data.chunk},t.t0=b,!t.t0){t.next=6;break}return t.next=5,i(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}C.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(C,{kind:e.kind,codec:o,mustSink:b});var S=new MediaStream,w=new Audio;w.srcObject=S,document.body.appendChild(w),s.add(new q((function(){C.terminate(),document.body.removeChild(w)})));break}var T=function(){var t=k()(x().mark((function t(n,r){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n},!b){t.next=9;break}return t.next=4,i(e,n);case 4:if(t.sent){t.next=8;break}n.data=Pt.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Pt.getSurrogateAudioSilentPerCodec(o)||n.data;case 9:r.enqueue(n);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),P=new TransformStream({transform:T}),E=l.createEncodedStreams(),F=E.readable,L=E.writable;F.pipeThrough(P).pipeTo(L);break;default:R(d)}})),{disposables:s,encodedVideoFrame:u,encodedAudioFrame:c}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new X;return e.getTracks().forEach((function(e){var a=e.kind;switch(a){case"video":if(t){var o=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:o}),c=new MediaStreamTrackGenerator({kind:o.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new q((function(){r.removeTrack(c)})))}else r.addTrack(e);break;case"audio":if(n){var h=e,f=new TransformStream({transform:function(t,r){n(e,t,r)}}),p=new MediaStreamTrackProcessor({track:h}),m=new MediaStreamTrackGenerator({kind:h.kind}),v=p.readable,g=m.writable;v.pipeThrough(f).pipeTo(g),r.addTrack(m);var y=new MediaStream,_=new Audio;y.addTrack(e),_.srcObject=y,document.body.appendChild(_),i.add(new q((function(){r.removeTrack(m),document.body.removeChild(_)})))}else r.addTrack(e);break;default:R(a)}})),{transformedStream:r,disposables:i}}}])}(),Ft=n(701).A;function Lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function It(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Dt=function(){return u()((function e(t,n,r,i,a){o()(this,e),l()(this,"_logger",V.getLogger("RealTimeStream")),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_handleStreamFailure",void 0),l()(this,"_disposables",void 0),this._channelContext=t,this._peerConnectionContext=n,this._streamTransformContext=r,this._frameTimingInformationContext=i,this._handleStreamFailure=a,this._disposables=new X,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,r){var i=this,a=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value;return Ft.all([Qe.discoverClosestEndPointWithCaching(e),ie.createPeerConnectionOffer("recvonly",a).then((function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=He()(e,2),r=n[0],a=n[1],o=a.localOffer,s=a.peerConnection;return i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+o.sdp),!f.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s.dispose(),!_e.forceGarbageCollectionOnRestart||f.isMobile&&_e.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection(),s=null,o=null,i._peerConnectionContext.peerConnection.value=s),r.subscribe(t,o,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,h=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=h,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,l),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then((function(e){var t,s=!1,h=!1,p=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e&&(s||_e.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?p.push(n.candidate):h=!0,t||(t=d.A.setTimeout((function(){i._channelContext.stream.value!==o||s||i._channelContext.endPoint.value.addIceCandidates(o,p,h).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(s=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=Se.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(d.A.navigatorIsOnLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:R(e.iceConnectionState)}}};var m=new Ft((function(t,n){if(f.onTrackDisabled){var r=function(n){d.A.clearTimeout(i),e.removeEventListener("track",r),e.removeEventListener("addstream",r),n.streams?t(n.streams[0]):t(n.stream)},i=d.A.setTimeout((function(){e.removeEventListener("track",r),e.removeEventListener("addstream",r),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",r),e.addEventListener("addstream",r)}else{var a=d.A.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){d.A.clearTimeout(a),t(e.streams[0])}}}));return new Ft((function(e){e()})).then((function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(o,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),m})).then((function(t){if(a){var n=new Ze(e.currentRemoteDescription.sdp),o=e.getReceivers(),s=Et.configureEncodedStreamPipeline(t,o,i._streamTransformContext.encodedVideoStreamSink,i._streamTransformContext.encodedAudioStreamSink,n.videoCodec,n.audioCodec),u=s.disposables,c=s.encodedVideoFrame;if("H264"===n.videoCodec.toUpperCase()&&(i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value)){var l=new wt(i._channelContext,i._frameTimingInformationContext);i._disposables.add(l),t.getVideoTracks().forEach((function(t){var n,r=o.filter((function(e){return e.track===t}))[0],a=e.supportsGetTransceivers?null===(n=e.getTransceivers().filter((function(e){return e.receiver===r}))[0])||void 0===n?void 0:n.mid:null;r?a?(i._disposables.add(c.subscribe((function(e){e&&l.processFrame(i._channelContext.streamId,a,e.track.id,e.chunk)}))),i._frameTimingInformationContext.isEnabled.value=!0):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no mid was found",i._channelContext.streamId,t.id):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no receiver was found",i._channelContext.streamId,t.id)}))}i._disposables.add(u)}if(i._streamTransformContext.hasInsertableStreams.value){var h=Et.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),f=h.transformedStream,p=h.disposables;i._disposables.add(p),t=f}i._peerConnectionContext.mediaStream.value=t;var m=new $e(e,t,i._channelContext.endPoint.value.roundTripTime/4);i._disposables.add(m);var v=m.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var n=!1,r=!1;if(t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&d.A.navigatorIsOnLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new xe(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((r=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&d.A.navigatorIsOnLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new xe(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),d.A.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=Se.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,m.dispose(),i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))}));else{if(i._peerConnectionContext.peerConnectionReconnectAttempts=0,i._channelContext.state.value!==Se.Reconnecting&&i._channelContext.state.value!==Se.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Se.Playing:Se.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Se[i._channelContext.state.value])}else i._channelContext.state.value=Se.Offline}));return i._disposables.add(v),_e.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=Se.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=k()(x().mark((function e(t,n){var r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Xe.truncateIceServers(n),e.abrupt("return",_e.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=It(It({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=Se.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<_e.maximalNumberOfPeerConnectionReconnectAttempts||!_e.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(f.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i)return;this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(a)}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"unauthorized":return Se.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"failed":return Se.Error;default:R(e)}}}]);var e}(),Rt=function(){return u()((function e(){throw o()(this,e),new Error("RealTimeStreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,r,i,a){var o=$.parseToken(e).capabilities;return o.includes("on-demand")?(this._logger.error("This build does not support On-Demand Stream playback."),void(t.state.value=Se.UnsupportedFeature)):o.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=Se.UnsupportedFeature)):new Dt(t,n,r,i,a)}}])}();l()(Rt,"_logger",V.getLogger("Streaming"));var At=n(701).A,Ot=function(){return u()((function e(t,n,r){var i=this;o()(this,e),l()(this,"_logger",V.getLogger("Channel")),l()(this,"_tokenContext",void 0),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_stateContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_readOnlyPeerConnection",void 0),l()(this,"_readOnlyState",void 0),l()(this,"_readOnlyAutoMuted",void 0),l()(this,"_readOnlyAutoPaused",void 0),l()(this,"_readOnlyTokenExpiring",void 0),l()(this,"_readOnlyAuthorized",void 0),l()(this,"_readOnlyOnline",void 0),l()(this,"_readOnlyLoading",void 0),l()(this,"_readOnlyPlaying",void 0),l()(this,"_readOnlyStandby",void 0),l()(this,"_readOnlyStopped",void 0),l()(this,"_readOnlyTargetLag",void 0),l()(this,"_readOnlyLag",void 0),l()(this,"_readOnlyBitrateLimit",void 0),l()(this,"_readOnlyResolution",void 0),l()(this,"_readOnlyFailureCount",void 0),l()(this,"_readOnlyEndPoint",void 0),l()(this,"_readOnlyStream",void 0),l()(this,"_readOnlyRtcStatistics",void 0),l()(this,"_readOnlyMediaStream",void 0),l()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),l()(this,"_readOnlyDecodedFrameTimingInformation",void 0),l()(this,"_readOnlyRenderedFrameTimingInformation",void 0),l()(this,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),l()(this,"_videoMetaDataChangedHandler",void 0);var a=$.parseToken(n),s={targetLag:null==r?void 0:r.targetLag},u={hasInsertableStreams:a.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:a.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==r?void 0:r.videoStreamTransformCallback,audioStreamTransformCallback:null==r?void 0:r.audioStreamTransformCallback,encodedVideoStreamSink:null==r?void 0:r.encodedVideoStreamSink,encodedAudioStreamSink:null==r?void 0:r.encodedAudioStreamSink};this._tokenContext=new Ie(n),this._channelContext=new De(s),this._peerConnectionContext=new Ue,this._streamTransformContext=new Ve(u),this._stateContext=new Be,this._exponentialBackoff=new he,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new Q(this._peerConnectionContext.peerConnection),this._readOnlyState=new Q(this._channelContext.state),this._readOnlyAutoMuted=new Q(this._channelContext.autoMuted),this._readOnlyAutoPaused=new Q(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new Q(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Q(this._channelContext.authorized),this._readOnlyOnline=new Q(this._channelContext.online),this._readOnlyLoading=new Q(this._channelContext.loading),this._readOnlyPlaying=new Q(this._channelContext.playing),this._readOnlyStandby=new Q(this._channelContext.standby),this._readOnlyStopped=new Q(this._channelContext.stopped),this._readOnlyTargetLag=new Q(this._channelContext.targetLag),this._readOnlyLag=new Q(this._channelContext.lag),this._readOnlyBitrateLimit=new Q(this._channelContext.bitrateLimit),this._readOnlyResolution=new Q(this._channelContext.resolution),this._readOnlyFailureCount=new Q(this._channelContext.failureCount),this._readOnlyEndPoint=new Q(this._channelContext.endPoint),this._readOnlyStream=new Q(this._channelContext.stream),this._readOnlyRtcStatistics=new Q(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new Q(this._peerConnectionContext.mediaStream);var c=(a.uri||_e.discoveryUri.value).toString();_e.tenancy.value=a.tenancy||_e.tenancy.value,ue.uri.value=c,this._metricsService=ge.getMetricsService(c),this._sessionTelemetry=new Ee(_e.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._frameTimingInformationContext=new Ne,this.configureFrameTimingInformation(a),this._readOnlyIsFrameTimingInformationEnabled=new Q(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new Q(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new Q(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){i._channelContext.rendererDisposables.dispose(),e&&(i._channelContext.rendererDisposables.add(i._channelContext.stream.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.dispose(),e&&i.videoElement&&(i.videoElement.dataset&&(i.videoElement.dataset.sessionId=_e.clientSessionId,i.videoElement.dataset.streamId=i.streamId),i._channelContext.videoTelemetry=new we(i.streamId,_e.pageLoadTime,i._channelStartTime,i._metricsService),i._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(i.videoElement),i._channelContext.videoTelemetry.setupListenerForRebuffering(i.videoElement),i._channelContext.state.value===Se.Stopped)&&i.restartAfterStop()}))),i._channelContext.channelDisposables.add(i._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){i._channelContext.clearFailureCountTimeout&&d.A.clearTimeout(i._channelContext.clearFailureCountTimeout),i._channelContext.failureCount.value&&e===Se.Playing&&(i._channelContext.clearFailureCountTimeout=d.A.setTimeout((function(){i._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&i._channelContext.endPoint.value&&i._channelContext.stream.value){var t=Date.now()-i._channelContext.channelInitialization.getTime();i._channelContext.endPoint.value.limitBitrate(i._channelContext.stream.value,t,e,Fe.Keep,Le.Normal).catch((function(e){i._logger.error("Error while setting limit bitrate",e)}))}})));var h=function(){i._channelContext.stream.value&&i._channelContext.endPoint.value&&i._channelContext.endPoint.value.destroyStreamOnUnmount(i._channelContext.stream.value,"client:termination-on-window-unload")};d.A.addWindowEventListener("beforeunload",h),this._channelContext.channelDisposables.add(new q((function(){d.A.removeWindowEventListener("beforeunload",h)}))),this.start()}),[{key:"videoElement",get:function(){return this._channelContext.videoElement.value},set:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.removeEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("resize",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.dataset&&(this._channelContext.videoElement.value.dataset.sessionId="",this._channelContext.videoElement.value.dataset.streamId=""),this._channelContext.rendererDisposables.dispose(),this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value!==Se.Initializing&&(this._channelContext.state.value=Se.Stopped),this._channelContext.videoElement.value=e,this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"handleVideoMetaDataChanged",value:function(){var e=this._channelContext.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._channelContext.resolution.value=new be(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=be.empty}},{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._channelContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=$.parseToken(this._tokenContext.token.value),n=(t.uri||_e.discoveryUri.value).toString();_e.tenancy.value=t.tenancy||_e.tenancy.value,ue.uri.value=n,this._metricsService=ge.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Fe.Keep,Le.Reset).then((function(t){"ok"===t.status&&(e._channelContext.bitrateLimit.value=0)})).catch((function(t){e._logger.error("Error while setting limit bitrate",t)}))}}},{key:"updateTargetLag",value:function(e){this._channelContext.targetLag.value=e}},{key:"stop",value:(h=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new At((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return h.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=Se.Stopped}},{key:"resume",value:(c=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._peerConnectionContext.mediaStream.value){e.next=3;break}return this._channelContext.autoPaused.value=!1,e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(s=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._channelContext.channelDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getUri",value:function(e){return $.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",_e.discoveryUri.value),new d.A.URL(_e.discoveryUri.value))}},{key:"start",value:(a=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Channel is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"processStart",value:(i=k()(x().mark((function e(){var t,n,r,i,a,o,s,u,c,l,h,p,m,v,g,y,_,b,C,k=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Se.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),$.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Se.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=18;break}if(r=Me.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),i=r.valid,a=r.validationResult,i){e.next=18;break}return this._logger.error(a),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 18:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=26;break}if(o=Me.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=o.valid,u=o.validationResult,s){e.next=26;break}return this._logger.error(u),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 26:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=34;break}if(c=Oe.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,h=c.validationResult,l){e.next=34;break}return this._logger.error(h),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 34:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=42;break}if(p=Oe.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),m=p.valid,v=p.validationResult,m){e.next=42;break}return this._logger.error(v),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 42:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=48;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 48:if(g="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,y="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!g||!y){e.next=56;break}return this._logger.error("Both Media Stream Track transform callback and encodedInsertableStreams sink function found, only use one type or the other"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 56:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=71;break}if(f.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 63:if(g){e.next=69;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 69:e.next=77;break;case 71:if(!g){e.next=77;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 77:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=92;break}if(f.isEncodedInsertableStreamsSupported||f.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 84:if(y){e.next=90;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 90:e.next=98;break;case 92:if(!y){e.next=98;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,_=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Se.Error&&e!==Se.Recovering||Qe.clearCachedClosestEndpoint(_)}))),b=function(){return new At((function(e){return k._stateContext.isStarting.value=!1,e(k.handleStreamFailure())}))},C=Rt.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,b)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",C.start(_,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){k._channelContext.loading.value=!1})).catch((function(e){n.fail(),k._channelContext.failureCount.value++,k._channelContext.online.value=!1,k.cleanUpResources("client:cleanup-after-failed-setup"),k._channelContext.state.value=Se.ClientStartError,k._logger.error("Failed to start channel",e)})).finally((function(){if(k._stateContext.isStarting.value=!1,k._channelContext.state.value!==Se.Playing&&_e.automaticRetryOnFailure){var e=d.A.setTimeout((function(){k.handleStreamFailure().catch((function(e){k._logger.error("Failed handling stream failure",e)}))}),k.getRetryInterval());k._channelContext.disposables.add(new q((function(){d.A.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"restartAfterStop",value:(r=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._peerConnectionContext.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 4:this._tokenContext.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"play",value:(n=k()(x().mark((function e(){var t;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._peerConnectionContext.mediaStream.value){e.next=3;break}return e.abrupt("return",this.start());case 3:return e.abrupt("return",this.playMediaStreamInVideoElement(t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Se.Initializing:case Se.StandBy:case Se.Offline:return 15e3;case Se.Error:case Se.Recovering:case Se.Unauthorized:case Se.GeoRestricted:case Se.GeoBlocked:case Se.Stopped:case Se.Starting:case Se.Playing:case Se.Paused:case Se.Reconnecting:case Se.UnsupportedFeature:case Se.ConfigurationError:case Se.TransientConfigurationError:case Se.ConnectionError:case Se.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:R(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(t=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Se.Error||e.t0===Se.Reconnecting||e.t0===Se.StandBy||e.t0===Se.Offline||e.t0===Se.Recovering||e.t0===Se.TransientConfigurationError||e.t0===Se.ConnectionError||e.t0===Se.ClientStartError?3:e.t0===Se.Unauthorized?5:e.t0===Se.GeoRestricted?7:e.t0===Se.GeoBlocked?9:e.t0===Se.Stopped?11:e.t0===Se.Initializing?13:e.t0===Se.Playing?15:e.t0===Se.Paused?17:e.t0===Se.Starting?19:e.t0===Se.UnsupportedFeature?21:e.t0===Se.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Se[this._channelContext.state.value]),e.abrupt("break",26);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is already initializing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 19:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 23:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 25:R(this._channelContext.state.value);case 26:return e.abrupt("return",this.start());case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!_e.forceGarbageCollectionOnRestart||f.isMobile&&_e.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.capabilities.find((function(e){return e.startsWith("frame-timing-information=")}));this._frameTimingInformationContext.shouldExtractTimecode.value=!1,this._frameTimingInformationContext.shouldExtractTimestamps.value=!1,this._frameTimingInformationContext.isEnabled.value=!1,n?f.isChannelFrameTimingInformationSupported?(n.split("=")[1].split(",").map((function(e){return e.trim()})).forEach((function(e){switch(e){case"timecode":t._frameTimingInformationContext.shouldExtractTimecode.value=!0;break;case"timestamps":t._frameTimingInformationContext.shouldExtractTimestamps.value=!0;break;default:t._logger.info("Ignoring unknown frame timing information option [%s]",e)}})),this._logger.info("Frame timing information configuration [(timecode [%s], timestamps [%s])]",this._frameTimingInformationContext.shouldExtractTimecode.value,this._frameTimingInformationContext.shouldExtractTimestamps.value)):this._logger.info("Disabling frame timing information as the environment does not support it [%s]",n):this._logger.info("Disabling frame timing information as no capability was found")}},{key:"playMediaStreamInVideoElement",value:(e=k()(x().mark((function e(t){var n,r,i=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this._channelContext.videoElement.value){e.next=8;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value=Se.Stopped,e.abrupt("return");case 8:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(r=n.play())){e.next=17;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!0,this._channelContext.state.value=Se.Playing,e.abrupt("return");case 17:return e.abrupt("return",r.then((function(){i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Se.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,a=!_e.automaticallyMuteVideoOnPlayFailure;return a||n.muted||!r?(n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Se.Paused,a?void i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then((function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._channelContext.autoMuted.value=!0,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Se.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Se.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,a,s,c,h}(),Mt=function(){return u()((function e(){throw o()(this,e),new Error("Channels is a static class that may not be instantiated")}),null,[{key:"createChannel",value:function(e){if(!_e.initialized.value)throw new Error("SDK is not loaded.");var t={targetLag:e.targetLag,videoStreamTransformCallback:e.videoStreamTransformCallback,audioStreamTransformCallback:e.audioStreamTransformCallback,encodedVideoStreamSink:e.encodedVideoStreamSink,encodedAudioStreamSink:e.encodedAudioStreamSink};return new Ot(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return f.isChannelFrameTimingInformationSupported}}])}(),Vt={SDK:_e,Channels:Mt,ChannelState:Se}})(),r})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(()=>(()=>{var e={787:(e,t,n)=>{"use strict";var r,i=n(383),a=n.n(i),o=n(579),s=n.n(o),u=n(693),c=n.n(u),l=function(){function e(){a()(this,e),c()(this,"_document",void 0),c()(this,"_location",void 0),c()(this,"_navigator",void 0),c()(this,"_window",void 0),this._document=document,this._location=location,this._navigator=navigator,this._window=window}return s()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"getInstance",value:function(){return e._instance}}])}();r=l,c()(l,"_instance",new r),t.A=l.getInstance()},701:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(738),i=n.n(r),a=n(383),o=n.n(a),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=u()((function e(t,n,r){o()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),f=function(){function e(t){if(o()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var a=r.length,o=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return o(t,e)}),n)}r[t]=s,0==--a&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)o(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,a=t.length;i<a;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){d.A.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new h(e,t,n)),n},f.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var p=f},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(701).A;function i(e,t,n,i,a,o,s){try{var u=e[o](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,a)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,a){var o=e.apply(t,n);function s(e){i(o,r,a,s,u,"next",e)}function u(e){i(o,r,a,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var r=n(701).A,i=n(738).default;function a(){"use strict";e.exports=a=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,s=o.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var i=t&&t.prototype instanceof C?t:C,a=Object.create(i.prototype),o=new A(r||[]);return u(a,"_invoke",{value:L(e,n,o)}),a}function m(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=p;var v="suspendedStart",g="suspendedYield",y="executing",_="completed",b={};function C(){}function k(){}function S(){}var x={};f(x,l,(function(){return this}));var w=Object.getPrototypeOf,T=w&&w(w(O([])));T&&T!==o&&s.call(T,l)&&(x=T);var P=S.prototype=C.prototype=Object.create(x);function E(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(r,a,o,u){var c=m(e[r],e,a);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(d)&&s.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,o,u)}),(function(e){n("throw",e,o,u)})):t.resolve(d).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,u)}))}u(c.arg)}var r;u(this,"_invoke",{value:function(e,i){function a(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(a,a):a()}})}function L(e,n,r){var i=v;return function(a,o){if(i===y)throw Error("Generator is already running");if(i===_){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=I(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===v)throw i=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=m(e,n,r);if("normal"===c.type){if(i=r.done?_:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=_,r.method="throw",r.arg=c.arg)}}}function I(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=m(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(i(e)+" is not iterable")}return k.prototype=S,u(P,"constructor",{value:S,configurable:!0}),u(S,"constructor",{value:k,configurable:!0}),k.displayName=f(S,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,f(e,h,"GeneratorFunction")),e.prototype=Object.create(P),e},n.awrap=function(e){return{__await:e}},E(F.prototype),f(F.prototype,d,(function(){return this})),n.AsyncIterator=F,n.async=function(e,t,i,a,o){void 0===o&&(o=r);var s=new F(p(e,t,i,a),o);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(P),f(P,h,"Generator"),f(P,l,(function(){return this})),f(P,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=O,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(R),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return o.type="throw",o.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=s.call(a,"catchLoc"),c=s.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),R(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;R(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},n}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),a=n(122),o=n(752);e.exports=function(e,t){return r(e)||i(e,t)||a(e,t)||o()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),a=n(122),o=n(869);e.exports=function(e){return r(e)||i(e)||a(e)||o()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.u=e=>e+".js",n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="",n.b=document.baseURI||self.location.href;var r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>Se,Channels:()=>Mt,SDK:()=>_e,default:()=>Vt});var e,t,i,a=n(383),o=n.n(a),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=function(){function e(){o()(this,e)}return u()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();e=h,l()(h,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),l()(h,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),l()(h,"_browserName",e.parseBrowserName()),l()(h,"_browserMajorVersion",e.parseBrowserMajorVersion()),l()(h,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(t=navigator)||void 0===t?void 0:t.userAgent)),l()(h,"_isAndroid",/Android/i.test(null===(i=navigator)||void 0===i?void 0:i.userAgent)),l()(h,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),l()(h,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),l()(h,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),l()(h,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),l()(h,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),l()(h,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),l()(h,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),l()(h,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var f=function(){function e(){o()(this,e)}return u()(e,null,[{key:"clientOfferDisabled",get:function(){return h.isChrome74||h.isChrome75||h.isChrome76||h.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return h.isChrome69||h.isChrome70||h.isChrome71||h.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=69||"Firefox"===h.browserName&&h.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=63||"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===h.browserName||"SamsungBrowser"===h.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==h.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){return"Chrome"===h.browserName&&"function"==typeof d.A.documentCreateElement}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion>=71||"Firefox"===h.browserName&&h.browserMajorVersion>=69||"Safari"===h.browserName}},{key:"isMobile",get:function(){return h.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==h.browserName&&"Safari"!==h.browserName}}])}(),p=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),m=function(){return u()((function e(t,n,r){o()(this,e),l()(this,"_category",void 0),l()(this,"_appenders",void 0),l()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?f.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),v=function(){return u()((function e(){o()(this,e),l()(this,"_appenders",[])}),[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}])}(),g=function(){return u()((function e(){o()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();l()(g,"_sendLocalCandidates",void 0),l()(g,"_sendLogs",void 0),l()(g,"_sendMetrics",void 0),l()(g,"_logToConsole",void 0),g.applyFeatures();var y=function(){return u()((function e(){o()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return p[g.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return p[g.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return p.Info}}])}(),_=function(){return u()((function e(){o()(this,e),l()(this,"_threshold",y.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),b=function(){return u()((function e(t){o()(this,e),l()(this,"_threshold",void 0),this._threshold=t}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(p[e],"] ").concat(t);e<p.Warn?console.log(i):console.error(i)}}}])}(),C=n(293),k=n.n(C),S=n(756),x=n.n(S),w=function(){function e(){throw o()(this,e),new Error("Numbers is a static class that may not be instantiated")}return u()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),T=function(){return u()((function e(){o()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2024-12-09T18:19:35.161Z (2024.2.8-beta.367)"}catch(e){return this._defaultVersion}}}])}();l()(T,"_defaultVersion",(new Date).toISOString());var P=function(){return u()((function e(t){o()(this,e),l()(this,"_telemetryConfiguration",void 0),l()(this,"_logs",[]),l()(this,"_isSending",void 0),l()(this,"_domain",d.A.locationHostname),this._telemetryConfiguration=t}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,a={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:p[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:T.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<p.Error?this._logs.push(a):this._logs.unshift(a),this.sendLogsIfAble()}},{key:"sendLogs",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=k()(x().mark((function e(){var t,n,r,i,a,o=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?w.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce((function(e,t){return e+(t?r(t):0)}),0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),a=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(a).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 12:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),E=function(){return u()((function e(t){o()(this,e),l()(this,"_telemetryService",void 0),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new P(t)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),F=function(){return u()((function e(){o()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_pageLoadTime",void 0),l()(this,"_threshold",y.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),L=function(){return u()((function e(){o()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return I[g.sendMetrics]}}])}(),I=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),D=function(){return u()((function e(){o()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_threshold",L.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),R=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},A=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case I.Off:return"Off";case I.Essential:return"Essential";case I.All:return"All";default:R(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return I.Off;case"Essential":return I.Essential;case"All":return I.All;default:R(e)}}}])}(),O=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case p.Off:return"Off";case p.Trace:return"Trace";case p.Debug:return"Debug";case p.Info:return"Trace";case p.Warn:return"Warn";case p.Error:return"Error";case p.Fatal:return"Fatal";case p.All:return"All";default:R(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return p.Off;case"Trace":return p.Trace;case"Debug":return p.Debug;case"Info":return p.Info;case"Warn":return p.Warn;case"Error":return p.Error;case"Fatal":return p.Fatal;case"All":return p.All;default:R(e)}}}])}(),M=function(){return u()((function e(){o()(this,e)}),[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":A.convertTelemetryLevelToTelemetryLevelType(L.defaultTelemetryLevel),"phenix-logging-level":O.convertLoggingLevelToLoggingLevelType(y.defaultLoggingLevel),"phenix-console-logging-level":O.convertLoggingLevelToLoggingLevelType(y.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":O.convertLoggingLevelToLoggingLevelType(y.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}}])}(),V=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new m(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");p[e]&&this._threshold.setThreshold(p[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(p[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new b(e||y.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||y.defaultTelemetryLoggingLevel,this._appenders.add(new E(this._telemetryConfiguration))}}])}();l()(V,"_configurationParameterReader",new M),l()(V,"_loggers",{}),l()(V,"_appenders",new v),l()(V,"_threshold",new _),l()(V,"_telemetryConfiguration",new F),V.applyLoggerConfigFromParameterConfiguration();var U=function(){return u()((function e(){throw o()(this,e),new Error("Strings is a static class that may not be instantiated")}),null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill((function(){return Math.random().toString(16).substring(2,15)})).reduce((function(e,t){return e+t()}),"").substring(0,e)}}])}(),B=n(452),N=n.n(B),j=n(72),H=n.n(j),z=n(511),G=n.n(z),q=function(){return u()((function e(t){o()(this,e),l()(this,"_disposed",void 0),l()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}),[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function W(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(W=function(){return!!e})()}var J=function(e){function t(e,n){return o()(this,t),r=this,i=t,a=[function(){var t=e.indexOf(n);t>=0&&e.splice(t,1)}],i=H()(i),N()(r,W()?Reflect.construct(i,a||[],H()(r).constructor):i.apply(r,a));var r,i,a}return G()(t,e),u()(t)}(q),K=function(){return u()((function e(t){o()(this,e),l()(this,"_listeners",void 0),l()(this,"_value",void 0),this._listeners=[],this._value=t}),[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new J(this._listeners,e)}}])}(),Q=function(){return u()((function e(t){o()(this,e),l()(this,"_subject",void 0),this._subject=t}),[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),Z=function(){return u()((function e(t){var n,r;o()(this,e),l()(this,"_applicationId",void 0),l()(this,"_token",void 0),this._applicationId=(null==t?void 0:t.applicationId)||"",this._token={uri:null!=t&&null!==(n=t.token)&&void 0!==n&&n.uri?new d.A.URL(t.token.uri):null,capabilities:(null==t||null===(r=t.token)||void 0===r?void 0:r.capabilities)||[]}}),[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),$=function(){function e(){o()(this,e)}return u()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new Z(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new Z(r)}catch(t){return e._logger.error("Cannot parse token value",t),new Z(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();l()($,"_logger",V.getLogger("EdgeAuthParser"));var X=function(){return u()((function e(){o()(this,e),l()(this,"_list",[])}),[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach((function(e){return e.dispose()})),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),Y="visibilitychange",ee=function(){return u()((function e(){o()(this,e),l()(this,"_disposables",new X),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new K(!0),this._readOnlyIsForeground=new Q(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!d.A.documentIsHidden},n=!1;d.A.addDocumentEventListener(Y,t,n),this._disposables.add(new q((function(){return d.A.removeDocumentEventListener(Y,t,n)})))}}])}(),te=n(701).A,ne=function(){return u()((function e(t){o()(this,e),l()(this,"_logger",V.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),f.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}),[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"connectionState",get:function(){return this._peerConnection.connectionState}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsGetTransceivers",get:function(){return!f.getTransceiversDisabled&&"function"==typeof this._peerConnection.getTransceivers}},{key:"supportsAddTransceiver",get:function(){return!f.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(r=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAnswer",value:(n=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLocalDescription",value:(t=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(f.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(f.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new te((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){return this._peerConnection.onconnectionstatechange},set:function(e){this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,t,n,r}(),re=function(){return u()((function e(){o()(this,e)}),[{key:"createPeerConnection",value:(e=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ne(t));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ie=function(){function e(){throw o()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return u()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){f.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=k()(x().mark((function t(){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=k()(x().mark((function t(){var n,r,i,a,o=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:"recvonly",r=o.length>1&&void 0!==o[1]&&o[1],!e._cached||e._cached.direction!==n||r){t.next=6;break}return i=e._cached.peerConnection,e._cached=null,t.abrupt("return",i);case 6:return a=f.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=k()(x().mark((function e(t){var r,i,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:n}),r=t.addTransceiver("video",{direction:n}),e.t0=i,e.t1=r,e.t2=t,e.next=9,t.createOffer(void 0);case 9:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 11:return a="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(a);case 15:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]);var t,n}();l()(ie,"_logger",V.getLogger("PeerConnectionService")),l()(ie,"_peerConnectionFactory",new K(new re)),l()(ie,"_cached",void 0),ie.initiateInitialPrecaching();var ae=function(){return u()((function e(){o()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new d.A.URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}])}(),oe=function(){return u()((function e(){o()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new d.A.URL(e).origin}catch(e){return""}}}])}(),se=function(){return u()((function e(){o()(this,e)}),null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();l()(se,"_discoveryParameters",void 0),se.applyParameters();var ue=function(){function e(){throw o()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return u()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new d.A.URL(e.toString()),n=T.sdkVersion,r=se.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();l()(ue,"_discoveryUri",new K("https://pcast.phenixrts.com/pcast/endPoints"));var ce,le=n(132),de=n.n(le),he=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;o()(this,e),l()(this,"_backoffIntervalInMillisecond",void 0),l()(this,"_minBackoffIntervalInMillisecond",void 0),l()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=t,this._minBackoffIntervalInMillisecond=n,this._maxBackoffIntervalInMillisecond=r}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,a=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(a,this._maxBackoffIntervalInMillisecond)}}])}(),fe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(fe||{}),pe=fe,me=function(){return u()((function e(t){o()(this,e),l()(this,"_metrics",void 0),this._metrics=t}),[{key:"getName",value:function(){return pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case pe.TimeToFirstFrame:case pe.ChannelCreationTimeToFirstFrame:return I.Essential;case pe.Stalled:case pe.Buffering:case pe.SetupCompleted:case pe.SetupFailed:case pe.RoundTripTime:case pe.DownlinkThroughputCapacity:case pe.NetworkType:case pe.ResolutionChanged:case pe.ApplicationForeground:case pe.ApplicationBackground:return I.All;default:R(this._metrics)}}}])}(),ve=function(){return u()((function e(t){o()(this,e),l()(this,"_logger",V.getLogger("MetricsService")),l()(this,"_metricsConfiguration",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_metrics",[]),l()(this,"_isSending",void 0),l()(this,"_failureCount",0),l()(this,"_domain",d.A.locationHostname),this._metricsConfiguration=t,this._exponentialBackoff=new he}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,a=e.resource,o=e.kind,s=new me(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:T.sdkVersion,runtime:i,resource:a,kind:o};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void d.A.setTimeout((function(){n._metrics=[].concat(de()(t),de()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()}),n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,t}(),ge=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var r=new D;return r.sessionId=_e.clientSessionId,r.tenancy=_e.tenancy.value,r.url=ae.getTelemetryUrl(t),r.environment=oe.getEnvironmentFromUrl(t),r.threshold=A.convertTelemetryLevelTypeToTelemetryLevel(_e.telemetryLevel),e._metricsServices[t]=new ve(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();l()(ge,"_metricsServices",{});var ye=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),_e=function(){function e(){throw o()(this,e),new Error("SDK is a static class that may not be instantiated")}return u()(e,null,[{key:"pageLoadTime",get:function(){return ye}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return O.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return A.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return h}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=V.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof E}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof E}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ge.getMetricsService(ue.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ge.setTelemetryLevel(I[t]),e._telemetryLevel.subscribe((function(e){ge.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=this._configurationParameterReader.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=this._configurationParameterReader.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=oe.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=$.parseToken(t);return e._tenancy.value=n.tenancy,ue.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return ue.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");if(i){var a=new d.A.URL(i);return a.pathname="/pcast/endPoints",ue.uri.value=a.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new ee),t){if(t.discoveryUri&&(ue.uri.value=t.discoveryUri),t.peerConnectionFactory&&(ie.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&I[t.telemetryLevel]&&(e._telemetryLevel.value=A.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&p[t.loggingLevel]&&this._logger.threshold.setThreshold(O.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&p[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof b}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new b(O.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ae.getTelemetryUrl(e)}}])}();ce=_e,l()(_e,"_automaticallyRetryOnFailure",!0),l()(_e,"_automaticallyReconnectPeerConnection",!0),l()(_e,"_automaticallyPlayMediaStream",!0),l()(_e,"_automaticallyMuteVideoOnPlayFailure",!0),l()(_e,"_forceGarbageCollectionOnRestart",!0),l()(_e,"_skipGarbageCollectionOnMobileDevices",!0),l()(_e,"_webPlayerLoader",null),l()(_e,"_shakaPlayerLoader",null),l()(_e,"_hlsJsLoader",null),l()(_e,"_configurationParameterReader",new M),l()(_e,"_applicationActivityMonitor",void 0),l()(_e,"_environment",new K("")),l()(_e,"_telemetryUrl",new K("https://telemetry.phenixrts.com/telemetry")),l()(_e,"_maximalNumberOfPeerConnectionReconnectAttempts",8),l()(_e,"_telemetryLevel",new K(L.defaultTelemetryLevel)),l()(_e,"_metricsService",void 0),l()(_e,"_metricsConfiguration",void 0),l()(_e,"_sendLocalCandidates",new K(g.sendLocalCandidates)),l()(_e,"_tenancy",new K("")),l()(_e,"_clientSessionId",U.random(32)),l()(_e,"_loadedTimestamp",new Date),l()(_e,"_logger",V.getLogger("SDK")),l()(_e,"_initialized",new K(!1)),l()(_e,"_readOnlyInitialized",new Q(ce._initialized)),l()(_e,"_readOnlyDiscoveryUri",new Q(ue.uri)),l()(_e,"_readOnlyPeerConnectionFactory",new Q(ie.peerConnectionFactory)),d.A.addWindowEventListener("unload",(function(){_e.dispose()})),_e.applyDiscoveryUriDefaultFromParameterConfiguration(),_e.applyMetricsConfiguration(),_e.applyTelemetryConfiguration(),_e.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),_e.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),_e.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),_e.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),_e.init();var be=function(){function e(t,n){o()(this,e),l()(this,"width",void 0),l()(this,"height",void 0),this.width=t,this.height=n}return u()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}],[{key:"empty",get:function(){return new e(0,0)}}])}(),Ce=function(){return u()((function e(){throw o()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}),null,[{key:"forceGarbageCollection",value:function(){f.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){f.isQueueMicrotaskSupported?d.A.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):d.A.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=d.A.documentCreateElement("img");e.src=d.A.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){d.A.URL.revokeObjectURL(this.src),e=null}}}])}(),ke=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.UnsupportedFeature=12]="UnsupportedFeature",e[e.ConfigurationError=13]="ConfigurationError",e[e.TransientConfigurationError=14]="TransientConfigurationError",e[e.ConnectionError=15]="ConnectionError",e[e.ClientStartError=16]="ClientStartError",e[e.Error=17]="Error",e}(ke||{}),Se=ke,xe=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;o()(this,e),l()(this,"_duration",void 0),this._duration=t}),[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,a=(n=Math.floor(n/60))%60,o=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),o&&s.push(o+"H"),a&&s.push(a+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),we=function(){return u()((function e(t,n,r,i){o()(this,e),l()(this,"_pageLoadTime",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_logger",V.getLogger("StreamTelemetry")),l()(this,"_disposables",new X),l()(this,"_streamId",void 0),l()(this,"_metricsService",void 0),l()(this,"_listenToFirstTime",void 0),l()(this,"_listenForStall",void 0),l()(this,"_listenForContinuation",void 0),l()(this,"_timeToFirstFrame",void 0),l()(this,"_channelCreationTimeToFirstFrame",void 0),l()(this,"_startRecordingFirstFrame",void 0),l()(this,"_videoStalled",void 0),l()(this,"_lastProgress",void 0),l()(this,"_videoResolution",void 0),l()(this,"_clearTimeToFirstFrameListener",void 0),l()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=r,this._metricsService=i}),[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new q((function(){e.removeEventListener("loadeddata",t._listenToFirstTime),e.removeEventListener("loadedmetadata",t._listenToFirstTime)})),this._disposables.add(this._clearTimeToFirstFrameListener)}},{key:"setupListenerForRebuffering",value:function(e){var t=this;this._listenForStall=function(){return t.onStall()},this._listenForContinuation=function(n){return t.onContinuation(n,e)},e.addEventListener("stalled",this._listenForStall),e.addEventListener("pause",this._listenForStall),e.addEventListener("suspend",this._listenForStall),e.addEventListener("play",this._listenForContinuation),e.addEventListener("playing",this._listenForContinuation),e.addEventListener("progress",this._listenForContinuation),e.addEventListener("timeupdate",this._listenForContinuation),this._clearRebufferingListener=new q((function(){e.removeEventListener("stalled",t._listenForStall),e.removeEventListener("pause",t._listenForStall),e.removeEventListener("suspend",t._listenForStall),e.removeEventListener("play",t._listenForContinuation),e.removeEventListener("playing",t._listenForContinuation),e.removeEventListener("progress",t._listenForContinuation),e.removeEventListener("timeupdate",t._listenForContinuation)})),this._disposables.add(this._clearRebufferingListener)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"durationSincePageLoad",get:function(){var e=Date.now();return new xe(e-this._pageLoadTime).toIsoString()}},{key:"callTimeToFirstFrame",value:function(){var e=Date.now();this.pushTimeToFirstFrame(e),this.pushChannelCreationTimeToFirstFrame(e),this._clearTimeToFirstFrameListener.dispose()}},{key:"pushTimeToFirstFrame",value:function(e){this._timeToFirstFrame=e-this._startRecordingFirstFrame,this._metricsService.push({metricType:pe.TimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._timeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] First frame [%s]",this.durationSincePageLoad,this._streamId,new xe(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:pe.ChannelCreationTimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._channelCreationTimeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] Channel creation to first frame [%s]",this.durationSincePageLoad,this._streamId,new xe(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:pe.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:pe.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new xe(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:pe.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Te=function(){return u()((function e(t){o()(this,e),l()(this,"_logger",V.getLogger("StreamSetupListener")),l()(this,"metricsService",_e.metricsService),l()(this,"_pageLoadTime",void 0),l()(this,"_startTime",void 0),l()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}),[{key:"success",value:function(e){this.recordStreamMetric(pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new me(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new xe(n-this._pageLoadTime).toIsoString(),t,i,new xe(r).toIsoString())}}}])}(),Pe=function(){return u()((function e(){o()(this,e),l()(this,"_disposables",new X),l()(this,"_isSupported",void 0!==d.A.navigatorConnection),l()(this,"_rtt",new K(void 0)),l()(this,"_effectiveType",new K(void 0)),l()(this,"_downlinkThroughputCapacity",new K(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}),[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=d.A.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=d.A.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=d.A.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=d.A.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new q((function(){var e;return null===(e=d.A.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),Ee=function(){return u()((function e(t,n){var r=this;o()(this,e),l()(this,"_logger",V.getLogger("SessionTelemetry")),l()(this,"_metricsService",void 0),l()(this,"_applicationActivityMonitor",_e.applicationActivityMonitor),l()(this,"_networkMonitor",new Pe),l()(this,"_pageLoadTime",void 0),l()(this,"_disposables",new X),l()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Te(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?pe.ApplicationForeground:pe.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new xe(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:pe.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new xe(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:pe.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new xe(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:pe.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new xe(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Fe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Le=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ie=u()((function e(t){o()(this,e),l()(this,"token",void 0),l()(this,"tokenExpiring",void 0),this.token=new K(t),this.tokenExpiring=new K(!1)})),De=function(){return u()((function e(t){var n;o()(this,e),l()(this,"channelInitialization",void 0),l()(this,"disposables",void 0),l()(this,"channelDisposables",void 0),l()(this,"rendererDisposables",void 0),l()(this,"videoElement",void 0),l()(this,"state",void 0),l()(this,"autoMuted",void 0),l()(this,"autoPaused",void 0),l()(this,"authorized",void 0),l()(this,"online",void 0),l()(this,"loading",void 0),l()(this,"playing",void 0),l()(this,"standby",void 0),l()(this,"stopped",void 0),l()(this,"targetLag",void 0),l()(this,"lag",void 0),l()(this,"bitrateLimit",void 0),l()(this,"resolution",void 0),l()(this,"failureCount",void 0),l()(this,"endPoint",void 0),l()(this,"stream",void 0),l()(this,"rtcStatistics",void 0),l()(this,"videoTelemetry",void 0),l()(this,"rtcAudioStatistic",void 0),l()(this,"rtcVideoStatistic",void 0),l()(this,"clearFailureCountTimeout",void 0),this.disposables=new X,this.channelDisposables=new X,this.rendererDisposables=new X,this.channelInitialization=new Date,this.videoElement=new K(null),this.state=new K(Se.Initializing),this.autoMuted=new K(!1),this.autoPaused=new K(!1),this.authorized=new K(!0),this.online=new K(!0),this.loading=new K(!1),this.playing=new K(!1),this.standby=new K(!1),this.stopped=new K(!1),this.targetLag=new K(null!==(n=null==t?void 0:t.targetLag)&&void 0!==n?n:0),this.lag=new K(0),this.bitrateLimit=new K(0),this.resolution=new K(be.empty),this.failureCount=new K(0),this.endPoint=new K(null),this.stream=new K(null),this.rtcStatistics=new K(null)}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=_e.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"no-stream":case"not-found":return Se.StandBy;case"geo-restricted":return Se.GeoRestricted;case"geo-blocked":return Se.GeoBlocked;case"unauthorized":return Se.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"forbidden-tag":return Se.ConfigurationError;case"port-in-range-not-found":return Se.TransientConfigurationError;case"failed":return Se.Error;default:R(e)}}}])}(),Re=n(738),Ae=n.n(Re),Oe=function(){return u()((function e(){throw o()(this,e),new Error("EncodedStreamSink is a static class that may not be instantiated")}),null,[{key:"validateEncodedStreamSink",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function type. Found [").concat(Ae()(t),"]")}:2!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function parameter length. Expected 2. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),Me=function(){return u()((function e(){o()(this,e)}),null,[{key:"validateMediaStreamTrackTransform",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function type. Found [").concat(Ae()(t),"]")}:3!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function parameter length. Expected 3. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),Ve=u()((function e(t){o()(this,e),l()(this,"hasInsertableStreams",void 0),l()(this,"hasEncodedInsertableStreams",void 0),l()(this,"videoStreamTransformCallback",void 0),l()(this,"audioStreamTransformCallback",void 0),l()(this,"encodedVideoStreamSink",void 0),l()(this,"encodedAudioStreamSink",void 0),this.hasInsertableStreams=new K(t.hasInsertableStreams),this.hasEncodedInsertableStreams=new K(t.hasEncodedInsertableStreams),this.videoStreamTransformCallback=t.videoStreamTransformCallback,this.audioStreamTransformCallback=t.audioStreamTransformCallback,this.encodedVideoStreamSink=t.encodedVideoStreamSink,this.encodedAudioStreamSink=t.encodedAudioStreamSink})),Ue=u()((function e(){o()(this,e),l()(this,"mediaStream",void 0),l()(this,"peerConnection",void 0),l()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new K(null),this.peerConnection=new K(null),this.peerConnectionReconnectAttempts=0})),Be=u()((function e(){o()(this,e),l()(this,"isStarting",void 0),l()(this,"isDisposed",void 0),this.isStarting=new K(!1),this.isDisposed=!1})),Ne=u()((function e(){o()(this,e),l()(this,"shouldExtractTimecode",void 0),l()(this,"shouldExtractTimestamps",void 0),l()(this,"isEnabled",void 0),l()(this,"decodedFrameTimingInformation",void 0),l()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new K(!1),this.shouldExtractTimestamps=new K(!1),this.isEnabled=new K(!1),this.decodedFrameTimingInformation=new K(null),this.renderedFrameTimingInformation=new K(null)})),je=n(715),He=n.n(je),ze=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Le.Normal:return"Normal";case Le.Force:return"Force";case Le.Reset:return"Reset";default:R(e)}}}])}(),Ge=function(){return u()((function e(){o()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Fe.Keep:return"Keep";case Fe.Reset:return"Reset";default:R(e)}}}])}(),qe=n(701).A,We=function(){return u()((function e(t,n){if(o()(this,e),l()(this,"_logger",V.getLogger("EndPoint")),l()(this,"_uri",void 0),l()(this,"_timeout",void 0),l()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}),[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(v=k()(x().mark((function e(){var t,n,r,i,a=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,qe.race([d.A.fetch(t,{method:"GET",cache:"no-cache"}),new qe((function(e,n){return d.A.setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),a._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(m=k()(x().mark((function e(t,n,r){var i,a,o,s,u,c,l,h,f,p,m,v,g=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=$.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return a=this.buildUrl([i,"stream","subscribe"]).toString(),o=new d.A.FormData,s=T.sdkVersion,0===r&&n?(u={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}},o.append("jsonBody",JSON.stringify(u))):(c={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},o.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,f=null,e.next=13,qe.race([d.A.fetch(a,{method:"POST",body:o}),new qe((function(e){return f=d.A.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){f&&d.A.clearTimeout(f)}));case 13:h=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(p=this.mapHttpStatusToSubscribeStatus(h))){e.next=23;break}return e.abrupt("return",{status:p});case 23:return m=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(i,h);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,m-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return m.apply(this,arguments)})},{key:"publish",value:(p=k()(x().mark((function e(t,n,r,i){var a,o,s,u,c,l,h,f,p,m,v,g,y=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=$.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([a,"stream","publish"]).toString(),s=new d.A.FormData,u=T.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),h=Date.now(),e.prev=9,p=null,e.next=13,qe.race([d.A.fetch(o,{method:"POST",body:s}),new qe((function(e){return p=d.A.setTimeout((function(){y._logger.error("Failed to publish",new Error("Publish timed out [".concat(o,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&d.A.clearTimeout(p)}));case 13:f=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(m=this.mapHttpStatusToPublishStatus(f))){e.next=23;break}return e.abrupt("return",{status:m});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(a,f);case 26:return g=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-h),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(f=k()(x().mark((function e(t,n){var r,i,a,o,s,u,c,l,h,f=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new d.A.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(a)),o=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(r,{method:"POST",body:i}),new qe((function(e){return u=d.A.setTimeout((function(){f._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 22:return h=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",h,l-o),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return f.apply(this,arguments)})},{key:"limitBitrate",value:(h=k()(x().mark((function e(t,n,r,i,a){var o,s,u,c,l,h,f,p,m=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new d.A.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Ge.convertBitrateStateToBitrateStateType(i),bitrateMode:ze.convertBitrateModeToBitrateModeType(a)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,h=null,e.next=9,qe.race([d.A.fetch(o,{method:"POST",body:s}),new qe((function(e){return h=d.A.setTimeout((function(){m._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(o,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){h&&d.A.clearTimeout(h)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return f=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",f,p-c),e.abrupt("return",{status:f});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(c=k()(x().mark((function e(t,n,r){var i,a,o,s,u,c,l,h,f,p,m=this,v=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],a=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),o=new d.A.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},o.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,qe.race([d.A.fetch(a,{method:"POST",body:o}),new qe((function(e){return l=d.A.setTimeout((function(){m._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(a,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){l&&d.A.clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(h=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:h});case 20:return f=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,f-u),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(s=k()(x().mark((function e(t,n){var r,i,a,o,s,u,c,l,h,f=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new d.A.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(a)),o=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new qe((function(e){return u=d.A.setTimeout((function(){f._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(s);case 22:return h=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",h,l-o),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(a=k()(x().mark((function e(t,n){var r,i,a,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),a=new d.A.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},a.append("jsonBody",JSON.stringify(o)),navigator.sendBeacon(i,a);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new d.A.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,de()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new d.A.URL(this._uri),t=T.sdkVersion,n=se.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(i=k()(x().mark((function e(t,n){var r,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(r=k()(x().mark((function e(t,n){var r,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(n=k()(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(t=k()(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=k()(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,a,s,c,h,f,p,m,v}(),Je=n(701).A,Ke=function(){return u()((function e(t){if(o()(this,e),l()(this,"_logger",V.getLogger("Discovery")),l()(this,"_metricsService",void 0),l()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ge.getMetricsService(t.toString()),this._uri=t}),[{key:"discoverNearbyEndPoints",value:(t=k()(x().mark((function e(t,n){var r,i,a,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new Error("Discovery requires timeout");case 2:return r=t.toString(),e.next=5,Je.race([d.A.fetch(r,{method:"GET",cache:"no-cache"}),new Je((function(e,t){return d.A.setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return a=e.sent,o=a.split(","),e.abrupt("return",o.map((function(e){return new We(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=k()(x().mark((function e(){var t,n,r,i,a,o,s=this,u=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ue.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new d.A.URL(n),t);case 4:return r=e.sent,i=0,a=function(){return new Je((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Je.race(r.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,a()})).then((function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:pe.RoundTripTime,runtime:(n-_e.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 9:return o=e.sent,e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),Qe=function(){function e(){throw o()(this,e),new Error("Discovery is a static class that may not be instantiated")}return u()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=k()(x().mark((function t(){var n;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new d.A.URL(_e.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=k()(x().mark((function t(n){var r,i,a;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new Ke(n),a=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){d.A.setTimeout((function(){e._cache[r]===a&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),t.abrupt("return",a);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();e._cache[n]&&delete e._cache[n]}}]);var t,n}();l()(Qe,"_cache",{}),Qe.precacheClosestEndPointDiscovery();var Ze=function(){return u()((function e(t){o()(this,e),l()(this,"_sdp",void 0),l()(this,"_audioCodec",void 0),l()(this,"_videoCodec",void 0),l()(this,"_isAudioTrackEnabled",void 0),l()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}),[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}])}(),$e=function(){return u()((function e(t,n,r){if(o()(this,e),l()(this,"_estimatedRoundTripTime",void 0),l()(this,"_estimatedVideoCodec",void 0),l()(this,"_estimatedAudioCodec",void 0),l()(this,"_rtcStatistic",new K({})),l()(this,"_peerConnection",void 0),l()(this,"_isMonitorRunning",!0),l()(this,"_updateTimeout",void 0),l()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!f.getCurrentOfferDisabled){var i=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(d.A.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,a=n._estimatedRoundTripTime;e.forEach((function(o){if("candidate-pair"===o.type&&o.currentRoundTripTime&&(a=1e3*o.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=a),r.video&&(r.video.roundTripTime=a)),"candidate-pair"===o.type&&o.lastPacketReceivedTimestamp&&(i=o.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===o.type){var s=o.kind||o.mediaType||t(o),u="";if(e.forEach((function(e){e.id===o.codecId&&(u=e.mimeType)})),s&&n._tracksToMonitor.includes(s)){var c,l,d,h,f,p=(o.bytesReceived||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesReceived)&&void 0!==c?c:0),m=o.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(f=h[s])||void 0===f?void 0:f.timestamp),v=p&&m?Math.floor(8*p/m*1e3):0;if(r[s]={ssrc:o.ssrc,mediaType:s,timestamp:o.timestamp,bitrate:v,bytesReceived:o.bytesReceived,packetsLost:o.packetsLost,packetsReceived:o.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:a},(o.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=o.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[s].framesDecoded=o.framesDecoded;var g=(o.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(r[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeout=d.A.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},r=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i=e.stat("mediaType").toString();n[i]={timestamp:Date.now()},n[i].ssrc=e.stat("ssrc").toString(),n[i].mediaType=i,n[i].bytesReceived=e.stat("bytesReceived"),n[i].packetsLost=e.stat("packetsLost"),n[i].packetsReceived=e.stat("packetsReceived"),n[i].codec=e.stat("googCodecName").toString()||t.getCodecByType(i),n[i].roundTripTime=r,"video"===i&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[i].framesDecoded=e.stat("framesDecoded"),n[i].fps=(n[i].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[i].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeout=d.A.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]);var e,t}(),Xe=function(){return u()((function e(){throw o()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}),null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),Ye=function(e){return e[e.BufferingPeriod=0]="BufferingPeriod",e[e.PictureTiming=1]="PictureTiming",e[e.PanScanRect=2]="PanScanRect",e[e.FillerPayload=3]="FillerPayload",e[e.UserDataRegistered=4]="UserDataRegistered",e[e.UserDataUnregistered=5]="UserDataUnregistered",e[e.RecoveryPoint=6]="RecoveryPoint",e[e.DecRefPicMarkingRepeition=7]="DecRefPicMarkingRepeition",e[e.SparePic=8]="SparePic",e[e.SceneInfo=9]="SceneInfo",e[e.SubSeqInfo=10]="SubSeqInfo",e[e.SubSeqLayerCharacteristics=11]="SubSeqLayerCharacteristics",e[e.SubSeqCharacteristics=12]="SubSeqCharacteristics",e[e.FullFrameFreeze=13]="FullFrameFreeze",e[e.FullFrameFreezeRelease=14]="FullFrameFreezeRelease",e[e.FullFrameSnapshot=15]="FullFrameSnapshot",e[e.ProgressiveRefinementSegmentStart=16]="ProgressiveRefinementSegmentStart",e[e.ProgressiveRefinementSegmentEnd=17]="ProgressiveRefinementSegmentEnd",e[e.MotionConstrainedSliceGroupSet=18]="MotionConstrainedSliceGroupSet",e[e.FilmGrainCharacteristic=19]="FilmGrainCharacteristic",e[e.DeblockingFilterDisplayReference=20]="DeblockingFilterDisplayReference",e[e.StereoVideoInfo=21]="StereoVideoInfo",e[e.PostFilterHint=22]="PostFilterHint",e[e.ToneMappingInfo=23]="ToneMappingInfo",e[e.ScalabilityInfo=24]="ScalabilityInfo",e[e.SubPicScalableLayer=25]="SubPicScalableLayer",e[e.NonRequiredLayerRep=26]="NonRequiredLayerRep",e[e.PariorityLayerInfo=27]="PariorityLayerInfo",e[e.LayersNotPresent=28]="LayersNotPresent",e[e.LayerDependencyChange=29]="LayerDependencyChange",e[e.ScalableNesting=30]="ScalableNesting",e[e.BaseLayerTemporalHrd=31]="BaseLayerTemporalHrd",e[e.QualityLayerIntegrityCheck=32]="QualityLayerIntegrityCheck",e[e.RedundantPicProperty=33]="RedundantPicProperty",e[e.Tl0DepRepIndex=34]="Tl0DepRepIndex",e[e.TlSwitchingPoint=35]="TlSwitchingPoint",e[e.ParallelDecodingInfo=36]="ParallelDecodingInfo",e[e.MvcScalableNesting=37]="MvcScalableNesting",e[e.ViewScalabilityInfo=38]="ViewScalabilityInfo",e[e.MultiviewSceneInfo=39]="MultiviewSceneInfo",e[e.MultiviewAcquisitionInfo=40]="MultiviewAcquisitionInfo",e[e.NonRequiredViewComponent=41]="NonRequiredViewComponent",e[e.ViewDependencyChange=42]="ViewDependencyChange",e[e.OperationPointsNotPresent=43]="OperationPointsNotPresent",e[e.BaseViewTemporalHdr=44]="BaseViewTemporalHdr",e[e.FramePackingArrangement=45]="FramePackingArrangement",e[e.MultiviewViewPosition=46]="MultiviewViewPosition",e[e.DisplayOrientation=47]="DisplayOrientation",e[e.MvcdScalableNesting=48]="MvcdScalableNesting",e[e.MvcdViewScalabilityInfo=49]="MvcdViewScalabilityInfo",e[e.DepthRepresentationInfo=50]="DepthRepresentationInfo",e[e.ThreeDimensionalReferenceDisplaysInfo=51]="ThreeDimensionalReferenceDisplaysInfo",e[e.DepthTiming=52]="DepthTiming",e[e.DepthSamplingInfo=53]="DepthSamplingInfo",e[e.ConstrainedDepthParameterSetIdentifier=54]="ConstrainedDepthParameterSetIdentifier",e[e.GreenMetadata=55]="GreenMetadata",e[e.MasteringDisplayColourVolumev=56]="MasteringDisplayColourVolumev",e[e.ColourRemappingInfo=57]="ColourRemappingInfo",e[e.ContentLightLevelInfo=58]="ContentLightLevelInfo",e[e.AlternativeTransferCharacteristics=59]="AlternativeTransferCharacteristics",e[e.AmbientViewingEnvironment=60]="AmbientViewingEnvironment",e[e.ContentColourVolume=61]="ContentColourVolume",e[e.EquirectangularProjection=62]="EquirectangularProjection",e[e.CubemapProjection=63]="CubemapProjection",e[e.SphereRotation=64]="SphereRotation",e[e.RegionwisePacking=65]="RegionwisePacking",e[e.OmniViewport=66]="OmniViewport",e[e.AlternativeDepthInfo=67]="AlternativeDepthInfo",e[e.SeiManifest=68]="SeiManifest",e[e.SeiPrefixIndication=69]="SeiPrefixIndication",e[e.AnnotatedRegions=70]="AnnotatedRegions",e[e.ShutterIntervalInfo=71]="ShutterIntervalInfo",e}(Ye||{}),et=Ye,tt=function(){return u()((function e(t){o()(this,e),l()(this,"_data",void 0),l()(this,"_bitOffset",void 0),this._data=t,this._bitOffset=0}),[{key:"readBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot read [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));for(var t=0,n=e;n>0;){var r=Math.floor(this._bitOffset/8),i=8-this._bitOffset%8,a=Math.min(n,i),o=(1<<a)-1;t=t<<a|this._data[r]>>i-a&o,n-=a,this._bitOffset+=a}return t}},{key:"skipBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot skip [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));this._bitOffset+=e}},{key:"getRemainingBits",value:function(){return 8*this._data.length-this._bitOffset}}])}(),nt=function(){return u()((function e(){throw o()(this,e),new Error("EmulationPreventionBytes is a static class that may not be instantiated")}),null,[{key:"getOffsetWithExpandedEmulationPreventionBytes",value:function(e,t,n){for(var r=0,i=0,a=n,o=t;o<e.length&&0!==a;o++,i++)2!==r||3!==e[o]?(0===e[o]?r++:r>0&&(r=0),a--):r=0;return i}},{key:"removeEmulationPreventionBytes",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,r=0,i=2;i<e.byteLength;i++)3===e[i]&&0===e[i-1]&&0===e[i-2]&&(t.set(e.subarray(r,i),n),n+=i-r,r=i+1);return r<e.byteLength&&t.set(e.subarray(r),n),t}}])}(),rt=function(e){return e[e.ProgressiveFrame=0]="ProgressiveFrame",e[e.TopField=1]="TopField",e[e.BottomField=2]="BottomField",e[e.TopFieldBottomField=3]="TopFieldBottomField",e[e.BottomFieldTopField=4]="BottomFieldTopField",e[e.TopFieldBottomFieldTopFieldRepeated=5]="TopFieldBottomFieldTopFieldRepeated",e[e.BottomFieldTopFieldBottomFieldRepeated=6]="BottomFieldTopFieldBottomFieldRepeated",e[e.FrameDoubling=7]="FrameDoubling",e[e.FrameTripling=8]="FrameTripling",e}(rt||{}),it=function(){return u()((function e(){o()(this,e)}),[{key:"parse",value:function(e,t){var n=new tt(nt.removeEmulationPreventionBytes(e)),r={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&(n.skipBits(t.cpbRemovalDelayLengthMinus1+1),n.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){var i=this.convertPicStructToNumClockTS(n.readBits(4));r.picStruct={numClockTS:i,clockTimestamps:[]};for(var a=0;a<r.picStruct.numClockTS;a++){var o=1===n.readBits(1);if(o){var s={ctType:n.readBits(2),nuitFieldBasedFlag:1===n.readBits(1),countingType:n.readBits(5),fullTimestampFlag:1===n.readBits(1),discontinuityFlag:1===n.readBits(1),cntDroppedFlag:1===n.readBits(1),nFrames:n.readBits(8)};s.fullTimestampFlag?(s.seconds=n.readBits(6),s.minutes=n.readBits(6),s.hours=n.readBits(5)):1===n.readBits(1)&&(s.seconds=n.readBits(6),1===n.readBits(1)&&(s.minutes=n.readBits(6),1===n.readBits(1)&&(s.hours=n.readBits(5)))),s.timeOffset=n.readBits(24),r.picStruct.clockTimestamps.push({clockTimestampFlag:o,clockTimestamp:s})}else r.picStruct.clockTimestamps.push({clockTimestampFlag:!1})}}return r}},{key:"convertPicStructToNumClockTS",value:function(e){switch(e){case rt.ProgressiveFrame:case rt.TopField:case rt.BottomField:return 1;case rt.TopFieldBottomField:case rt.BottomFieldTopField:case rt.FrameDoubling:return 2;case rt.TopFieldBottomFieldTopFieldRepeated:case rt.BottomFieldTopFieldBottomFieldRepeated:case rt.FrameTripling:return 3;default:return 0}}}])}();function at(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ot=function(){return u()((function e(){o()(this,e),l()(this,"_listeners",new Set)}),[{key:"subscribe",value:function(e){var t=this;return this._listeners.add(e),new q((function(){return t._listeners.delete(e)}))}},{key:"emit",value:function(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return at(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?at(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}(this._listeners);try{for(n.s();!(t=n.n()).done;)(0,t.value)(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._listeners.clear()}}])}(),st=function(){return u()((function e(){o()(this,e),l()(this,"_eventEmitters",new Map),l()(this,"_onEventWithNoSubscriberHandlers",new Set),l()(this,"_disposables",new X)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new q((function(){return t._onEventWithNoSubscriberHandlers.delete(e)}))}},{key:"subscribe",value:function(e,t){var n=(this._eventEmitters.get(e)||this.createEmitter(e)).subscribe(t);return this._disposables.add(n),n}},{key:"publish",value:function(e,t){var n=this._eventEmitters.get(e);n?n.emit(t):this._onEventWithNoSubscriberHandlers.forEach((function(n){return n(e,t)}))}},{key:"dispose",value:function(){this._disposables.dispose(),this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._eventEmitters.clear(),this._onEventWithNoSubscriberHandlers.clear()}},{key:"createEmitter",value:function(e){var t=new ot;return this._eventEmitters.set(e,t),t}}])}(),ut=function(e){return e[e.EncodedVideoStreamChunk=0]="EncodedVideoStreamChunk",e[e.NalUnit=1]="NalUnit",e[e.SeiPayload=2]="SeiPayload",e[e.Payload=3]="Payload",e[e.PayloadSubscription=4]="PayloadSubscription",e[e.EndOfChunk=5]="EndOfChunk",e}({}),ct=function(){return u()((function e(t){o()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_disposables",new X),this._eventPublisher=t}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(ut.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(ut.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(ut.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(ut.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),lt=function(){function e(){throw o()(this,e),new Error("Uint8Arrays is a static class that may not be instantiated")}return u()(e,null,[{key:"isDataAtOffsetTargetByteSequence",value:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]!==t[n+r])return!1;return!0}},{key:"findTargetByteSequenceIndexFromOffset",value:function(t,n,r){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,a=r;a<=n.byteLength;a++)if(e.isDataAtOffsetTargetByteSequence(t,n,a))return a;return i}},{key:"getUuidStringFromUint8Array",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=[],r=0;r<t;r++){var i=e[r].toString(16).padStart(2,"0");n.push(i),3!==r&&5!==r&&7!==r&&9!==r||n.push("-")}return n.join("")}}])}(),dt=function(e){return e[e.Unspecified=0]="Unspecified",e[e.SliceLayerNonIdrData=1]="SliceLayerNonIdrData",e[e.SliceDataPartitionALayer=2]="SliceDataPartitionALayer",e[e.SliceDataPartitionBLayer=3]="SliceDataPartitionBLayer",e[e.SliceDataPartitionCLayer=4]="SliceDataPartitionCLayer",e[e.SliceLayerIdrData=5]="SliceLayerIdrData",e[e.SupplementalEnhancementInformation=6]="SupplementalEnhancementInformation",e[e.SequenceParameterSet=7]="SequenceParameterSet",e[e.PictureParameterSet=8]="PictureParameterSet",e[e.AccessUnitDelimiter=9]="AccessUnitDelimiter",e[e.EndOfSequence=10]="EndOfSequence",e[e.EndOfStream=11]="EndOfStream",e[e.FillerData=12]="FillerData",e[e.SequenceParamterSetExtension=13]="SequenceParamterSetExtension",e[e.PrefixNalUnit=14]="PrefixNalUnit",e[e.SubsetSequenceParamterSet=15]="SubsetSequenceParamterSet",e[e.DepthParamterSet=16]="DepthParamterSet",e[e.Reserved17=17]="Reserved17",e[e.Reserved18=18]="Reserved18",e[e.SliceLayerAuxiliary=19]="SliceLayerAuxiliary",e[e.SliceExtension=20]="SliceExtension",e[e.SliceExtensionDepthViewComponent=21]="SliceExtensionDepthViewComponent",e[e.Reserved22=22]="Reserved22",e[e.Reserverd23=23]="Reserverd23",e[e.Unspecified24=24]="Unspecified24",e[e.Unspecified25=25]="Unspecified25",e[e.Unspecified26=26]="Unspecified26",e[e.Unspecified27=27]="Unspecified27",e[e.Unspecified28=28]="Unspecified28",e[e.Unspecified29=29]="Unspecified29",e[e.Unspecified30=30]="Unspecified30",e[e.Unspecified31=31]="Unspecified31",e}(dt||{}),ht=dt,ft=function(){function e(t,n){o()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_vclExtractionStrategy",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._vclExtractionStrategy=n,this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents())}return u()(e,[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.parseEncodedVideoStreamChunk.bind(this))}},{key:"parseEncodedVideoStreamChunk",value:function(e){for(var t=e.context,n=e.data,r=0;r<n.byteLength;)r+=this.handleExtractedData(t,this.extractNalUnitAtOffset(n,r));this.notifyEndOfChunk(t)}},{key:"handleExtractedData",value:function(e,t){var n=t.annexBStartCodeLength,r=t.nalUnit,i=t.seiPayloads;return this.publishNalUnit(e,r),null==i||i.forEach(this.handleSeiPayload.bind(this,e)),r.data.byteLength+n}},{key:"handleSeiPayload",value:function(e,t){this.publishSeiPayload(e,t),t.type===et.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=lt.getUuidStringFromUint8Array(t.data.subarray(0,16)),r=t.data.subarray(16);this.publishPayload(e,{uuid:n,data:r})}},{key:"publishNalUnit",value:function(e,t){this._eventPublisher.publish(ut.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(ut.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(ut.EndOfChunk,{context:e,data:null})}},{key:"extractNalUnitAtOffset",value:function(e,t){var n,r=1===e[t+2]?3:4,i=t+r,a=31&e[i];switch(a){case ht.SliceLayerNonIdrData:case ht.SliceDataPartitionALayer:case ht.SliceDataPartitionBLayer:case ht.SliceDataPartitionCLayer:case ht.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,i);break;case ht.SupplementalEnhancementInformation:n=this.extractSeiNalUnit(e,i);break;default:n=this.extractNonVclNalUnit(e,i)}return{annexBStartCodeLength:r,nalUnit:{type:a,data:n.nalUnitData},seiPayloads:n.seiPayloads}}},{key:"extractSeiNalUnit",value:function(t,n){for(var r=n+1,i=[];!lt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,r)&&!lt.isDataAtOffsetTargetByteSequence(e._seiPayload3ByteEndCode,t,r)&&r<t.byteLength;){var a=this.extractSeiPayload(t,r);i.push({data:a.payload,type:a.payloadType}),r=a.endIndex}return r++,{nalUnitData:t.subarray(n,r),seiPayloads:i}}},{key:"extractNonVclNalUnit",value:function(t,n){var r=e.findAnnexBStartIndexFromOffset(t,n,t.byteLength);return{nalUnitData:t.subarray(n,r)}}},{key:"extractSeiPayload",value:function(e,t){for(var n=t,r=0;255===e[n];)n++,r++;var i=255*r+e[n];for(n++,r=0;255===e[n];)n++,r++;var a=255*r+e[n],o=++n+nt.getOffsetWithExpandedEmulationPreventionBytes(e,n,a);return{payloadType:i,payload:e.subarray(n,o),endIndex:o}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,r){var i=lt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,r);return i!==r?i:lt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,r)}}])}();l()(ft,"annexB3ByteStartCode",new Uint8Array([0,0,1])),l()(ft,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),l()(ft,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),l()(ft,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var pt=function(){return u()((function e(){o()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=ft.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),mt=function(){function e(){o()(this,e)}return u()(e,[{key:"extractVclNalUnit",value:function(t,n){var r=n+ft.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(lt.isDataAtOffsetTargetByteSequence(ft.annexB4ByteStartCode,t,r))return{nalUnitData:t.subarray(n+ft.annexB4ByteStartCode.byteLength,r)};var i=n+ft.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return lt.isDataAtOffsetTargetByteSequence(ft.annexB3ByteStartCode,t,i)?{nalUnitData:t.subarray(n+ft.annexB3ByteStartCode.byteLength,i)}:{nalUnitData:t.subarray(n)}}}])}();l()(mt,"_truncatedVclNalUnitByteLength",32);var vt=function(){},gt=function(){function e(t){o()(this,e),l()(this,"_logger",V.getLogger("PhenixEmbeddedIsoBmff2023")),l()(this,"_eventPublisher",void 0),l()(this,"_expectedPayloadUuid",new Set),l()(this,"_endOfChunkHandlersByTrackId",new Map),l()(this,"_disposables",new X),l()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new q(this.enableWarningLogWhenVclEmbeddedDataNotFound.bind(this))),this._eventPublisher=t,this._expectedPayloadUuid.add(e._phenixVclEmbeddedDataUuid),this._expectedPayloadUuid.add(e._phenixInitializationSegmentUuid),this._disposables.add(this.subscribeToPayloadEvents()),this._disposables.add(this.subscribeToPayloadSubscriptionEvents()),this._disposables.add(this.subscribeToNalUnitEvents())}return u()(e,[{key:"subscribeToEmbeddedData",value:function(t){return this._enableWarningLogWhenVclEmbeddedDataNotFound.dispose(),this._eventPublisher.subscribe(ut.Payload,(function(n){var r=n.context,i=n.data;switch(i.uuid){case e._phenixInitializationSegmentUuid:t({context:r,data:{type:"Initialization",data:i.data}});break;case e._phenixVclEmbeddedDataUuid:t({context:r,data:{type:"Media",data:i.data}})}}))}},{key:"dispose",value:function(){this._disposables.dispose(),this._endOfChunkHandlersByTrackId.clear(),this._expectedPayloadUuid.clear()}},{key:"enableWarningLogWhenVclEmbeddedDataNotFound",value:function(){this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents()),this._disposables.add(this.subscribeToEndOfChunkEvents())}},{key:"subscribeToPayloadSubscriptionEvents",value:function(){var e=this;return this._eventPublisher.subscribe(ut.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(ut.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,r=t.data;r.type>ht.SliceLayerIdrData||r.data.byteLength<e._truncatedVclNalUnitDataByteLength||(this.publishVclEmbeddedPayload(n,{uuid:e._phenixVclEmbeddedDataUuid,data:this.extractVclEmbeddedData(r)}),this.disarmLoggingNoVclEmbeddedDataFound(n.trackId))}},{key:"extractVclEmbeddedData",value:function(t){return t.data.subarray(e._truncatedVclNalUnitDataByteLength)}},{key:"publishVclEmbeddedPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"armLoggingNoVclEmbeddedDataFound",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.set(t.trackId,this.logWarningVclEmbeddedDataNotFound.bind(this,t.trackId))}},{key:"disarmLoggingNoVclEmbeddedDataFound",value:function(e){this._endOfChunkHandlersByTrackId.set(e,vt)}},{key:"logWarningVclEmbeddedDataNotFound",value:function(e){this._logger.warn("[%s] [%s] No VCL embedded data found in an encoded video stream chunk from track with id [%s]",e.streamId,e.contextId,e.trackId)}},{key:"subscribeToEndOfChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EndOfChunk,this.handleEndOfEncodedVideoStreamChunk.bind(this))}},{key:"handleEndOfEncodedVideoStreamChunk",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.get(t.trackId)()}},{key:"subscribeToPayloadEvents",value:function(){return this._eventPublisher.subscribe(ut.Payload,this.handlePayloadEvent.bind(this))}},{key:"handlePayloadEvent",value:function(e){var t=e.context,n=e.data;this._expectedPayloadUuid.has(n.uuid)||d.A.setTimeout(this.logWarningUnexpectedPayloadUuidReceivedOnce.bind(this,t,n.uuid))}},{key:"logWarningUnexpectedPayloadUuidReceivedOnce",value:function(e,t){this._logger.warn("[%s] [%s] [%s] Received unexpected payload with uuid [%s]",e.streamId,e.contextId,e.trackId,t),this._expectedPayloadUuid.add(t)}}])}();l()(gt,"_truncatedVclNalUnitDataByteLength",32),l()(gt,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),l()(gt,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var yt=function(){return u()((function e(t,n,r){o()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_bitstream",void 0),l()(this,"_parser",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._bitstream=n,this._parser=r,this._disposables.add(this._bitstream),this._disposables.add(this._parser)}),[{key:"bitstream",get:function(){return this._bitstream}},{key:"decode",value:function(e){this._eventPublisher.publish(ut.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),_t=function(){return u()((function e(t,n){o()(this,e),l()(this,"_h264VideoBitstreamDecoder",void 0),l()(this,"_encoding",void 0),l()(this,"_disposables",void 0),this._h264VideoBitstreamDecoder=t,this._encoding=n,this._disposables=new X,this._disposables.add(this._h264VideoBitstreamDecoder),this._disposables.add(this._encoding)}),[{key:"bitstream",get:function(){return this._h264VideoBitstreamDecoder.bitstream}},{key:"decode",value:function(e){this._h264VideoBitstreamDecoder.decode(e)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEmbeddedData",value:function(e,t){return t?this._encoding.subscribeToEmbeddedData((function(n){n.trackId===t&&e(n)})):this._encoding.subscribeToEmbeddedData(e)}}])}(),bt=function(){return u()((function e(){throw o()(this,e),new Error("BitstreamDecoders is a static class that may not be instantiated")}),null,[{key:"createH264VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new ft(e,new pt);return new yt(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new ft(e,new mt),r=new yt(e,t,n),i=new gt(e);return new _t(r,i)}}])}();function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ct(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var xt,wt=function(){function e(t,n){var r=this;o()(this,e),l()(this,"_channelContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_bitstreamDecoder",bt.createH264VideoBitstreamDecoder()),l()(this,"_frameTimingsByRtpTimestamp",new Map),l()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),l()(this,"_pictureTimingParser",new it),l()(this,"_videoElementDisposables",new X),l()(this,"_currentPlaybackState","waiting"),l()(this,"_armedVideoFrameCallbackId",null),l()(this,"_disposables",new X),l()(this,"_disposed",!1),this._channelContext=t,this._frameTimingInformationContext=n,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new q((function(){return r._frameTimingsByRtpTimestamp.clear()}))),this._disposables.add(this._videoElementDisposables),this._channelContext.videoElement.value&&this.setupVideoEventListeners(this._channelContext.videoElement.value),this._disposables.add(this._channelContext.videoElement.subscribe((function(e){r._videoElementDisposables.dispose(),e&&r.setupVideoEventListeners(e)}))),this._frameTimingInformationContext.shouldExtractTimecode.value&&this._disposables.add(this._bitstreamDecoder.bitstream.subscribeToSeiPayloadType(et.PictureTiming,this.onPictureTimingExtracted.bind(this)))}return u()(e,[{key:"processFrame",value:function(e,t,n,r){if(!this._disposed){var i={mid:t,trackId:n,receiveTimestamp:new Date};this.removeFrameTimingsExceedingMaxCapacity();var a=r.timestamp.toString(10);this._frameTimingsByRtpTimestamp.has(a),this._frameTimingsByRtpTimestamp.set(a,i),this._bitstreamDecoder.decode({context:{streamId:e,trackId:n,contextId:a},data:new Uint8Array(r.data)})}}},{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"onPictureTimingExtracted",value:function(e){var t,n,r,i,a,o=e.context,s=o.contextId,u=o.trackId,c=e.data;if(!this._disposed){var l=null===(t=this._pictureTimingParser.parse(c.data,this._picturingTimingParsingConfig).picStruct)||void 0===t||null===(n=t.clockTimestamps.find((function(e){return!0===e.clockTimestampFlag})))||void 0===n?void 0:n.clockTimestamp;if(l){var d=this._frameTimingsByRtpTimestamp.get(s);if(d){var h={mid:d.mid,trackId:u,kind:"video",codec:"H264",timecode:{hours:null!==(r=l.hours)&&void 0!==r?r:null,minutes:null!==(i=l.minutes)&&void 0!==i?i:null,seconds:null!==(a=l.seconds)&&void 0!==a?a:null,frames:l.nFrames,isFrameDrop:l.countingType>1},sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,receiveTimestamp:new Date(d.receiveTimestamp),playbackState:this._currentPlaybackState};d.decodedFrameTimingInformation=h,this._frameTimingInformationContext.decodedFrameTimingInformation.value=h}}}}},{key:"videoFrameCallback",value:function(e,t){if(!this._disposed){this.armVideoFrameCallback();var n=t.rtpTimestamp;if(n){var r,i=[],a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return St(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?St(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}(this._frameTimingsByRtpTimestamp);try{for(a.s();!(r=a.n()).done;){var o=He()(r.value,2),s=o[0],u=o[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=kt(kt({},u.decodedFrameTimingInformation),{},{renderTimestamp:new Date(performance.timeOrigin+e),playbackState:"playing"})),i.push(s)}}catch(e){a.e(e)}finally{a.f()}for(var c=0,l=i;c<l.length;c++){var d=l[c];this._frameTimingsByRtpTimestamp.delete(d)}}}}},{key:"removeFrameTimingsExceedingMaxCapacity",value:function(){var t=this._frameTimingsByRtpTimestamp.size-(e.MAX_FRAME_TIMING_ENTRIES-1);if(!(t<=0))for(var n=this._frameTimingsByRtpTimestamp.keys(),r=0;r<t;r++){var i=n.next().value;this._frameTimingsByRtpTimestamp.delete(i)}}},{key:"setupVideoEventListeners",value:function(e){var t=this,n=function(){return t._currentPlaybackState="playing"};e.addEventListener("playing",n),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("playing",n)})));var r=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",r),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("pause",r)})));var i=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",i),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("stalled",i)})));var a=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",a),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("waiting",a)})));var o=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",o),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("ended",o)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new q((function(){var e;t._armedVideoFrameCallbackId&&(null===(e=t._channelContext.videoElement.value)||void 0===e||e.cancelVideoFrameCallback(t._armedVideoFrameCallbackId))})))}},{key:"armVideoFrameCallback",value:function(){var e;this._armedVideoFrameCallbackId=null===(e=this._channelContext.videoElement.value)||void 0===e?void 0:e.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}}])}();l()(wt,"MAX_FRAME_TIMING_ENTRIES",1800);var Tt=Symbol(),Pt=function(){function e(){throw o()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return u()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){if("OPUS"===t.toUpperCase())return e._dummyAudioSilentPerCodec.OPUS.buffer}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._dummy82x82H264.IFrame.buffer):e._dummy2x2VideoIFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return"H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber&&(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._isAndroidChrome)?Tt:e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?e.getSurrogate82x82PFrameAndUpdateFrameNumber():e._dummy2x2VideoPFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoPFrame",value:function(t){if("H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber){var n=e._surrogate82x82PFrameFrameNumber,r=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return n>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?Tt:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,r)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var t=(14&e._surrogate82x82PFrameFrameNumber)>>1,n=(1&e._surrogate82x82PFrameFrameNumber)<<7,r=e._dummy82x82H264.PFrame.slice().buffer,i=e._dummy82x82H264PFrameFrameNumberIndex;return r[i]|=t,r[i+1]|=n,e._surrogate82x82PFrameFrameNumber++,r}}])}();xt=Pt,l()(Pt,"_isSafari","Safari"===h.browserName),l()(Pt,"_isMobileChrome","Chrome"===h.browserName&&h.isMobile()),l()(Pt,"_isAndroidChrome","Chrome"===h.browserName&&h.isAndroid),l()(Pt,"_singleZeroByte",new Uint8Array([0])),l()(Pt,"_dummyAudioSilentPerCodec",{OPUS:new Uint8Array([104,7,217,171,188,121,135,171,142,74,20,243,167,28,242,154,122,69,167,45,68,37,116,76,173,22,179,14,81,87,234,231,173,42,56,206,51])}),l()(Pt,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203,0,0,0,1,104,235,227,196,72,68,0,0,1,101,136,130,0,63,112,35,134,230,209,128,9,175,10,65,102,107,84,70,251,113,217,127,255,255,249]),VP8:new Uint8Array([176,2,0,157,1,42,1,0,1,0,57,107,0,39,28,36,12,44,44,68,204,36,65,168,0,19,167,163,122,80,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([130,73,131,66,0,0,0,0,6,118,56,36,28,25,160,0,0,32,64,0,17,191,221,119,255,64,127,177,0])}),l()(Pt,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,65,154,104,73,168,65,104,153,76,15,255,146,129]),VP8:new Uint8Array([49,3,0,228,224,168,155,55,175,16,79,79,177,10,47,228,146,192,31,231,79,70,255,238,81,193,93,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([134,0,64,146,156,36,72,0,0,3,112,0,0,75,64])}),l()(Pt,"_dummy82x82H264",{IFrame:new Uint8Array([0,0,0,1,103,66,192,13,218,24,222,34,34,16,0,0,3,0,16,0,0,3,3,200,241,66,170,0,0,0,1,104,206,15,200,0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[95],de()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],de()(new Uint8Array(3).fill(255)),[15,69,0,1,87,159,39,39,39,39,39,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,120])),PFrame:new Uint8Array([0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[164],de()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),l()(Pt,"_dummy82x82H264PFrameFrameNumberIndex",10418),l()(Pt,"_surrogate82x82PFrameFrameNumberReset",1),l()(Pt,"_useUpdateSurrogate82x82PFrameFrameNumber",xt._isMobileChrome||xt._isSafari),l()(Pt,"_surrogate82x82PFrameFrameNumber",xt._surrogate82x82PFrameFrameNumberReset);var Et=function(){return u()((function e(){throw o()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"configureEncodedStreamPipeline",value:function(e,t,r,i,a,o){var s=new X,u=new K(null),c=new K(null);return e.getTracks().forEach((function(e){var l=t.filter((function(t){return t.track===e}))[0],d=e.kind;switch(d){case"video":var h=!!r;if(f.isRTCRtpScriptTransformSupported){var p=new Worker(new URL(n.p+n.u(63),n.b),{type:void 0});p.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=h,!t.t0){t.next=6;break}return t.next=5,r(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}p.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(p,{kind:e.kind,codec:a,mustSink:h}),s.add(new q((function(){p.terminate()})));break}var m=function(){var t=k()(x().mark((function t(n,i){var o;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!h){t.next=12;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=11;break}if((o="key"===n.type?Pt.getInvalidSurrogateVideoIFrame(a):Pt.getInvalidSurrogateVideoPFrame(a))!==Tt){t.next=8;break}return t.abrupt("return");case 8:n.data=o||n.data,t.next=12;break;case 11:"key"===n.type?n.data=Pt.getSurrogateVideoIFramePerCodec(a)||n.data:n.data=Pt.getSurrogateVideoPFramePerCodec(a)||n.data;case 12:i.enqueue(n);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),v=new TransformStream({transform:m}),g=l.createEncodedStreams(),y=g.readable,_=g.writable;y.pipeThrough(v).pipeTo(_);break;case"audio":var b=!!i;if(f.isRTCRtpScriptTransformSupported){var C=new Worker(new URL(n.p+n.u(444),n.b),{type:void 0});C.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n.data.chunk},t.t0=b,!t.t0){t.next=6;break}return t.next=5,i(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}C.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(C,{kind:e.kind,codec:o,mustSink:b});var S=new MediaStream,w=new Audio;w.srcObject=S,document.body.appendChild(w),s.add(new q((function(){C.terminate(),document.body.removeChild(w)})));break}var T=function(){var t=k()(x().mark((function t(n,r){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n},!b){t.next=9;break}return t.next=4,i(e,n);case 4:if(t.sent){t.next=8;break}n.data=Pt.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Pt.getSurrogateAudioSilentPerCodec(o)||n.data;case 9:r.enqueue(n);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),P=new TransformStream({transform:T}),E=l.createEncodedStreams(),F=E.readable,L=E.writable;F.pipeThrough(P).pipeTo(L);break;default:R(d)}})),{disposables:s,encodedVideoFrame:u,encodedAudioFrame:c}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new X;return e.getTracks().forEach((function(e){var a=e.kind;switch(a){case"video":if(t){var o=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:o}),c=new MediaStreamTrackGenerator({kind:o.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new q((function(){r.removeTrack(c)})))}else r.addTrack(e);break;case"audio":if(n){var h=e,f=new TransformStream({transform:function(t,r){n(e,t,r)}}),p=new MediaStreamTrackProcessor({track:h}),m=new MediaStreamTrackGenerator({kind:h.kind}),v=p.readable,g=m.writable;v.pipeThrough(f).pipeTo(g),r.addTrack(m);var y=new MediaStream,_=new Audio;y.addTrack(e),_.srcObject=y,document.body.appendChild(_),i.add(new q((function(){r.removeTrack(m),document.body.removeChild(_)})))}else r.addTrack(e);break;default:R(a)}})),{transformedStream:r,disposables:i}}}])}(),Ft=n(701).A;function Lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function It(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Dt=function(){return u()((function e(t,n,r,i,a){o()(this,e),l()(this,"_logger",V.getLogger("RealTimeStream")),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_handleStreamFailure",void 0),l()(this,"_disposables",void 0),this._channelContext=t,this._peerConnectionContext=n,this._streamTransformContext=r,this._frameTimingInformationContext=i,this._handleStreamFailure=a,this._disposables=new X,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,r){var i=this,a=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value;return Ft.all([Qe.discoverClosestEndPointWithCaching(e),ie.createPeerConnectionOffer("recvonly",a).then((function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=He()(e,2),r=n[0],a=n[1],o=a.localOffer,s=a.peerConnection;return i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+o.sdp),!f.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s.dispose(),!_e.forceGarbageCollectionOnRestart||f.isMobile&&_e.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection(),s=null,o=null,i._peerConnectionContext.peerConnection.value=s),r.subscribe(t,o,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,h=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=h,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,l),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then((function(e){var t,s=!1,h=!1,p=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e&&(s||_e.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?p.push(n.candidate):h=!0,t||(t=d.A.setTimeout((function(){i._channelContext.stream.value!==o||s||i._channelContext.endPoint.value.addIceCandidates(o,p,h).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(s=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=Se.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(d.A.navigatorIsOnLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:R(e.iceConnectionState)}}};var m=new Ft((function(t,n){if(f.onTrackDisabled){var r=function(n){d.A.clearTimeout(i),e.removeEventListener("track",r),e.removeEventListener("addstream",r),n.streams?t(n.streams[0]):t(n.stream)},i=d.A.setTimeout((function(){e.removeEventListener("track",r),e.removeEventListener("addstream",r),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",r),e.addEventListener("addstream",r)}else{var a=d.A.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){d.A.clearTimeout(a),t(e.streams[0])}}}));return new Ft((function(e){e()})).then((function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(o,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),m})).then((function(t){if(a){var n=new Ze(e.currentRemoteDescription.sdp),o=e.getReceivers(),s=Et.configureEncodedStreamPipeline(t,o,i._streamTransformContext.encodedVideoStreamSink,i._streamTransformContext.encodedAudioStreamSink,n.videoCodec,n.audioCodec),u=s.disposables,c=s.encodedVideoFrame;if("H264"===n.videoCodec.toUpperCase()&&(i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value)){var l=new wt(i._channelContext,i._frameTimingInformationContext);i._disposables.add(l),t.getVideoTracks().forEach((function(t){var n,r=o.filter((function(e){return e.track===t}))[0],a=e.supportsGetTransceivers?null===(n=e.getTransceivers().filter((function(e){return e.receiver===r}))[0])||void 0===n?void 0:n.mid:null;r?a?(i._disposables.add(c.subscribe((function(e){e&&l.processFrame(i._channelContext.streamId,a,e.track.id,e.chunk)}))),i._frameTimingInformationContext.isEnabled.value=!0):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no mid was found",i._channelContext.streamId,t.id):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no receiver was found",i._channelContext.streamId,t.id)}))}i._disposables.add(u)}if(i._streamTransformContext.hasInsertableStreams.value){var h=Et.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),f=h.transformedStream,p=h.disposables;i._disposables.add(p),t=f}i._peerConnectionContext.mediaStream.value=t;var m=new $e(e,t,i._channelContext.endPoint.value.roundTripTime/4);i._disposables.add(m);var v=m.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var n=!1,r=!1;if(t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&d.A.navigatorIsOnLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new xe(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((r=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&d.A.navigatorIsOnLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new xe(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),d.A.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=Se.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,m.dispose(),i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))}));else{if(i._peerConnectionContext.peerConnectionReconnectAttempts=0,i._channelContext.state.value!==Se.Reconnecting&&i._channelContext.state.value!==Se.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Se.Playing:Se.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Se[i._channelContext.state.value])}else i._channelContext.state.value=Se.Offline}));return i._disposables.add(v),_e.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=Se.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=k()(x().mark((function e(t,n){var r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Xe.truncateIceServers(n),e.abrupt("return",_e.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=It(It({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=Se.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<_e.maximalNumberOfPeerConnectionReconnectAttempts||!_e.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(f.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i)return;this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(a)}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"unauthorized":return Se.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"failed":return Se.Error;default:R(e)}}}]);var e}(),Rt=function(){return u()((function e(){throw o()(this,e),new Error("RealTimeStreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,r,i,a){var o=$.parseToken(e).capabilities;return o.includes("on-demand")?(this._logger.error("This build does not support On-Demand Stream playback."),void(t.state.value=Se.UnsupportedFeature)):o.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=Se.UnsupportedFeature)):new Dt(t,n,r,i,a)}}])}();l()(Rt,"_logger",V.getLogger("Streaming"));var At=n(701).A,Ot=function(){return u()((function e(t,n,r){var i=this;o()(this,e),l()(this,"_logger",V.getLogger("Channel")),l()(this,"_tokenContext",void 0),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_stateContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_readOnlyPeerConnection",void 0),l()(this,"_readOnlyState",void 0),l()(this,"_readOnlyAutoMuted",void 0),l()(this,"_readOnlyAutoPaused",void 0),l()(this,"_readOnlyTokenExpiring",void 0),l()(this,"_readOnlyAuthorized",void 0),l()(this,"_readOnlyOnline",void 0),l()(this,"_readOnlyLoading",void 0),l()(this,"_readOnlyPlaying",void 0),l()(this,"_readOnlyStandby",void 0),l()(this,"_readOnlyStopped",void 0),l()(this,"_readOnlyTargetLag",void 0),l()(this,"_readOnlyLag",void 0),l()(this,"_readOnlyBitrateLimit",void 0),l()(this,"_readOnlyResolution",void 0),l()(this,"_readOnlyFailureCount",void 0),l()(this,"_readOnlyEndPoint",void 0),l()(this,"_readOnlyStream",void 0),l()(this,"_readOnlyRtcStatistics",void 0),l()(this,"_readOnlyMediaStream",void 0),l()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),l()(this,"_readOnlyDecodedFrameTimingInformation",void 0),l()(this,"_readOnlyRenderedFrameTimingInformation",void 0),l()(this,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),l()(this,"_videoMetaDataChangedHandler",void 0);var a=$.parseToken(n),s={targetLag:null==r?void 0:r.targetLag},u={hasInsertableStreams:a.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:a.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==r?void 0:r.videoStreamTransformCallback,audioStreamTransformCallback:null==r?void 0:r.audioStreamTransformCallback,encodedVideoStreamSink:null==r?void 0:r.encodedVideoStreamSink,encodedAudioStreamSink:null==r?void 0:r.encodedAudioStreamSink};this._tokenContext=new Ie(n),this._channelContext=new De(s),this._peerConnectionContext=new Ue,this._streamTransformContext=new Ve(u),this._stateContext=new Be,this._exponentialBackoff=new he,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new Q(this._peerConnectionContext.peerConnection),this._readOnlyState=new Q(this._channelContext.state),this._readOnlyAutoMuted=new Q(this._channelContext.autoMuted),this._readOnlyAutoPaused=new Q(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new Q(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Q(this._channelContext.authorized),this._readOnlyOnline=new Q(this._channelContext.online),this._readOnlyLoading=new Q(this._channelContext.loading),this._readOnlyPlaying=new Q(this._channelContext.playing),this._readOnlyStandby=new Q(this._channelContext.standby),this._readOnlyStopped=new Q(this._channelContext.stopped),this._readOnlyTargetLag=new Q(this._channelContext.targetLag),this._readOnlyLag=new Q(this._channelContext.lag),this._readOnlyBitrateLimit=new Q(this._channelContext.bitrateLimit),this._readOnlyResolution=new Q(this._channelContext.resolution),this._readOnlyFailureCount=new Q(this._channelContext.failureCount),this._readOnlyEndPoint=new Q(this._channelContext.endPoint),this._readOnlyStream=new Q(this._channelContext.stream),this._readOnlyRtcStatistics=new Q(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new Q(this._peerConnectionContext.mediaStream);var c=(a.uri||_e.discoveryUri.value).toString();_e.tenancy.value=a.tenancy||_e.tenancy.value,ue.uri.value=c,this._metricsService=ge.getMetricsService(c),this._sessionTelemetry=new Ee(_e.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._frameTimingInformationContext=new Ne,this.configureFrameTimingInformation(a),this._readOnlyIsFrameTimingInformationEnabled=new Q(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new Q(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new Q(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){i._channelContext.rendererDisposables.dispose(),e&&(i._channelContext.rendererDisposables.add(i._channelContext.stream.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.dispose(),e&&i.videoElement&&(i.videoElement.dataset&&(i.videoElement.dataset.sessionId=_e.clientSessionId,i.videoElement.dataset.streamId=i.streamId),i._channelContext.videoTelemetry=new we(i.streamId,_e.pageLoadTime,i._channelStartTime,i._metricsService),i._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(i.videoElement),i._channelContext.videoTelemetry.setupListenerForRebuffering(i.videoElement),i._channelContext.state.value===Se.Stopped)&&i.restartAfterStop()}))),i._channelContext.channelDisposables.add(i._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){i._channelContext.clearFailureCountTimeout&&d.A.clearTimeout(i._channelContext.clearFailureCountTimeout),i._channelContext.failureCount.value&&e===Se.Playing&&(i._channelContext.clearFailureCountTimeout=d.A.setTimeout((function(){i._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&i._channelContext.endPoint.value&&i._channelContext.stream.value){var t=Date.now()-i._channelContext.channelInitialization.getTime();i._channelContext.endPoint.value.limitBitrate(i._channelContext.stream.value,t,e,Fe.Keep,Le.Normal).catch((function(e){i._logger.error("Error while setting limit bitrate",e)}))}})));var h=function(){i._channelContext.stream.value&&i._channelContext.endPoint.value&&i._channelContext.endPoint.value.destroyStreamOnUnmount(i._channelContext.stream.value,"client:termination-on-window-unload")};d.A.addWindowEventListener("beforeunload",h),this._channelContext.channelDisposables.add(new q((function(){d.A.removeWindowEventListener("beforeunload",h)}))),this.start()}),[{key:"videoElement",get:function(){return this._channelContext.videoElement.value},set:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.removeEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("resize",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.dataset&&(this._channelContext.videoElement.value.dataset.sessionId="",this._channelContext.videoElement.value.dataset.streamId=""),this._channelContext.rendererDisposables.dispose(),this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value!==Se.Initializing&&(this._channelContext.state.value=Se.Stopped),this._channelContext.videoElement.value=e,this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"handleVideoMetaDataChanged",value:function(){var e=this._channelContext.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._channelContext.resolution.value=new be(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=be.empty}},{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._channelContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=$.parseToken(this._tokenContext.token.value),n=(t.uri||_e.discoveryUri.value).toString();_e.tenancy.value=t.tenancy||_e.tenancy.value,ue.uri.value=n,this._metricsService=ge.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Fe.Keep,Le.Reset).then((function(t){"ok"===t.status&&(e._channelContext.bitrateLimit.value=0)})).catch((function(t){e._logger.error("Error while setting limit bitrate",t)}))}}},{key:"updateTargetLag",value:function(e){this._channelContext.targetLag.value=e}},{key:"stop",value:(h=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new At((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return h.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=Se.Stopped}},{key:"resume",value:(c=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._peerConnectionContext.mediaStream.value){e.next=3;break}return this._channelContext.autoPaused.value=!1,e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(s=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._channelContext.channelDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getUri",value:function(e){return $.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",_e.discoveryUri.value),new d.A.URL(_e.discoveryUri.value))}},{key:"start",value:(a=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Channel is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"processStart",value:(i=k()(x().mark((function e(){var t,n,r,i,a,o,s,u,c,l,h,p,m,v,g,y,_,b,C,k=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Se.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),$.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Se.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=18;break}if(r=Me.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),i=r.valid,a=r.validationResult,i){e.next=18;break}return this._logger.error(a),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 18:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=26;break}if(o=Me.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=o.valid,u=o.validationResult,s){e.next=26;break}return this._logger.error(u),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 26:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=34;break}if(c=Oe.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,h=c.validationResult,l){e.next=34;break}return this._logger.error(h),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 34:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=42;break}if(p=Oe.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),m=p.valid,v=p.validationResult,m){e.next=42;break}return this._logger.error(v),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 42:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=48;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 48:if(g="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,y="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!g||!y){e.next=56;break}return this._logger.error("Both Media Stream Track transform callback and encodedInsertableStreams sink function found, only use one type or the other"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 56:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=71;break}if(f.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 63:if(g){e.next=69;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 69:e.next=77;break;case 71:if(!g){e.next=77;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 77:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=92;break}if(f.isEncodedInsertableStreamsSupported||f.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 84:if(y){e.next=90;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 90:e.next=98;break;case 92:if(!y){e.next=98;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,_=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Se.Error&&e!==Se.Recovering||Qe.clearCachedClosestEndpoint(_)}))),b=function(){return new At((function(e){return k._stateContext.isStarting.value=!1,e(k.handleStreamFailure())}))},C=Rt.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,b)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",C.start(_,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){k._channelContext.loading.value=!1})).catch((function(e){n.fail(),k._channelContext.failureCount.value++,k._channelContext.online.value=!1,k.cleanUpResources("client:cleanup-after-failed-setup"),k._channelContext.state.value=Se.ClientStartError,k._logger.error("Failed to start channel",e)})).finally((function(){if(k._stateContext.isStarting.value=!1,k._channelContext.state.value!==Se.Playing&&_e.automaticRetryOnFailure){var e=d.A.setTimeout((function(){k.handleStreamFailure().catch((function(e){k._logger.error("Failed handling stream failure",e)}))}),k.getRetryInterval());k._channelContext.disposables.add(new q((function(){d.A.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"restartAfterStop",value:(r=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._peerConnectionContext.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 4:this._tokenContext.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"play",value:(n=k()(x().mark((function e(){var t;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._peerConnectionContext.mediaStream.value){e.next=3;break}return e.abrupt("return",this.start());case 3:return e.abrupt("return",this.playMediaStreamInVideoElement(t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Se.Initializing:case Se.StandBy:case Se.Offline:return 15e3;case Se.Error:case Se.Recovering:case Se.Unauthorized:case Se.GeoRestricted:case Se.GeoBlocked:case Se.Stopped:case Se.Starting:case Se.Playing:case Se.Paused:case Se.Reconnecting:case Se.UnsupportedFeature:case Se.ConfigurationError:case Se.TransientConfigurationError:case Se.ConnectionError:case Se.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:R(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(t=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Se.Error||e.t0===Se.Reconnecting||e.t0===Se.StandBy||e.t0===Se.Offline||e.t0===Se.Recovering||e.t0===Se.TransientConfigurationError||e.t0===Se.ConnectionError||e.t0===Se.ClientStartError?3:e.t0===Se.Unauthorized?5:e.t0===Se.GeoRestricted?7:e.t0===Se.GeoBlocked?9:e.t0===Se.Stopped?11:e.t0===Se.Initializing?13:e.t0===Se.Playing?15:e.t0===Se.Paused?17:e.t0===Se.Starting?19:e.t0===Se.UnsupportedFeature?21:e.t0===Se.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Se[this._channelContext.state.value]),e.abrupt("break",26);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is already initializing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 19:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 23:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 25:R(this._channelContext.state.value);case 26:return e.abrupt("return",this.start());case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!_e.forceGarbageCollectionOnRestart||f.isMobile&&_e.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.capabilities.find((function(e){return e.startsWith("frame-timing-information=")}));this._frameTimingInformationContext.shouldExtractTimecode.value=!1,this._frameTimingInformationContext.shouldExtractTimestamps.value=!1,this._frameTimingInformationContext.isEnabled.value=!1,n?f.isChannelFrameTimingInformationSupported?(n.split("=")[1].split(",").map((function(e){return e.trim()})).forEach((function(e){switch(e){case"timecode":t._frameTimingInformationContext.shouldExtractTimecode.value=!0;break;case"timestamps":t._frameTimingInformationContext.shouldExtractTimestamps.value=!0;break;default:t._logger.info("Ignoring unknown frame timing information option [%s]",e)}})),this._logger.info("Frame timing information configuration [(timecode [%s], timestamps [%s])]",this._frameTimingInformationContext.shouldExtractTimecode.value,this._frameTimingInformationContext.shouldExtractTimestamps.value)):this._logger.info("Disabling frame timing information as the environment does not support it [%s]",n):this._logger.info("Disabling frame timing information as no capability was found")}},{key:"playMediaStreamInVideoElement",value:(e=k()(x().mark((function e(t){var n,r,i=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this._channelContext.videoElement.value){e.next=8;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value=Se.Stopped,e.abrupt("return");case 8:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(r=n.play())){e.next=17;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!0,this._channelContext.state.value=Se.Playing,e.abrupt("return");case 17:return e.abrupt("return",r.then((function(){i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Se.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,a=!_e.automaticallyMuteVideoOnPlayFailure;return a||n.muted||!r?(n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Se.Paused,a?void i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then((function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._channelContext.autoMuted.value=!0,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Se.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Se.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,a,s,c,h}(),Mt=function(){return u()((function e(){throw o()(this,e),new Error("Channels is a static class that may not be instantiated")}),null,[{key:"createChannel",value:function(e){if(!_e.initialized.value)throw new Error("SDK is not loaded.");var t={targetLag:e.targetLag,videoStreamTransformCallback:e.videoStreamTransformCallback,audioStreamTransformCallback:e.audioStreamTransformCallback,encodedVideoStreamSink:e.encodedVideoStreamSink,encodedAudioStreamSink:e.encodedAudioStreamSink};return new Ot(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return f.isChannelFrameTimingInformationSupported}}])}(),Vt={SDK:_e,Channels:Mt,ChannelState:Se}})(),r})()));
3
3
  //# sourceMappingURL=channels.js.map