@phenixrts/sdk 2023.0.2 → 2023.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/debug/channels.js +1 -1
  2. package/dist/debug/full.js +1 -1
  3. package/dist/debug/groups.js +1 -1
  4. package/dist/debug/messaging.js +1 -1
  5. package/dist/debug/publish.js +3 -3
  6. package/dist/debug.private/channels.js +1 -1
  7. package/dist/debug.private/full.js +1 -1
  8. package/dist/debug.private/groups.js +1 -1
  9. package/dist/debug.private/messaging.js +1 -1
  10. package/dist/debug.private/publish.js +3 -3
  11. package/dist/es5.debug.private/channels.js +1 -1
  12. package/dist/es5.debug.private/full.js +1 -1
  13. package/dist/es5.debug.private/groups.js +1 -1
  14. package/dist/es5.debug.private/messaging.js +1 -1
  15. package/dist/es5.debug.private/publish.js +3 -3
  16. package/dist/legacy.debug/channels.js +1 -1
  17. package/dist/legacy.debug/full.js +1 -1
  18. package/dist/legacy.debug/groups.js +1 -1
  19. package/dist/legacy.debug/messaging.js +1 -1
  20. package/dist/legacy.debug/publish.js +3 -3
  21. package/dist/legacy.debug.private/channels.js +1 -1
  22. package/dist/legacy.debug.private/full.js +1 -1
  23. package/dist/legacy.debug.private/groups.js +1 -1
  24. package/dist/legacy.debug.private/messaging.js +1 -1
  25. package/dist/legacy.debug.private/publish.js +3 -3
  26. package/dist/legacy.min/channels.js +1 -1
  27. package/dist/legacy.min/full.js +1 -1
  28. package/dist/legacy.min/groups.js +1 -1
  29. package/dist/legacy.min/messaging.js +1 -1
  30. package/dist/legacy.min/publish.js +1 -1
  31. package/dist/legacy.min/publish.js.map +1 -1
  32. package/dist/min/channels.js +1 -1
  33. package/dist/min/full.js +1 -1
  34. package/dist/min/groups.js +1 -1
  35. package/dist/min/messaging.js +1 -1
  36. package/dist/min/publish.js +1 -1
  37. package/dist/min/publish.js.map +1 -1
  38. package/dist/min.private/channels.js +1 -1
  39. package/dist/min.private/full.js +1 -1
  40. package/dist/min.private/groups.js +1 -1
  41. package/dist/min.private/messaging.js +1 -1
  42. package/dist/min.private/publish.js +1 -1
  43. package/dist/min.private/publish.js.map +1 -1
  44. package/examples/src/channel-viewer-native-peer-connection-access.html +13 -0
  45. package/examples/src/channel-viewer-native-peer-connection-access.js +57 -0
  46. package/examples/src/user-media-publisher-change-video-track.html +27 -0
  47. package/examples/src/user-media-publisher-change-video-track.js +122 -0
  48. package/package.json +1 -1
