@phenixrts/sdk 2025.2.3-beta.607 → 2025.2.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 (41) hide show
  1. package/channels/debug/channels.js +1084 -1084
  2. package/channels/debug/package.json +1 -1
  3. package/channels/debug.private/channels.js +1001 -1001
  4. package/channels/debug.private/package.json +1 -1
  5. package/channels/debug.provideGlobalScope/channels.js +1056 -1056
  6. package/channels/debug.provideGlobalScope/package.json +1 -1
  7. package/channels/es5.debug.private/channels.js +2 -2
  8. package/channels/es5.debug.private/package.json +1 -1
  9. package/channels/min/channels.js +1 -1
  10. package/channels/min/channels.js.map +1 -1
  11. package/channels/min/package.json +1 -1
  12. package/channels/min.private/channels.js +1 -1
  13. package/channels/min.private/channels.js.map +1 -1
  14. package/channels/min.private/package.json +1 -1
  15. package/channels/min.provideGlobalScope/channels.js +1 -1
  16. package/channels/min.provideGlobalScope/channels.js.map +1 -1
  17. package/channels/min.provideGlobalScope/package.json +1 -1
  18. package/channels/package.json +1 -1
  19. package/full/debug/full.js +1195 -1195
  20. package/full/debug/package.json +1 -1
  21. package/full/debug.private/full.js +1112 -1112
  22. package/full/debug.private/package.json +1 -1
  23. package/full/min/full.js +1 -1
  24. package/full/min/full.js.map +1 -1
  25. package/full/min/package.json +1 -1
  26. package/full/min.private/full.js +1 -1
  27. package/full/min.private/full.js.map +1 -1
  28. package/full/min.private/package.json +1 -1
  29. package/full/package.json +1 -1
  30. package/package.json +1 -1
  31. package/publish/debug/package.json +1 -1
  32. package/publish/debug/publish.js +772 -772
  33. package/publish/debug.private/package.json +1 -1
  34. package/publish/debug.private/publish.js +772 -772
  35. package/publish/min/package.json +1 -1
  36. package/publish/min/publish.js +1 -1
  37. package/publish/min/publish.js.map +1 -1
  38. package/publish/min.private/package.json +1 -1
  39. package/publish/min.private/publish.js +1 -1
  40. package/publish/min.private/publish.js.map +1 -1
  41. package/publish/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see publish.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,()=>(()=>{var e={981:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});var r=n(738),i=n.n(r),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),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}),f=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=null,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=[]}},{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,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 a(t,e)},n)}r[t]=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){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,t){var n=new f(function(){return null});return this.handle(new d(e,t,n)),n},f.prototype.finally=function(e){return this.then(function(t){return f.resolve(e()).then(function(){return t},function(){return null})},function(t){return f.resolve(e()).then(function(){return f.reject(t)},function(){return null})})};var h=f},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(981).A;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},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,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},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},847:(e,t,n)=>{var r=n(893);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},893:e=>{e.exports=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),o=n(122),a=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),a=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}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})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{PublisherState:()=>Ue,Publishers:()=>It,SDK:()=>Ne,default:()=>Mt});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),a=n(693),s=n.n(a),u=n(132),c=n.n(u),l=n(452),d=n.n(l),f=n(72),h=n.n(f),p=n(511),v=n.n(p),g=function(){return o()(function e(n){t()(this,e),s()(this,"_disposed",void 0),s()(this,"_disposable",void 0),this._disposed=!1,this._disposable=n},[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}var m,_=function(e){function n(e,r){return t()(this,n),i=this,o=n,a=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=h()(o),d()(i,y()?Reflect.construct(o,a||[],h()(i).constructor):o.apply(i,a));var i,o,a}return v()(n,e),o()(n)}(g),b=function(){return o()(function e(n){t()(this,e),s()(this,"_listeners",void 0),s()(this,"_value",void 0),this._listeners=[],this._value=n},[{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))}if(t){this._value=e;for(var r=0,i=c()(this._listeners);r<i.length;r++)(0,i[r])(e)}}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new _(this._listeners,e)}}])}(),C=function(){return o()(function e(n){t()(this,e),s()(this,"_subject",void 0),this._subject=n},[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),w={document,location,navigator,window},k=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"HTMLVideoElement",get:function(){return this._window.HTMLVideoElement}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"MediaSource",get:function(){return this._window.MediaSource}},{key:"RTCPeerConnection",get:function(){return this._window.RTCPeerConnection}},{key:"RTCSessionDescription",get:function(){return this._window.RTCSessionDescription}},{key:"RTCIceCandidate",get:function(){return this._window.RTCIceCandidate}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"pageLoadTime",get:function(){return this._window.__phenixPageLoadTime||this._window.__pageLoadTime}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"requestAnimationFrame",get:function(){return this._window.requestAnimationFrame.bind(this._window)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"setInstance",value:function(e){throw new Error("This build does not support setting the GlobalScope")}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();m=k,s()(k,"_instance",new b(new m(w))),s()(k,"_readOnlyInstance",new C(m._instance));var S,T,x,O=k.getInstance(),P=function(){function e(){t()(this,e)}return o()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();S=P,s()(P,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(P,"_browserNameAndVersion",S.parseBrowserNameAndVersion()),s()(P,"_browserName",S.parseBrowserName()),s()(P,"_browserMajorVersion",S.parseBrowserMajorVersion()),s()(P,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(T=navigator)||void 0===T?void 0:T.userAgent)),s()(P,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(P,"_isChrome69",S._browserNameAndVersion.includes("Chrome/69.")),s()(P,"_isChrome70",S._browserNameAndVersion.includes("Chrome/70.")),s()(P,"_isChrome71",S._browserNameAndVersion.includes("Chrome/71.")),s()(P,"_isChrome72",S._browserNameAndVersion.includes("Chrome/72.")),s()(P,"_isChrome74",S._browserNameAndVersion.includes("Chrome/74.")),s()(P,"_isChrome75",S._browserNameAndVersion.includes("Chrome/75.")),s()(P,"_isChrome76",S._browserNameAndVersion.includes("Chrome/76.")),s()(P,"_isChrome77",S._browserNameAndVersion.includes("Chrome/77."));var E=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return P.isChrome74||P.isChrome75||P.isChrome76||P.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return P.isChrome69||P.isChrome70||P.isChrome71||P.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=69||"Firefox"===P.browserName&&P.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=63||"Firefox"===P.browserName&&P.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===P.browserName&&P.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===P.browserName||"SamsungBrowser"===P.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==P.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===P.browserName&&"function"==typeof(null===(e=O.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion>=71||"Firefox"===P.browserName&&P.browserMajorVersion>=69||"Safari"===P.browserName}},{key:"isMobile",get:function(){return P.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=O.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isRequestAnimationFrameSupported",get:function(){var e;return"function"==typeof(null===(e=O.value)||void 0===e?void 0:e.requestAnimationFrame)}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==P.browserName&&"Safari"!==P.browserName}}])}(),R=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),L=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i},[{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.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")})),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n},2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),D=function(){return o()(function e(){t()(this,e),s()(this,"_appenders",[])},[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce(function(t,n){return n!==e&&t.push(n),t},[])}}])}(),F=function(){return o()(function e(){t()(this,e)},null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(F,"_sendLocalCandidates",void 0),s()(F,"_sendLogs",void 0),s()(F,"_sendMetrics",void 0),s()(F,"_logToConsole",void 0),F.applyFeatures();var j=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultLoggingLevel",get:function(){return R[F.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return R[F.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return R.Info}}])}(),I=function(){return o()(function e(){t()(this,e),s()(this,"_threshold",j.defaultLoggingLevel)},[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),M=function(){return o()(function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n},[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(R[e],"] ").concat(t);e<R.Warn?console.log(i):console.error(i)}}}])}(),A=n(293),N=n.n(A),G=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),V=function(){return o()(function e(){t()(this,e)},null,[{key:"sdkVersion",get:function(){try{return"2026-04-01T18:35:31.540Z (2025.2.3-beta.607)"}catch(e){return this._defaultVersion}}}])}();s()(V,"_defaultVersion",(new Date).toISOString());var U=n(981).A;function B(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return z(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(z(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,z(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,z(d,"constructor",c),z(c,"constructor",u),u.displayName="GeneratorFunction",z(c,i,"GeneratorFunction"),z(d),z(d,i,"Generator"),z(d,r,function(){return this}),z(d,"toString",function(){return"[object Generator]"}),(B=function(){return{w:o,m:f}})()}function z(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}z=function(e,t,n,r){function o(t,n){z(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},z(e,t,n,r)}var H=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=e})},[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:R[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:V.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<R.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new U(function(e){var t=O.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendLogs",value:(n=N()(B().m(function e(t){var n;return B().w(function(e){for(;;)switch(e.n){case 0:return(n=new O.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,O.value.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=N()(B().m(function e(){var t,n,r,i,o,a=this;return B().w(function(e){for(;;)switch(e.n){case 0:if(!(this._logs.length<=0||this._isSending)&&O.value){e.n=1;break}return e.a(2);case 1:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?G.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce(function(e,t){return e+(t?r(t):0)},0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.a(2,this.sendLogs(o).then(function(e){return a._isSending=!1,a.sendLogsIfAble(),e}).catch(function(){a._isSending=!1,a.sendLogsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),W=function(){return o()(function e(n){t()(this,e),s()(this,"_telemetryService",void 0),s()(this,"_tenancy",void 0),s()(this,"_sessionId",void 0),s()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new H(n)},[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),q=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_pageLoadTime",0),s()(this,"_threshold",j.defaultTelemetryLoggingLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new O.value.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),J=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},K=function(){return o()(function e(){t()(this,e)},null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case R.Off:return"Off";case R.Trace:return"Trace";case R.Debug:return"Debug";case R.Info:return"Trace";case R.Warn:return"Warn";case R.Error:return"Error";case R.Fatal:return"Fatal";case R.All:return"All";default:J(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return R.Off;case"Trace":return R.Trace;case"Debug":return R.Debug;case"Info":return R.Info;case"Warn":return R.Warn;case"Error":return R.Error;case"Fatal":return R.Fatal;case"All":return R.All;default:J(e)}}}])}(),Q=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),$=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_threshold",Z.defaultTelemetryLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new O.value.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}}])}(),Z=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultTelemetryLevel",get:function(){return Q[F.sendMetrics]}}])}(),X=function(){return o()(function e(){t()(this,e)},null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case Q.Off:return"Off";case Q.Essential:return"Essential";case Q.All:return"All";default:J(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return Q.Off;case"Essential":return Q.Essential;case"All":return Q.All;default:J(e)}}}])}(),Y=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.readConfigurationParameterValue(t)||e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"))||e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n)return"true"===n||"1"===n||"On"===n;var r=e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"));return r?"true"===r||"1"===r||"On"===r:!0===e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":X.convertTelemetryLevelToTelemetryLevelType(Z.defaultTelemetryLevel),"phenix-logging-level":K.convertLoggingLevelToLoggingLevelType(j.defaultLoggingLevel),"phenix-console-logging-level":K.convertLoggingLevelToLoggingLevelType(j.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":K.convertLoggingLevelToLoggingLevelType(j.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}},{key:"readConfigurationParameterValue",value:function(e){var t=O.value.documentQuerySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n){var r=new O.value.URLSearchParams(O.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),ee=function(){function e(){throw t()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return o()(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 L(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=Y.getStringValue("phenix-logging-level");R[e]&&this._threshold.setThreshold(R[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Y.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(R[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new M(e||j.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||j.defaultTelemetryLoggingLevel,this._appenders.add(new W(this._telemetryConfiguration))}}])}();s()(ee,"_loggers",{}),s()(ee,"_appenders",new D),s()(ee,"_threshold",new I),s()(ee,"_telemetryConfiguration",new q),ee.applyLoggerConfigFromParameterConfiguration();var te=function(){return o()(function e(){throw t()(this,e),new Error("Strings is a static class that may not be instantiated")},null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill(function(){return Math.random().toString(16).substring(2,15)}).reduce(function(e,t){return e+t()},"").substring(0,e)}}])}(),ne=function(){return o()(function e(n){var r,i;t()(this,e),s()(this,"_applicationId",void 0),s()(this,"_token",void 0),this._applicationId=(null==n?void 0:n.applicationId)||"",this._token={uri:null!=n&&null!==(r=n.token)&&void 0!==r&&r.uri?new O.value.URL(n.token.uri):null,capabilities:(null==n||null===(i=n.token)||void 0===i?void 0:i.capabilities)||[]}},[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),re=function(){function e(){t()(this,e)}return o()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new ne(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new ne(r)}catch(t){return e._logger.error("Cannot parse token value",t),new ne(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(re,"_logger",ee.getLogger("EdgeAuthParser"));var ie=function(){return o()(function e(){t()(this,e),s()(this,"_list",[])},[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach(function(e){return e.dispose()}),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),oe="visibilitychange",ae=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),s()(this,"_lastBackgroundDuration",null),this._isForeground=new b(!0),this._readOnlyIsForeground=new C(this._isForeground),this.initialize()},[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"getLastBackgroundDuration",value:function(){return this._lastBackgroundDuration}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=null,n=function(){var n=!O.value.documentIsHidden;n?t&&(e._lastBackgroundDuration=Date.now()-t):(t=Date.now(),e._lastBackgroundDuration=null),e._isForeground.value=n},r=!1;O.value.addDocumentEventListener(oe,n,r),this._disposables.add(new g(function(){return O.value.removeDocumentEventListener(oe,n,r)}))}}])}(),se=n(981).A;function ue(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ce(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(ce(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,ce(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,ce(d,"constructor",c),ce(c,"constructor",u),u.displayName="GeneratorFunction",ce(c,i,"GeneratorFunction"),ce(d),ce(d,i,"Generator"),ce(d,r,function(){return this}),ce(d,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:o,m:f}})()}function ce(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ce=function(e,t,n,r){function o(t,n){ce(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},ce(e,t,n,r)}var le=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),E.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new O.value.RTCPeerConnection(n)},[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentLocalDescription)||null}},{key:"currentRemoteDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentRemoteDescription)||null}},{key:"connectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.connectionState)||null}},{key:"iceConnectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.iceConnectionState)||null}},{key:"supportsGetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getConfiguration)}},{key:"supportsSetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.setConfiguration)}},{key:"supportsGetTransceivers",get:function(){var e;return!E.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!E.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=N()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!E.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createOffer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createOffer(t))}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=N()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!E.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createAnswer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createAnswer(t))}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=N()(ue().m(function e(t){return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:return e.a(2,this._peerConnection.setLocalDescription(E.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=N()(ue().m(function e(t){var n;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1: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.a(2,this._peerConnection.setRemoteDescription(E.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;if(!this._peerConnection)throw new Error("No PeerConnection initialized");return new se(function(t){e._peerConnection.getStats(t)})}},{key:"addEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach(function(e){if(!t._peerConnection)throw new Error("No PeerConnection initialized");t._peerConnection.addTrack(e)})}},{key:"getConfiguration",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.ontrack},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onicecandidate},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.oniceconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){var e;null===(e=this._peerConnection)||void 0===e||e.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,n,r,i}(),de=n(981).A;function fe(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return he(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(he(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,he(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,he(d,"constructor",c),he(c,"constructor",u),u.displayName="GeneratorFunction",he(c,i,"GeneratorFunction"),he(d),he(d,i,"Generator"),he(d,r,function(){return this}),he(d,"toString",function(){return"[object Generator]"}),(fe=function(){return{w:o,m:f}})()}function he(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}he=function(e,t,n,r){function o(t,n){he(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},he(e,t,n,r)}var pe=function(){return o()(function e(){t()(this,e)},[{key:"createPeerConnection",value:(e=N()(fe().m(function e(t){return fe().w(function(e){for(;;)if(0===e.n)return e.a(2,new de(function(e){var n=O.subscribe(function(r){r&&(e(new le(t)),n.dispose())})}))},e)})),function(t){return e.apply(this,arguments)})}]);var e}();function ve(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ge(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(ge(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,ge(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,ge(d,"constructor",c),ge(c,"constructor",u),u.displayName="GeneratorFunction",ge(c,i,"GeneratorFunction"),ge(d),ge(d,i,"Generator"),ge(d,r,function(){return this}),ge(d,"toString",function(){return"[object Generator]"}),(ve=function(){return{w:o,m:f}})()}function ge(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ge=function(e,t,n,r){function o(t,n){ge(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},ge(e,t,n,r)}var ye=function(e){return e[e.Disabled=0]="Disabled",e[e.Enabled=1]="Enabled",e}({}),me=["audio","video"],_e=function(){function e(){throw t()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return o()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){E.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch(function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)})}},{key:"precacheCreatePeerConnectionOffer",value:(r=N()(ve().m(function t(){return ve().w(function(t){for(;;)if(0===t.n)return t.a(2,e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch(function(t){throw e._cached=null,t})})},t)})),function(){return r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=N()(ve().m(function t(){var n,r,i,o,a,s=arguments;return ve().w(function(t){for(;;)switch(t.n){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]?s[1]:me,i=s.length>2&&void 0!==s[2]?s[2]:ye.Disabled,!e._cached||e._cached.direction!==n||i!==ye.Disabled||!this.isTracksKindsEquivalentToDefault(r)){t.n=1;break}return o=e._cached.peerConnection,e._cached=null,t.a(2,o);case 1:return a=E.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i===ye.Enabled}:void 0,t.a(2,e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=N()(ve().m(function e(t){var i,o,a,s,u,c,l,d,f,h;return ve().w(function(e){for(;;)switch(e.n){case 0:if(i=t.supportsAddTransceiver,o=[],a=[],!i){e.n=2;break}return r.forEach(function(e){"audio"!==e?"video"!==e||a.push(t.addTransceiver(e,{direction:n})):o.push(t.addTransceiver(e,{direction:n}))}),u=o,c=a,l=t,e.n=1,t.createOffer(void 0);case 1:return d=e.v,e.a(2,{audioTransceivers:u,videoTransceivers:c,peerConnection:l,localOffer:d});case 2:return s="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},f=t,e.n=3,t.createOffer(s);case 3:return h=e.v,e.a(2,{peerConnection:f,localOffer:h})}},e)}));return function(t){return e.apply(this,arguments)}}()))}},t,this)})),function(){return n.apply(this,arguments)})},{key:"isTracksKindsEquivalentToDefault",value:function(e){if(e.length!==me.length)return!1;var t=function(e){return e.reduce(function(e,t){return e[t]=(e[t]||0)+1,e},{audio:0,video:0})},n=t(e),r=t(me);return n.audio===r.audio&&n.video===r.video}}]);var n,r}();s()(_e,"_logger",ee.getLogger("PeerConnectionService")),s()(_e,"_peerConnectionFactory",new b(new pe)),s()(_e,"_cached",void 0),_e.initiateInitialPrecaching();var be=function(){return o()(function e(){t()(this,e)},null,[{key:"getTelemetryUrl",value:function(e){try{var t=new O.value.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}}}])}(),Ce=function(){return o()(function e(){t()(this,e)},null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new O.value.URL(e).origin}catch(e){return""}}}])}(),we=function(){return o()(function e(){t()(this,e)},null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"contribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(we,"_discoveryParameters",void 0),we.applyParameters();var ke=function(){function e(){throw t()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return o()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new O.value.URL(e.toString()),n=V.sdkVersion,r=we.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(ke,"_discoveryUri",new b("https://pcast.phenixrts.com/pcast/endPoints"));var Se=n(738),Te=n.n(Se),xe=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;t()(this,e),s()(this,"_backoffIntervalInMillisecond",void 0),s()(this,"_minBackoffIntervalInMillisecond",void 0),s()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=n,this._minBackoffIntervalInMillisecond=r,this._maxBackoffIntervalInMillisecond=i},[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),Oe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(Oe||{}),Pe=Oe,Ee=function(){return o()(function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n},[{key:"getName",value:function(){return Pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Pe.TimeToFirstFrame:case Pe.ChannelCreationTimeToFirstFrame:return Q.Essential;case Pe.Stalled:case Pe.Buffering:case Pe.SetupCompleted:case Pe.SetupFailed:case Pe.RoundTripTime:case Pe.DownlinkThroughputCapacity:case Pe.NetworkType:case Pe.ResolutionChanged:case Pe.ApplicationForeground:case Pe.ApplicationBackground:return Q.All;default:J(this._metrics)}}}])}(),Re=n(981).A;function Le(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return De(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(De(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,De(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,De(d,"constructor",c),De(c,"constructor",u),u.displayName="GeneratorFunction",De(c,i,"GeneratorFunction"),De(d),De(d,i,"Generator"),De(d,r,function(){return this}),De(d,"toString",function(){return"[object Generator]"}),(Le=function(){return{w:o,m:f}})()}function De(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}De=function(e,t,n,r){function o(t,n){De(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},De(e,t,n,r)}var Fe,je,Ie=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_logger",ee.getLogger("MetricsService")),s()(this,"_metricsConfiguration",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_metrics",[]),s()(this,"_isSending",!1),s()(this,"_failureCount",0),s()(this,"_domain",""),this._metricsConfiguration=n,this._exponentialBackoff=new xe,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=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 Ee(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:V.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Re(function(e){var t=O.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendMetrics",value:(n=N()(Le().m(function e(t){var n;return Le().w(function(e){for(;;)switch(e.n){case 0:return(n=new O.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,O.value.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=N()(Le().m(function e(){var t,n=this;return Le().w(function(e){for(;;)switch(e.n){case 0:if(!(this._metrics.length<=0||this._isSending)&&O.value){e.n=1;break}return e.a(2);case 1:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.a(2,this.sendMetrics(t).then(function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void O.value.setTimeout(function(){n._metrics=[].concat(c()(t),c()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()},n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e}).catch(function(){n._isSending=!1,n.sendMetricsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,n}(),Me=function(){function e(){throw t()(this,e),new Error("MetricsFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("url must be a string instead received [".concat(Te()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new $;return r.sessionId=Ne.clientSessionId,r.tenancy=Ne.tenancy.value,r.url=be.getTelemetryUrl(t),r.environment=Ce.getEnvironmentFromUrl(t),r.threshold=X.convertTelemetryLevelTypeToTelemetryLevel(Ne.telemetryLevel),e._metricsServices[t]=new Ie(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach(function(e){e.metricsConfiguration.threshold=t})}}])}();s()(Me,"_metricsServices",{});var Ae=(null===(Fe=k.getInstance().value)||void 0===Fe?void 0:Fe.pageLoadTime)||Date.now(),Ne=function(){function e(){throw t()(this,e),new Error("SDK is a static class that may not be instantiated")}return o()(e,null,[{key:"pageLoadTime",get:function(){return Ae}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return K.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return X.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return P}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=ee.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe(function(e){n.environment=e}),e.telemetryUrl.subscribe(function(e){var r=t._logger.appenders.value.find(function(e){return e instanceof W});r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(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 W});r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))})}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Me.getMetricsService(ke.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=Y.getStringValue("phenix-metrics-level");t&&Me.setTelemetryLevel(Q[t]),e._telemetryLevel.subscribe(function(e){Me.setTelemetryLevel(e)})}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Y.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=Y.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=Y.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe(function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=Ce.getEnvironmentFromUrl(t)});var t=Y.getStringValue("phenix-channel-token");if(t){var n=re.parseToken(t);return e._tenancy.value=n.tenancy,ke.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=Y.getStringValue("phenix-uri");if(r)return ke.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Y.getStringValue("phenix-base-uri");if(i){var o=new(k.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",ke.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"onLoad",value:function(t){t&&(this._initialized.value?this._logger.warn("SDK has already been loaded"):(t.addWindowEventListener("unload",function(){e.dispose()}),e.applyDiscoveryUriDefaultFromParameterConfiguration(),e.applyMetricsConfiguration(),e.applyTelemetryConfiguration(),this._applicationActivityMonitor=new ae,this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices),this._initialized.value=!0))}},{key:"init",value:function(t){if(t){var n=t;if(n.globalScope&&k.setInstance(n.globalScope),t.discoveryUri&&(ke.uri.value=t.discoveryUri),t.peerConnectionFactory&&(_e.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&Q[t.telemetryLevel]&&(e._telemetryLevel.value=X.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&R[t.loggingLevel]&&this._logger.threshold.setThreshold(K.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&R[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find(function(e){return e instanceof M});r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new M(K.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)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return be.getTelemetryUrl(e)}}])}();je=Ne,s()(Ne,"_automaticallyRetryOnFailure",Y.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Ne,"_automaticallyReconnectPeerConnection",Y.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Ne,"_automaticallyPlayMediaStream",!0),s()(Ne,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Ne,"_forceGarbageCollectionOnRestart",Y.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Ne,"_skipGarbageCollectionOnMobileDevices",Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Ne,"_webPlayerLoader",void 0),s()(Ne,"_shakaPlayerLoader",void 0),s()(Ne,"_hlsJsLoader",void 0),s()(Ne,"_applicationActivityMonitor",void 0),s()(Ne,"_environment",new b("")),s()(Ne,"_telemetryUrl",new b("https://telemetry.phenixrts.com/telemetry")),s()(Ne,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Ne,"_telemetryLevel",new b(Z.defaultTelemetryLevel)),s()(Ne,"_metricsService",void 0),s()(Ne,"_metricsConfiguration",void 0),s()(Ne,"_sendLocalCandidates",new b(F.sendLocalCandidates)),s()(Ne,"_tenancy",new b("")),s()(Ne,"_clientSessionId",te.random(32)),s()(Ne,"_loadedTimestamp",new Date),s()(Ne,"_logger",ee.getLogger("SDK")),s()(Ne,"_initialized",new b(!1)),s()(Ne,"_readOnlyInitialized",new C(je._initialized)),s()(Ne,"_readOnlyDiscoveryUri",new C(ke.uri)),s()(Ne,"_readOnlyPeerConnectionFactory",new C(_e.peerConnectionFactory)),k.subscribe(Ne.onLoad.bind(Ne));var Ge=function(){return o()(function e(){throw t()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")},null,[{key:"forceGarbageCollection",value:function(){E.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){E.isQueueMicrotaskSupported?O.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):O.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=O.value.documentCreateElement("img");e.src=O.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){O.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Ve=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.Stopped=6]="Stopped",e[e.Unauthorized=7]="Unauthorized",e[e.GeoRestricted=8]="GeoRestricted",e[e.GeoBlocked=9]="GeoBlocked",e[e.UnsupportedFeature=10]="UnsupportedFeature",e[e.NotFound=11]="NotFound",e[e.ConfigurationError=12]="ConfigurationError",e[e.TransientConfigurationError=13]="TransientConfigurationError",e[e.ConnectionError=14]="ConnectionError",e[e.ClientStartError=15]="ClientStartError",e[e.Error=16]="Error",e}(Ve||{}),Ue=Ve,Be=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),s()(this,"_duration",void 0),this._duration=n},[{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)}}])}(),ze=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("StreamSetupListener")),s()(this,"metricsService",Ne.metricsService),s()(this,"_pageLoadTime",void 0),s()(this,"_startTime",void 0),s()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n},[{key:"success",value:function(e){this.recordStreamMetric(Pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Ee(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 Be(n-this._pageLoadTime).toIsoString(),t,i,new Be(r).toIsoString())}}}])}(),He=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_isSupported",void 0!==O.value.navigatorConnection),s()(this,"_rtt",new b(void 0)),s()(this,"_effectiveType",new b(void 0)),s()(this,"_downlinkThroughputCapacity",new b(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())},[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=O.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=O.value.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=O.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=O.value.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=O.value.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=O.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new g(function(){var e;return null===(e=O.value.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)}))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),We=function(){return o()(function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Ne.applicationActivityMonitor),s()(this,"_networkMonitor",new He),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ie),s()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=n,this._disposables.add(this._networkMonitor),this._metricsService=r,!this._applicationActivityMonitor)throw new Error("SessionTelemetry Failed: No application monitor initialized.");this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe(function(e){i.recordForegroundChange(e)})),this._disposables.add(this._networkMonitor.rtt.subscribe(function(e){e&&i.recordNetworkRTTUpdate(e)})),this._disposables.add(this._networkMonitor.effectiveType.subscribe(function(e){e&&i.recordNetworkTypeChangeUpdate(e)})),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe(function(e){e&&i.recordNetworkDownlinkThroughputCapacityUpdate(e)})))},[{key:"listenOnStreamSetup",value:function(){return new ze(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t,n=Date.now(),r=null===(t=this._applicationActivityMonitor)||void 0===t?void 0:t.getTimeSinceLastChange();r&&(this._metricsService.push({metricType:e?Pe.ApplicationForeground:Pe.ApplicationBackground,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new Be(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Pe.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new Be(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:Pe.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new Be(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:Pe.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new Be(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),qe=o()(function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new b(n),this.tokenExpiring=new b(!1)}),Je=function(){return o()(function e(n){t()(this,e),s()(this,"publisherInitialization",void 0),s()(this,"disposables",void 0),s()(this,"publisherDisposables",void 0),s()(this,"state",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"publishing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"clearFailureCountTimeout",void 0),s()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),s()(this,"name",void 0),this.disposables=new ie,this.publisherDisposables=new ie,this.publisherInitialization=new Date,this.state=new b(Ue.Initializing),this.authorized=new b(!0),this.online=new b(!0),this.loading=new b(!1),this.publishing=new b(!1),this.standby=new b(!1),this.stopped=new b(!1),this.failureCount=new b(0),this.endPoint=new b(null),this.stream=new b(null),this.rtcStatistics=new b(null),this.clearFailureCountTimeout=0,this.name=n&&n.length?n:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0},[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyPublishStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":case"geo-restricted":case"geo-blocked":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applySetRemoteDescriptionStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applyAddIceCandidatesStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Ue.Starting;case"not-found":return Ue.NotFound;case"geo-restricted":return Ue.GeoRestricted;case"geo-blocked":return Ue.GeoBlocked;case"unauthorized":return Ue.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ue.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Ue.ConfigurationError;case"port-in-range-not-found":return Ue.TransientConfigurationError;case"failed":return Ue.Error;default:J(e)}}},{key:"applyUnhandledError",value:function(){this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyUnauthorized",value:function(){this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyNotFound",value:function(){this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"generateScreenName",value:function(){return te.random(12)}}])}(),Ke=o()(function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new b(null),this.peerConnection=new b(null),this.peerConnectionReconnectAttempts=0}),Qe=o()(function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new b(!1),this.isDisposed=!1}),$e=n(847),Ze=n.n($e),Xe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ye=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),et=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ye.Normal:return"Normal";case Ye.Force:return"Force";case Ye.Reset:return"Reset";default:J(e)}}}])}(),tt=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Xe.Keep:return"Keep";case Xe.Reset:return"Reset";default:J(e)}}}])}(),nt=n(981).A,rt=["status","streamId","sharedSecret","lag","rtcConfiguration","setRemoteDescriptionResponse","createAnswerDescriptionResponse","createOfferDescriptionResponse"];function it(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 ot(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function at(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return st(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(st(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,st(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,st(d,"constructor",c),st(c,"constructor",u),u.displayName="GeneratorFunction",st(c,i,"GeneratorFunction"),st(d),st(d,i,"Generator"),st(d,r,function(){return this}),st(d,"toString",function(){return"[object Generator]"}),(at=function(){return{w:o,m:f}})()}function st(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}st=function(e,t,n,r){function o(t,n){st(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},st(e,t,n,r)}var ut=function(){return o()(function e(n,r){if(t()(this,e),s()(this,"_logger",ee.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeout",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeout=r,!r)throw new Error("End point requires a timeout")},[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(g=N()(at().m(function e(){var t,n,r,i,o=this;return at().w(function(e){for(;;)switch(e.n){case 0:return t=this.buildPingUrl(),n=Date.now(),e.n=1,nt.race([O.value.fetch(t,{method:"GET",cache:"no-cache"}),new nt(function(e,n){return O.value.setTimeout(function(){return n(new Error("Ping timed out [".concat(t,"]")))},o._timeout)})]);case 1:if(r=e.v,i=Date.now(),r.ok){e.n=2;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 2:return this._roundTripTime=i-n,e.a(2,this._roundTripTime)}},e,this)})),function(){return g.apply(this,arguments)})},{key:"subscribe",value:(v=N()(at().m(function e(t,n,r){var i,o,a,s,u,c,l,d,f,h,p,v,g,y,m,_,b,C=this,w=arguments;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a=w.length>3&&void 0!==w[3]?w[3]:{},s=re.parseToken(t).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),e.a(2,{status:"unauthorized"});case 1:return u=this.buildUrl([s,"stream","subscribe"]).toString(),c=new O.value.FormData,l=V.sdkVersion,d=0===r&&n?{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}}:{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},e.n=2,null===(i=a.onSubscribeRequestCallback)||void 0===i?void 0:i.call(a,d);case 2:return c.append("jsonBody",JSON.stringify(d)),f=Date.now(),e.p=3,p=null,e.n=4,nt.race([O.value.fetch(u,{method:"POST",body:c}),new nt(function(e){return p=O.value.setTimeout(function(){C._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(u,"]"))),e({status:408})},C._timeout)})]).finally(function(){p&&O.value.clearTimeout(p)});case 4:h=e.v,e.n=6;break;case 5:return e.p=5,b=e.v,this._logger.error("Failed to subscribe",b),e.a(2,{status:"failed"});case 6:if("ok"===(v=this.mapHttpStatusToSubscribeStatus(h))){e.n=8;break}return y={status:v},e.n=7,null===(g=a.onSubscribeResponseCallback)||void 0===g?void 0:g.call(a,y);case 7:return e.a(2,y);case 8:return m=Date.now(),e.n=9,this.convertHttpResponseToSubscribeResponse(s,h);case 9:return _=e.v,this._logger.debug("Got subscribe response [%j] in [%s] ms",_,m-f),e.n=10,null===(o=a.onSubscribeResponseCallback)||void 0===o?void 0:o.call(a,_);case 10:return e.a(2,_)}},e,this,[[3,5]])})),function(e,t,n){return v.apply(this,arguments)})},{key:"publish",value:(p=N()(at().m(function e(t,n,r,i){var o,a,s,u,c,l,d,f,h,p,v,g,y,m=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=re.parseToken(n).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",n),e.a(2,{status:"unauthorized"});case 1:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new O.value.FormData,u=V.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.p=2,h=null,e.n=3,nt.race([O.value.fetch(a,{method:"POST",body:s}),new nt(function(e){return h=O.value.setTimeout(function(){m._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})},m._timeout)})]).finally(function(){h&&O.value.clearTimeout(h)});case 3:f=e.v,e.n=5;break;case 4:return e.p=4,y=e.v,this._logger.error("Failed to publish",y),e.a(2,{status:"failed"});case 5:if("ok"===(p=this.mapHttpStatusToPublishStatus(f))){e.n=6;break}return e.a(2,{status:p});case 6:return v=Date.now(),e.n=7,this.convertHttpResponseToPublishResponse(o,f);case 7:return g=e.v,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-d),e.a(2,g)}},e,this,[[2,4]])})),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=N()(at().m(function e(t,n){var r,i,o,a,s,u,c,l,d,f,h=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new O.value.FormData,o={apiVersion:7,sharedSecret:null==t?void 0:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,nt.race([O.value.fetch(r,{method:"POST",body:i}),new nt(function(e){return u=O.value.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&&O.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,f=e.v,this._logger.error("Failed to set remote description",f),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 6:return d=e.v,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return h.apply(this,arguments)})},{key:"limitBitrate",value:(f=N()(at().m(function e(t,n,r,i,o){var a,s,u,c,l,d,f,h,p,v=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new O.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:tt.convertBitrateStateToBitrateStateType(i),bitrateMode:et.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.p=1,d=null,e.n=2,nt.race([O.value.fetch(a,{method:"POST",body:s}),new nt(function(e){return d=O.value.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&&O.value.clearTimeout(d)});case 2:l=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to set limit bitrate timed",p),e.a(2,{status:"failed"});case 4:return f=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),h=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",f,h-c),e.a(2,{status:f})}},e,this,[[1,3]])})),function(e,t,n,r,i){return f.apply(this,arguments)})},{key:"addIceCandidates",value:(d=N()(at().m(function e(t,n,r){var i,o,a,s,u,c,l,d,f,h,p,v=this,g=arguments;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=g.length>3&&void 0!==g[3]?g[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new O.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.p=1,l=null,e.n=2,nt.race([O.value.fetch(o,{method:"POST",body:a}),new nt(function(e){return l=O.value.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&&O.value.clearTimeout(l)});case 2:c=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to add ice candidates",p),e.a(2,{status:"failed"});case 4:if("ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.n=5;break}return e.a(2,{status:d});case 5:return f=Date.now(),e.n=6,this.convertHttpResponseToAddIceCandidatesResponse(c);case 6:return h=e.v,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",h,f-u),e.a(2,h)}},e,this,[[1,3]])})),function(e,t,n){return d.apply(this,arguments)})},{key:"destroyStream",value:(l=N()(at().m(function e(t,n){var r,i,o,a,s,u,c,l,d,f,h=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new O.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,nt.race([O.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new nt(function(e){return u=O.value.setTimeout(function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})},h._timeout)})]).finally(function(){u&&O.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,f=e.v,this._logger.error("Failed to delete stream",f),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToDestroyStreamResponse(s);case 6:return d=e.v,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return l.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=N()(at().m(function e(t,n){var r,i,o,a;return at().w(function(e){for(;;)switch(e.n){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new O.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(i,o);case 1:return e.a(2)}},e,this)})),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new O.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,c()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new O.value.URL(this._uri),t=V.sdkVersion,n=we.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=N()(at().m(function e(t,n){var r,i,o,a,s,u,c,l,d,f,h;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i=r.status,o=r.streamId,a=r.sharedSecret,s=r.lag,u=r.rtcConfiguration,c=r.setRemoteDescriptionResponse,l=r.createAnswerDescriptionResponse,d=r.createOfferDescriptionResponse,f=Ze()(r,rt),h=ot({status:i,stream:{tenancy:t,streamId:o,sharedSecret:a},lag:s},f),u&&(h.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(u)),null!=c&&c.sessionDescription&&(h.setRemoteDescriptionResponse={sessionDescription:c.sessionDescription}),null!=l&&l.sessionDescription&&(h.createAnswerDescriptionResponse={sessionDescription:l.sessionDescription}),null!=d&&d.sessionDescription&&(h.createOfferDescriptionResponse={sessionDescription:d.sessionDescription}),e.a(2,h)}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=N()(at().m(function e(t,n){var r,i;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret}},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.a(2,i)}},e,this)})),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=N()(at().m(function e(t){var n,r;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.a(2,r)}},e)})),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=N()(at().m(function e(t){var n,r;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.a(2,r)}},e)})),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=N()(at().m(function e(t){var n,r;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},e.a(2,r)}},e)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,l,d,f,h,p,v,g}(),ct=n(981).A;function lt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return dt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(dt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,dt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,dt(d,"constructor",c),dt(c,"constructor",u),u.displayName="GeneratorFunction",dt(c,i,"GeneratorFunction"),dt(d),dt(d,i,"Generator"),dt(d,r,function(){return this}),dt(d,"toString",function(){return"[object Generator]"}),(lt=function(){return{w:o,m:f}})()}function dt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}dt=function(e,t,n,r){function o(t,n){dt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},dt(e,t,n,r)}var ft=function(){return o()(function e(n){if(t()(this,e),s()(this,"_logger",ee.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Me.getMetricsService(n.toString()),this._uri=n},[{key:"discoverNearbyEndPoints",value:(n=N()(lt().m(function e(t,n){var r,i,o,a;return lt().w(function(e){for(;;)switch(e.n){case 0:if(n){e.n=1;break}throw new Error("Discovery requires timeout");case 1:return r=t.toString(),e.n=2,ct.race([O.value.fetch(r,{method:"GET",cache:"no-cache"}),new ct(function(e,t){return O.value.setTimeout(function(){return t(new Error("Discovery timed out [".concat(r,"]")))},n)})]);case 2:if((i=e.v).ok){e.n=3;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 3:if(null!==i.body){e.n=4;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 4:return e.n=5,i.text();case 5:return o=e.v,a=o.split(","),e.a(2,a.map(function(e){return new ut(e,n)}))}},e)})),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=N()(lt().m(function e(){var t,n,r,i,o,a,s=this,u=arguments;return lt().w(function(e){for(;;)switch(e.n){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ke.buildDiscoveryUrl(this._uri),e.n=1,this.discoverNearbyEndPoints(new O.value.URL(n),t);case 1:return r=e.v,i=0,o=function(){return new ct(function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))})},e.n=2,ct.race(r.map(function(e){return e.ping().catch(function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,o()}).then(function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:Pe.RoundTripTime,runtime:(n-Ne.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e})}));case 2:return a=e.v,e.a(2,a)}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),ht=n(981).A;function pt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return vt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(vt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,vt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,vt(d,"constructor",c),vt(c,"constructor",u),u.displayName="GeneratorFunction",vt(c,i,"GeneratorFunction"),vt(d),vt(d,i,"Generator"),vt(d,r,function(){return this}),vt(d,"toString",function(){return"[object Generator]"}),(pt=function(){return{w:o,m:f}})()}function vt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}vt=function(e,t,n,r){function o(t,n){vt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},vt(e,t,n,r)}var gt=function(){function e(){throw t()(this,e),new Error("Discovery is a static class that may not be instantiated")}return o()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(r=N()(pt().m(function t(){return pt().w(function(t){for(;;)if(0===t.n)return t.a(2,new ht(function(t){var n=O.subscribe(function(r){if(r){var i=new r.URL(Ne.discoveryUri.value);return e.discoverClosestEndPointWithCaching(i).then(t).then(function(){return n.dispose()})}})}))},t)})),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=N()(pt().m(function t(n){var r,i,o;return pt().w(function(t){for(;;)switch(t.n){case 0:if(!((r=n.toString())in e._cache)){t.n=1;break}return t.a(2,e._cache[r]);case 1:return i=new ft(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then(function(){O.value.setTimeout(function(){e._cache[r]===o&&delete e._cache[r]},6e4)}).catch(function(){delete e._cache[r]}),t.a(2,o)}},t)})),function(e){return n.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();n in e._cache&&delete e._cache[n]}}]);var n,r}();s()(gt,"_cache",{}),gt.precacheClosestEndPointDiscovery();var yt=n(715),mt=n.n(yt),_t=function(){return o()(function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_audioCodec",void 0),s()(this,"_videoCodec",void 0),s()(this,"_isAudioTrackEnabled",void 0),s()(this,"_isVideoTrackEnabled",void 0),this._sdp=n;var r=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)},[{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){var n,r=(null===(n=t.find(function(t){return t.includes("m=".concat(e))}))||void 0===n?void 0:n.split(" ")[3])||"",i=t.find(function(e){return e.includes("a=rtpmap:".concat(r))});return((null==i?void 0:i.split(" ")[1])||"").split("/")[0]}}])}(),bt=n(981).A;function Ct(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return wt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(wt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,wt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,wt(d,"constructor",c),wt(c,"constructor",u),u.displayName="GeneratorFunction",wt(c,i,"GeneratorFunction"),wt(d),wt(d,i,"Generator"),wt(d,r,function(){return this}),wt(d,"toString",function(){return"[object Generator]"}),(Ct=function(){return{w:o,m:f}})()}function wt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}wt=function(e,t,n,r){function o(t,n){wt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},wt(e,t,n,r)}var kt=function(){return o()(function e(n,r,i){var o,a,u,c,l=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("RtcPublishMonitor")),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new b({})),s()(this,"_disposables",new ie),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",void 0),s()(this,"_monitorGeneration",0),s()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentLocalDescription)&&void 0!==a&&a.sdp&&null!==(u=this._peerConnection)&&void 0!==u&&null!==(c=u.currentRemoteDescription)&&void 0!==c&&c.sdp){var d=new _t(this._peerConnection.currentLocalDescription.sdp),f=new _t(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=f.audioCodec,this._estimatedVideoCodec=f.videoCodec,this._availableTracks={audio:d.isAudioTrackEnabled&&f.isAudioTrackEnabled,video:d.isVideoTrackEnabled&&f.isVideoTrackEnabled};var h=!0;this._disposables.add(i.subscribe(function(e){h?h=!1:e&&l._isMonitorRunning&&(l._monitorGeneration++,O.value.clearTimeout(l._updateTimeout),l._logger.debug("Restarting stats polling after foreground transition"),l.updateStatistic())})),this.updateStatistic()}},[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._monitorGeneration++,this._isMonitorRunning=!1,this._peerConnection=null,this._disposables.dispose(),O.value.clearTimeout(this._updateTimeout),this._updateTimeout=void 0}},{key:"updateStatistic",value:(e=N()(Ct().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,f=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!E.getStatsPromiseBasedDisabled){e.n=1;break}return e.a(2);case 1:if(t=this._monitorGeneration,n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.p=2,o=null===(i=this._peerConnection)||void 0===i?void 0:i.getStats(null)){e.n=3;break}return e.a(2);case 3:return a=new bt(function(e){r=O.value.setTimeout(function(){return e(void 0)},5e3)}),e.n=4,bt.race([o,a]);case 4:if(s=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=5;break}return e.a(2);case 5:s?(u={},c=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(c=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=c),u.video&&(u.video.roundTripTime=c)),"candidate-pair"===e.type&&e.lastPacketSentTimestamp&&(l=e.lastPacketSentTimestamp,u.audio&&(u.audio.lastPacketSentTimestamp=l),u.video&&(u.video.lastPacketSentTimestamp=l)),"outbound-rtp"===e.type){var t,r=e.kind||e.mediaType||n(e),i="";if(s.forEach(function(t){t.id===e.codecId&&(i=t.mimeType)}),r&&null!==(t=f._availableTracks)&&void 0!==t&&t[r]){var o,a,d,h,p,v,g,y=(e.bytesSent||0)-(null!==(o=null===(a=f._rtcStatistic.value)||void 0===a||null===(d=a[r])||void 0===d?void 0:d.bytesSent)&&void 0!==o?o:0),m=e.timestamp-(null===(h=f._rtcStatistic.value)||void 0===h||null===(p=h[r])||void 0===p?void 0:p.timestamp),_=y&&m?Math.floor(8*y/m*1e3):0;if(u[r]={ssrc:e.ssrc,mediaType:r,timestamp:e.timestamp,bitrate:_,bytesSent:e.bytesSent,packetsSent:e.packetsSent,retransmittedBytesSent:e.retransmittedBytesSent,codec:i||f.getCodecByType(r),roundTripTime:c},(e.lastPacketSentTimestamp||l)&&(u[r].lastPacketSentTimestamp=e.lastPacketSentTimestamp||l),"video"===r&&(u[r].firCount=e.firCount,u[r].frameHeight=e.frameHeight,u[r].frameWidth=e.frameWidth,u[r].framesEncoded=e.framesEncoded,u[r].framesSent=e.framesSent,u[r].headerBytesSent=e.headerBytesSent,u[r].hugeFramesSent=e.hugeFramesSent,u[r].pliCount=e.pliCount,u[r].qpSum=e.qpSum,u[r].totalEncodeTime=e.totalEncodeTime,u[r].totalEncodedBytesTarget=e.totalEncodedBytesTarget,null!==(v=f._rtcStatistic.value)&&void 0!==v&&null!==(g=v.video)&&void 0!==g&&g.framesEncoded)){var b=(e.framesEncoded-f._rtcStatistic.value.video.framesEncoded)/(u[r].timestamp-f._rtcStatistic.value.video.timestamp)*1e3;u[r].fps=b?Math.round(100*b)/100:0}}}}),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,d=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",d);case 8:return e.p=8,O.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=O.value.setTimeout(function(){return f.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),St=function(){return o()(function e(){throw t()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")},null,[{key:"truncateIceServers",value:function(e){var t=[];if(!e.iceServers)return e;for(var 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}}])}(),Tt=n(981).A;function xt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Ot(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Ot(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ot(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Ot(d,"constructor",c),Ot(c,"constructor",u),u.displayName="GeneratorFunction",Ot(c,i,"GeneratorFunction"),Ot(d),Ot(d,i,"Generator"),Ot(d,r,function(){return this}),Ot(d,"toString",function(){return"[object Generator]"}),(xt=function(){return{w:o,m:f}})()}function Ot(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Ot=function(e,t,n,r){function o(t,n){Ot(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Ot(e,t,n,r)}function Pt(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 Et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Pt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Rt=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_logger",ee.getLogger("RealTimePublisher")),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i},[{key:"start",value:function(e,t,n){var r=this;if(!O.value.navigatorIsOnLine)return this._publisherContext.state.value=Ue.Offline,Tt.resolve();var i=this._peerConnectionContext.mediaStream.value;if(!i)return this._logger.error("Publish failed no media stream provided"),this._publisherContext.state.value=Ue.ConfigurationError,Tt.resolve();var o=i.getTracks().reduce(function(e,t){return"audio"===t.kind||"video"===t.kind?e.push(t.kind):r._logger.warn("[%s] Track kind is not supported",t.kind),e},[]);return Tt.all([gt.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("sendonly",o).then(function(e){var t=e.localOffer,n=e.peerConnection;return r._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}})]).then(function(e){var n=mt()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),E.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(s.close(),s.dispose(),!Ne.forceGarbageCollectionOnRestart||E.isMobile&&Ne.skipGarbageCollectionOnMobileDevices||Ge.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,a,r._publisherContext.failureCount.value)}).then(function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),"ok"!==t)return r._publisherContext.stream.value=null,void r._logger.info("[%s] Publish failed with status [%s]",r._publisherContext.streamId,t);var i=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;return r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,a,s,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then(function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||Ne.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=O.value.setTimeout(function(){var t;r._publisherContext.stream.value!==i||o||null===(t=r._publisherContext.endPoint.value)||void 0===t||t.addIceCandidates(i,l,c).then(function(t){var n=t.status,a=t.options;if("ok"===n)null!=a&&a.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,n,a);else{if(r._publisherContext.stream.value!==i)return;if(r._peerConnectionContext.peerConnection.value!==e)return;r._publisherContext.state.value=r.mapAddIceCandidatesStatusToPublisherStatus(n),r._publisherContext.applyAddIceCandidatesStatus(n),r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n,e)})}}).catch(function(t){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,t),r._publisherContext.state.value=Ue.ConnectionError,r._publisherContext.applyUnhandledError(),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates",r._publisherContext.streamId,e)}))})},100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=Ue.ConnectionError,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch(function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)})};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),void r.reconnectPeerConnection(e,t);case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:J(e.iceConnectionState)}}},new Tt(function(e){e()}).then(function(){if(a)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,a.sessionDescription,e.message),e})}).then(function(){var t;if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,null==u||null===(t=u.sessionDescription)||void 0===t?void 0:t.sdp),e.setRemoteDescription(u.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e})}).then(function(){if(s)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e}).then(function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})}).then(function(e){r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp);var t=r._publisherContext.endPoint.value;if(!t)throw new Error("Failed to set remote description, EndPoint is not set");return t.setRemoteDescription(i,e)}).then(function(t){var n=t.status,i=t.sessionDescription;if(r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),r._publisherContext.applySetRemoteDescriptionStatus(n),"ok"===n)return r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,null==i?void 0:i.sdp),e.setLocalDescription(i).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})})}).then(function(){var t;if(n.success(r._publisherContext.streamId),r._publisherContext.state.value!==Ue.Starting)return Tt.resolve();r._publisherContext.state.value=Ue.Publishing,r._publisherContext.publishing.value=!0;var i=new kt(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0,Ne.applicationActivityMonitor.isForeground);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe(function(e){r._publisherContext.rtcStatistics.value=e}),Tt.resolve()})})})}},{key:"applyRtcConfiguration",value:(e=N()(xt().m(function e(t,n){var r;return xt().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=St.truncateIceServers(n),e.a(2,Ne.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=Et(Et({},t.getConfiguration()),n),t.setConfiguration(r),e.a(2,t)}},e)})),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Ue.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ne.maximalNumberOfPeerConnectionReconnectAttempts||!Ne.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(E.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=O.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);return void this._publisherContext.disposables.add(new g(function(){return O.value.clearTimeout(o)}))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then(function(r){return e.setLocalDescription(r).then(function(){return e.setLocalDescription(a).then(function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=O.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);n._publisherContext.disposables.add(new g(function(){return O.value.clearTimeout(r)}))}else n._publisherContext.state.value=Ue.Publishing})})}).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:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Ue.Starting;case"unauthorized":return Ue.Unauthorized;case"not-found":return Ue.NotFound;case"capacity":case"rate-limited":case"timeout":return Ue.Recovering;case"failed":return Ue.Error;default:J(e)}}},{key:"mapAddIceCandidatesStatusToPublisherStatus",value:function(e){switch(e){case"ok":return this._publisherContext.state.value;case"unauthorized":return Ue.Unauthorized;case"not-found":return Ue.NotFound;case"capacity":case"rate-limited":case"timeout":return Ue.Recovering;case"failed":return Ue.Error;default:J(e)}}}]);var e}(),Lt=n(981).A;function Dt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Ft(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Ft(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ft(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Ft(d,"constructor",c),Ft(c,"constructor",u),u.displayName="GeneratorFunction",Ft(c,i,"GeneratorFunction"),Ft(d),Ft(d,i,"Generator"),Ft(d,r,function(){return this}),Ft(d,"toString",function(){return"[object Generator]"}),(Dt=function(){return{w:o,m:f}})()}function Ft(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Ft=function(e,t,n,r){function o(t,n){Ft(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Ft(e,t,n,r)}var jt=function(){return o()(function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",ee.getLogger("Publisher")),s()(this,"_tokenContext",void 0),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_publisherStartTime",void 0),s()(this,"_readOnlyToken",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPublishing",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),this._tokenContext=new qe(r),this._publisherContext=new Je(i),this._peerConnectionContext=new Ke,this._stateContext=new Qe,this._exponentialBackoff=new xe,this._publisherStartTime=Date.now(),this._readOnlyToken=new C(this._tokenContext.token),this._readOnlyPeerConnection=new C(this._peerConnectionContext.peerConnection),this._readOnlyState=new C(this._publisherContext.state),this._readOnlyTokenExpiring=new C(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new C(this._publisherContext.authorized),this._readOnlyOnline=new C(this._publisherContext.online),this._readOnlyLoading=new C(this._publisherContext.loading),this._readOnlyPublishing=new C(this._publisherContext.publishing),this._readOnlyStandby=new C(this._publisherContext.standby),this._readOnlyStopped=new C(this._publisherContext.stopped),this._readOnlyFailureCount=new C(this._publisherContext.failureCount),this._readOnlyEndPoint=new C(this._publisherContext.endPoint),this._readOnlyStream=new C(this._publisherContext.stream),this._readOnlyRtcStatistics=new C(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var a=re.parseToken(this._tokenContext.token.value),u=(a.uri||Ne.discoveryUri.value).toString();Ne.tenancy.value=a.tenancy||Ne.tenancy.value,ke.uri.value=u,this._metricsService=Me.getMetricsService(u),this._sessionTelemetry=new We(Ne.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe(function(e){o._publisherContext.clearFailureCountTimeout&&O.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Ue.Publishing&&(o._publisherContext.clearFailureCountTimeout=O.value.setTimeout(function(){o._publisherContext.failureCount.value=0},3e3))}));var c=function(){o._publisherContext.stream.value&&o._publisherContext.endPoint.value&&o._publisherContext.endPoint.value.destroyStreamOnUnmount(o._publisherContext.stream.value,"client:termination-on-window-unload")};O.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new g(function(){O.value.removeWindowEventListener("beforeunload",c)})),this.start()},[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=re.parseToken(this._tokenContext.token.value),n=(t.uri||Ne.discoveryUri.value).toString();Ne.tenancy.value=t.tenancy||Ne.tenancy.value,ke.uri.value=n,this._metricsService=Me.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{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:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{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._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=N()(Dt().m(function e(t){var n=this;return Dt().w(function(e){for(;;)if(0===e.n)return e.a(2,new Lt(function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe(function(r){r||(n.processStop(t),e())}))}))},e)})),function(e){return a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=Ue.Stopped}},{key:"dispose",value:(i=N()(Dt().m(function e(){var t=this;return Dt().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0}))},e,this)})),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return re.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ne.discoveryUri.value),new O.value.URL(Ne.discoveryUri.value))}},{key:"start",value:(r=N()(Dt().m(function e(){return Dt().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._stateContext.isStarting.value){e.n=2;break}return this._logger.info("Publisher is already starting, skipping start"),e.a(2);case 2:return this._stateContext.isStarting.value=!0,e.a(2,this.processStart())}},e,this)})),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=N()(Dt().m(function e(){var t,n,r,i,o,a=this;return Dt().w(function(e){for(;;)switch(e.n){case 0:if(this._publisherContext.state.value=Ue.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),re.isEncodedEdgeTokenValid(t)){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Ue.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 1:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe(function(e){e!==Ue.Error&&e!==Ue.Recovering||gt.clearCachedClosestEndpoint(r)})),i=function(){return new Lt(function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())})},o=new Rt(this._publisherContext,this._peerConnectionContext,i),e.a(2,o.start(r,t,n).then(function(){a._publisherContext.loading.value=!1}).catch(function(e){n.fail(),a._publisherContext.failureCount.value++,a._publisherContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._publisherContext.state.value=Ue.ClientStartError,a._logger.error("Failed to start publishing",e)}).finally(function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Ue.Publishing&&Ne.automaticRetryOnFailure){var e=O.value.setTimeout(function(){a.handleStreamFailure().catch(function(e){a._logger.error("Failed handling stream failure",e)})},a.getRetryInterval());a._publisherContext.disposables.add(new g(function(){O.value.clearTimeout(e)}))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0}))}},e,this)})),function(){return n.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach(function(e){var n;null===(n=t._peerConnectionContext.peerConnection.value)||void 0===n||n.getSenders().forEach(function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)})})}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case Ue.Offline:return 15e3;case Ue.Initializing:case Ue.NotFound:case Ue.Error:case Ue.Recovering:case Ue.Unauthorized:case Ue.GeoRestricted:case Ue.GeoBlocked:case Ue.Stopped:case Ue.Starting:case Ue.Publishing:case Ue.Reconnecting:case Ue.UnsupportedFeature:case Ue.ConfigurationError:case Ue.TransientConfigurationError:case Ue.ConnectionError:case Ue.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:J(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=N()(Dt().m(function e(){var t;return Dt().w(function(e){for(;;)switch(e.n){case 0:t=this._publisherContext.state.value,e.n=t===Ue.Error||t===Ue.Reconnecting||t===Ue.Offline||t===Ue.Recovering||t===Ue.TransientConfigurationError||t===Ue.ConnectionError||t===Ue.ClientStartError?1:t===Ue.Unauthorized?3:t===Ue.GeoRestricted?4:t===Ue.GeoBlocked?5:t===Ue.Stopped?6:t===Ue.Publishing?7:t===Ue.Initializing?8:t===Ue.Starting?9:t===Ue.UnsupportedFeature?10:t===Ue.NotFound?11:t===Ue.ConfigurationError?12:13;break;case 1:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.n=2;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Ue[this._publisherContext.state.value]),e.a(2);case 2:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Ue[this._publisherContext.state.value]),e.a(3,14);case 3:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 4:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 5:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 6:return this._logger.info("Publisher is stopped, skipping retry of start."),e.a(2);case 7:return this._logger.info("Publisher is publishing, skipping retry of start"),e.a(2);case 8:return this._logger.info("Publisher is initializing, skipping retry of start"),e.a(2);case 9:return this._logger.info("Publisher is already starting, skipping retry of start"),e.a(2);case 10:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.a(2);case 11:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.a(2);case 12:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.a(2);case 13:J(this._publisherContext.state.value);case 14:return e.a(2,this.start())}},e,this)})),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ne.forceGarbageCollectionOnRestart||E.isMobile&&Ne.skipGarbageCollectionOnMobileDevices||Ge.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.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._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,n,r,i,a}(),It=function(){return o()(function e(){throw t()(this,e),new Error("Publishers is a static class that may not be instantiated")},null,[{key:"createPublisher",value:function(e){if(!Ne.initialized.value)throw new Error("SDK is not loaded.");return new jt(e.mediaStream,e.token,e.name)}}])}(),Mt={SDK:Ne,Publishers:It,PublisherState:Ue}})(),r})());
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,()=>(()=>{var e={981:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});var r=n(738),i=n.n(r),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),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}),f=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=null,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=[]}},{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,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 a(t,e)},n)}r[t]=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){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,t){var n=new f(function(){return null});return this.handle(new d(e,t,n)),n},f.prototype.finally=function(e){return this.then(function(t){return f.resolve(e()).then(function(){return t},function(){return null})},function(t){return f.resolve(e()).then(function(){return f.reject(t)},function(){return null})})};var h=f},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(981).A;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},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,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},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},847:(e,t,n)=>{var r=n(893);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},893:e=>{e.exports=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),o=n(122),a=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),a=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}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})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{PublisherState:()=>Ue,Publishers:()=>It,SDK:()=>Ne,default:()=>Mt});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),a=n(693),s=n.n(a),u=n(132),c=n.n(u),l=n(452),d=n.n(l),f=n(72),h=n.n(f),p=n(511),v=n.n(p),g=function(){return o()(function e(n){t()(this,e),s()(this,"_disposed",void 0),s()(this,"_disposable",void 0),this._disposed=!1,this._disposable=n},[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}var m,_=function(e){function n(e,r){return t()(this,n),i=this,o=n,a=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=h()(o),d()(i,y()?Reflect.construct(o,a||[],h()(i).constructor):o.apply(i,a));var i,o,a}return v()(n,e),o()(n)}(g),b=function(){return o()(function e(n){t()(this,e),s()(this,"_listeners",void 0),s()(this,"_value",void 0),this._listeners=[],this._value=n},[{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))}if(t){this._value=e;for(var r=0,i=c()(this._listeners);r<i.length;r++)(0,i[r])(e)}}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new _(this._listeners,e)}}])}(),C=function(){return o()(function e(n){t()(this,e),s()(this,"_subject",void 0),this._subject=n},[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),w={document,location,navigator,window},k=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"HTMLVideoElement",get:function(){return this._window.HTMLVideoElement}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"MediaSource",get:function(){return this._window.MediaSource}},{key:"RTCPeerConnection",get:function(){return this._window.RTCPeerConnection}},{key:"RTCSessionDescription",get:function(){return this._window.RTCSessionDescription}},{key:"RTCIceCandidate",get:function(){return this._window.RTCIceCandidate}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"pageLoadTime",get:function(){return this._window.__phenixPageLoadTime||this._window.__pageLoadTime}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"requestAnimationFrame",get:function(){return this._window.requestAnimationFrame.bind(this._window)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"setInstance",value:function(e){throw new Error("This build does not support setting the GlobalScope")}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();m=k,s()(k,"_instance",new b(new m(w))),s()(k,"_readOnlyInstance",new C(m._instance));var S,T,x,O=k.getInstance(),P=function(){function e(){t()(this,e)}return o()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();S=P,s()(P,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(P,"_browserNameAndVersion",S.parseBrowserNameAndVersion()),s()(P,"_browserName",S.parseBrowserName()),s()(P,"_browserMajorVersion",S.parseBrowserMajorVersion()),s()(P,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(T=navigator)||void 0===T?void 0:T.userAgent)),s()(P,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(P,"_isChrome69",S._browserNameAndVersion.includes("Chrome/69.")),s()(P,"_isChrome70",S._browserNameAndVersion.includes("Chrome/70.")),s()(P,"_isChrome71",S._browserNameAndVersion.includes("Chrome/71.")),s()(P,"_isChrome72",S._browserNameAndVersion.includes("Chrome/72.")),s()(P,"_isChrome74",S._browserNameAndVersion.includes("Chrome/74.")),s()(P,"_isChrome75",S._browserNameAndVersion.includes("Chrome/75.")),s()(P,"_isChrome76",S._browserNameAndVersion.includes("Chrome/76.")),s()(P,"_isChrome77",S._browserNameAndVersion.includes("Chrome/77."));var E=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return P.isChrome74||P.isChrome75||P.isChrome76||P.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return P.isChrome69||P.isChrome70||P.isChrome71||P.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=69||"Firefox"===P.browserName&&P.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=63||"Firefox"===P.browserName&&P.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===P.browserName&&P.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===P.browserName||"SamsungBrowser"===P.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==P.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===P.browserName&&"function"==typeof(null===(e=O.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===P.browserName&&P.browserMajorVersion>=71||"Firefox"===P.browserName&&P.browserMajorVersion>=69||"Safari"===P.browserName}},{key:"isMobile",get:function(){return P.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=O.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isRequestAnimationFrameSupported",get:function(){var e;return"function"==typeof(null===(e=O.value)||void 0===e?void 0:e.requestAnimationFrame)}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==P.browserName&&"Safari"!==P.browserName}}])}(),R=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),L=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i},[{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.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")})),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n},2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),D=function(){return o()(function e(){t()(this,e),s()(this,"_appenders",[])},[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce(function(t,n){return n!==e&&t.push(n),t},[])}}])}(),F=function(){return o()(function e(){t()(this,e)},null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(F,"_sendLocalCandidates",void 0),s()(F,"_sendLogs",void 0),s()(F,"_sendMetrics",void 0),s()(F,"_logToConsole",void 0),F.applyFeatures();var j=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultLoggingLevel",get:function(){return R[F.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return R[F.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return R.Info}}])}(),I=function(){return o()(function e(){t()(this,e),s()(this,"_threshold",j.defaultLoggingLevel)},[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),M=function(){return o()(function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n},[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(R[e],"] ").concat(t);e<R.Warn?console.log(i):console.error(i)}}}])}(),A=n(293),N=n.n(A),G=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),V=function(){return o()(function e(){t()(this,e)},null,[{key:"sdkVersion",get:function(){try{return"2026-04-02T15:30:55.442Z (2025.2.3)"}catch(e){return this._defaultVersion}}}])}();s()(V,"_defaultVersion",(new Date).toISOString());var U=n(981).A;function B(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return z(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(z(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,z(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,z(d,"constructor",c),z(c,"constructor",u),u.displayName="GeneratorFunction",z(c,i,"GeneratorFunction"),z(d),z(d,i,"Generator"),z(d,r,function(){return this}),z(d,"toString",function(){return"[object Generator]"}),(B=function(){return{w:o,m:f}})()}function z(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}z=function(e,t,n,r){function o(t,n){z(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},z(e,t,n,r)}var H=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=e})},[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:R[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:V.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<R.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new U(function(e){var t=O.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendLogs",value:(n=N()(B().m(function e(t){var n;return B().w(function(e){for(;;)switch(e.n){case 0:return(n=new O.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,O.value.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=N()(B().m(function e(){var t,n,r,i,o,a=this;return B().w(function(e){for(;;)switch(e.n){case 0:if(!(this._logs.length<=0||this._isSending)&&O.value){e.n=1;break}return e.a(2);case 1:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?G.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce(function(e,t){return e+(t?r(t):0)},0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.a(2,this.sendLogs(o).then(function(e){return a._isSending=!1,a.sendLogsIfAble(),e}).catch(function(){a._isSending=!1,a.sendLogsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),W=function(){return o()(function e(n){t()(this,e),s()(this,"_telemetryService",void 0),s()(this,"_tenancy",void 0),s()(this,"_sessionId",void 0),s()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new H(n)},[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),q=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_pageLoadTime",0),s()(this,"_threshold",j.defaultTelemetryLoggingLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new O.value.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),J=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},K=function(){return o()(function e(){t()(this,e)},null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case R.Off:return"Off";case R.Trace:return"Trace";case R.Debug:return"Debug";case R.Info:return"Trace";case R.Warn:return"Warn";case R.Error:return"Error";case R.Fatal:return"Fatal";case R.All:return"All";default:J(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return R.Off;case"Trace":return R.Trace;case"Debug":return R.Debug;case"Info":return R.Info;case"Warn":return R.Warn;case"Error":return R.Error;case"Fatal":return R.Fatal;case"All":return R.All;default:J(e)}}}])}(),Q=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),$=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_threshold",Z.defaultTelemetryLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new O.value.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}}])}(),Z=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultTelemetryLevel",get:function(){return Q[F.sendMetrics]}}])}(),X=function(){return o()(function e(){t()(this,e)},null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case Q.Off:return"Off";case Q.Essential:return"Essential";case Q.All:return"All";default:J(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return Q.Off;case"Essential":return Q.Essential;case"All":return Q.All;default:J(e)}}}])}(),Y=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.readConfigurationParameterValue(t)||e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"))||e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n)return"true"===n||"1"===n||"On"===n;var r=e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"));return r?"true"===r||"1"===r||"On"===r:!0===e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":X.convertTelemetryLevelToTelemetryLevelType(Z.defaultTelemetryLevel),"phenix-logging-level":K.convertLoggingLevelToLoggingLevelType(j.defaultLoggingLevel),"phenix-console-logging-level":K.convertLoggingLevelToLoggingLevelType(j.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":K.convertLoggingLevelToLoggingLevelType(j.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}},{key:"readConfigurationParameterValue",value:function(e){var t=O.value.documentQuerySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n){var r=new O.value.URLSearchParams(O.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),ee=function(){function e(){throw t()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return o()(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 L(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=Y.getStringValue("phenix-logging-level");R[e]&&this._threshold.setThreshold(R[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Y.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(R[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new M(e||j.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||j.defaultTelemetryLoggingLevel,this._appenders.add(new W(this._telemetryConfiguration))}}])}();s()(ee,"_loggers",{}),s()(ee,"_appenders",new D),s()(ee,"_threshold",new I),s()(ee,"_telemetryConfiguration",new q),ee.applyLoggerConfigFromParameterConfiguration();var te=function(){return o()(function e(){throw t()(this,e),new Error("Strings is a static class that may not be instantiated")},null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill(function(){return Math.random().toString(16).substring(2,15)}).reduce(function(e,t){return e+t()},"").substring(0,e)}}])}(),ne=function(){return o()(function e(n){var r,i;t()(this,e),s()(this,"_applicationId",void 0),s()(this,"_token",void 0),this._applicationId=(null==n?void 0:n.applicationId)||"",this._token={uri:null!=n&&null!==(r=n.token)&&void 0!==r&&r.uri?new O.value.URL(n.token.uri):null,capabilities:(null==n||null===(i=n.token)||void 0===i?void 0:i.capabilities)||[]}},[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),re=function(){function e(){t()(this,e)}return o()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new ne(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new ne(r)}catch(t){return e._logger.error("Cannot parse token value",t),new ne(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(re,"_logger",ee.getLogger("EdgeAuthParser"));var ie=function(){return o()(function e(){t()(this,e),s()(this,"_list",[])},[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach(function(e){return e.dispose()}),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),oe="visibilitychange",ae=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),s()(this,"_lastBackgroundDuration",null),this._isForeground=new b(!0),this._readOnlyIsForeground=new C(this._isForeground),this.initialize()},[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"getLastBackgroundDuration",value:function(){return this._lastBackgroundDuration}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=null,n=function(){var n=!O.value.documentIsHidden;n?t&&(e._lastBackgroundDuration=Date.now()-t):(t=Date.now(),e._lastBackgroundDuration=null),e._isForeground.value=n},r=!1;O.value.addDocumentEventListener(oe,n,r),this._disposables.add(new g(function(){return O.value.removeDocumentEventListener(oe,n,r)}))}}])}(),se=n(981).A;function ue(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ce(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(ce(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,ce(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,ce(d,"constructor",c),ce(c,"constructor",u),u.displayName="GeneratorFunction",ce(c,i,"GeneratorFunction"),ce(d),ce(d,i,"Generator"),ce(d,r,function(){return this}),ce(d,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:o,m:f}})()}function ce(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ce=function(e,t,n,r){function o(t,n){ce(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},ce(e,t,n,r)}var le=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),E.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new O.value.RTCPeerConnection(n)},[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentLocalDescription)||null}},{key:"currentRemoteDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentRemoteDescription)||null}},{key:"connectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.connectionState)||null}},{key:"iceConnectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.iceConnectionState)||null}},{key:"supportsGetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getConfiguration)}},{key:"supportsSetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.setConfiguration)}},{key:"supportsGetTransceivers",get:function(){var e;return!E.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!E.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=N()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!E.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createOffer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createOffer(t))}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=N()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!E.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createAnswer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createAnswer(t))}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=N()(ue().m(function e(t){return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:return e.a(2,this._peerConnection.setLocalDescription(E.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=N()(ue().m(function e(t){var n;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1: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.a(2,this._peerConnection.setRemoteDescription(E.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;if(!this._peerConnection)throw new Error("No PeerConnection initialized");return new se(function(t){e._peerConnection.getStats(t)})}},{key:"addEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach(function(e){if(!t._peerConnection)throw new Error("No PeerConnection initialized");t._peerConnection.addTrack(e)})}},{key:"getConfiguration",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.ontrack},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onicecandidate},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.oniceconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){var e;null===(e=this._peerConnection)||void 0===e||e.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,n,r,i}(),de=n(981).A;function fe(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return he(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(he(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,he(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,he(d,"constructor",c),he(c,"constructor",u),u.displayName="GeneratorFunction",he(c,i,"GeneratorFunction"),he(d),he(d,i,"Generator"),he(d,r,function(){return this}),he(d,"toString",function(){return"[object Generator]"}),(fe=function(){return{w:o,m:f}})()}function he(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}he=function(e,t,n,r){function o(t,n){he(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},he(e,t,n,r)}var pe=function(){return o()(function e(){t()(this,e)},[{key:"createPeerConnection",value:(e=N()(fe().m(function e(t){return fe().w(function(e){for(;;)if(0===e.n)return e.a(2,new de(function(e){var n=O.subscribe(function(r){r&&(e(new le(t)),n.dispose())})}))},e)})),function(t){return e.apply(this,arguments)})}]);var e}();function ve(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ge(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(ge(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,ge(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,ge(d,"constructor",c),ge(c,"constructor",u),u.displayName="GeneratorFunction",ge(c,i,"GeneratorFunction"),ge(d),ge(d,i,"Generator"),ge(d,r,function(){return this}),ge(d,"toString",function(){return"[object Generator]"}),(ve=function(){return{w:o,m:f}})()}function ge(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ge=function(e,t,n,r){function o(t,n){ge(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},ge(e,t,n,r)}var ye=function(e){return e[e.Disabled=0]="Disabled",e[e.Enabled=1]="Enabled",e}({}),me=["audio","video"],_e=function(){function e(){throw t()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return o()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){E.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch(function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)})}},{key:"precacheCreatePeerConnectionOffer",value:(r=N()(ve().m(function t(){return ve().w(function(t){for(;;)if(0===t.n)return t.a(2,e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch(function(t){throw e._cached=null,t})})},t)})),function(){return r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=N()(ve().m(function t(){var n,r,i,o,a,s=arguments;return ve().w(function(t){for(;;)switch(t.n){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]?s[1]:me,i=s.length>2&&void 0!==s[2]?s[2]:ye.Disabled,!e._cached||e._cached.direction!==n||i!==ye.Disabled||!this.isTracksKindsEquivalentToDefault(r)){t.n=1;break}return o=e._cached.peerConnection,e._cached=null,t.a(2,o);case 1:return a=E.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i===ye.Enabled}:void 0,t.a(2,e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=N()(ve().m(function e(t){var i,o,a,s,u,c,l,d,f,h;return ve().w(function(e){for(;;)switch(e.n){case 0:if(i=t.supportsAddTransceiver,o=[],a=[],!i){e.n=2;break}return r.forEach(function(e){"audio"!==e?"video"!==e||a.push(t.addTransceiver(e,{direction:n})):o.push(t.addTransceiver(e,{direction:n}))}),u=o,c=a,l=t,e.n=1,t.createOffer(void 0);case 1:return d=e.v,e.a(2,{audioTransceivers:u,videoTransceivers:c,peerConnection:l,localOffer:d});case 2:return s="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},f=t,e.n=3,t.createOffer(s);case 3:return h=e.v,e.a(2,{peerConnection:f,localOffer:h})}},e)}));return function(t){return e.apply(this,arguments)}}()))}},t,this)})),function(){return n.apply(this,arguments)})},{key:"isTracksKindsEquivalentToDefault",value:function(e){if(e.length!==me.length)return!1;var t=function(e){return e.reduce(function(e,t){return e[t]=(e[t]||0)+1,e},{audio:0,video:0})},n=t(e),r=t(me);return n.audio===r.audio&&n.video===r.video}}]);var n,r}();s()(_e,"_logger",ee.getLogger("PeerConnectionService")),s()(_e,"_peerConnectionFactory",new b(new pe)),s()(_e,"_cached",void 0),_e.initiateInitialPrecaching();var be=function(){return o()(function e(){t()(this,e)},null,[{key:"getTelemetryUrl",value:function(e){try{var t=new O.value.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}}}])}(),Ce=function(){return o()(function e(){t()(this,e)},null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new O.value.URL(e).origin}catch(e){return""}}}])}(),we=function(){return o()(function e(){t()(this,e)},null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"contribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(we,"_discoveryParameters",void 0),we.applyParameters();var ke=function(){function e(){throw t()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return o()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new O.value.URL(e.toString()),n=V.sdkVersion,r=we.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(ke,"_discoveryUri",new b("https://pcast.phenixrts.com/pcast/endPoints"));var Se=n(738),Te=n.n(Se),xe=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;t()(this,e),s()(this,"_backoffIntervalInMillisecond",void 0),s()(this,"_minBackoffIntervalInMillisecond",void 0),s()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=n,this._minBackoffIntervalInMillisecond=r,this._maxBackoffIntervalInMillisecond=i},[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),Oe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(Oe||{}),Pe=Oe,Ee=function(){return o()(function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n},[{key:"getName",value:function(){return Pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Pe.TimeToFirstFrame:case Pe.ChannelCreationTimeToFirstFrame:return Q.Essential;case Pe.Stalled:case Pe.Buffering:case Pe.SetupCompleted:case Pe.SetupFailed:case Pe.RoundTripTime:case Pe.DownlinkThroughputCapacity:case Pe.NetworkType:case Pe.ResolutionChanged:case Pe.ApplicationForeground:case Pe.ApplicationBackground:return Q.All;default:J(this._metrics)}}}])}(),Re=n(981).A;function Le(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return De(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(De(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,De(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,De(d,"constructor",c),De(c,"constructor",u),u.displayName="GeneratorFunction",De(c,i,"GeneratorFunction"),De(d),De(d,i,"Generator"),De(d,r,function(){return this}),De(d,"toString",function(){return"[object Generator]"}),(Le=function(){return{w:o,m:f}})()}function De(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}De=function(e,t,n,r){function o(t,n){De(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},De(e,t,n,r)}var Fe,je,Ie=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_logger",ee.getLogger("MetricsService")),s()(this,"_metricsConfiguration",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_metrics",[]),s()(this,"_isSending",!1),s()(this,"_failureCount",0),s()(this,"_domain",""),this._metricsConfiguration=n,this._exponentialBackoff=new xe,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=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 Ee(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:V.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Re(function(e){var t=O.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendMetrics",value:(n=N()(Le().m(function e(t){var n;return Le().w(function(e){for(;;)switch(e.n){case 0:return(n=new O.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,O.value.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=N()(Le().m(function e(){var t,n=this;return Le().w(function(e){for(;;)switch(e.n){case 0:if(!(this._metrics.length<=0||this._isSending)&&O.value){e.n=1;break}return e.a(2);case 1:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.a(2,this.sendMetrics(t).then(function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void O.value.setTimeout(function(){n._metrics=[].concat(c()(t),c()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()},n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e}).catch(function(){n._isSending=!1,n.sendMetricsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,n}(),Me=function(){function e(){throw t()(this,e),new Error("MetricsFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("url must be a string instead received [".concat(Te()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new $;return r.sessionId=Ne.clientSessionId,r.tenancy=Ne.tenancy.value,r.url=be.getTelemetryUrl(t),r.environment=Ce.getEnvironmentFromUrl(t),r.threshold=X.convertTelemetryLevelTypeToTelemetryLevel(Ne.telemetryLevel),e._metricsServices[t]=new Ie(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach(function(e){e.metricsConfiguration.threshold=t})}}])}();s()(Me,"_metricsServices",{});var Ae=(null===(Fe=k.getInstance().value)||void 0===Fe?void 0:Fe.pageLoadTime)||Date.now(),Ne=function(){function e(){throw t()(this,e),new Error("SDK is a static class that may not be instantiated")}return o()(e,null,[{key:"pageLoadTime",get:function(){return Ae}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return K.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return X.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return P}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=ee.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe(function(e){n.environment=e}),e.telemetryUrl.subscribe(function(e){var r=t._logger.appenders.value.find(function(e){return e instanceof W});r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(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 W});r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))})}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Me.getMetricsService(ke.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=Y.getStringValue("phenix-metrics-level");t&&Me.setTelemetryLevel(Q[t]),e._telemetryLevel.subscribe(function(e){Me.setTelemetryLevel(e)})}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Y.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=Y.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=Y.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe(function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=Ce.getEnvironmentFromUrl(t)});var t=Y.getStringValue("phenix-channel-token");if(t){var n=re.parseToken(t);return e._tenancy.value=n.tenancy,ke.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=Y.getStringValue("phenix-uri");if(r)return ke.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Y.getStringValue("phenix-base-uri");if(i){var o=new(k.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",ke.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"onLoad",value:function(t){t&&(this._initialized.value?this._logger.warn("SDK has already been loaded"):(t.addWindowEventListener("unload",function(){e.dispose()}),e.applyDiscoveryUriDefaultFromParameterConfiguration(),e.applyMetricsConfiguration(),e.applyTelemetryConfiguration(),this._applicationActivityMonitor=new ae,this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices),this._initialized.value=!0))}},{key:"init",value:function(t){if(t){var n=t;if(n.globalScope&&k.setInstance(n.globalScope),t.discoveryUri&&(ke.uri.value=t.discoveryUri),t.peerConnectionFactory&&(_e.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&Q[t.telemetryLevel]&&(e._telemetryLevel.value=X.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&R[t.loggingLevel]&&this._logger.threshold.setThreshold(K.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&R[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find(function(e){return e instanceof M});r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new M(K.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)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return be.getTelemetryUrl(e)}}])}();je=Ne,s()(Ne,"_automaticallyRetryOnFailure",Y.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Ne,"_automaticallyReconnectPeerConnection",Y.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Ne,"_automaticallyPlayMediaStream",!0),s()(Ne,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Ne,"_forceGarbageCollectionOnRestart",Y.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Ne,"_skipGarbageCollectionOnMobileDevices",Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Ne,"_webPlayerLoader",void 0),s()(Ne,"_shakaPlayerLoader",void 0),s()(Ne,"_hlsJsLoader",void 0),s()(Ne,"_applicationActivityMonitor",void 0),s()(Ne,"_environment",new b("")),s()(Ne,"_telemetryUrl",new b("https://telemetry.phenixrts.com/telemetry")),s()(Ne,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Ne,"_telemetryLevel",new b(Z.defaultTelemetryLevel)),s()(Ne,"_metricsService",void 0),s()(Ne,"_metricsConfiguration",void 0),s()(Ne,"_sendLocalCandidates",new b(F.sendLocalCandidates)),s()(Ne,"_tenancy",new b("")),s()(Ne,"_clientSessionId",te.random(32)),s()(Ne,"_loadedTimestamp",new Date),s()(Ne,"_logger",ee.getLogger("SDK")),s()(Ne,"_initialized",new b(!1)),s()(Ne,"_readOnlyInitialized",new C(je._initialized)),s()(Ne,"_readOnlyDiscoveryUri",new C(ke.uri)),s()(Ne,"_readOnlyPeerConnectionFactory",new C(_e.peerConnectionFactory)),k.subscribe(Ne.onLoad.bind(Ne));var Ge=function(){return o()(function e(){throw t()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")},null,[{key:"forceGarbageCollection",value:function(){E.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){E.isQueueMicrotaskSupported?O.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):O.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=O.value.documentCreateElement("img");e.src=O.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){O.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Ve=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.Stopped=6]="Stopped",e[e.Unauthorized=7]="Unauthorized",e[e.GeoRestricted=8]="GeoRestricted",e[e.GeoBlocked=9]="GeoBlocked",e[e.UnsupportedFeature=10]="UnsupportedFeature",e[e.NotFound=11]="NotFound",e[e.ConfigurationError=12]="ConfigurationError",e[e.TransientConfigurationError=13]="TransientConfigurationError",e[e.ConnectionError=14]="ConnectionError",e[e.ClientStartError=15]="ClientStartError",e[e.Error=16]="Error",e}(Ve||{}),Ue=Ve,Be=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),s()(this,"_duration",void 0),this._duration=n},[{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)}}])}(),ze=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("StreamSetupListener")),s()(this,"metricsService",Ne.metricsService),s()(this,"_pageLoadTime",void 0),s()(this,"_startTime",void 0),s()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n},[{key:"success",value:function(e){this.recordStreamMetric(Pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Ee(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 Be(n-this._pageLoadTime).toIsoString(),t,i,new Be(r).toIsoString())}}}])}(),He=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_isSupported",void 0!==O.value.navigatorConnection),s()(this,"_rtt",new b(void 0)),s()(this,"_effectiveType",new b(void 0)),s()(this,"_downlinkThroughputCapacity",new b(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())},[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=O.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=O.value.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=O.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=O.value.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=O.value.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=O.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new g(function(){var e;return null===(e=O.value.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)}))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),We=function(){return o()(function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Ne.applicationActivityMonitor),s()(this,"_networkMonitor",new He),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ie),s()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=n,this._disposables.add(this._networkMonitor),this._metricsService=r,!this._applicationActivityMonitor)throw new Error("SessionTelemetry Failed: No application monitor initialized.");this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe(function(e){i.recordForegroundChange(e)})),this._disposables.add(this._networkMonitor.rtt.subscribe(function(e){e&&i.recordNetworkRTTUpdate(e)})),this._disposables.add(this._networkMonitor.effectiveType.subscribe(function(e){e&&i.recordNetworkTypeChangeUpdate(e)})),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe(function(e){e&&i.recordNetworkDownlinkThroughputCapacityUpdate(e)})))},[{key:"listenOnStreamSetup",value:function(){return new ze(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t,n=Date.now(),r=null===(t=this._applicationActivityMonitor)||void 0===t?void 0:t.getTimeSinceLastChange();r&&(this._metricsService.push({metricType:e?Pe.ApplicationForeground:Pe.ApplicationBackground,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new Be(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Pe.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new Be(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:Pe.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new Be(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:Pe.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new Be(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),qe=o()(function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new b(n),this.tokenExpiring=new b(!1)}),Je=function(){return o()(function e(n){t()(this,e),s()(this,"publisherInitialization",void 0),s()(this,"disposables",void 0),s()(this,"publisherDisposables",void 0),s()(this,"state",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"publishing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"clearFailureCountTimeout",void 0),s()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),s()(this,"name",void 0),this.disposables=new ie,this.publisherDisposables=new ie,this.publisherInitialization=new Date,this.state=new b(Ue.Initializing),this.authorized=new b(!0),this.online=new b(!0),this.loading=new b(!1),this.publishing=new b(!1),this.standby=new b(!1),this.stopped=new b(!1),this.failureCount=new b(0),this.endPoint=new b(null),this.stream=new b(null),this.rtcStatistics=new b(null),this.clearFailureCountTimeout=0,this.name=n&&n.length?n:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0},[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyPublishStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":case"geo-restricted":case"geo-blocked":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applySetRemoteDescriptionStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applyAddIceCandidatesStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Ue.Starting;case"not-found":return Ue.NotFound;case"geo-restricted":return Ue.GeoRestricted;case"geo-blocked":return Ue.GeoBlocked;case"unauthorized":return Ue.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ue.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Ue.ConfigurationError;case"port-in-range-not-found":return Ue.TransientConfigurationError;case"failed":return Ue.Error;default:J(e)}}},{key:"applyUnhandledError",value:function(){this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyUnauthorized",value:function(){this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyNotFound",value:function(){this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"generateScreenName",value:function(){return te.random(12)}}])}(),Ke=o()(function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new b(null),this.peerConnection=new b(null),this.peerConnectionReconnectAttempts=0}),Qe=o()(function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new b(!1),this.isDisposed=!1}),$e=n(847),Ze=n.n($e),Xe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ye=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),et=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ye.Normal:return"Normal";case Ye.Force:return"Force";case Ye.Reset:return"Reset";default:J(e)}}}])}(),tt=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Xe.Keep:return"Keep";case Xe.Reset:return"Reset";default:J(e)}}}])}(),nt=n(981).A,rt=["status","streamId","sharedSecret","lag","rtcConfiguration","setRemoteDescriptionResponse","createAnswerDescriptionResponse","createOfferDescriptionResponse"];function it(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 ot(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function at(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return st(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(st(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,st(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,st(d,"constructor",c),st(c,"constructor",u),u.displayName="GeneratorFunction",st(c,i,"GeneratorFunction"),st(d),st(d,i,"Generator"),st(d,r,function(){return this}),st(d,"toString",function(){return"[object Generator]"}),(at=function(){return{w:o,m:f}})()}function st(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}st=function(e,t,n,r){function o(t,n){st(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},st(e,t,n,r)}var ut=function(){return o()(function e(n,r){if(t()(this,e),s()(this,"_logger",ee.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeout",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeout=r,!r)throw new Error("End point requires a timeout")},[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(g=N()(at().m(function e(){var t,n,r,i,o=this;return at().w(function(e){for(;;)switch(e.n){case 0:return t=this.buildPingUrl(),n=Date.now(),e.n=1,nt.race([O.value.fetch(t,{method:"GET",cache:"no-cache"}),new nt(function(e,n){return O.value.setTimeout(function(){return n(new Error("Ping timed out [".concat(t,"]")))},o._timeout)})]);case 1:if(r=e.v,i=Date.now(),r.ok){e.n=2;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 2:return this._roundTripTime=i-n,e.a(2,this._roundTripTime)}},e,this)})),function(){return g.apply(this,arguments)})},{key:"subscribe",value:(v=N()(at().m(function e(t,n,r){var i,o,a,s,u,c,l,d,f,h,p,v,g,y,m,_,b,C=this,w=arguments;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a=w.length>3&&void 0!==w[3]?w[3]:{},s=re.parseToken(t).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),e.a(2,{status:"unauthorized"});case 1:return u=this.buildUrl([s,"stream","subscribe"]).toString(),c=new O.value.FormData,l=V.sdkVersion,d=0===r&&n?{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}}:{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},e.n=2,null===(i=a.onSubscribeRequestCallback)||void 0===i?void 0:i.call(a,d);case 2:return c.append("jsonBody",JSON.stringify(d)),f=Date.now(),e.p=3,p=null,e.n=4,nt.race([O.value.fetch(u,{method:"POST",body:c}),new nt(function(e){return p=O.value.setTimeout(function(){C._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(u,"]"))),e({status:408})},C._timeout)})]).finally(function(){p&&O.value.clearTimeout(p)});case 4:h=e.v,e.n=6;break;case 5:return e.p=5,b=e.v,this._logger.error("Failed to subscribe",b),e.a(2,{status:"failed"});case 6:if("ok"===(v=this.mapHttpStatusToSubscribeStatus(h))){e.n=8;break}return y={status:v},e.n=7,null===(g=a.onSubscribeResponseCallback)||void 0===g?void 0:g.call(a,y);case 7:return e.a(2,y);case 8:return m=Date.now(),e.n=9,this.convertHttpResponseToSubscribeResponse(s,h);case 9:return _=e.v,this._logger.debug("Got subscribe response [%j] in [%s] ms",_,m-f),e.n=10,null===(o=a.onSubscribeResponseCallback)||void 0===o?void 0:o.call(a,_);case 10:return e.a(2,_)}},e,this,[[3,5]])})),function(e,t,n){return v.apply(this,arguments)})},{key:"publish",value:(p=N()(at().m(function e(t,n,r,i){var o,a,s,u,c,l,d,f,h,p,v,g,y,m=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=re.parseToken(n).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",n),e.a(2,{status:"unauthorized"});case 1:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new O.value.FormData,u=V.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.p=2,h=null,e.n=3,nt.race([O.value.fetch(a,{method:"POST",body:s}),new nt(function(e){return h=O.value.setTimeout(function(){m._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})},m._timeout)})]).finally(function(){h&&O.value.clearTimeout(h)});case 3:f=e.v,e.n=5;break;case 4:return e.p=4,y=e.v,this._logger.error("Failed to publish",y),e.a(2,{status:"failed"});case 5:if("ok"===(p=this.mapHttpStatusToPublishStatus(f))){e.n=6;break}return e.a(2,{status:p});case 6:return v=Date.now(),e.n=7,this.convertHttpResponseToPublishResponse(o,f);case 7:return g=e.v,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-d),e.a(2,g)}},e,this,[[2,4]])})),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=N()(at().m(function e(t,n){var r,i,o,a,s,u,c,l,d,f,h=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new O.value.FormData,o={apiVersion:7,sharedSecret:null==t?void 0:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,nt.race([O.value.fetch(r,{method:"POST",body:i}),new nt(function(e){return u=O.value.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&&O.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,f=e.v,this._logger.error("Failed to set remote description",f),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 6:return d=e.v,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return h.apply(this,arguments)})},{key:"limitBitrate",value:(f=N()(at().m(function e(t,n,r,i,o){var a,s,u,c,l,d,f,h,p,v=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new O.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:tt.convertBitrateStateToBitrateStateType(i),bitrateMode:et.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.p=1,d=null,e.n=2,nt.race([O.value.fetch(a,{method:"POST",body:s}),new nt(function(e){return d=O.value.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&&O.value.clearTimeout(d)});case 2:l=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to set limit bitrate timed",p),e.a(2,{status:"failed"});case 4:return f=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),h=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",f,h-c),e.a(2,{status:f})}},e,this,[[1,3]])})),function(e,t,n,r,i){return f.apply(this,arguments)})},{key:"addIceCandidates",value:(d=N()(at().m(function e(t,n,r){var i,o,a,s,u,c,l,d,f,h,p,v=this,g=arguments;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=g.length>3&&void 0!==g[3]?g[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new O.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.p=1,l=null,e.n=2,nt.race([O.value.fetch(o,{method:"POST",body:a}),new nt(function(e){return l=O.value.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&&O.value.clearTimeout(l)});case 2:c=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to add ice candidates",p),e.a(2,{status:"failed"});case 4:if("ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.n=5;break}return e.a(2,{status:d});case 5:return f=Date.now(),e.n=6,this.convertHttpResponseToAddIceCandidatesResponse(c);case 6:return h=e.v,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",h,f-u),e.a(2,h)}},e,this,[[1,3]])})),function(e,t,n){return d.apply(this,arguments)})},{key:"destroyStream",value:(l=N()(at().m(function e(t,n){var r,i,o,a,s,u,c,l,d,f,h=this;return at().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new O.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,nt.race([O.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new nt(function(e){return u=O.value.setTimeout(function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})},h._timeout)})]).finally(function(){u&&O.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,f=e.v,this._logger.error("Failed to delete stream",f),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToDestroyStreamResponse(s);case 6:return d=e.v,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return l.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=N()(at().m(function e(t,n){var r,i,o,a;return at().w(function(e){for(;;)switch(e.n){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new O.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(i,o);case 1:return e.a(2)}},e,this)})),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new O.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,c()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new O.value.URL(this._uri),t=V.sdkVersion,n=we.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=N()(at().m(function e(t,n){var r,i,o,a,s,u,c,l,d,f,h;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i=r.status,o=r.streamId,a=r.sharedSecret,s=r.lag,u=r.rtcConfiguration,c=r.setRemoteDescriptionResponse,l=r.createAnswerDescriptionResponse,d=r.createOfferDescriptionResponse,f=Ze()(r,rt),h=ot({status:i,stream:{tenancy:t,streamId:o,sharedSecret:a},lag:s},f),u&&(h.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(u)),null!=c&&c.sessionDescription&&(h.setRemoteDescriptionResponse={sessionDescription:c.sessionDescription}),null!=l&&l.sessionDescription&&(h.createAnswerDescriptionResponse={sessionDescription:l.sessionDescription}),null!=d&&d.sessionDescription&&(h.createOfferDescriptionResponse={sessionDescription:d.sessionDescription}),e.a(2,h)}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=N()(at().m(function e(t,n){var r,i;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret}},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.a(2,i)}},e,this)})),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=N()(at().m(function e(t){var n,r;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.a(2,r)}},e)})),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=N()(at().m(function e(t){var n,r;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.a(2,r)}},e)})),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=N()(at().m(function e(t){var n,r;return at().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},e.a(2,r)}},e)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,l,d,f,h,p,v,g}(),ct=n(981).A;function lt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return dt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(dt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,dt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,dt(d,"constructor",c),dt(c,"constructor",u),u.displayName="GeneratorFunction",dt(c,i,"GeneratorFunction"),dt(d),dt(d,i,"Generator"),dt(d,r,function(){return this}),dt(d,"toString",function(){return"[object Generator]"}),(lt=function(){return{w:o,m:f}})()}function dt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}dt=function(e,t,n,r){function o(t,n){dt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},dt(e,t,n,r)}var ft=function(){return o()(function e(n){if(t()(this,e),s()(this,"_logger",ee.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Me.getMetricsService(n.toString()),this._uri=n},[{key:"discoverNearbyEndPoints",value:(n=N()(lt().m(function e(t,n){var r,i,o,a;return lt().w(function(e){for(;;)switch(e.n){case 0:if(n){e.n=1;break}throw new Error("Discovery requires timeout");case 1:return r=t.toString(),e.n=2,ct.race([O.value.fetch(r,{method:"GET",cache:"no-cache"}),new ct(function(e,t){return O.value.setTimeout(function(){return t(new Error("Discovery timed out [".concat(r,"]")))},n)})]);case 2:if((i=e.v).ok){e.n=3;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 3:if(null!==i.body){e.n=4;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 4:return e.n=5,i.text();case 5:return o=e.v,a=o.split(","),e.a(2,a.map(function(e){return new ut(e,n)}))}},e)})),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=N()(lt().m(function e(){var t,n,r,i,o,a,s=this,u=arguments;return lt().w(function(e){for(;;)switch(e.n){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ke.buildDiscoveryUrl(this._uri),e.n=1,this.discoverNearbyEndPoints(new O.value.URL(n),t);case 1:return r=e.v,i=0,o=function(){return new ct(function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))})},e.n=2,ct.race(r.map(function(e){return e.ping().catch(function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,o()}).then(function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:Pe.RoundTripTime,runtime:(n-Ne.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e})}));case 2:return a=e.v,e.a(2,a)}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),ht=n(981).A;function pt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return vt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(vt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,vt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,vt(d,"constructor",c),vt(c,"constructor",u),u.displayName="GeneratorFunction",vt(c,i,"GeneratorFunction"),vt(d),vt(d,i,"Generator"),vt(d,r,function(){return this}),vt(d,"toString",function(){return"[object Generator]"}),(pt=function(){return{w:o,m:f}})()}function vt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}vt=function(e,t,n,r){function o(t,n){vt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},vt(e,t,n,r)}var gt=function(){function e(){throw t()(this,e),new Error("Discovery is a static class that may not be instantiated")}return o()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(r=N()(pt().m(function t(){return pt().w(function(t){for(;;)if(0===t.n)return t.a(2,new ht(function(t){var n=O.subscribe(function(r){if(r){var i=new r.URL(Ne.discoveryUri.value);return e.discoverClosestEndPointWithCaching(i).then(t).then(function(){return n.dispose()})}})}))},t)})),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=N()(pt().m(function t(n){var r,i,o;return pt().w(function(t){for(;;)switch(t.n){case 0:if(!((r=n.toString())in e._cache)){t.n=1;break}return t.a(2,e._cache[r]);case 1:return i=new ft(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then(function(){O.value.setTimeout(function(){e._cache[r]===o&&delete e._cache[r]},6e4)}).catch(function(){delete e._cache[r]}),t.a(2,o)}},t)})),function(e){return n.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();n in e._cache&&delete e._cache[n]}}]);var n,r}();s()(gt,"_cache",{}),gt.precacheClosestEndPointDiscovery();var yt=n(715),mt=n.n(yt),_t=function(){return o()(function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_audioCodec",void 0),s()(this,"_videoCodec",void 0),s()(this,"_isAudioTrackEnabled",void 0),s()(this,"_isVideoTrackEnabled",void 0),this._sdp=n;var r=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)},[{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){var n,r=(null===(n=t.find(function(t){return t.includes("m=".concat(e))}))||void 0===n?void 0:n.split(" ")[3])||"",i=t.find(function(e){return e.includes("a=rtpmap:".concat(r))});return((null==i?void 0:i.split(" ")[1])||"").split("/")[0]}}])}(),bt=n(981).A;function Ct(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return wt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(wt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,wt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,wt(d,"constructor",c),wt(c,"constructor",u),u.displayName="GeneratorFunction",wt(c,i,"GeneratorFunction"),wt(d),wt(d,i,"Generator"),wt(d,r,function(){return this}),wt(d,"toString",function(){return"[object Generator]"}),(Ct=function(){return{w:o,m:f}})()}function wt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}wt=function(e,t,n,r){function o(t,n){wt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},wt(e,t,n,r)}var kt=function(){return o()(function e(n,r,i){var o,a,u,c,l=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("RtcPublishMonitor")),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new b({})),s()(this,"_disposables",new ie),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",void 0),s()(this,"_monitorGeneration",0),s()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentLocalDescription)&&void 0!==a&&a.sdp&&null!==(u=this._peerConnection)&&void 0!==u&&null!==(c=u.currentRemoteDescription)&&void 0!==c&&c.sdp){var d=new _t(this._peerConnection.currentLocalDescription.sdp),f=new _t(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=f.audioCodec,this._estimatedVideoCodec=f.videoCodec,this._availableTracks={audio:d.isAudioTrackEnabled&&f.isAudioTrackEnabled,video:d.isVideoTrackEnabled&&f.isVideoTrackEnabled};var h=!0;this._disposables.add(i.subscribe(function(e){h?h=!1:e&&l._isMonitorRunning&&(l._monitorGeneration++,O.value.clearTimeout(l._updateTimeout),l._logger.debug("Restarting stats polling after foreground transition"),l.updateStatistic())})),this.updateStatistic()}},[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._monitorGeneration++,this._isMonitorRunning=!1,this._peerConnection=null,this._disposables.dispose(),O.value.clearTimeout(this._updateTimeout),this._updateTimeout=void 0}},{key:"updateStatistic",value:(e=N()(Ct().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,f=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!E.getStatsPromiseBasedDisabled){e.n=1;break}return e.a(2);case 1:if(t=this._monitorGeneration,n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.p=2,o=null===(i=this._peerConnection)||void 0===i?void 0:i.getStats(null)){e.n=3;break}return e.a(2);case 3:return a=new bt(function(e){r=O.value.setTimeout(function(){return e(void 0)},5e3)}),e.n=4,bt.race([o,a]);case 4:if(s=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=5;break}return e.a(2);case 5:s?(u={},c=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(c=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=c),u.video&&(u.video.roundTripTime=c)),"candidate-pair"===e.type&&e.lastPacketSentTimestamp&&(l=e.lastPacketSentTimestamp,u.audio&&(u.audio.lastPacketSentTimestamp=l),u.video&&(u.video.lastPacketSentTimestamp=l)),"outbound-rtp"===e.type){var t,r=e.kind||e.mediaType||n(e),i="";if(s.forEach(function(t){t.id===e.codecId&&(i=t.mimeType)}),r&&null!==(t=f._availableTracks)&&void 0!==t&&t[r]){var o,a,d,h,p,v,g,y=(e.bytesSent||0)-(null!==(o=null===(a=f._rtcStatistic.value)||void 0===a||null===(d=a[r])||void 0===d?void 0:d.bytesSent)&&void 0!==o?o:0),m=e.timestamp-(null===(h=f._rtcStatistic.value)||void 0===h||null===(p=h[r])||void 0===p?void 0:p.timestamp),_=y&&m?Math.floor(8*y/m*1e3):0;if(u[r]={ssrc:e.ssrc,mediaType:r,timestamp:e.timestamp,bitrate:_,bytesSent:e.bytesSent,packetsSent:e.packetsSent,retransmittedBytesSent:e.retransmittedBytesSent,codec:i||f.getCodecByType(r),roundTripTime:c},(e.lastPacketSentTimestamp||l)&&(u[r].lastPacketSentTimestamp=e.lastPacketSentTimestamp||l),"video"===r&&(u[r].firCount=e.firCount,u[r].frameHeight=e.frameHeight,u[r].frameWidth=e.frameWidth,u[r].framesEncoded=e.framesEncoded,u[r].framesSent=e.framesSent,u[r].headerBytesSent=e.headerBytesSent,u[r].hugeFramesSent=e.hugeFramesSent,u[r].pliCount=e.pliCount,u[r].qpSum=e.qpSum,u[r].totalEncodeTime=e.totalEncodeTime,u[r].totalEncodedBytesTarget=e.totalEncodedBytesTarget,null!==(v=f._rtcStatistic.value)&&void 0!==v&&null!==(g=v.video)&&void 0!==g&&g.framesEncoded)){var b=(e.framesEncoded-f._rtcStatistic.value.video.framesEncoded)/(u[r].timestamp-f._rtcStatistic.value.video.timestamp)*1e3;u[r].fps=b?Math.round(100*b)/100:0}}}}),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,d=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",d);case 8:return e.p=8,O.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=O.value.setTimeout(function(){return f.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),St=function(){return o()(function e(){throw t()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")},null,[{key:"truncateIceServers",value:function(e){var t=[];if(!e.iceServers)return e;for(var 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}}])}(),Tt=n(981).A;function xt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Ot(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Ot(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ot(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Ot(d,"constructor",c),Ot(c,"constructor",u),u.displayName="GeneratorFunction",Ot(c,i,"GeneratorFunction"),Ot(d),Ot(d,i,"Generator"),Ot(d,r,function(){return this}),Ot(d,"toString",function(){return"[object Generator]"}),(xt=function(){return{w:o,m:f}})()}function Ot(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Ot=function(e,t,n,r){function o(t,n){Ot(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Ot(e,t,n,r)}function Pt(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 Et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Pt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Rt=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_logger",ee.getLogger("RealTimePublisher")),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i},[{key:"start",value:function(e,t,n){var r=this;if(!O.value.navigatorIsOnLine)return this._publisherContext.state.value=Ue.Offline,Tt.resolve();var i=this._peerConnectionContext.mediaStream.value;if(!i)return this._logger.error("Publish failed no media stream provided"),this._publisherContext.state.value=Ue.ConfigurationError,Tt.resolve();var o=i.getTracks().reduce(function(e,t){return"audio"===t.kind||"video"===t.kind?e.push(t.kind):r._logger.warn("[%s] Track kind is not supported",t.kind),e},[]);return Tt.all([gt.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("sendonly",o).then(function(e){var t=e.localOffer,n=e.peerConnection;return r._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}})]).then(function(e){var n=mt()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),E.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(s.close(),s.dispose(),!Ne.forceGarbageCollectionOnRestart||E.isMobile&&Ne.skipGarbageCollectionOnMobileDevices||Ge.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,a,r._publisherContext.failureCount.value)}).then(function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),"ok"!==t)return r._publisherContext.stream.value=null,void r._logger.info("[%s] Publish failed with status [%s]",r._publisherContext.streamId,t);var i=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;return r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,a,s,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then(function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||Ne.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=O.value.setTimeout(function(){var t;r._publisherContext.stream.value!==i||o||null===(t=r._publisherContext.endPoint.value)||void 0===t||t.addIceCandidates(i,l,c).then(function(t){var n=t.status,a=t.options;if("ok"===n)null!=a&&a.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,n,a);else{if(r._publisherContext.stream.value!==i)return;if(r._peerConnectionContext.peerConnection.value!==e)return;r._publisherContext.state.value=r.mapAddIceCandidatesStatusToPublisherStatus(n),r._publisherContext.applyAddIceCandidatesStatus(n),r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n,e)})}}).catch(function(t){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,t),r._publisherContext.state.value=Ue.ConnectionError,r._publisherContext.applyUnhandledError(),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates",r._publisherContext.streamId,e)}))})},100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=Ue.ConnectionError,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch(function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)})};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),void r.reconnectPeerConnection(e,t);case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:J(e.iceConnectionState)}}},new Tt(function(e){e()}).then(function(){if(a)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,a.sessionDescription,e.message),e})}).then(function(){var t;if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,null==u||null===(t=u.sessionDescription)||void 0===t?void 0:t.sdp),e.setRemoteDescription(u.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e})}).then(function(){if(s)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e}).then(function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})}).then(function(e){r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp);var t=r._publisherContext.endPoint.value;if(!t)throw new Error("Failed to set remote description, EndPoint is not set");return t.setRemoteDescription(i,e)}).then(function(t){var n=t.status,i=t.sessionDescription;if(r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),r._publisherContext.applySetRemoteDescriptionStatus(n),"ok"===n)return r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,null==i?void 0:i.sdp),e.setLocalDescription(i).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})})}).then(function(){var t;if(n.success(r._publisherContext.streamId),r._publisherContext.state.value!==Ue.Starting)return Tt.resolve();r._publisherContext.state.value=Ue.Publishing,r._publisherContext.publishing.value=!0;var i=new kt(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0,Ne.applicationActivityMonitor.isForeground);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe(function(e){r._publisherContext.rtcStatistics.value=e}),Tt.resolve()})})})}},{key:"applyRtcConfiguration",value:(e=N()(xt().m(function e(t,n){var r;return xt().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=St.truncateIceServers(n),e.a(2,Ne.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=Et(Et({},t.getConfiguration()),n),t.setConfiguration(r),e.a(2,t)}},e)})),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Ue.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ne.maximalNumberOfPeerConnectionReconnectAttempts||!Ne.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(E.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=O.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);return void this._publisherContext.disposables.add(new g(function(){return O.value.clearTimeout(o)}))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then(function(r){return e.setLocalDescription(r).then(function(){return e.setLocalDescription(a).then(function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=O.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);n._publisherContext.disposables.add(new g(function(){return O.value.clearTimeout(r)}))}else n._publisherContext.state.value=Ue.Publishing})})}).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:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Ue.Starting;case"unauthorized":return Ue.Unauthorized;case"not-found":return Ue.NotFound;case"capacity":case"rate-limited":case"timeout":return Ue.Recovering;case"failed":return Ue.Error;default:J(e)}}},{key:"mapAddIceCandidatesStatusToPublisherStatus",value:function(e){switch(e){case"ok":return this._publisherContext.state.value;case"unauthorized":return Ue.Unauthorized;case"not-found":return Ue.NotFound;case"capacity":case"rate-limited":case"timeout":return Ue.Recovering;case"failed":return Ue.Error;default:J(e)}}}]);var e}(),Lt=n(981).A;function Dt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Ft(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function h(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],h=f.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((i=n<2&&h<o[1])?(s=0,f.v=r,f.n=o[1]):h<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),h(s,u)):f.n=u:f.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(r,f))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Ft(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ft(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Ft(d,"constructor",c),Ft(c,"constructor",u),u.displayName="GeneratorFunction",Ft(c,i,"GeneratorFunction"),Ft(d),Ft(d,i,"Generator"),Ft(d,r,function(){return this}),Ft(d,"toString",function(){return"[object Generator]"}),(Dt=function(){return{w:o,m:f}})()}function Ft(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Ft=function(e,t,n,r){function o(t,n){Ft(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Ft(e,t,n,r)}var jt=function(){return o()(function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",ee.getLogger("Publisher")),s()(this,"_tokenContext",void 0),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_publisherStartTime",void 0),s()(this,"_readOnlyToken",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPublishing",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),this._tokenContext=new qe(r),this._publisherContext=new Je(i),this._peerConnectionContext=new Ke,this._stateContext=new Qe,this._exponentialBackoff=new xe,this._publisherStartTime=Date.now(),this._readOnlyToken=new C(this._tokenContext.token),this._readOnlyPeerConnection=new C(this._peerConnectionContext.peerConnection),this._readOnlyState=new C(this._publisherContext.state),this._readOnlyTokenExpiring=new C(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new C(this._publisherContext.authorized),this._readOnlyOnline=new C(this._publisherContext.online),this._readOnlyLoading=new C(this._publisherContext.loading),this._readOnlyPublishing=new C(this._publisherContext.publishing),this._readOnlyStandby=new C(this._publisherContext.standby),this._readOnlyStopped=new C(this._publisherContext.stopped),this._readOnlyFailureCount=new C(this._publisherContext.failureCount),this._readOnlyEndPoint=new C(this._publisherContext.endPoint),this._readOnlyStream=new C(this._publisherContext.stream),this._readOnlyRtcStatistics=new C(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var a=re.parseToken(this._tokenContext.token.value),u=(a.uri||Ne.discoveryUri.value).toString();Ne.tenancy.value=a.tenancy||Ne.tenancy.value,ke.uri.value=u,this._metricsService=Me.getMetricsService(u),this._sessionTelemetry=new We(Ne.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe(function(e){o._publisherContext.clearFailureCountTimeout&&O.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Ue.Publishing&&(o._publisherContext.clearFailureCountTimeout=O.value.setTimeout(function(){o._publisherContext.failureCount.value=0},3e3))}));var c=function(){o._publisherContext.stream.value&&o._publisherContext.endPoint.value&&o._publisherContext.endPoint.value.destroyStreamOnUnmount(o._publisherContext.stream.value,"client:termination-on-window-unload")};O.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new g(function(){O.value.removeWindowEventListener("beforeunload",c)})),this.start()},[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=re.parseToken(this._tokenContext.token.value),n=(t.uri||Ne.discoveryUri.value).toString();Ne.tenancy.value=t.tenancy||Ne.tenancy.value,ke.uri.value=n,this._metricsService=Me.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{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:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{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._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=N()(Dt().m(function e(t){var n=this;return Dt().w(function(e){for(;;)if(0===e.n)return e.a(2,new Lt(function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe(function(r){r||(n.processStop(t),e())}))}))},e)})),function(e){return a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=Ue.Stopped}},{key:"dispose",value:(i=N()(Dt().m(function e(){var t=this;return Dt().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0}))},e,this)})),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return re.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ne.discoveryUri.value),new O.value.URL(Ne.discoveryUri.value))}},{key:"start",value:(r=N()(Dt().m(function e(){return Dt().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._stateContext.isStarting.value){e.n=2;break}return this._logger.info("Publisher is already starting, skipping start"),e.a(2);case 2:return this._stateContext.isStarting.value=!0,e.a(2,this.processStart())}},e,this)})),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=N()(Dt().m(function e(){var t,n,r,i,o,a=this;return Dt().w(function(e){for(;;)switch(e.n){case 0:if(this._publisherContext.state.value=Ue.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),re.isEncodedEdgeTokenValid(t)){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Ue.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 1:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe(function(e){e!==Ue.Error&&e!==Ue.Recovering||gt.clearCachedClosestEndpoint(r)})),i=function(){return new Lt(function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())})},o=new Rt(this._publisherContext,this._peerConnectionContext,i),e.a(2,o.start(r,t,n).then(function(){a._publisherContext.loading.value=!1}).catch(function(e){n.fail(),a._publisherContext.failureCount.value++,a._publisherContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._publisherContext.state.value=Ue.ClientStartError,a._logger.error("Failed to start publishing",e)}).finally(function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Ue.Publishing&&Ne.automaticRetryOnFailure){var e=O.value.setTimeout(function(){a.handleStreamFailure().catch(function(e){a._logger.error("Failed handling stream failure",e)})},a.getRetryInterval());a._publisherContext.disposables.add(new g(function(){O.value.clearTimeout(e)}))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0}))}},e,this)})),function(){return n.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach(function(e){var n;null===(n=t._peerConnectionContext.peerConnection.value)||void 0===n||n.getSenders().forEach(function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)})})}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case Ue.Offline:return 15e3;case Ue.Initializing:case Ue.NotFound:case Ue.Error:case Ue.Recovering:case Ue.Unauthorized:case Ue.GeoRestricted:case Ue.GeoBlocked:case Ue.Stopped:case Ue.Starting:case Ue.Publishing:case Ue.Reconnecting:case Ue.UnsupportedFeature:case Ue.ConfigurationError:case Ue.TransientConfigurationError:case Ue.ConnectionError:case Ue.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:J(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=N()(Dt().m(function e(){var t;return Dt().w(function(e){for(;;)switch(e.n){case 0:t=this._publisherContext.state.value,e.n=t===Ue.Error||t===Ue.Reconnecting||t===Ue.Offline||t===Ue.Recovering||t===Ue.TransientConfigurationError||t===Ue.ConnectionError||t===Ue.ClientStartError?1:t===Ue.Unauthorized?3:t===Ue.GeoRestricted?4:t===Ue.GeoBlocked?5:t===Ue.Stopped?6:t===Ue.Publishing?7:t===Ue.Initializing?8:t===Ue.Starting?9:t===Ue.UnsupportedFeature?10:t===Ue.NotFound?11:t===Ue.ConfigurationError?12:13;break;case 1:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.n=2;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Ue[this._publisherContext.state.value]),e.a(2);case 2:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Ue[this._publisherContext.state.value]),e.a(3,14);case 3:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 4:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 5:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 6:return this._logger.info("Publisher is stopped, skipping retry of start."),e.a(2);case 7:return this._logger.info("Publisher is publishing, skipping retry of start"),e.a(2);case 8:return this._logger.info("Publisher is initializing, skipping retry of start"),e.a(2);case 9:return this._logger.info("Publisher is already starting, skipping retry of start"),e.a(2);case 10:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.a(2);case 11:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.a(2);case 12:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.a(2);case 13:J(this._publisherContext.state.value);case 14:return e.a(2,this.start())}},e,this)})),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ne.forceGarbageCollectionOnRestart||E.isMobile&&Ne.skipGarbageCollectionOnMobileDevices||Ge.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.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._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,n,r,i,a}(),It=function(){return o()(function e(){throw t()(this,e),new Error("Publishers is a static class that may not be instantiated")},null,[{key:"createPublisher",value:function(e){if(!Ne.initialized.value)throw new Error("SDK is not loaded.");return new jt(e.mediaStream,e.token,e.name)}}])}(),Mt={SDK:Ne,Publishers:It,PublisherState:Ue}})(),r})());
3
3
  //# sourceMappingURL=publish.js.map