package/dist/min/full.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see full.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,(function(){return(()=>{var e={7228:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},2858:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},3646:(e,t,n)=>{var r=n(7228);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},1506: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},8926:(e,t,n)=>{var r=n(202).default;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},4575: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},3913:(e,t,n)=>{var r=n(3696);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},9713:(e,t,n)=>{var r=n(3696);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},9754: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},2205:(e,t,n)=>{var r=n(9489);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},6860: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},3884: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,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.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&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},521: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},8206: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},8585:(e,t,n)=>{var r=n(8).default,i=n(1506);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},9591:(e,t,n)=>{var r=n(202).default,i=n(8).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,a=n.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",d=u.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,o=Object.create(i.prototype),a=new L(r||[]);return s(o,"_invoke",{value:S(e,n,a)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var v={};function m(){}function g(){}function y(){}var _={};h(_,c,(function(){return this}));var C=Object.getPrototypeOf,w=C&&C(C(R([])));w&&w!==n&&a.call(w,c)&&(_=w);var b=y.prototype=m.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function n(r,o,s,u){var c=f(e[r],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var r;s(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function S(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=T(a,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function T(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,v;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,v):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function Z(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 P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(Z,this),this.reset(!0)}function R(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(a.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:E}}function E(){return{value:void 0,done:!0}}return g.prototype=y,s(b,"constructor",{value:y,configurable:!0}),s(y,"constructor",{value:g,configurable:!0}),g.displayName=h(y,d,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,h(e,d,"GeneratorFunction")),e.prototype=Object.create(b),e},t.awrap=function(e){return{__await:e}},k(x.prototype),h(x.prototype,l,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,i,o,a){void 0===a&&(a=r);var s=new x(p(e,n,i,o),a);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},k(b),h(b,d,"Generator"),h(b,c,(function(){return this})),h(b,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=R,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},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 t=this;function n(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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&&a.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 o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},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),P(n),v}},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;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),v}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},9489: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},3038:(e,t,n)=>{var r=n(2858),i=n(3884),o=n(379),a=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},319:(e,t,n)=>{var r=n(3646),i=n(6860),o=n(379),a=n(8206);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},8868:(e,t,n)=>{var r=n(8).default;e.exports=function(e,t){if("object"!==r(e)||null===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},3696:(e,t,n)=>{var r=n(8).default,i=n(8868);e.exports=function(e){var t=i(e,"string");return"symbol"===r(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},8: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},379:(e,t,n)=>{var r=n(7228);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.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},7757:(e,t,n)=>{var r=n(9591)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},6406:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(8),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(6330),h=n(7426),p=n(841),f=n(5656),v=function(){function e(){a()(this,e),l()(this,"_disposables",new f.Z),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),l()(this,"_documentFocusInterval",void 0),this._isForeground=new h.Z(!0),this._readOnlyIsForeground=new p.Z(this._isForeground),this.detectTabFocusChange()}return u()(e,[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":i()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new d.Z((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new d.Z((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}]),e}()},9845:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{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:"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}();u()(c,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),u()(c,"_browserNameAndVersion",c.parseBrowserNameAndVersion()),u()(c,"_browserName",c.parseBrowserName()),u()(c,"_browserMajorVersion",c.parseBrowserMajorVersion()),u()(c,"_isChrome69",c._browserNameAndVersion.includes("Chrome/69.")),u()(c,"_isChrome70",c._browserNameAndVersion.includes("Chrome/70.")),u()(c,"_isChrome71",c._browserNameAndVersion.includes("Chrome/71.")),u()(c,"_isChrome72",c._browserNameAndVersion.includes("Chrome/72.")),u()(c,"_isChrome74",c._browserNameAndVersion.includes("Chrome/74.")),u()(c,"_isChrome75",c._browserNameAndVersion.includes("Chrome/75.")),u()(c,"_isChrome76",c._browserNameAndVersion.includes("Chrome/76.")),u()(c,"_isChrome77",c._browserNameAndVersion.includes("Chrome/77."))},4381:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(3588),u=n(4417),c=n(2394),l=n(1178),d=function(){function e(){i()(this,e)}return a()(e,[{key:"getStringValue",value:function(e){return this.readConfigurationParameterValue(e)||this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"))||this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){var t=this.readConfigurationParameterValue(e);return t||this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"))?"true"===t||"1"===t||"On"===t:!0===this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":u.Z.convertTelemetryLevelToTelemetryLevelType(s.Z.defaultTelemetryLevel),"phenix-logging-level":c.Z.convertLoggingLevelToLoggingLevelType(l.Z.defaultLoggingLevel),"phenix-console-logging-level":c.Z.convertLoggingLevelToLoggingLevelType(l.Z.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":c.Z.convertLoggingLevelToLoggingLevelType(l.Z.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}}},{key:"readConfigurationParameterValue",value:function(e){var t=document.querySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(e){var t=this.readConfigurationParameterValue(e);if(t){var n=new URLSearchParams(location.search).get(t)||void 0;if(n)return n}}}]),e}()},3953:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"isPrivate",get:function(){return this._isPrivate}},{key:"applyIsPrivate",value:function(){try{this._isPrivate=!1}catch(e){this._isPrivate=!1}}}]),e}();u()(c,"_isPrivate",void 0),c.applyIsPrivate()},6330:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(t){i()(this,e),u()(this,"_disposed",void 0),u()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}return a()(e,[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}]),e}()},5656:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e),u()(this,"_list",[])}return a()(e,[{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,"]")}}]),e}()},4827:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=function(){function e(){throw i()(this,e),new Error("Strings is a static class that may not be instantiated")}return a()(e,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)}}]),e}()},8701:(e,t,n)=>{"use strict";t.Z=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))}},709:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e),u()(this,"_appenders",[])}return a()(e,[{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}),[])}}]),e}()},1502:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(5149),l=function(){function e(t){i()(this,e),u()(this,"_threshold",void 0),this._threshold=t}return a()(e,[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(c.G[e],"] ").concat(t);e<c.G.Warn?console.log(i):console.error(i)}}}]),e}()},5149:(e,t,n)=>{"use strict";n.d(t,{G:()=>r,Z:()=>l});var r,i=n(4575),o=n.n(i),a=n(3913),s=n.n(a),u=n(9713),c=n.n(u);!function(e){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"}(r||(r={}));var l=function(){function e(t,n,r){o()(this,e),c()(this,"_category",void 0),c()(this,"_appenders",void 0),c()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return s()(e,[{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>r.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.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?e+"\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}}]),e}()},1178:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(3953),u=n(5149),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"defaultLoggingLevel",get:function(){return s.Z.isPrivate?u.G.Off:u.G.All}},{key:"defaultConsoleLoggingLevel",get:function(){return s.Z.isPrivate?u.G.Off:u.G.All}},{key:"defaultTelemetryLoggingLevel",get:function(){return u.G.Info}}]),e}()},9571:(e,t,n)=>{"use strict";n.d(t,{Z:()=>g});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(5149),l=n(709),d=n(6016),h=n(1502),p=n(3552),f=n(5259),v=n(4381),m=n(1178),g=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(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 c.Z(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");c.G[e]&&this._threshold.setThreshold(c.G[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(c.G[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new h.Z(e||m.Z.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||m.Z.defaultTelemetryLoggingLevel,this._appenders.add(new p.Z(this._telemetryConfiguration))}}]),e}();u()(g,"_configurationParameterReader",new v.Z),u()(g,"_loggers",{}),u()(g,"_appenders",new l.Z),u()(g,"_threshold",new d.Z),u()(g,"_telemetryConfiguration",new f.Z),g.applyLoggerConfigFromParameterConfiguration()},2394:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(8701),u=n(5149),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case u.G.Off:return"Off";case u.G.Trace:return"Trace";case u.G.Debug:return"Debug";case u.G.Info:return"Trace";case u.G.Warn:return"Warn";case u.G.Error:return"Error";case u.G.Fatal:return"Fatal";case u.G.All:return"All";default:(0,s.Z)(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return u.G.Off;case"Trace":return u.G.Trace;case"Debug":return u.G.Debug;case"Info":return u.G.Info;case"Warn":return u.G.Warn;case"Error":return u.G.Error;case"Fatal":return u.G.Fatal;case"All":return u.G.All;default:(0,s.Z)(e)}}}]),e}()},6016:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(1178),l=function(){function e(){i()(this,e),u()(this,"_threshold",c.Z.defaultLoggingLevel)}return a()(e,[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}]),e}()},4574:(e,t,n)=>{"use strict";n.d(t,{Z:()=>h});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(2889),l=n(8701),d=n(8963),h=function(){function e(t){i()(this,e),u()(this,"_metrics",void 0),this._metrics=t}return a()(e,[{key:"getName",value:function(){return d.Z[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case d.Z.TimeToFirstFrame:case d.Z.ChannelCreationTimeToFirstFrame:return c.g.Essential;case d.Z.Stalled:case d.Z.Buffering:case d.Z.SetupCompleted:case d.Z.SetupFailed:case d.Z.RoundTripTime:case d.Z.DownlinkThroughputCapacity:case d.Z.NetworkType:case d.Z.ResolutionChanged:case d.Z.ApplicationForeground:case d.Z.ApplicationBackground:return c.g.All;default:(0,l.Z)(this._metrics)}}}]),e}()},2889:(e,t,n)=>{"use strict";n.d(t,{g:()=>r,Z:()=>d});var r,i=n(4575),o=n.n(i),a=n(3913),s=n.n(a),u=n(9713),c=n.n(u),l=n(3588);!function(e){e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All"}(r||(r={}));var d=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",l.Z.defaultTelemetryLevel)}return s()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new 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}}]),e}()},6062:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(3896),l=n(2889),d=n(5508),h=n(4760),p=n(5021),f=n(4417),v=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(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 l.Z;return r.sessionId=d.Z.clientSessionId,r.tenancy=d.Z.tenancy.value,r.url=h.Z.getTelemetryUrl(t),r.environment=p.Z.getEnvironmentFromUrl(t),r.threshold=f.Z.convertTelemetryLevelTypeToTelemetryLevel(d.Z.telemetryLevel),e._metricsServices[t]=new c.Z(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();u()(v,"_metricsServices",{})},3896:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(7757),h=n.n(d),p=n(8862),f=n(4574),v=function(){function e(t){a()(this,e),l()(this,"_metricsConfiguration",void 0),l()(this,"_metrics",[]),l()(this,"_isSending",void 0),l()(this,"_domain",location.hostname),this._metricsConfiguration=t}var t,n;return u()(e,[{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,o=e.resource,a=e.kind,s=new f.Z(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:p.Z.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=i()(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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 n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(t=i()(h().mark((function e(){var t,n=this;return h().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){return n._isSending=!1,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}()},8963:(e,t)=>{"use strict";var n;!function(e){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"}(n||(n={})),t.Z=n},4417:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(2889),u=n(8701),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case s.g.Off:return"Off";case s.g.Essential:return"Essential";case s.g.All:return"All";default:(0,u.Z)(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return s.g.Off;case"Essential":return s.g.Essential;case"All":return s.g.All;default:(0,u.Z)(e)}}}]),e}()},3588:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(3953),u=n(2889),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"defaultTelemetryLevel",get:function(){return s.Z.isPrivate?u.g.Essential:u.g.All}}]),e}()},202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>p});var r=n(8),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=u()((function e(t,n,r){a()(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})),h=function(){function e(t){if(a()(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 o=r.length,a=function t(a,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 t(a,e)}),n)}r[a]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(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,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.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=h},4554:(e,t,n)=>{"use strict";var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(7757),h=n.n(d),p=n(9571),f=n(1228),v=n(202).default,m=function(){function e(t){a()(this,e),l()(this,"_logger",p.Z.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),f.Z.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,o;return u()(e,[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{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:"supportsAddTransceiver",get:function(){return!f.Z.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(o=i()(h().mark((function e(t){var n=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.Z.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new v((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 o.apply(this,arguments)})},{key:"createAnswer",value:(r=i()(h().mark((function e(t){var n=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.Z.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new v((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 r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=i()(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(f.Z.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(t=i()(h().mark((function e(t){var n;return h().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.Z.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new v((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:"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:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}}]),e}();t.Z=m},4009:(e,t,n)=>{"use strict";var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(7757),l=n.n(c),d=n(4554),h=function(){function e(){a()(this,e)}var t;return u()(e,[{key:"createPeerConnection",value:(t=i()(l().mark((function e(t){return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new d.Z(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();t.Z=h},841:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(t){i()(this,e),u()(this,"_subject",void 0),this._subject=t}return a()(e,[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}]),e}()},7426:(e,t,n)=>{"use strict";n.d(t,{Z:()=>m});var r=n(9713),i=n.n(r),o=n(3913),a=n.n(o),s=n(4575),u=n.n(s),c=n(2205),l=n.n(c),d=n(8585),h=n.n(d),p=n(9754),f=n.n(p);var v=function(e){l()(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=f()(t);if(n){var i=f()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h()(this,e)});function i(e,t){return u()(this,i),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return a()(i)}(n(6330).Z),m=function(){function e(t){u()(this,e),i()(this,"_listeners",void 0),i()(this,"_value",void 0),this._listeners=[],this._value=t}return a()(e,[{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 v(this._listeners,e)}}]),e}()},5021:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=function(){function e(){i()(this,e)}return a()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}()},5508:(e,t,n)=>{"use strict";n.d(t,{Z:()=>E});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(9571),l=n(4827),d=n(7426),h=n(841),p=n(4009),f=n(3297),v=n(5149),m=n(1502),g=n(3552),y=n(4381),_=n(2889),C=n(4417),w=n(2394),b=n(3953),k=n(9845),x=n(6406),S=n(4760),T=n(5021),Z=n(5564),P=n(6062),L=n(3588),R=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),E=function(){function e(){throw i()(this,e),new Error("SDK is a static class that may not be instantiated")}return a()(e,null,[{key:"pageLoadTime",get:function(){return R}},{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:"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 w.Z.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return C.Z.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return k.Z}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=c.Z.telemetryConfiguration;n.sessionId=e.clientSessionId,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 g.Z}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new g.Z(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 g.Z}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new g.Z(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=P.Z.getMetricsService(Z.Z.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&&P.Z.setTelemetryLevel(_.g[t]),e._telemetryLevel.subscribe((function(e){P.Z.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:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=T.Z.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=f.Z.parseToken(t);return e._tenancy.value=f.Z.getTenancy(n),Z.Z.uri.value=(f.Z.getUri(n)||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 Z.Z.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");return i?(Z.Z.uri.value="".concat(i,"/pcast/endPoints"),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)):void 0}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new x.Z),t){if(t.discoveryUri&&(Z.Z.uri.value=t.discoveryUri),t.peerConnectionFactory&&(e._peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&_.g[t.telemetryLevel]&&(e._telemetryLevel.value=C.Z.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&v.G[t.loggingLevel]&&this._logger.threshold.setThreshold(w.Z.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&v.G[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof m.Z}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new m.Z(w.Z.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 S.Z.getTelemetryUrl(e)}}]),e}();u()(E,"_automaticallyRetryOnFailure",!0),u()(E,"_automaticallyReconnectPeerConnection",!0),u()(E,"_automaticallyPlayMediaStream",!0),u()(E,"_automaticallyMuteVideoOnPlayFailure",!0),u()(E,"_webPlayerLoader",null),u()(E,"_shakaPlayerLoader",null),u()(E,"_hlsJsLoader",null),u()(E,"_configurationParameterReader",new y.Z),u()(E,"_applicationActivityMonitor",void 0),u()(E,"_environment",new d.Z("")),u()(E,"_telemetryUrl",new d.Z("https://telemetry.phenixrts.com/telemetry")),u()(E,"_maximalNumberOfPeerConnectionReconnectAttempts",8),u()(E,"_telemetryLevel",new d.Z(L.Z.defaultTelemetryLevel)),u()(E,"_metricsService",void 0),u()(E,"_metricsConfiguration",void 0),u()(E,"_sendLocalCandidates",new d.Z(!b.Z.isPrivate)),u()(E,"_tenancy",new d.Z("")),u()(E,"_clientSessionId",l.Z.random(32)),u()(E,"_loadedTimestamp",new Date),u()(E,"_logger",c.Z.getLogger("SDK")),u()(E,"_initialized",new d.Z(!1)),u()(E,"_peerConnectionFactory",new d.Z(new p.Z)),u()(E,"_readOnlyInitialized",new h.Z(E._initialized)),u()(E,"_readOnlyDiscoveryUri",new h.Z(Z.Z.uri)),u()(E,"_readOnlyPeerConnectionFactory",new h.Z(E._peerConnectionFactory)),window.addEventListener("unload",(function(){E.dispose()})),E.applyDiscoveryUriDefaultFromParameterConfiguration(),E.applyMetricsConfiguration(),E.applyTelemetryConfiguration(),E.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),E.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),E.init()},4760:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=function(){function e(){i()(this,e)}return a()(e,null,[{key:"getTelemetryUrl",value:function(e){try{var t=new 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}}}]),e}()},2250:(e,t)=>{"use strict";var n;!function(e){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.Error=12]="Error",e[e.UnsupportedFeature=13]="UnsupportedFeature"}(n||(n={})),t.Z=n},6644:(e,t,n)=>{"use strict";n.d(t,{Z:()=>ke});var r,i,o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(8926),l=n.n(c),d=n(9713),h=n.n(d),p=n(7757),f=n.n(p),v=n(9571),m=n(841),g=function(){function e(t,n){a()(this,e),h()(this,"width",void 0),h()(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)}}]),e}(),y=n(5508),_=n(2250),C=n(8701),w=n(6330),b=n(3297),k=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;a()(this,e),h()(this,"_duration",void 0),this._duration=t}return u()(e,[{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,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"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)}}]),e}(),x=n(8963),S=n(5656),T=function(){function e(t,n,r,i){a()(this,e),h()(this,"_pageLoadTime",void 0),h()(this,"_channelStartTime",void 0),h()(this,"_logger",v.Z.getLogger("StreamTelemetry")),h()(this,"_disposables",new S.Z),h()(this,"_streamId",void 0),h()(this,"_metricsService",void 0),h()(this,"_listenToFirstTime",void 0),h()(this,"_listenForStall",void 0),h()(this,"_listenForContinuation",void 0),h()(this,"_timeToFirstFrame",void 0),h()(this,"_channelCreationTimeToFirstFrame",void 0),h()(this,"_startRecordingFirstFrame",void 0),h()(this,"_videoStalled",void 0),h()(this,"_lastProgress",void 0),h()(this,"_videoResolution",void 0),h()(this,"_clearTimeToFirstFrameListener",void 0),h()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=r,this._metricsService=i}return u()(e,[{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 w.Z((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 w.Z((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 k(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:x.Z.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 k(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:x.Z.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 k(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:x.Z.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:x.Z.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 k(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:x.Z.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}]),e}(),Z=n(4574),P=function(){function e(t){a()(this,e),h()(this,"_logger",v.Z.getLogger("StreamSetupListener")),h()(this,"metricsService",y.Z.metricsService),h()(this,"_pageLoadTime",void 0),h()(this,"_startTime",void 0),h()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return u()(e,[{key:"success",value:function(e){this.recordStreamMetric(x.Z.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(x.Z.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Z.Z(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 k(n-this._pageLoadTime).toIsoString(),t,i,new k(r).toIsoString())}}}]),e}(),L=n(7426),R=function(){function e(){a()(this,e),h()(this,"_disposables",new S.Z),h()(this,"_isSupported",navigator&&navigator.connection),h()(this,"_rtt",new L.Z(void 0)),h()(this,"_effectiveType",new L.Z(void 0)),h()(this,"_downlinkThroughputCapacity",new L.Z(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return u()(e,[{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(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new w.Z((function(){navigator.connection.removeEventListener("change",t)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}]),e}(),E=function(){function e(t,n){var r=this;a()(this,e),h()(this,"_logger",v.Z.getLogger("SessionTelemetry")),h()(this,"_metricsService",void 0),h()(this,"_applicationActivityMonitor",y.Z.applicationActivityMonitor),h()(this,"_networkMonitor",new R),h()(this,"_pageLoadTime",void 0),h()(this,"_disposables",new S.Z),h()(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)}))))}return u()(e,[{key:"listenOnStreamSetup",value:function(){return new P(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?x.Z.ApplicationForeground:x.Z.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 k(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:x.Z.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 k(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:x.Z.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 k(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:x.Z.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 k(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}();!function(e){e[e.Keep=0]="Keep",e[e.Reset=1]="Reset"}(r||(r={})),function(e){e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset"}(i||(i={}));var D=u()((function e(t){a()(this,e),h()(this,"token",void 0),h()(this,"tokenExpiring",void 0),this.token=new L.Z(t),this.tokenExpiring=new L.Z(!1)})),O=function(){function e(t){a()(this,e),h()(this,"channelInitialization",void 0),h()(this,"disposables",void 0),h()(this,"channelDisposables",void 0),h()(this,"rendererDisposables",void 0),h()(this,"videoElement",void 0),h()(this,"state",void 0),h()(this,"autoMuted",void 0),h()(this,"autoPaused",void 0),h()(this,"authorized",void 0),h()(this,"online",void 0),h()(this,"loading",void 0),h()(this,"playing",void 0),h()(this,"standby",void 0),h()(this,"stopped",void 0),h()(this,"targetLag",void 0),h()(this,"lag",void 0),h()(this,"bitrateLimit",void 0),h()(this,"resolution",void 0),h()(this,"failureCount",void 0),h()(this,"endPoint",void 0),h()(this,"stream",void 0),h()(this,"rtcStatistics",void 0),h()(this,"videoTelemetry",void 0),h()(this,"rtcAudioStatistic",void 0),h()(this,"rtcVideoStatistic",void 0),h()(this,"clearFailureCountTimeout",void 0),this.disposables=new S.Z,this.channelDisposables=new S.Z,this.rendererDisposables=new S.Z,this.channelInitialization=new Date,this.videoElement=new L.Z(null),this.state=new L.Z(_.Z.Starting),this.autoMuted=new L.Z(!1),this.autoPaused=new L.Z(!1),this.authorized=new L.Z(!0),this.online=new L.Z(!0),this.loading=new L.Z(!1),this.playing=new L.Z(!1),this.standby=new L.Z(!1),this.stopped=new L.Z(!1),this.targetLag=new L.Z(t),this.lag=new L.Z(0),this.bitrateLimit=new L.Z(0),this.resolution=new L.Z(g.empty),this.failureCount=new L.Z(0),this.endPoint=new L.Z(null),this.stream=new L.Z(null),this.rtcStatistics=new L.Z(null)}return u()(e,[{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,this.stream.value=null,void(this.state.value=_.Z.Error)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=y.Z.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return _.Z.Starting;case"no-stream":case"not-found":return _.Z.StandBy;case"geo-restricted":return _.Z.GeoRestricted;case"geo-blocked":return _.Z.GeoBlocked;case"unauthorized":return _.Z.Unauthorized;case"capacity":case"rate-limited":case"timeout":return _.Z.Recovering;case"failed":return _.Z.Error;default:(0,C.Z)(e)}}}]),e}(),F=u()((function e(){a()(this,e),h()(this,"mediaStream",void 0),h()(this,"peerConnection",void 0),h()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new L.Z(null),this.peerConnection=new L.Z(null),this.peerConnectionReconnectAttempts=0})),I=u()((function e(){a()(this,e),h()(this,"isStarting",void 0),h()(this,"isDisposed",void 0),this.isStarting=new L.Z(!1),this.isDisposed=!1})),A=n(319),M=n.n(A),j=n(8862),N=function(){function e(){a()(this,e)}return u()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case i.Normal:return"Normal";case i.Force:return"Force";case i.Reset:return"Reset";default:(0,C.Z)(e)}}}]),e}(),V=function(){function e(){a()(this,e)}return u()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case r.Keep:return"Keep";case r.Reset:return"Reset";default:(0,C.Z)(e)}}}]),e}(),U=n(202).default,B=function(){function e(t,n){if(a()(this,e),h()(this,"_logger",v.Z.getLogger("EndPoint")),h()(this,"_uri",void 0),h()(this,"_timeout",void 0),h()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}var t,n,r,i,o,s,c,d,p,m,g,y;return u()(e,[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(y=l()(f().mark((function e(){var t,n,r,i,o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,U.race([fetch(t,{method:"GET",cache:"no-cache"}),new U((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._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 y.apply(this,arguments)})},{key:"subscribe",value:(g=l()(f().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,v,m,g,y=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((i=b.Z.parseToken(t))&&i.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=i.applicationId,a=this.buildUrl([o,"stream","subscribe"]).toString(),s=new FormData,u=j.Z.sdkVersion,0===r&&n?(c={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},createAnswerDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=10,p=null,e.next=14,U.race([fetch(a,{method:"POST",body:s}),new U((function(e){return p=window.setTimeout((function(){y._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(a,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&clearTimeout(p)}));case 14:h=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(v=this.mapHttpStatusToSubscribeStatus(h))){e.next=24;break}return e.abrupt("return",{status:v});case 24:return m=Date.now(),e.next=27,this.convertHttpResponseToSubscribeResponse(o,h);case 27:return g=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",g,m-d),e.abrupt("return",g);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n){return g.apply(this,arguments)})},{key:"publish",value:(m=l()(f().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,p,v,m,g,y,_=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((o=b.Z.parseToken(n))&&o.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return a=o.applicationId,s=this.buildUrl([a,"stream","publish"]).toString(),u=new FormData,c=j.Z.sdkVersion,0===i&&r?(l={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(r.type),sdp:r.sdp}},createAnswerDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(l))):(d={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(d))),h=Date.now(),e.prev=10,v=null,e.next=14,U.race([fetch(s,{method:"POST",body:u}),new U((function(e){return v=window.setTimeout((function(){_._logger.error("Failed to publish",new Error("Publish timed out [".concat(s,"]"))),e({status:408})}),_._timeout)}))]).finally((function(){v&&clearTimeout(v)}));case 14:p=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(m=this.mapHttpStatusToPublishStatus(p))){e.next=24;break}return e.abrupt("return",{status:m});case 24:return g=Date.now(),e.next=27,this.convertHttpResponseToPublishResponse(a,p);case 27:return y=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",y,g-h),e.abrupt("return",y);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n,r){return m.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=l()(f().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return f().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 FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,U.race([fetch(r,{method:"POST",body:i}),new U((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(d=l()(f().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,v=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new FormData,u={apiVersion:6,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:V.convertBitrateStateToBitrateStateType(i),bitrateMode:N.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,U.race([fetch(a,{method:"POST",body:s}),new U((function(e){return d=window.setTimeout((function(){v._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),v._timeout)}))]).finally((function(){d&&clearTimeout(d)}));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 h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,p-c),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return d.apply(this,arguments)})},{key:"addIceCandidates",value:(c=l()(f().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,v=this,m=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new FormData,s={apiVersion:6,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,U.race([fetch(o,{method:"POST",body:a}),new U((function(e){return l=window.setTimeout((function(){v._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),v._timeout)}))]).finally((function(){l&&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"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=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,h-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=l()(f().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,U.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new U((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,M()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=j.Z.sdkVersion;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["_","".concat(Date.now())]]).toString()),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 408:return"timeout";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 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:(o=l()(f().mark((function e(t,n){var r,i;return f().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:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=l()(f().mark((function e(t,n){var r,i;return f().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:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={};if(e.bundlePolicy)switch(e.bundlePolicy){case"BundlePolicyBalanced":t.bundlePolicy="balanced";break;case"BundlePolicyMaxCompat":t.bundlePolicy="max-compat";break;case"BundlePolicyMaxBundle":t.bundlePolicy="max-bundle";break;default:(0,C.Z)(e.bundlePolicy)}if("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}if(e.iceTransportPolicy)switch(e.iceTransportPolicy){case"IceTransportPolicyAll":t.iceTransportPolicy="all";break;case"IceTransportPolicyRelay":t.iceTransportPolicy="relay";break;case"IceTransportPolicyPublic":break;default:(0,C.Z)(e.iceTransportPolicy)}if(e.peerIdentity&&(t.peerIdentity=e.peerIdentity),e.rtcpMuxPolicy)switch(e.rtcpMuxPolicy){case"RtcpMuxPolicyNegotiate":t.rtcpMuxPolicy="negotiate";break;case"RtcpMuxPolicyRequire":t.rtcpMuxPolicy="require";break;default:(0,C.Z)(e.rtcpMuxPolicy)}return t}},{key:"convertISessionDescriptionToRTCSessionDescription",value:function(e){var t={sdp:e.sdp};switch(e.type){case"Offer":t.type="offer";break;case"Answer":t.type="answer";break;default:(0,C.Z)(e.type)}return t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=l()(f().mark((function e(t){var n,r;return f().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=this.convertISessionDescriptionToRTCSessionDescription(n.sessionDescription)),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=l()(f().mark((function e(t){var n,r;return f().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 n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(t=l()(f().mark((function e(t){var n,r;return f().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(e){return t.apply(this,arguments)})},{key:"convertRTCSdpTypeToSdpType",value:function(e){switch(e){case"answer":return"Answer";case"offer":return"Offer";case"pranswer":case"rollback":throw new Error("SDP type [".concat(e,"] is not supported"));default:(0,C.Z)(e)}}}]),e}(),G=n(5564),z=n(6062),H=n(202).default,W=function(){function e(t){if(a()(this,e),h()(this,"_logger",v.Z.getLogger("Discovery")),h()(this,"_metricsService",void 0),h()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=z.Z.getMetricsService(t.toString()),this._uri=t}var t,n;return u()(e,[{key:"discoverNearbyEndPoints",value:(n=l()(f().mark((function e(t,n){var r,i,o,a;return f().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,H.race([fetch(r,{method:"GET",cache:"no-cache"}),new H((function(e,t){return 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 o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new B(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=l()(f().mark((function e(){var t,n,r,i,o,a=this,s=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.length>0&&void 0!==s[0]?s[0]:2e4,n=G.Z.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=function(){return new H((function(){a._logger.info("Request [%s] failed, preventing it from completing",n)}))},e.next=8,H.race(r.map((function(e){return e.ping().catch((function(t){return a._logger.warn("Failed to ping end point [%s]",e,t),i()})).then((function(t){var n=Date.now();return a._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),a._metricsService.push({metricType:x.Z.RoundTripTime,runtime:(n-y.Z.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 8:return o=e.sent,e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),J=function(){function e(){throw a()(this,e),new Error("Discovery is a static class that may not be instantiated")}var t,n;return u()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=l()(f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(y.Z.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=l()(f().mark((function t(n){var r,i,o;return f().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 W(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(t){throw delete e._cache[r],t})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]),e}();h()(J,"_cache",{}),J.precacheClosestEndPointDiscovery();var q,K=n(4146),Q=n(1228);function Y(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 $(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}!function(e){e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource"}(q||(q={}));var X=function(){function e(t,n,r,i,o){a()(this,e),h()(this,"_logger",v.Z.getLogger("WebPlayer")),h()(this,"_videoElement",void 0),h()(this,"_kind",void 0),h()(this,"_streamId",void 0),h()(this,"_manifestURI",void 0),h()(this,"_options",void 0),h()(this,"_player",void 0),h()(this,"_lastReloadTime",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}return u()(e,[{key:"start",value:function(){var e=this;if(se.phenixWebPlayer){var t=$($({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new se.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,t),this._player.start(this._manifestURI),void this._player.addEventListener("error",(function(t){e.canReload()&&t&&(3===t.code||t.severity===se.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t)}))}}},{key:"isSupported",value:function(){return se.phenixWebPlayer&&se.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:q.NetworkNoSource,dataBuffered:0};var e=this._player.getStats(),t=e.currentTime||this._videoElement.currentTime,n=(Date.now()-this._options.originStartTime)/1e3;return this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),e.isNative&&"Hls"===e.deliveryType&&(e.currentTime=t-e.lag),e.currentTime||(e.currentTime=t),e.isNative||(e.lag=Math.max(0,n-t)),e.estimatedBandwidth>0?e.networkState=q.NetworkLoading:e.playTime>0?e.networkState=q.NetworkIdle:e.video?e.networkState=q.NetworkEmpty:e.networkState=q.NetworkNoSource,e}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return this._videoElement&&this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player.dispose(),this._player=null,this.start()}}]),e}();function ee(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 te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ne=function(){function e(t,n,r,i,o){a()(this,e),h()(this,"_logger",v.Z.getLogger("ShakaPlayer")),h()(this,"_videoElement",void 0),h()(this,"_kind",void 0),h()(this,"_streamId",void 0),h()(this,"_manifestURI",void 0),h()(this,"_options",void 0),h()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}return u()(e,[{key:"start",value:function(){if(se.shaka)return this._player=new se.shaka.Player(this._videoElement),void this.loadPlayer({abr:{defaultBandwidthEstimate:2e6},manifest:{retryParameters:{timeout:1e4}},streaming:{rebufferingGoal:2,bufferingGoal:10,bufferBehind:30,retryParameters:{timeout:1e4,maxAttempts:10,backoffFactor:1.1}}})}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:q.NetworkNoSource};var e=te(te({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth>0?e.networkState=q.NetworkLoading:e.playTime>0?e.networkState=q.NetworkIdle:e.video?e.networkState=q.NetworkEmpty:e.networkState=q.NetworkNoSource,e}},{key:"dispose",value:function(){this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t=this;this._player.configure(e),this._player.load(this._manifestURI).then((function(){t._logger.info("[%s] DASH live stream has been loaded",t._streamId),t._videoElement.play&&t._videoElement.play()})).catch((function(e){t._logger.error("[%s] Error while loading DASH live stream [%s]",t._streamId,e.code,e)}))}}]),e}(),re=function(){function e(t,n,r,i,o){a()(this,e),h()(this,"_videoElement",void 0),h()(this,"_kind",void 0),h()(this,"_streamId",void 0),h()(this,"_manifestURI",void 0),h()(this,"_options",void 0),h()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}return u()(e,[{key:"start",value:function(){se.hlsPlayer&&(se.hlsPlayer.isSupported()?(this._player=new se.hlsPlayer({enableWorker:!0,maxBufferLength:1,liveBackBufferLength:0,liveSyncDuration:7,liveDurationInfinity:!0,liveMaxLatencyDuration:1/0,highBufferWatchdogPeriod:1}),this._player.loadSource(this._manifestURI),this._player.attachMedia(this._videoElement)):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&(this._videoElement.src=this._manifestURI))}},{key:"isSupported",value:function(){return se.hlsPlayer&&se.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:q.NetworkNoSource};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:q.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=q.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=q.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=q.NetworkLoading:e.networkState=q.NetworkEmpty;var t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3;return e.lag=Math.max(0,t+this._options.lag/1e3-n),e}},{key:"dispose",value:function(){this._player&&this._player.destroy&&(this._player.destroy(),this._player=null)}}]),e}(),ie=n(202).default;function oe(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 ae(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var se=function(){function e(){a()(this,e)}var t;return u()(e,null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(t=l()(f().mark((function e(t,n,r,i){var o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._options=i,!(this._hlsPlayer||this._shaka||this._phenixWebPlayer)){e.next=3;break}return e.abrupt("return",this.loaded(t,n,r));case 3:if(y.Z.webPlayerLoader||y.Z.shakaPlayerLoader||y.Z.hlsJsLoader){e.next=5;break}throw new Error("No player is provided");case 5:if(y.Z.webPlayerLoader||y.Z.shakaPlayerLoader||y.Z.hlsJsLoader){e.next=7;break}throw new Error("Unsupported-feature, add stream player");case 7:return e.abrupt("return",new ie((function(e){y.Z.hlsJsLoader&&(o._pending=!0,y.Z.hlsJsLoader((function(i){o._hlsPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),y.Z.webPlayerLoader&&(o._pending=!0,y.Z.webPlayerLoader((function(i){o._phenixWebPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),y.Z.shakaPlayerLoader&&(o._pending=!0,y.Z.shakaPlayerLoader((function(i){o._shaka=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))})))})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,n,r,i){return t.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:function(e,t,n,r,i){var o=r.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),a=r.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),s=o&&o[1]?o[1]:"",u=a&&a[1]?a[1]:"";return Q.Z.shouldUseNativeHls||this._hlsPlayer&&this._hlsPlayer.isSupported()?(this._player=new e(t,"hls",n,u,i),this._player.start(),this._player):(this._player=new e(t,"dash",n,s,i),this._player.start(),this._player)}},{key:"loaded",value:function(e,t,n){if(this._shaka||this._phenixWebPlayer||this._hlsPlayer)return this._hlsPlayer?this.play(re,e,t,n,ae(ae({},this._options),{},{preferNative:Q.Z.shouldUseNativeHls})):this._phenixWebPlayer?this.play(X,e,t,n,ae(ae({},this._options),{},{preferNative:Q.Z.shouldUseNativeHls})):this._shaka?this.play(ne,e,t,n,ae(ae({},this._options),{},{preferNative:Q.Z.shouldUseNativeHls})):void 0}}]),e}();h()(se,"_pending",!1),h()(se,"_hlsPlayer",void 0),h()(se,"_phenixWebPlayer",void 0),h()(se,"_shaka",void 0),h()(se,"_options",void 0),h()(se,"_player",void 0);var ue=function(){function e(t,n){a()(this,e),h()(this,"_logger",v.Z.getLogger("ChunkedStream")),h()(this,"_channelContext",void 0),h()(this,"_monitorDisposables",new S.Z),h()(this,"_handleStreamFailure",void 0),h()(this,"_streamStatistics",void 0),h()(this,"_monitorFailureCount",0),this._channelContext=t,this._handleStreamFailure=n,this._channelContext.disposables.add(this)}return u()(e,[{key:"start",value:function(e,t){var n=this;return J.discoverClosestEndPointWithCaching(e).then((function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)})).then((function(e){var t=e.status,r=e.stream,i=e.createOfferDescriptionResponse,o=e.lag;if(n._channelContext.stream.value=r,n._channelContext.lag.value=o,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",n._channelContext.streamId,t,i),n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(t),n._channelContext.applyStatus(t),"ok"===t){var a=i.sessionDescription.sdp,s={originStartTime:Date.now()-o+n._channelContext.endPoint.value.roundTripTime/2,lag:o};return se.start(n._channelContext.videoElement.value,n._channelContext.streamId,a,s).then((function(e){return n.monitor(e),e})).catch((function(e){n._logger.error("LiveStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=K.ChannelState.Stopped}))}}))}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=window.setTimeout((function(){var n=se.getStats();if(t._streamStatistics&&t._streamStatistics.currentTime>=n.currentTime&&t._streamStatistics.dataBuffered>=n.dataBuffered){if(t._monitorFailureCount++,t._monitorFailureCount>6)return t._monitorFailureCount=0,t._channelContext.state.value=K.ChannelState.Error,t._channelContext.playing.value=!1,t._channelContext.loading.value=!0,e.dispose(),t._monitorDisposables.dispose(),void t._handleStreamFailure().catch((function(e){t._logger.error("Failed handling stream failure",e)}))}else t._monitorFailureCount=0;t._channelContext.videoElement.value.paused&&t._channelContext.state.value===K.ChannelState.Playing&&(t._channelContext.state.value=K.ChannelState.Paused),t._channelContext.videoElement.value.paused||t._channelContext.state.value===K.ChannelState.Playing||(t._channelContext.state.value=K.ChannelState.Playing),t._streamStatistics=n,t.monitor(e)}),1e3);this._monitorDisposables.add(new w.Z((function(){clearTimeout(n)})))}},{key:"dispose",value:function(){this._monitorDisposables.dispose()}}]),e}(),ce=n(3038),le=n.n(ce),de=function(){function e(){throw a()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}var t,n;return u()(e,null,[{key:"initiateInitialPrecaching",value:function(){Q.Z.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error('Failed to pre-cache peer connection offer"',t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=l()(f().mark((function t(){return f().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=l()(f().mark((function t(){var n,r,i,o=arguments;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:"recvonly",!e._cached||e._cached.direction!==n){t.next=5;break}return r=e._cached.peerConnection,e._cached=null,t.abrupt("return",r);case 5:return i=y.Z.peerConnectionFactory.value,t.abrupt("return",i.createPeerConnection().then(function(){var e=l()(f().mark((function e(t){var r,i,o;return f().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 o="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(o);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 7:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]),e}();h()(de,"_logger",v.Z.getLogger("PeerConnectionService")),h()(de,"_cached",void 0),de.initiateInitialPrecaching();var he=function(){function e(t){a()(this,e),h()(this,"_sdp",void 0),h()(this,"_audioCodec",void 0),h()(this,"_videoCodec",void 0),h()(this,"_isAudioTrackEnabled",void 0),h()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split("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)}return u()(e,[{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}(),pe=function(){function e(t,n,r){if(a()(this,e),h()(this,"_estimatedRoundTripTime",void 0),h()(this,"_estimatedVideoCodec",void 0),h()(this,"_estimatedAudioCodec",void 0),h()(this,"_rtcStatistic",new L.Z({})),h()(this,"_peerConnection",void 0),h()(this,"_isMonitorRunning",!0),h()(this,"_updateTimeOut",void 0),h()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!Q.Z.getCurrentOfferDisabled){var i=new he(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}var t,n;return u()(e,[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeOut&&(clearTimeout(this._updateTimeOut),this._updateTimeOut=null)}},{key:"updateStatistic",value:(n=l()(f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Q.Z.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,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&n._tracksToMonitor.includes(s)){var c,l,d,h,p,f=(a.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),v=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),m=f&&v?Math.floor(8*f/v*1e3):0;if(r[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:m,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[s].framesDecoded=a.framesDecoded;var g=(a.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=window.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(t=l()(f().mark((function e(){var t=this;return f().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=window.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]),e}(),fe=function(){function e(){throw a()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}return u()(e,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}}]),e}(),ve=n(202).default;function me(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 ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ye=function(){function e(t,n,r){a()(this,e),h()(this,"_logger",v.Z.getLogger("RealTimeStream")),h()(this,"_channelContext",void 0),h()(this,"_peerConnectionContext",void 0),h()(this,"_handleStreamFailure",void 0),this._channelContext=t,this._peerConnectionContext=n,this._handleStreamFailure=r}var t;return u()(e,[{key:"start",value:function(e,t,n,r){var i=this;return ve.all([J.discoverClosestEndPointWithCaching(e),de.createPeerConnectionOffer()]).then((function(e){var n=le()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.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"+a.sdp),!Q.Z.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s=null,a=null),i._peerConnectionContext.peerConnection.value=s,r.subscribe(t,a,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,a=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,u=e.createOfferDescriptionResponse,c=e.createAnswerDescriptionResponse,l=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=l,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,a,s,u,c),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,a).then((function(e){var t,a=!1,l=!1,d=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e&&(a||y.Z.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?d.push(n.candidate):l=!0,t||(t=setTimeout((function(){i._channelContext.stream.value!==o||a||i._channelContext.endPoint.value.addIceCandidates(o,d,l).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(a=!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=_.Z.Error,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(navigator.onLine&&(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:(0,C.Z)(e.iceConnectionState)}}};var h=new ve((function(t,n){if(Q.Z.onTrackDisabled){var r=function n(r){clearTimeout(i),e.removeEventListener("track",n),e.removeEventListener("addstream",n),r.streams?t(r.streams[0]):t(r.stream)},i=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 o=setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){clearTimeout(o),t(e.streams[0])}}}));return new ve((function(e){e()})).then((function(){if(s)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,s.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP answer [%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(){if(u)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,u.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),h})).then((function(t){i._peerConnectionContext.mediaStream.value=t;var n=new pe(e,t,i._channelContext.endPoint.value.roundTripTime/4);return i._channelContext.disposables.add(n),n.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 r=!1,o=!1;t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((r=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&navigator.onLine&&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 k(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&&((o=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&navigator.onLine&&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 k(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),(o||r)&&navigator.onLine?i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=_.Z.Error,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,n.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)}))})):i._peerConnectionContext.peerConnectionReconnectAttempts=0})),y.Z.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=_.Z.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(t=l()(f().mark((function e(t,n){var r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=fe.truncateIceServers(n),e.abrupt("return",y.Z.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=ge(ge({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=_.Z.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<y.Z.maximalNumberOfPeerConnectionReconnectAttempts||!y.Z.automaticallyReconnectPeerConnection){if(this._peerConnectionContext.peerConnectionReconnectAttempts++,Q.Z.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||this._channelContext.failureCount.value)return;this._logger.info("Reconnecting peer connection by restarting ICE");var r=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(r)}))})).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:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return _.Z.Starting;case"unauthorized":return _.Z.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return _.Z.Recovering;case"failed":return _.Z.Error;default:(0,C.Z)(e)}}}]),e}(),_e=function(){function e(){throw a()(this,e),new Error("StreamFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"create",value:function(e,t,n,r){var i=b.Z.parseToken(e);return i&&i.token&&i.token.capabilities&&i.token.capabilities.includes("rtmp")?(this._logger.error("This build does not support RTMP playback."),void(t.state.value=_.Z.UnsupportedFeature)):i&&i.token&&i.token.capabilities&&i.token.capabilities.includes("streaming")?new ue(t,r):new ye(t,n,r)}}]),e}();h()(_e,"_logger",v.Z.getLogger("Streaming"));var Ce=n(202).default,we="client:termination",be=function(){function e(t,n){var o=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;a()(this,e),h()(this,"_logger",v.Z.getLogger("Channel")),h()(this,"_tokenContext",void 0),h()(this,"_channelContext",void 0),h()(this,"_peerConnectionContext",void 0),h()(this,"_stateContext",void 0),h()(this,"_channelStartTime",void 0),h()(this,"_readOnlyVideoElement",void 0),h()(this,"_readOnlyToken",void 0),h()(this,"_readOnlyPeerConnection",void 0),h()(this,"_readOnlyState",void 0),h()(this,"_readOnlyAutoMuted",void 0),h()(this,"_readOnlyAutoPaused",void 0),h()(this,"_readOnlyTokenExpiring",void 0),h()(this,"_readOnlyAuthorized",void 0),h()(this,"_readOnlyOnline",void 0),h()(this,"_readOnlyLoading",void 0),h()(this,"_readOnlyPlaying",void 0),h()(this,"_readOnlyStandby",void 0),h()(this,"_readOnlyStopped",void 0),h()(this,"_readOnlyTargetLag",void 0),h()(this,"_readOnlyLag",void 0),h()(this,"_readOnlyBitrateLimit",void 0),h()(this,"_readOnlyResolution",void 0),h()(this,"_readOnlyFailureCount",void 0),h()(this,"_readOnlyEndPoint",void 0),h()(this,"_readOnlyStream",void 0),h()(this,"_readOnlyRtcStatistics",void 0),h()(this,"_readOnlyMediaStream",void 0),h()(this,"_metricsService",void 0),h()(this,"_sessionTelemetry",void 0),h()(this,"_videoMetaDataChangedHandler",void 0),this._tokenContext=new D(n),this._channelContext=new O(s),this._peerConnectionContext=new F,this._stateContext=new I,this._channelStartTime=Date.now(),this._readOnlyVideoElement=new m.Z(this._channelContext.videoElement),this._readOnlyToken=new m.Z(this._tokenContext.token),this._readOnlyPeerConnection=new m.Z(this._peerConnectionContext.peerConnection),this._readOnlyState=new m.Z(this._channelContext.state),this._readOnlyAutoMuted=new m.Z(this._channelContext.autoMuted),this._readOnlyAutoPaused=new m.Z(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new m.Z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new m.Z(this._channelContext.authorized),this._readOnlyOnline=new m.Z(this._channelContext.online),this._readOnlyLoading=new m.Z(this._channelContext.loading),this._readOnlyPlaying=new m.Z(this._channelContext.playing),this._readOnlyStandby=new m.Z(this._channelContext.standby),this._readOnlyStopped=new m.Z(this._channelContext.stopped),this._readOnlyTargetLag=new m.Z(this._channelContext.targetLag),this._readOnlyLag=new m.Z(this._channelContext.lag),this._readOnlyBitrateLimit=new m.Z(this._channelContext.bitrateLimit),this._readOnlyResolution=new m.Z(this._channelContext.resolution),this._readOnlyFailureCount=new m.Z(this._channelContext.failureCount),this._readOnlyEndPoint=new m.Z(this._channelContext.endPoint),this._readOnlyStream=new m.Z(this._channelContext.stream),this._readOnlyRtcStatistics=new m.Z(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new m.Z(this._peerConnectionContext.mediaStream);var u=b.Z.parseToken(this._tokenContext.token.value),c=(b.Z.getUri(u)||y.Z.discoveryUri.value).toString();y.Z.tenancy.value=b.Z.getTenancy(u)||y.Z.tenancy.value,G.Z.uri.value=c,this._metricsService=z.Z.getMetricsService(c),this._sessionTelemetry=new E(y.Z.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){o._channelContext.rendererDisposables.dispose(),e&&(o._channelContext.rendererDisposables.add(o._channelContext.stream.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.dispose(),e&&o.videoElement&&(o.videoElement.dataset&&(o.videoElement.dataset.sessionId=y.Z.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new T(o.streamId,y.Z.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===_.Z.Stopped)&&o.restartAfterStop()}))),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){o._channelContext.clearFailureCountTimeout&&clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===_.Z.Playing&&(o._channelContext.clearFailureCountTimeout=window.setTimeout((function(){o._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&o._channelContext.endPoint.value&&o._channelContext.stream.value){var t=Date.now()-o._channelContext.channelInitialization.getTime();o._channelContext.endPoint.value.limitBitrate(o._channelContext.stream.value,t,e,r.Keep,i.Normal).catch((function(e){o._logger.error("Error while setting limit bitrate",e)}))}})));var l=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStream(o._channelContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",l),this._channelContext.channelDisposables.add(new w.Z((function(){window.removeEventListener("beforeunload",l)}))),this.start()}var t,n,o,s,c,d,p,k,x;return u()(e,[{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=_.Z.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 g(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=g.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=b.Z.parseToken(this._tokenContext.token.value),n=(b.Z.getUri(t)||y.Z.discoveryUri.value).toString();y.Z.tenancy.value=b.Z.getTenancy(t)||y.Z.tenancy.value,G.Z.uri.value=n,this._metricsService=z.Z.getMetricsService(n),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:"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,r.Keep,i.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:(x=l()(f().mark((function e(t){var n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ce((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 x.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=_.Z.Stopped}},{key:"resume",value:(k=l()(f().mark((function e(){return f().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 k.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:(p=l()(f().mark((function e(){var t=this;return f().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 p.apply(this,arguments)})},{key:"getUri",value:function(e){var t=b.Z.parseToken(e);return b.Z.getUri(t)||(this._logger.info("Fall back to the default discover URI [%s]",y.Z.discoveryUri.value),new URL(y.Z.discoveryUri.value))}},{key:"start",value:(d=l()(f().mark((function e(){return f().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 d.apply(this,arguments)})},{key:"processStart",value:(c=l()(f().mark((function e(){var t,n,r,i,o,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),b.Z.isValidToken(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=_.Z.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:if(this.cleanUpResources("client:start"),this._channelContext.state.value=_.Z.Starting,this._channelContext.loading.value=!0,r=this.getUri(t),i=function(){return new Ce((function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())}))},o=_e.create(t,this._channelContext,this._peerConnectionContext,i)){e.next=17;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 17:return e.abrupt("return",o.start(r,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){a._channelContext.loading.value=!1})).catch((function(e){n.fail(),a._channelContext.failureCount.value++,a._channelContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._channelContext.state.value=_.Z.Error,a._logger.error("Failed to start channel",e)})).finally((function(){if(a._stateContext.isStarting.value=!1,a._channelContext.state.value!==_.Z.Playing&&y.Z.automaticRetryOnFailure){var e=setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._channelContext.disposables.add(new w.Z((function(){clearTimeout(e)})))}})));case 18:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"restartAfterStop",value:(s=l()(f().mark((function e(){return f().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 s.apply(this,arguments)})},{key:"play",value:(o=l()(f().mark((function e(){var t;return f().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 o.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case _.Z.StandBy:case _.Z.Offline:return 15e3;case _.Z.Error:case _.Z.Recovering:case _.Z.Unauthorized:case _.Z.GeoRestricted:case _.Z.GeoBlocked:case _.Z.Stopped:case _.Z.Starting:case _.Z.Playing:case _.Z.Paused:case _.Z.Reconnecting:case _.Z.UnsupportedFeature:return Math.min(3e5,Math.pow(2e3,Math.max(0,this._channelContext.failureCount.value-1)));default:(0,C.Z)(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=l()(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===_.Z.Error||e.t0===_.Z.Reconnecting||e.t0===_.Z.StandBy||e.t0===_.Z.Offline||e.t0===_.Z.Recovering?3:e.t0===_.Z.Unauthorized?5:e.t0===_.Z.GeoRestricted?7:e.t0===_.Z.GeoBlocked?9:e.t0===_.Z.Stopped?11:e.t0===_.Z.Playing?13:e.t0===_.Z.Paused?15:e.t0===_.Z.Starting?17:e.t0===_.Z.UnsupportedFeature?19:21;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,_.Z[this._channelContext.state.value]),e.abrupt("break",22);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 playing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 17:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 19:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 21:(0,C.Z)(this._channelContext.state.value);case 22:return e.abrupt("return",this.start());case 23:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:we;this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close()),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:"playMediaStreamInVideoElement",value:(t=l()(f().mark((function e(t){var n,r,i=this;return f().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=_.Z.Stopped,e.abrupt("return");case 8:if(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=_.Z.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=_.Z.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})),o=!y.Z.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=_.Z.Paused,o?(i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e),void(n.srcObject=null)):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=_.Z.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=_.Z.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),ke=function(){function e(){throw a()(this,e),new Error("Channels is a static class that may not be instantiated")}return u()(e,null,[{key:"createChannel",value:function(e){if(!y.Z.initialized.value)throw new Error("SDK is not loaded.");return new be(e.videoElement,e.token,e.targetLag)}}]),e}()},4146:(e,t,n)=>{"use strict";n.d(t,{ChannelState:()=>o.Z});var r=n(5508),i=n(6644),o=n(2250);r.Z,i.Z,o.Z},79:(e,t,n)=>{"use strict";n.d(t,{w:()=>r});var r="https://pcast.phenixrts.com/pcast/endPoints"},5564:(e,t,n)=>{"use strict";n.d(t,{Z:()=>h});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(79),l=n(7426),d=n(8862),h=function(){function e(){throw i()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return a()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=d.Z.sdkVersion;return t.search="?".concat(new URLSearchParams([["version",n],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}]),e}();u()(h,"_discoveryUri",new l.Z(c.w))},3297:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(9571),l="DIGEST:",d=function(){function e(){i()(this,e)}return a()(e,null,[{key:"parseToken",value:function(t){if(this.isValidToken(t))try{var n=atob(t.substr(l.length)),r=JSON.parse(n);return r.token=JSON.parse(r.token),r}catch(t){return void e._logger.error("Cannot parse token value",t)}else e._logger.error("Token is not valid [%s]",t)}},{key:"getUri",value:function(e){return e&&e.token&&e.token.uri?new URL(e.token.uri):null}},{key:"getTenancy",value:function(e){return e&&e.applicationId?e.applicationId:""}},{key:"isValidToken",value:function(e){return!!e&&e.startsWith(l)}}]),e}();u()(d,"_logger",c.Z.getLogger("EdgeAuth"))},1228:(e,t,n)=>{"use strict";n.d(t,{Z:()=>u});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9845),u=function(){function e(){i()(this,e)}return a()(e,null,[{key:"clientOfferDisabled",get:function(){return s.Z.isChrome74||s.Z.isChrome75||s.Z.isChrome76||s.Z.isChrome77}},{key:"addTranceiverDisabled",get:function(){return s.Z.isChrome69||s.Z.isChrome70||s.Z.isChrome71||s.Z.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=69||"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=63||"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===s.Z.browserName||"SamsungBrowser"===s.Z.browserName}},{key:"isRTMPEnabled",get:function(){return"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<84||"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<70||"Edge"===s.Z.browserName||"IE"===s.Z.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==s.Z.browserName}}]),e}()},2480:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SDK:()=>r.Z,Channels:()=>i.Z,ChannelState:()=>o.Z});var r=n(5508),i=n(6644),o=n(2250);t.default={SDK:r.Z,Channels:i.Z,ChannelState:o.Z}},8862:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"sdkVersion",get:function(){try{return"2022-12-23T18:20:11.081Z (2023.0.2)"}catch(e){return this._defaultVersion}}}]),e}();u()(c,"_defaultVersion",(new Date).toISOString())},3552:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(5183),l=function(){function e(t){i()(this,e),u()(this,"_telemetryService",void 0),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new c.Z(t)}return a()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}()},5259:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(1178),l=function(){function e(){i()(this,e),u()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_environment",void 0),u()(this,"_threshold",c.Z.defaultTelemetryLoggingLevel)}return a()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new 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:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}()},5183:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(7757),h=n.n(d),p=n(5149),f=n(8862),v=function(){function e(t){a()(this,e),l()(this,"_telemetryConfiguration",void 0),l()(this,"_logs",[]),l()(this,"_isSending",void 0),l()(this,"_domain",location.hostname),this._telemetryConfiguration=t}var t,n;return u()(e,[{key:"push",value:function(e,t,n,r){var i={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:p.G[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:f.Z.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<p.G.Error?this._logs.push(i):this._logs.unshift(i),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=i()(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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 n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(t=i()(h().mark((function e(){var t,n,r,i,o=this;return h().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 Object.values(e).reduce((function(e,t){return e+(t?t.length:0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),i=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(i).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}()}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return 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.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(2480)})()}));
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,(function(){return(()=>{var e={7228:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},2858:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},3646:(e,t,n)=>{var r=n(7228);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},1506: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},8926:(e,t,n)=>{var r=n(202).default;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},4575: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},3913:(e,t,n)=>{var r=n(3696);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},9713:(e,t,n)=>{var r=n(3696);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},9754: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},2205:(e,t,n)=>{var r=n(9489);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},6860: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},3884: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,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.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&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},521: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},8206: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},8585:(e,t,n)=>{var r=n(8).default,i=n(1506);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},9591:(e,t,n)=>{var r=n(202).default,i=n(8).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,a=n.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",d=u.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,o=Object.create(i.prototype),a=new L(r||[]);return s(o,"_invoke",{value:S(e,n,a)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var v={};function m(){}function g(){}function y(){}var _={};h(_,c,(function(){return this}));var C=Object.getPrototypeOf,w=C&&C(C(R([])));w&&w!==n&&a.call(w,c)&&(_=w);var b=y.prototype=m.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function n(r,o,s,u){var c=f(e[r],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var r;s(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function S(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=T(a,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function T(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,v;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,v):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function Z(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 P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(Z,this),this.reset(!0)}function R(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(a.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:E}}function E(){return{value:void 0,done:!0}}return g.prototype=y,s(b,"constructor",{value:y,configurable:!0}),s(y,"constructor",{value:g,configurable:!0}),g.displayName=h(y,d,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,h(e,d,"GeneratorFunction")),e.prototype=Object.create(b),e},t.awrap=function(e){return{__await:e}},k(x.prototype),h(x.prototype,l,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,i,o,a){void 0===a&&(a=r);var s=new x(p(e,n,i,o),a);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},k(b),h(b,d,"Generator"),h(b,c,(function(){return this})),h(b,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=R,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},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 t=this;function n(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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&&a.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 o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},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),P(n),v}},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;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),v}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},9489: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},3038:(e,t,n)=>{var r=n(2858),i=n(3884),o=n(379),a=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},319:(e,t,n)=>{var r=n(3646),i=n(6860),o=n(379),a=n(8206);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},8868:(e,t,n)=>{var r=n(8).default;e.exports=function(e,t){if("object"!==r(e)||null===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},3696:(e,t,n)=>{var r=n(8).default,i=n(8868);e.exports=function(e){var t=i(e,"string");return"symbol"===r(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},8: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},379:(e,t,n)=>{var r=n(7228);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.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},7757:(e,t,n)=>{var r=n(9591)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},6406:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(8),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(6330),h=n(7426),p=n(841),f=n(5656),v=function(){function e(){a()(this,e),l()(this,"_disposables",new f.Z),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),l()(this,"_documentFocusInterval",void 0),this._isForeground=new h.Z(!0),this._readOnlyIsForeground=new p.Z(this._isForeground),this.detectTabFocusChange()}return u()(e,[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":i()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new d.Z((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new d.Z((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}]),e}()},9845:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{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:"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}();u()(c,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),u()(c,"_browserNameAndVersion",c.parseBrowserNameAndVersion()),u()(c,"_browserName",c.parseBrowserName()),u()(c,"_browserMajorVersion",c.parseBrowserMajorVersion()),u()(c,"_isChrome69",c._browserNameAndVersion.includes("Chrome/69.")),u()(c,"_isChrome70",c._browserNameAndVersion.includes("Chrome/70.")),u()(c,"_isChrome71",c._browserNameAndVersion.includes("Chrome/71.")),u()(c,"_isChrome72",c._browserNameAndVersion.includes("Chrome/72.")),u()(c,"_isChrome74",c._browserNameAndVersion.includes("Chrome/74.")),u()(c,"_isChrome75",c._browserNameAndVersion.includes("Chrome/75.")),u()(c,"_isChrome76",c._browserNameAndVersion.includes("Chrome/76.")),u()(c,"_isChrome77",c._browserNameAndVersion.includes("Chrome/77."))},4381:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(3588),u=n(4417),c=n(2394),l=n(1178),d=function(){function e(){i()(this,e)}return a()(e,[{key:"getStringValue",value:function(e){return this.readConfigurationParameterValue(e)||this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"))||this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){var t=this.readConfigurationParameterValue(e);return t||this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"))?"true"===t||"1"===t||"On"===t:!0===this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":u.Z.convertTelemetryLevelToTelemetryLevelType(s.Z.defaultTelemetryLevel),"phenix-logging-level":c.Z.convertLoggingLevelToLoggingLevelType(l.Z.defaultLoggingLevel),"phenix-console-logging-level":c.Z.convertLoggingLevelToLoggingLevelType(l.Z.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":c.Z.convertLoggingLevelToLoggingLevelType(l.Z.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}}},{key:"readConfigurationParameterValue",value:function(e){var t=document.querySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(e){var t=this.readConfigurationParameterValue(e);if(t){var n=new URLSearchParams(location.search).get(t)||void 0;if(n)return n}}}]),e}()},3953:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"isPrivate",get:function(){return this._isPrivate}},{key:"applyIsPrivate",value:function(){try{this._isPrivate=!1}catch(e){this._isPrivate=!1}}}]),e}();u()(c,"_isPrivate",void 0),c.applyIsPrivate()},6330:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(t){i()(this,e),u()(this,"_disposed",void 0),u()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}return a()(e,[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}]),e}()},5656:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e),u()(this,"_list",[])}return a()(e,[{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,"]")}}]),e}()},4827:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=function(){function e(){throw i()(this,e),new Error("Strings is a static class that may not be instantiated")}return a()(e,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)}}]),e}()},8701:(e,t,n)=>{"use strict";t.Z=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))}},709:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e),u()(this,"_appenders",[])}return a()(e,[{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}),[])}}]),e}()},1502:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(5149),l=function(){function e(t){i()(this,e),u()(this,"_threshold",void 0),this._threshold=t}return a()(e,[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(c.G[e],"] ").concat(t);e<c.G.Warn?console.log(i):console.error(i)}}}]),e}()},5149:(e,t,n)=>{"use strict";n.d(t,{G:()=>r,Z:()=>l});var r,i=n(4575),o=n.n(i),a=n(3913),s=n.n(a),u=n(9713),c=n.n(u);!function(e){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"}(r||(r={}));var l=function(){function e(t,n,r){o()(this,e),c()(this,"_category",void 0),c()(this,"_appenders",void 0),c()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return s()(e,[{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>r.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.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?e+"\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}}]),e}()},1178:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(3953),u=n(5149),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"defaultLoggingLevel",get:function(){return s.Z.isPrivate?u.G.Off:u.G.All}},{key:"defaultConsoleLoggingLevel",get:function(){return s.Z.isPrivate?u.G.Off:u.G.All}},{key:"defaultTelemetryLoggingLevel",get:function(){return u.G.Info}}]),e}()},9571:(e,t,n)=>{"use strict";n.d(t,{Z:()=>g});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(5149),l=n(709),d=n(6016),h=n(1502),p=n(3552),f=n(5259),v=n(4381),m=n(1178),g=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(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 c.Z(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");c.G[e]&&this._threshold.setThreshold(c.G[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(c.G[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new h.Z(e||m.Z.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||m.Z.defaultTelemetryLoggingLevel,this._appenders.add(new p.Z(this._telemetryConfiguration))}}]),e}();u()(g,"_configurationParameterReader",new v.Z),u()(g,"_loggers",{}),u()(g,"_appenders",new l.Z),u()(g,"_threshold",new d.Z),u()(g,"_telemetryConfiguration",new f.Z),g.applyLoggerConfigFromParameterConfiguration()},2394:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(8701),u=n(5149),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case u.G.Off:return"Off";case u.G.Trace:return"Trace";case u.G.Debug:return"Debug";case u.G.Info:return"Trace";case u.G.Warn:return"Warn";case u.G.Error:return"Error";case u.G.Fatal:return"Fatal";case u.G.All:return"All";default:(0,s.Z)(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return u.G.Off;case"Trace":return u.G.Trace;case"Debug":return u.G.Debug;case"Info":return u.G.Info;case"Warn":return u.G.Warn;case"Error":return u.G.Error;case"Fatal":return u.G.Fatal;case"All":return u.G.All;default:(0,s.Z)(e)}}}]),e}()},6016:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(1178),l=function(){function e(){i()(this,e),u()(this,"_threshold",c.Z.defaultLoggingLevel)}return a()(e,[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}]),e}()},4574:(e,t,n)=>{"use strict";n.d(t,{Z:()=>h});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(2889),l=n(8701),d=n(8963),h=function(){function e(t){i()(this,e),u()(this,"_metrics",void 0),this._metrics=t}return a()(e,[{key:"getName",value:function(){return d.Z[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case d.Z.TimeToFirstFrame:case d.Z.ChannelCreationTimeToFirstFrame:return c.g.Essential;case d.Z.Stalled:case d.Z.Buffering:case d.Z.SetupCompleted:case d.Z.SetupFailed:case d.Z.RoundTripTime:case d.Z.DownlinkThroughputCapacity:case d.Z.NetworkType:case d.Z.ResolutionChanged:case d.Z.ApplicationForeground:case d.Z.ApplicationBackground:return c.g.All;default:(0,l.Z)(this._metrics)}}}]),e}()},2889:(e,t,n)=>{"use strict";n.d(t,{g:()=>r,Z:()=>d});var r,i=n(4575),o=n.n(i),a=n(3913),s=n.n(a),u=n(9713),c=n.n(u),l=n(3588);!function(e){e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All"}(r||(r={}));var d=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",l.Z.defaultTelemetryLevel)}return s()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new 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}}]),e}()},6062:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(3896),l=n(2889),d=n(5508),h=n(4760),p=n(5021),f=n(4417),v=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(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 l.Z;return r.sessionId=d.Z.clientSessionId,r.tenancy=d.Z.tenancy.value,r.url=h.Z.getTelemetryUrl(t),r.environment=p.Z.getEnvironmentFromUrl(t),r.threshold=f.Z.convertTelemetryLevelTypeToTelemetryLevel(d.Z.telemetryLevel),e._metricsServices[t]=new c.Z(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();u()(v,"_metricsServices",{})},3896:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(7757),h=n.n(d),p=n(8862),f=n(4574),v=function(){function e(t){a()(this,e),l()(this,"_metricsConfiguration",void 0),l()(this,"_metrics",[]),l()(this,"_isSending",void 0),l()(this,"_domain",location.hostname),this._metricsConfiguration=t}var t,n;return u()(e,[{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,o=e.resource,a=e.kind,s=new f.Z(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:p.Z.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=i()(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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 n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(t=i()(h().mark((function e(){var t,n=this;return h().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){return n._isSending=!1,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}()},8963:(e,t)=>{"use strict";var n;!function(e){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"}(n||(n={})),t.Z=n},4417:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(2889),u=n(8701),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case s.g.Off:return"Off";case s.g.Essential:return"Essential";case s.g.All:return"All";default:(0,u.Z)(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return s.g.Off;case"Essential":return s.g.Essential;case"All":return s.g.All;default:(0,u.Z)(e)}}}]),e}()},3588:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(3953),u=n(2889),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"defaultTelemetryLevel",get:function(){return s.Z.isPrivate?u.g.Essential:u.g.All}}]),e}()},202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>p});var r=n(8),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=u()((function e(t,n,r){a()(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})),h=function(){function e(t){if(a()(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 o=r.length,a=function t(a,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 t(a,e)}),n)}r[a]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(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,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.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=h},4554:(e,t,n)=>{"use strict";var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(7757),h=n.n(d),p=n(9571),f=n(1228),v=n(202).default,m=function(){function e(t){a()(this,e),l()(this,"_logger",p.Z.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),f.Z.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,o;return u()(e,[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{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:"supportsAddTransceiver",get:function(){return!f.Z.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(o=i()(h().mark((function e(t){var n=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.Z.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new v((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 o.apply(this,arguments)})},{key:"createAnswer",value:(r=i()(h().mark((function e(t){var n=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.Z.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new v((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 r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=i()(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(f.Z.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(t=i()(h().mark((function e(t){var n;return h().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.Z.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new v((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:"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:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}}]),e}();t.Z=m},4009:(e,t,n)=>{"use strict";var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(7757),l=n.n(c),d=n(4554),h=function(){function e(){a()(this,e)}var t;return u()(e,[{key:"createPeerConnection",value:(t=i()(l().mark((function e(t){return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new d.Z(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();t.Z=h},841:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(t){i()(this,e),u()(this,"_subject",void 0),this._subject=t}return a()(e,[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}]),e}()},7426:(e,t,n)=>{"use strict";n.d(t,{Z:()=>m});var r=n(9713),i=n.n(r),o=n(3913),a=n.n(o),s=n(4575),u=n.n(s),c=n(2205),l=n.n(c),d=n(8585),h=n.n(d),p=n(9754),f=n.n(p);var v=function(e){l()(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=f()(t);if(n){var i=f()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return h()(this,e)});function i(e,t){return u()(this,i),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return a()(i)}(n(6330).Z),m=function(){function e(t){u()(this,e),i()(this,"_listeners",void 0),i()(this,"_value",void 0),this._listeners=[],this._value=t}return a()(e,[{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 v(this._listeners,e)}}]),e}()},5021:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=function(){function e(){i()(this,e)}return a()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}()},5508:(e,t,n)=>{"use strict";n.d(t,{Z:()=>E});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(9571),l=n(4827),d=n(7426),h=n(841),p=n(4009),f=n(3297),v=n(5149),m=n(1502),g=n(3552),y=n(4381),_=n(2889),C=n(4417),w=n(2394),b=n(3953),k=n(9845),x=n(6406),S=n(4760),T=n(5021),Z=n(5564),P=n(6062),L=n(3588),R=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),E=function(){function e(){throw i()(this,e),new Error("SDK is a static class that may not be instantiated")}return a()(e,null,[{key:"pageLoadTime",get:function(){return R}},{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:"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 w.Z.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return C.Z.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return k.Z}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=c.Z.telemetryConfiguration;n.sessionId=e.clientSessionId,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 g.Z}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new g.Z(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 g.Z}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new g.Z(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=P.Z.getMetricsService(Z.Z.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&&P.Z.setTelemetryLevel(_.g[t]),e._telemetryLevel.subscribe((function(e){P.Z.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:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=T.Z.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=f.Z.parseToken(t);return e._tenancy.value=f.Z.getTenancy(n),Z.Z.uri.value=(f.Z.getUri(n)||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 Z.Z.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");return i?(Z.Z.uri.value="".concat(i,"/pcast/endPoints"),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)):void 0}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new x.Z),t){if(t.discoveryUri&&(Z.Z.uri.value=t.discoveryUri),t.peerConnectionFactory&&(e._peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&_.g[t.telemetryLevel]&&(e._telemetryLevel.value=C.Z.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&v.G[t.loggingLevel]&&this._logger.threshold.setThreshold(w.Z.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&v.G[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof m.Z}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new m.Z(w.Z.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 S.Z.getTelemetryUrl(e)}}]),e}();u()(E,"_automaticallyRetryOnFailure",!0),u()(E,"_automaticallyReconnectPeerConnection",!0),u()(E,"_automaticallyPlayMediaStream",!0),u()(E,"_automaticallyMuteVideoOnPlayFailure",!0),u()(E,"_webPlayerLoader",null),u()(E,"_shakaPlayerLoader",null),u()(E,"_hlsJsLoader",null),u()(E,"_configurationParameterReader",new y.Z),u()(E,"_applicationActivityMonitor",void 0),u()(E,"_environment",new d.Z("")),u()(E,"_telemetryUrl",new d.Z("https://telemetry.phenixrts.com/telemetry")),u()(E,"_maximalNumberOfPeerConnectionReconnectAttempts",8),u()(E,"_telemetryLevel",new d.Z(L.Z.defaultTelemetryLevel)),u()(E,"_metricsService",void 0),u()(E,"_metricsConfiguration",void 0),u()(E,"_sendLocalCandidates",new d.Z(!b.Z.isPrivate)),u()(E,"_tenancy",new d.Z("")),u()(E,"_clientSessionId",l.Z.random(32)),u()(E,"_loadedTimestamp",new Date),u()(E,"_logger",c.Z.getLogger("SDK")),u()(E,"_initialized",new d.Z(!1)),u()(E,"_peerConnectionFactory",new d.Z(new p.Z)),u()(E,"_readOnlyInitialized",new h.Z(E._initialized)),u()(E,"_readOnlyDiscoveryUri",new h.Z(Z.Z.uri)),u()(E,"_readOnlyPeerConnectionFactory",new h.Z(E._peerConnectionFactory)),window.addEventListener("unload",(function(){E.dispose()})),E.applyDiscoveryUriDefaultFromParameterConfiguration(),E.applyMetricsConfiguration(),E.applyTelemetryConfiguration(),E.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),E.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),E.init()},4760:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=function(){function e(){i()(this,e)}return a()(e,null,[{key:"getTelemetryUrl",value:function(e){try{var t=new 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}}}]),e}()},2250:(e,t)=>{"use strict";var n;!function(e){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.Error=12]="Error",e[e.UnsupportedFeature=13]="UnsupportedFeature"}(n||(n={})),t.Z=n},6644:(e,t,n)=>{"use strict";n.d(t,{Z:()=>ke});var r,i,o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(8926),l=n.n(c),d=n(9713),h=n.n(d),p=n(7757),f=n.n(p),v=n(9571),m=n(841),g=function(){function e(t,n){a()(this,e),h()(this,"width",void 0),h()(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)}}]),e}(),y=n(5508),_=n(2250),C=n(8701),w=n(6330),b=n(3297),k=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;a()(this,e),h()(this,"_duration",void 0),this._duration=t}return u()(e,[{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,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"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)}}]),e}(),x=n(8963),S=n(5656),T=function(){function e(t,n,r,i){a()(this,e),h()(this,"_pageLoadTime",void 0),h()(this,"_channelStartTime",void 0),h()(this,"_logger",v.Z.getLogger("StreamTelemetry")),h()(this,"_disposables",new S.Z),h()(this,"_streamId",void 0),h()(this,"_metricsService",void 0),h()(this,"_listenToFirstTime",void 0),h()(this,"_listenForStall",void 0),h()(this,"_listenForContinuation",void 0),h()(this,"_timeToFirstFrame",void 0),h()(this,"_channelCreationTimeToFirstFrame",void 0),h()(this,"_startRecordingFirstFrame",void 0),h()(this,"_videoStalled",void 0),h()(this,"_lastProgress",void 0),h()(this,"_videoResolution",void 0),h()(this,"_clearTimeToFirstFrameListener",void 0),h()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=r,this._metricsService=i}return u()(e,[{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 w.Z((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 w.Z((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 k(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:x.Z.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 k(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:x.Z.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 k(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:x.Z.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:x.Z.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 k(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:x.Z.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}]),e}(),Z=n(4574),P=function(){function e(t){a()(this,e),h()(this,"_logger",v.Z.getLogger("StreamSetupListener")),h()(this,"metricsService",y.Z.metricsService),h()(this,"_pageLoadTime",void 0),h()(this,"_startTime",void 0),h()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return u()(e,[{key:"success",value:function(e){this.recordStreamMetric(x.Z.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(x.Z.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Z.Z(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 k(n-this._pageLoadTime).toIsoString(),t,i,new k(r).toIsoString())}}}]),e}(),L=n(7426),R=function(){function e(){a()(this,e),h()(this,"_disposables",new S.Z),h()(this,"_isSupported",navigator&&navigator.connection),h()(this,"_rtt",new L.Z(void 0)),h()(this,"_effectiveType",new L.Z(void 0)),h()(this,"_downlinkThroughputCapacity",new L.Z(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return u()(e,[{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(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new w.Z((function(){navigator.connection.removeEventListener("change",t)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}]),e}(),E=function(){function e(t,n){var r=this;a()(this,e),h()(this,"_logger",v.Z.getLogger("SessionTelemetry")),h()(this,"_metricsService",void 0),h()(this,"_applicationActivityMonitor",y.Z.applicationActivityMonitor),h()(this,"_networkMonitor",new R),h()(this,"_pageLoadTime",void 0),h()(this,"_disposables",new S.Z),h()(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)}))))}return u()(e,[{key:"listenOnStreamSetup",value:function(){return new P(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?x.Z.ApplicationForeground:x.Z.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 k(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:x.Z.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 k(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:x.Z.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 k(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:x.Z.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 k(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}();!function(e){e[e.Keep=0]="Keep",e[e.Reset=1]="Reset"}(r||(r={})),function(e){e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset"}(i||(i={}));var D=u()((function e(t){a()(this,e),h()(this,"token",void 0),h()(this,"tokenExpiring",void 0),this.token=new L.Z(t),this.tokenExpiring=new L.Z(!1)})),O=function(){function e(t){a()(this,e),h()(this,"channelInitialization",void 0),h()(this,"disposables",void 0),h()(this,"channelDisposables",void 0),h()(this,"rendererDisposables",void 0),h()(this,"videoElement",void 0),h()(this,"state",void 0),h()(this,"autoMuted",void 0),h()(this,"autoPaused",void 0),h()(this,"authorized",void 0),h()(this,"online",void 0),h()(this,"loading",void 0),h()(this,"playing",void 0),h()(this,"standby",void 0),h()(this,"stopped",void 0),h()(this,"targetLag",void 0),h()(this,"lag",void 0),h()(this,"bitrateLimit",void 0),h()(this,"resolution",void 0),h()(this,"failureCount",void 0),h()(this,"endPoint",void 0),h()(this,"stream",void 0),h()(this,"rtcStatistics",void 0),h()(this,"videoTelemetry",void 0),h()(this,"rtcAudioStatistic",void 0),h()(this,"rtcVideoStatistic",void 0),h()(this,"clearFailureCountTimeout",void 0),this.disposables=new S.Z,this.channelDisposables=new S.Z,this.rendererDisposables=new S.Z,this.channelInitialization=new Date,this.videoElement=new L.Z(null),this.state=new L.Z(_.Z.Starting),this.autoMuted=new L.Z(!1),this.autoPaused=new L.Z(!1),this.authorized=new L.Z(!0),this.online=new L.Z(!0),this.loading=new L.Z(!1),this.playing=new L.Z(!1),this.standby=new L.Z(!1),this.stopped=new L.Z(!1),this.targetLag=new L.Z(t),this.lag=new L.Z(0),this.bitrateLimit=new L.Z(0),this.resolution=new L.Z(g.empty),this.failureCount=new L.Z(0),this.endPoint=new L.Z(null),this.stream=new L.Z(null),this.rtcStatistics=new L.Z(null)}return u()(e,[{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,this.stream.value=null,void(this.state.value=_.Z.Error)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=y.Z.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return _.Z.Starting;case"no-stream":case"not-found":return _.Z.StandBy;case"geo-restricted":return _.Z.GeoRestricted;case"geo-blocked":return _.Z.GeoBlocked;case"unauthorized":return _.Z.Unauthorized;case"capacity":case"rate-limited":case"timeout":return _.Z.Recovering;case"failed":return _.Z.Error;default:(0,C.Z)(e)}}}]),e}(),F=u()((function e(){a()(this,e),h()(this,"mediaStream",void 0),h()(this,"peerConnection",void 0),h()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new L.Z(null),this.peerConnection=new L.Z(null),this.peerConnectionReconnectAttempts=0})),I=u()((function e(){a()(this,e),h()(this,"isStarting",void 0),h()(this,"isDisposed",void 0),this.isStarting=new L.Z(!1),this.isDisposed=!1})),A=n(319),M=n.n(A),j=n(8862),N=function(){function e(){a()(this,e)}return u()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case i.Normal:return"Normal";case i.Force:return"Force";case i.Reset:return"Reset";default:(0,C.Z)(e)}}}]),e}(),V=function(){function e(){a()(this,e)}return u()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case r.Keep:return"Keep";case r.Reset:return"Reset";default:(0,C.Z)(e)}}}]),e}(),U=n(202).default,B=function(){function e(t,n){if(a()(this,e),h()(this,"_logger",v.Z.getLogger("EndPoint")),h()(this,"_uri",void 0),h()(this,"_timeout",void 0),h()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}var t,n,r,i,o,s,c,d,p,m,g,y;return u()(e,[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(y=l()(f().mark((function e(){var t,n,r,i,o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,U.race([fetch(t,{method:"GET",cache:"no-cache"}),new U((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._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 y.apply(this,arguments)})},{key:"subscribe",value:(g=l()(f().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,v,m,g,y=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((i=b.Z.parseToken(t))&&i.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=i.applicationId,a=this.buildUrl([o,"stream","subscribe"]).toString(),s=new FormData,u=j.Z.sdkVersion,0===r&&n?(c={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},createAnswerDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=10,p=null,e.next=14,U.race([fetch(a,{method:"POST",body:s}),new U((function(e){return p=window.setTimeout((function(){y._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(a,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&clearTimeout(p)}));case 14:h=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(v=this.mapHttpStatusToSubscribeStatus(h))){e.next=24;break}return e.abrupt("return",{status:v});case 24:return m=Date.now(),e.next=27,this.convertHttpResponseToSubscribeResponse(o,h);case 27:return g=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",g,m-d),e.abrupt("return",g);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n){return g.apply(this,arguments)})},{key:"publish",value:(m=l()(f().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,p,v,m,g,y,_=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((o=b.Z.parseToken(n))&&o.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return a=o.applicationId,s=this.buildUrl([a,"stream","publish"]).toString(),u=new FormData,c=j.Z.sdkVersion,0===i&&r?(l={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(r.type),sdp:r.sdp}},createAnswerDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(l))):(d={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(d))),h=Date.now(),e.prev=10,v=null,e.next=14,U.race([fetch(s,{method:"POST",body:u}),new U((function(e){return v=window.setTimeout((function(){_._logger.error("Failed to publish",new Error("Publish timed out [".concat(s,"]"))),e({status:408})}),_._timeout)}))]).finally((function(){v&&clearTimeout(v)}));case 14:p=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(m=this.mapHttpStatusToPublishStatus(p))){e.next=24;break}return e.abrupt("return",{status:m});case 24:return g=Date.now(),e.next=27,this.convertHttpResponseToPublishResponse(a,p);case 27:return y=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",y,g-h),e.abrupt("return",y);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n,r){return m.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=l()(f().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return f().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 FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,U.race([fetch(r,{method:"POST",body:i}),new U((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(d=l()(f().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,v=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new FormData,u={apiVersion:6,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:V.convertBitrateStateToBitrateStateType(i),bitrateMode:N.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,U.race([fetch(a,{method:"POST",body:s}),new U((function(e){return d=window.setTimeout((function(){v._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),v._timeout)}))]).finally((function(){d&&clearTimeout(d)}));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 h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,p-c),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return d.apply(this,arguments)})},{key:"addIceCandidates",value:(c=l()(f().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,v=this,m=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new FormData,s={apiVersion:6,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,U.race([fetch(o,{method:"POST",body:a}),new U((function(e){return l=window.setTimeout((function(){v._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),v._timeout)}))]).finally((function(){l&&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"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=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,h-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=l()(f().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,U.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new U((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,M()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=j.Z.sdkVersion;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["_","".concat(Date.now())]]).toString()),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 408:return"timeout";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 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:(o=l()(f().mark((function e(t,n){var r,i;return f().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:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=l()(f().mark((function e(t,n){var r,i;return f().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:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={};if(e.bundlePolicy)switch(e.bundlePolicy){case"BundlePolicyBalanced":t.bundlePolicy="balanced";break;case"BundlePolicyMaxCompat":t.bundlePolicy="max-compat";break;case"BundlePolicyMaxBundle":t.bundlePolicy="max-bundle";break;default:(0,C.Z)(e.bundlePolicy)}if("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}if(e.iceTransportPolicy)switch(e.iceTransportPolicy){case"IceTransportPolicyAll":t.iceTransportPolicy="all";break;case"IceTransportPolicyRelay":t.iceTransportPolicy="relay";break;case"IceTransportPolicyPublic":break;default:(0,C.Z)(e.iceTransportPolicy)}if(e.peerIdentity&&(t.peerIdentity=e.peerIdentity),e.rtcpMuxPolicy)switch(e.rtcpMuxPolicy){case"RtcpMuxPolicyNegotiate":t.rtcpMuxPolicy="negotiate";break;case"RtcpMuxPolicyRequire":t.rtcpMuxPolicy="require";break;default:(0,C.Z)(e.rtcpMuxPolicy)}return t}},{key:"convertISessionDescriptionToRTCSessionDescription",value:function(e){var t={sdp:e.sdp};switch(e.type){case"Offer":t.type="offer";break;case"Answer":t.type="answer";break;default:(0,C.Z)(e.type)}return t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=l()(f().mark((function e(t){var n,r;return f().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=this.convertISessionDescriptionToRTCSessionDescription(n.sessionDescription)),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=l()(f().mark((function e(t){var n,r;return f().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 n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(t=l()(f().mark((function e(t){var n,r;return f().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(e){return t.apply(this,arguments)})},{key:"convertRTCSdpTypeToSdpType",value:function(e){switch(e){case"answer":return"Answer";case"offer":return"Offer";case"pranswer":case"rollback":throw new Error("SDP type [".concat(e,"] is not supported"));default:(0,C.Z)(e)}}}]),e}(),G=n(5564),z=n(6062),H=n(202).default,W=function(){function e(t){if(a()(this,e),h()(this,"_logger",v.Z.getLogger("Discovery")),h()(this,"_metricsService",void 0),h()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=z.Z.getMetricsService(t.toString()),this._uri=t}var t,n;return u()(e,[{key:"discoverNearbyEndPoints",value:(n=l()(f().mark((function e(t,n){var r,i,o,a;return f().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,H.race([fetch(r,{method:"GET",cache:"no-cache"}),new H((function(e,t){return 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 o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new B(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=l()(f().mark((function e(){var t,n,r,i,o,a=this,s=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.length>0&&void 0!==s[0]?s[0]:2e4,n=G.Z.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=function(){return new H((function(){a._logger.info("Request [%s] failed, preventing it from completing",n)}))},e.next=8,H.race(r.map((function(e){return e.ping().catch((function(t){return a._logger.warn("Failed to ping end point [%s]",e,t),i()})).then((function(t){var n=Date.now();return a._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),a._metricsService.push({metricType:x.Z.RoundTripTime,runtime:(n-y.Z.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 8:return o=e.sent,e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),J=function(){function e(){throw a()(this,e),new Error("Discovery is a static class that may not be instantiated")}var t,n;return u()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=l()(f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(y.Z.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=l()(f().mark((function t(n){var r,i,o;return f().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 W(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(t){throw delete e._cache[r],t})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]),e}();h()(J,"_cache",{}),J.precacheClosestEndPointDiscovery();var q,K=n(4146),Q=n(1228);function Y(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 $(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}!function(e){e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource"}(q||(q={}));var X=function(){function e(t,n,r,i,o){a()(this,e),h()(this,"_logger",v.Z.getLogger("WebPlayer")),h()(this,"_videoElement",void 0),h()(this,"_kind",void 0),h()(this,"_streamId",void 0),h()(this,"_manifestURI",void 0),h()(this,"_options",void 0),h()(this,"_player",void 0),h()(this,"_lastReloadTime",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}return u()(e,[{key:"start",value:function(){var e=this;if(se.phenixWebPlayer){var t=$($({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new se.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,t),this._player.start(this._manifestURI),void this._player.addEventListener("error",(function(t){e.canReload()&&t&&(3===t.code||t.severity===se.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t)}))}}},{key:"isSupported",value:function(){return se.phenixWebPlayer&&se.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:q.NetworkNoSource,dataBuffered:0};var e=this._player.getStats(),t=e.currentTime||this._videoElement.currentTime,n=(Date.now()-this._options.originStartTime)/1e3;return this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),e.isNative&&"Hls"===e.deliveryType&&(e.currentTime=t-e.lag),e.currentTime||(e.currentTime=t),e.isNative||(e.lag=Math.max(0,n-t)),e.estimatedBandwidth>0?e.networkState=q.NetworkLoading:e.playTime>0?e.networkState=q.NetworkIdle:e.video?e.networkState=q.NetworkEmpty:e.networkState=q.NetworkNoSource,e}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return this._videoElement&&this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player.dispose(),this._player=null,this.start()}}]),e}();function ee(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 te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ne=function(){function e(t,n,r,i,o){a()(this,e),h()(this,"_logger",v.Z.getLogger("ShakaPlayer")),h()(this,"_videoElement",void 0),h()(this,"_kind",void 0),h()(this,"_streamId",void 0),h()(this,"_manifestURI",void 0),h()(this,"_options",void 0),h()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}return u()(e,[{key:"start",value:function(){if(se.shaka)return this._player=new se.shaka.Player(this._videoElement),void this.loadPlayer({abr:{defaultBandwidthEstimate:2e6},manifest:{retryParameters:{timeout:1e4}},streaming:{rebufferingGoal:2,bufferingGoal:10,bufferBehind:30,retryParameters:{timeout:1e4,maxAttempts:10,backoffFactor:1.1}}})}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:q.NetworkNoSource};var e=te(te({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth>0?e.networkState=q.NetworkLoading:e.playTime>0?e.networkState=q.NetworkIdle:e.video?e.networkState=q.NetworkEmpty:e.networkState=q.NetworkNoSource,e}},{key:"dispose",value:function(){this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t=this;this._player.configure(e),this._player.load(this._manifestURI).then((function(){t._logger.info("[%s] DASH live stream has been loaded",t._streamId),t._videoElement.play&&t._videoElement.play()})).catch((function(e){t._logger.error("[%s] Error while loading DASH live stream [%s]",t._streamId,e.code,e)}))}}]),e}(),re=function(){function e(t,n,r,i,o){a()(this,e),h()(this,"_videoElement",void 0),h()(this,"_kind",void 0),h()(this,"_streamId",void 0),h()(this,"_manifestURI",void 0),h()(this,"_options",void 0),h()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}return u()(e,[{key:"start",value:function(){se.hlsPlayer&&(se.hlsPlayer.isSupported()?(this._player=new se.hlsPlayer({enableWorker:!0,maxBufferLength:1,liveBackBufferLength:0,liveSyncDuration:7,liveDurationInfinity:!0,liveMaxLatencyDuration:1/0,highBufferWatchdogPeriod:1}),this._player.loadSource(this._manifestURI),this._player.attachMedia(this._videoElement)):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&(this._videoElement.src=this._manifestURI))}},{key:"isSupported",value:function(){return se.hlsPlayer&&se.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:q.NetworkNoSource};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:q.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=q.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=q.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=q.NetworkLoading:e.networkState=q.NetworkEmpty;var t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3;return e.lag=Math.max(0,t+this._options.lag/1e3-n),e}},{key:"dispose",value:function(){this._player&&this._player.destroy&&(this._player.destroy(),this._player=null)}}]),e}(),ie=n(202).default;function oe(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 ae(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var se=function(){function e(){a()(this,e)}var t;return u()(e,null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(t=l()(f().mark((function e(t,n,r,i){var o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._options=i,!(this._hlsPlayer||this._shaka||this._phenixWebPlayer)){e.next=3;break}return e.abrupt("return",this.loaded(t,n,r));case 3:if(y.Z.webPlayerLoader||y.Z.shakaPlayerLoader||y.Z.hlsJsLoader){e.next=5;break}throw new Error("No player is provided");case 5:if(y.Z.webPlayerLoader||y.Z.shakaPlayerLoader||y.Z.hlsJsLoader){e.next=7;break}throw new Error("Unsupported-feature, add stream player");case 7:return e.abrupt("return",new ie((function(e){y.Z.hlsJsLoader&&(o._pending=!0,y.Z.hlsJsLoader((function(i){o._hlsPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),y.Z.webPlayerLoader&&(o._pending=!0,y.Z.webPlayerLoader((function(i){o._phenixWebPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),y.Z.shakaPlayerLoader&&(o._pending=!0,y.Z.shakaPlayerLoader((function(i){o._shaka=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))})))})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,n,r,i){return t.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:function(e,t,n,r,i){var o=r.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),a=r.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),s=o&&o[1]?o[1]:"",u=a&&a[1]?a[1]:"";return Q.Z.shouldUseNativeHls||this._hlsPlayer&&this._hlsPlayer.isSupported()?(this._player=new e(t,"hls",n,u,i),this._player.start(),this._player):(this._player=new e(t,"dash",n,s,i),this._player.start(),this._player)}},{key:"loaded",value:function(e,t,n){if(this._shaka||this._phenixWebPlayer||this._hlsPlayer)return this._hlsPlayer?this.play(re,e,t,n,ae(ae({},this._options),{},{preferNative:Q.Z.shouldUseNativeHls})):this._phenixWebPlayer?this.play(X,e,t,n,ae(ae({},this._options),{},{preferNative:Q.Z.shouldUseNativeHls})):this._shaka?this.play(ne,e,t,n,ae(ae({},this._options),{},{preferNative:Q.Z.shouldUseNativeHls})):void 0}}]),e}();h()(se,"_pending",!1),h()(se,"_hlsPlayer",void 0),h()(se,"_phenixWebPlayer",void 0),h()(se,"_shaka",void 0),h()(se,"_options",void 0),h()(se,"_player",void 0);var ue=function(){function e(t,n){a()(this,e),h()(this,"_logger",v.Z.getLogger("ChunkedStream")),h()(this,"_channelContext",void 0),h()(this,"_monitorDisposables",new S.Z),h()(this,"_handleStreamFailure",void 0),h()(this,"_streamStatistics",void 0),h()(this,"_monitorFailureCount",0),this._channelContext=t,this._handleStreamFailure=n,this._channelContext.disposables.add(this)}return u()(e,[{key:"start",value:function(e,t){var n=this;return J.discoverClosestEndPointWithCaching(e).then((function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)})).then((function(e){var t=e.status,r=e.stream,i=e.createOfferDescriptionResponse,o=e.lag;if(n._channelContext.stream.value=r,n._channelContext.lag.value=o,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",n._channelContext.streamId,t,i),n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(t),n._channelContext.applyStatus(t),"ok"===t){var a=i.sessionDescription.sdp,s={originStartTime:Date.now()-o+n._channelContext.endPoint.value.roundTripTime/2,lag:o};return se.start(n._channelContext.videoElement.value,n._channelContext.streamId,a,s).then((function(e){return n.monitor(e),e})).catch((function(e){n._logger.error("LiveStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=K.ChannelState.Stopped}))}}))}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=window.setTimeout((function(){var n=se.getStats();if(t._streamStatistics&&t._streamStatistics.currentTime>=n.currentTime&&t._streamStatistics.dataBuffered>=n.dataBuffered){if(t._monitorFailureCount++,t._monitorFailureCount>6)return t._monitorFailureCount=0,t._channelContext.state.value=K.ChannelState.Error,t._channelContext.playing.value=!1,t._channelContext.loading.value=!0,e.dispose(),t._monitorDisposables.dispose(),void t._handleStreamFailure().catch((function(e){t._logger.error("Failed handling stream failure",e)}))}else t._monitorFailureCount=0;t._channelContext.videoElement.value.paused&&t._channelContext.state.value===K.ChannelState.Playing&&(t._channelContext.state.value=K.ChannelState.Paused),t._channelContext.videoElement.value.paused||t._channelContext.state.value===K.ChannelState.Playing||(t._channelContext.state.value=K.ChannelState.Playing),t._streamStatistics=n,t.monitor(e)}),1e3);this._monitorDisposables.add(new w.Z((function(){clearTimeout(n)})))}},{key:"dispose",value:function(){this._monitorDisposables.dispose()}}]),e}(),ce=n(3038),le=n.n(ce),de=function(){function e(){throw a()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}var t,n;return u()(e,null,[{key:"initiateInitialPrecaching",value:function(){Q.Z.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error('Failed to pre-cache peer connection offer"',t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=l()(f().mark((function t(){return f().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=l()(f().mark((function t(){var n,r,i,o=arguments;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:"recvonly",!e._cached||e._cached.direction!==n){t.next=5;break}return r=e._cached.peerConnection,e._cached=null,t.abrupt("return",r);case 5:return i=y.Z.peerConnectionFactory.value,t.abrupt("return",i.createPeerConnection().then(function(){var e=l()(f().mark((function e(t){var r,i,o;return f().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 o="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(o);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 7:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]),e}();h()(de,"_logger",v.Z.getLogger("PeerConnectionService")),h()(de,"_cached",void 0),de.initiateInitialPrecaching();var he=function(){function e(t){a()(this,e),h()(this,"_sdp",void 0),h()(this,"_audioCodec",void 0),h()(this,"_videoCodec",void 0),h()(this,"_isAudioTrackEnabled",void 0),h()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split("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)}return u()(e,[{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}(),pe=function(){function e(t,n,r){if(a()(this,e),h()(this,"_estimatedRoundTripTime",void 0),h()(this,"_estimatedVideoCodec",void 0),h()(this,"_estimatedAudioCodec",void 0),h()(this,"_rtcStatistic",new L.Z({})),h()(this,"_peerConnection",void 0),h()(this,"_isMonitorRunning",!0),h()(this,"_updateTimeOut",void 0),h()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!Q.Z.getCurrentOfferDisabled){var i=new he(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}var t,n;return u()(e,[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeOut&&(clearTimeout(this._updateTimeOut),this._updateTimeOut=null)}},{key:"updateStatistic",value:(n=l()(f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Q.Z.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,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&n._tracksToMonitor.includes(s)){var c,l,d,h,p,f=(a.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),v=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),m=f&&v?Math.floor(8*f/v*1e3):0;if(r[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:m,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[s].framesDecoded=a.framesDecoded;var g=(a.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=window.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(t=l()(f().mark((function e(){var t=this;return f().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=window.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]),e}(),fe=function(){function e(){throw a()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}return u()(e,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}}]),e}(),ve=n(202).default;function me(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 ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(Object(n),!0).forEach((function(t){h()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ye=function(){function e(t,n,r){a()(this,e),h()(this,"_logger",v.Z.getLogger("RealTimeStream")),h()(this,"_channelContext",void 0),h()(this,"_peerConnectionContext",void 0),h()(this,"_handleStreamFailure",void 0),this._channelContext=t,this._peerConnectionContext=n,this._handleStreamFailure=r}var t;return u()(e,[{key:"start",value:function(e,t,n,r){var i=this;return ve.all([J.discoverClosestEndPointWithCaching(e),de.createPeerConnectionOffer()]).then((function(e){var n=le()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.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"+a.sdp),!Q.Z.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s=null,a=null),i._peerConnectionContext.peerConnection.value=s,r.subscribe(t,a,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,a=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,u=e.createOfferDescriptionResponse,c=e.createAnswerDescriptionResponse,l=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=l,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,a,s,u,c),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,a).then((function(e){var t,a=!1,l=!1,d=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e&&(a||y.Z.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?d.push(n.candidate):l=!0,t||(t=setTimeout((function(){i._channelContext.stream.value!==o||a||i._channelContext.endPoint.value.addIceCandidates(o,d,l).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(a=!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=_.Z.Error,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(navigator.onLine&&(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:(0,C.Z)(e.iceConnectionState)}}};var h=new ve((function(t,n){if(Q.Z.onTrackDisabled){var r=function n(r){clearTimeout(i),e.removeEventListener("track",n),e.removeEventListener("addstream",n),r.streams?t(r.streams[0]):t(r.stream)},i=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 o=setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){clearTimeout(o),t(e.streams[0])}}}));return new ve((function(e){e()})).then((function(){if(s)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,s.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP answer [%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(){if(u)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,u.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),h})).then((function(t){i._peerConnectionContext.mediaStream.value=t;var n=new pe(e,t,i._channelContext.endPoint.value.roundTripTime/4);return i._channelContext.disposables.add(n),n.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 r=!1,o=!1;t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((r=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&navigator.onLine&&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 k(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&&((o=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&navigator.onLine&&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 k(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),(o||r)&&navigator.onLine?i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=_.Z.Error,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,n.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)}))})):i._peerConnectionContext.peerConnectionReconnectAttempts=0})),y.Z.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=_.Z.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(t=l()(f().mark((function e(t,n){var r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=fe.truncateIceServers(n),e.abrupt("return",y.Z.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=ge(ge({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=_.Z.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<y.Z.maximalNumberOfPeerConnectionReconnectAttempts||!y.Z.automaticallyReconnectPeerConnection){if(this._peerConnectionContext.peerConnectionReconnectAttempts++,Q.Z.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||this._channelContext.failureCount.value)return;this._logger.info("Reconnecting peer connection by restarting ICE");var r=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(r)}))})).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:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return _.Z.Starting;case"unauthorized":return _.Z.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return _.Z.Recovering;case"failed":return _.Z.Error;default:(0,C.Z)(e)}}}]),e}(),_e=function(){function e(){throw a()(this,e),new Error("StreamFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"create",value:function(e,t,n,r){var i=b.Z.parseToken(e);return i&&i.token&&i.token.capabilities&&i.token.capabilities.includes("rtmp")?(this._logger.error("This build does not support RTMP playback."),void(t.state.value=_.Z.UnsupportedFeature)):i&&i.token&&i.token.capabilities&&i.token.capabilities.includes("streaming")?new ue(t,r):new ye(t,n,r)}}]),e}();h()(_e,"_logger",v.Z.getLogger("Streaming"));var Ce=n(202).default,we="client:termination",be=function(){function e(t,n){var o=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;a()(this,e),h()(this,"_logger",v.Z.getLogger("Channel")),h()(this,"_tokenContext",void 0),h()(this,"_channelContext",void 0),h()(this,"_peerConnectionContext",void 0),h()(this,"_stateContext",void 0),h()(this,"_channelStartTime",void 0),h()(this,"_readOnlyVideoElement",void 0),h()(this,"_readOnlyToken",void 0),h()(this,"_readOnlyPeerConnection",void 0),h()(this,"_readOnlyState",void 0),h()(this,"_readOnlyAutoMuted",void 0),h()(this,"_readOnlyAutoPaused",void 0),h()(this,"_readOnlyTokenExpiring",void 0),h()(this,"_readOnlyAuthorized",void 0),h()(this,"_readOnlyOnline",void 0),h()(this,"_readOnlyLoading",void 0),h()(this,"_readOnlyPlaying",void 0),h()(this,"_readOnlyStandby",void 0),h()(this,"_readOnlyStopped",void 0),h()(this,"_readOnlyTargetLag",void 0),h()(this,"_readOnlyLag",void 0),h()(this,"_readOnlyBitrateLimit",void 0),h()(this,"_readOnlyResolution",void 0),h()(this,"_readOnlyFailureCount",void 0),h()(this,"_readOnlyEndPoint",void 0),h()(this,"_readOnlyStream",void 0),h()(this,"_readOnlyRtcStatistics",void 0),h()(this,"_readOnlyMediaStream",void 0),h()(this,"_metricsService",void 0),h()(this,"_sessionTelemetry",void 0),h()(this,"_videoMetaDataChangedHandler",void 0),this._tokenContext=new D(n),this._channelContext=new O(s),this._peerConnectionContext=new F,this._stateContext=new I,this._channelStartTime=Date.now(),this._readOnlyVideoElement=new m.Z(this._channelContext.videoElement),this._readOnlyToken=new m.Z(this._tokenContext.token),this._readOnlyPeerConnection=new m.Z(this._peerConnectionContext.peerConnection),this._readOnlyState=new m.Z(this._channelContext.state),this._readOnlyAutoMuted=new m.Z(this._channelContext.autoMuted),this._readOnlyAutoPaused=new m.Z(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new m.Z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new m.Z(this._channelContext.authorized),this._readOnlyOnline=new m.Z(this._channelContext.online),this._readOnlyLoading=new m.Z(this._channelContext.loading),this._readOnlyPlaying=new m.Z(this._channelContext.playing),this._readOnlyStandby=new m.Z(this._channelContext.standby),this._readOnlyStopped=new m.Z(this._channelContext.stopped),this._readOnlyTargetLag=new m.Z(this._channelContext.targetLag),this._readOnlyLag=new m.Z(this._channelContext.lag),this._readOnlyBitrateLimit=new m.Z(this._channelContext.bitrateLimit),this._readOnlyResolution=new m.Z(this._channelContext.resolution),this._readOnlyFailureCount=new m.Z(this._channelContext.failureCount),this._readOnlyEndPoint=new m.Z(this._channelContext.endPoint),this._readOnlyStream=new m.Z(this._channelContext.stream),this._readOnlyRtcStatistics=new m.Z(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new m.Z(this._peerConnectionContext.mediaStream);var u=b.Z.parseToken(this._tokenContext.token.value),c=(b.Z.getUri(u)||y.Z.discoveryUri.value).toString();y.Z.tenancy.value=b.Z.getTenancy(u)||y.Z.tenancy.value,G.Z.uri.value=c,this._metricsService=z.Z.getMetricsService(c),this._sessionTelemetry=new E(y.Z.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){o._channelContext.rendererDisposables.dispose(),e&&(o._channelContext.rendererDisposables.add(o._channelContext.stream.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.dispose(),e&&o.videoElement&&(o.videoElement.dataset&&(o.videoElement.dataset.sessionId=y.Z.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new T(o.streamId,y.Z.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===_.Z.Stopped)&&o.restartAfterStop()}))),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){o._channelContext.clearFailureCountTimeout&&clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===_.Z.Playing&&(o._channelContext.clearFailureCountTimeout=window.setTimeout((function(){o._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&o._channelContext.endPoint.value&&o._channelContext.stream.value){var t=Date.now()-o._channelContext.channelInitialization.getTime();o._channelContext.endPoint.value.limitBitrate(o._channelContext.stream.value,t,e,r.Keep,i.Normal).catch((function(e){o._logger.error("Error while setting limit bitrate",e)}))}})));var l=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStream(o._channelContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",l),this._channelContext.channelDisposables.add(new w.Z((function(){window.removeEventListener("beforeunload",l)}))),this.start()}var t,n,o,s,c,d,p,k,x;return u()(e,[{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=_.Z.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 g(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=g.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=b.Z.parseToken(this._tokenContext.token.value),n=(b.Z.getUri(t)||y.Z.discoveryUri.value).toString();y.Z.tenancy.value=b.Z.getTenancy(t)||y.Z.tenancy.value,G.Z.uri.value=n,this._metricsService=z.Z.getMetricsService(n),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:"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,r.Keep,i.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:(x=l()(f().mark((function e(t){var n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ce((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 x.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=_.Z.Stopped}},{key:"resume",value:(k=l()(f().mark((function e(){return f().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 k.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:(p=l()(f().mark((function e(){var t=this;return f().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 p.apply(this,arguments)})},{key:"getUri",value:function(e){var t=b.Z.parseToken(e);return b.Z.getUri(t)||(this._logger.info("Fall back to the default discover URI [%s]",y.Z.discoveryUri.value),new URL(y.Z.discoveryUri.value))}},{key:"start",value:(d=l()(f().mark((function e(){return f().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 d.apply(this,arguments)})},{key:"processStart",value:(c=l()(f().mark((function e(){var t,n,r,i,o,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),b.Z.isValidToken(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=_.Z.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:if(this.cleanUpResources("client:start"),this._channelContext.state.value=_.Z.Starting,this._channelContext.loading.value=!0,r=this.getUri(t),i=function(){return new Ce((function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())}))},o=_e.create(t,this._channelContext,this._peerConnectionContext,i)){e.next=17;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 17:return e.abrupt("return",o.start(r,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){a._channelContext.loading.value=!1})).catch((function(e){n.fail(),a._channelContext.failureCount.value++,a._channelContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._channelContext.state.value=_.Z.Error,a._logger.error("Failed to start channel",e)})).finally((function(){if(a._stateContext.isStarting.value=!1,a._channelContext.state.value!==_.Z.Playing&&y.Z.automaticRetryOnFailure){var e=setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._channelContext.disposables.add(new w.Z((function(){clearTimeout(e)})))}})));case 18:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"restartAfterStop",value:(s=l()(f().mark((function e(){return f().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 s.apply(this,arguments)})},{key:"play",value:(o=l()(f().mark((function e(){var t;return f().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 o.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case _.Z.StandBy:case _.Z.Offline:return 15e3;case _.Z.Error:case _.Z.Recovering:case _.Z.Unauthorized:case _.Z.GeoRestricted:case _.Z.GeoBlocked:case _.Z.Stopped:case _.Z.Starting:case _.Z.Playing:case _.Z.Paused:case _.Z.Reconnecting:case _.Z.UnsupportedFeature:return Math.min(3e5,Math.pow(2e3,Math.max(0,this._channelContext.failureCount.value-1)));default:(0,C.Z)(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=l()(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===_.Z.Error||e.t0===_.Z.Reconnecting||e.t0===_.Z.StandBy||e.t0===_.Z.Offline||e.t0===_.Z.Recovering?3:e.t0===_.Z.Unauthorized?5:e.t0===_.Z.GeoRestricted?7:e.t0===_.Z.GeoBlocked?9:e.t0===_.Z.Stopped?11:e.t0===_.Z.Playing?13:e.t0===_.Z.Paused?15:e.t0===_.Z.Starting?17:e.t0===_.Z.UnsupportedFeature?19:21;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,_.Z[this._channelContext.state.value]),e.abrupt("break",22);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 playing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 17:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 19:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 21:(0,C.Z)(this._channelContext.state.value);case 22:return e.abrupt("return",this.start());case 23:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:we;this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close()),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:"playMediaStreamInVideoElement",value:(t=l()(f().mark((function e(t){var n,r,i=this;return f().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=_.Z.Stopped,e.abrupt("return");case 8:if(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=_.Z.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=_.Z.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})),o=!y.Z.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=_.Z.Paused,o?(i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e),void(n.srcObject=null)):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=_.Z.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=_.Z.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),ke=function(){function e(){throw a()(this,e),new Error("Channels is a static class that may not be instantiated")}return u()(e,null,[{key:"createChannel",value:function(e){if(!y.Z.initialized.value)throw new Error("SDK is not loaded.");return new be(e.videoElement,e.token,e.targetLag)}}]),e}()},4146:(e,t,n)=>{"use strict";n.d(t,{ChannelState:()=>o.Z});var r=n(5508),i=n(6644),o=n(2250);r.Z,i.Z,o.Z},79:(e,t,n)=>{"use strict";n.d(t,{w:()=>r});var r="https://pcast.phenixrts.com/pcast/endPoints"},5564:(e,t,n)=>{"use strict";n.d(t,{Z:()=>h});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(79),l=n(7426),d=n(8862),h=function(){function e(){throw i()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return a()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=d.Z.sdkVersion;return t.search="?".concat(new URLSearchParams([["version",n],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}]),e}();u()(h,"_discoveryUri",new l.Z(c.w))},3297:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(9571),l="DIGEST:",d=function(){function e(){i()(this,e)}return a()(e,null,[{key:"parseToken",value:function(t){if(this.isValidToken(t))try{var n=atob(t.substr(l.length)),r=JSON.parse(n);return r.token=JSON.parse(r.token),r}catch(t){return void e._logger.error("Cannot parse token value",t)}else e._logger.error("Token is not valid [%s]",t)}},{key:"getUri",value:function(e){return e&&e.token&&e.token.uri?new URL(e.token.uri):null}},{key:"getTenancy",value:function(e){return e&&e.applicationId?e.applicationId:""}},{key:"isValidToken",value:function(e){return!!e&&e.startsWith(l)}}]),e}();u()(d,"_logger",c.Z.getLogger("EdgeAuth"))},1228:(e,t,n)=>{"use strict";n.d(t,{Z:()=>u});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9845),u=function(){function e(){i()(this,e)}return a()(e,null,[{key:"clientOfferDisabled",get:function(){return s.Z.isChrome74||s.Z.isChrome75||s.Z.isChrome76||s.Z.isChrome77}},{key:"addTranceiverDisabled",get:function(){return s.Z.isChrome69||s.Z.isChrome70||s.Z.isChrome71||s.Z.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=69||"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=63||"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===s.Z.browserName||"SamsungBrowser"===s.Z.browserName}},{key:"isRTMPEnabled",get:function(){return"Firefox"===s.Z.browserName&&s.Z.browserMajorVersion<84||"Chrome"===s.Z.browserName&&s.Z.browserMajorVersion<70||"Edge"===s.Z.browserName||"IE"===s.Z.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==s.Z.browserName}}]),e}()},2480:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SDK:()=>r.Z,Channels:()=>i.Z,ChannelState:()=>o.Z});var r=n(5508),i=n(6644),o=n(2250);t.default={SDK:r.Z,Channels:i.Z,ChannelState:o.Z}},8862:(e,t,n)=>{"use strict";n.d(t,{Z:()=>c});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"sdkVersion",get:function(){try{return"2023-01-06T18:19:52.372Z (2023.0.3)"}catch(e){return this._defaultVersion}}}]),e}();u()(c,"_defaultVersion",(new Date).toISOString())},3552:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(5183),l=function(){function e(t){i()(this,e),u()(this,"_telemetryService",void 0),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new c.Z(t)}return a()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}()},5259:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(4575),i=n.n(r),o=n(3913),a=n.n(o),s=n(9713),u=n.n(s),c=n(1178),l=function(){function e(){i()(this,e),u()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_environment",void 0),u()(this,"_threshold",c.Z.defaultTelemetryLoggingLevel)}return a()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new 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:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}()},5183:(e,t,n)=>{"use strict";n.d(t,{Z:()=>v});var r=n(8926),i=n.n(r),o=n(4575),a=n.n(o),s=n(3913),u=n.n(s),c=n(9713),l=n.n(c),d=n(7757),h=n.n(d),p=n(5149),f=n(8862),v=function(){function e(t){a()(this,e),l()(this,"_telemetryConfiguration",void 0),l()(this,"_logs",[]),l()(this,"_isSending",void 0),l()(this,"_domain",location.hostname),this._telemetryConfiguration=t}var t,n;return u()(e,[{key:"push",value:function(e,t,n,r){var i={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:p.G[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:f.Z.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<p.G.Error?this._logs.push(i):this._logs.unshift(i),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=i()(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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 n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(t=i()(h().mark((function e(){var t,n,r,i,o=this;return h().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 Object.values(e).reduce((function(e,t){return e+(t?t.length:0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),i=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(i).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}()}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return 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.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(2480)})()}));
3
3
  //# sourceMappingURL=full.js.map