@phenixrts/sdk 2025.0.2-beta.405 → 2025.0.2

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 (43) hide show
  1. package/channels/debug/channels.js +1282 -1250
  2. package/channels/debug/package.json +1 -1
  3. package/channels/debug.private/channels.js +1195 -1163
  4. package/channels/debug.private/package.json +1 -1
  5. package/channels/debug.provideGlobalScope/channels.js +1252 -1222
  6. package/channels/debug.provideGlobalScope/package.json +1 -1
  7. package/channels/es5.debug.private/channels.js +55 -25
  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 +1403 -1371
  20. package/full/debug/package.json +1 -1
  21. package/full/debug.private/full.js +1316 -1284
  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 +871 -839
  33. package/publish/debug.private/package.json +1 -1
  34. package/publish/debug.private/publish.js +871 -839
  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
  42. package/types/metrics/MetricsService.d.ts +1 -0
  43. package/types/telemetry/TelemetryService.d.ts +1 -0
@@ -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:()=>p});var r=n(738),i=n.n(r),o=n(383),s=n.n(o),a=n(579),u=n.n(a),c=n(693),l=n.n(c),d=u()((function e(t,n,r){s()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),h=function(){function e(t){if(s()(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,s=function(t,a){try{if(a&&("object"===i()(a)||"function"==typeof a)){var u=a.then;if("function"==typeof u)return void u.call(a,(function(e){return s(t,e)}),n)}r[t]=a,0==--o&&e(r)}catch(e){n(e)}},a=0;a<r.length;a++)s(a,r[a])}))}},{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)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new h((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){return this.then((function(t){return h.resolve(e()).then((function(){return t}),(function(){return null}))}),(function(t){return h.resolve(e()).then((function(){return h.reject(t)}),(function(){return null}))}))};var p=h},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,s,a){try{var u=e[s](a),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 s=e.apply(t,n);function a(e){i(s,r,o,a,u,"next",e)}function u(e){i(s,r,o,a,u,"throw",e)}a(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,s,a=[],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)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var r=n(981).A,i=n(738).default;function o(){"use strict";e.exports=o=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},s=Object.prototype,a=s.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof C?t:C,o=Object.create(i.prototype),s=new M(r||[]);return u(o,"_invoke",{value:E(e,n,s)}),o}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var g="suspendedStart",m="suspendedYield",y="executing",_="completed",b={};function C(){}function w(){}function k(){}var S={};p(S,l,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(A([])));T&&T!==s&&a.call(T,l)&&(S=T);var L=k.prototype=C.prototype=Object.create(S);function P(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(r,o,s,u){var c=v(e[r],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var r;u(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function E(e,n,r){var i=g;return function(o,s){if(i===y)throw Error("Generator is already running");if(i===_){if("throw"===o)throw s;return{value:t,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var u=D(a,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===g)throw i=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=v(e,n,r);if("normal"===c.type){if(i=r.done?_:m,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=_,r.method="throw",r.arg=c.arg)}}}function D(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,D(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=v(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var s=o.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function A(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(a.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return w.prototype=k,u(L,"constructor",{value:k,configurable:!0}),u(k,"constructor",{value:w,configurable:!0}),w.displayName=p(k,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,p(e,h,"GeneratorFunction")),e.prototype=Object.create(L),e},n.awrap=function(e){return{__await:e}},P(R.prototype),p(R.prototype,d,(function(){return this})),n.AsyncIterator=R,n.async=function(e,t,i,o,s){void 0===s&&(s=r);var a=new R(f(e,t,i,o),s);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},P(L),p(L,h,"Generator"),p(L,l,(function(){return this})),p(L,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=A,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;I(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:A(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},n}e.exports=o,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),s=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),s=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var 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:()=>Re,Publishers:()=>ot,SDK:()=>Te,default:()=>st});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),s=n(693),a=n.n(s),u=n(452),c=n.n(u),l=n(72),d=n.n(l),h=n(511),p=n.n(h),f=function(){return o()((function e(n){t()(this,e),a()(this,"_disposed",void 0),a()(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 v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(v=function(){return!!e})()}var g,m=function(e){function n(e,r){return t()(this,n),i=this,o=n,s=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=d()(o),c()(i,v()?Reflect.construct(o,s||[],d()(i).constructor):o.apply(i,s));var i,o,s}return p()(n,e),o()(n)}(f),y=function(){return o()((function e(n){t()(this,e),a()(this,"_listeners",void 0),a()(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))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new m(this._listeners,e)}}])}(),_=function(){return o()((function e(n){t()(this,e),a()(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)}}])}(),b={document,location,navigator,window},C=function(){function e(n){t()(this,e),a()(this,"_document",void 0),a()(this,"_location",void 0),a()(this,"_navigator",void 0),a()(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:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{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:"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)}}])}();g=C,a()(C,"_instance",new y(new g(b))),a()(C,"_readOnlyInstance",new _(g._instance));var w,k,S,x=C.getInstance(),T=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""}}])}();w=T,a()(T,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),a()(T,"_browserNameAndVersion",w.parseBrowserNameAndVersion()),a()(T,"_browserName",w.parseBrowserName()),a()(T,"_browserMajorVersion",w.parseBrowserMajorVersion()),a()(T,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(k=navigator)||void 0===k?void 0:k.userAgent)),a()(T,"_isAndroid",/Android/i.test(null===(S=navigator)||void 0===S?void 0:S.userAgent)),a()(T,"_isChrome69",w._browserNameAndVersion.includes("Chrome/69.")),a()(T,"_isChrome70",w._browserNameAndVersion.includes("Chrome/70.")),a()(T,"_isChrome71",w._browserNameAndVersion.includes("Chrome/71.")),a()(T,"_isChrome72",w._browserNameAndVersion.includes("Chrome/72.")),a()(T,"_isChrome74",w._browserNameAndVersion.includes("Chrome/74.")),a()(T,"_isChrome75",w._browserNameAndVersion.includes("Chrome/75.")),a()(T,"_isChrome76",w._browserNameAndVersion.includes("Chrome/76.")),a()(T,"_isChrome77",w._browserNameAndVersion.includes("Chrome/77."));var L=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return T.isChrome74||T.isChrome75||T.isChrome76||T.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return T.isChrome69||T.isChrome70||T.isChrome71||T.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=69||"Firefox"===T.browserName&&T.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=63||"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===T.browserName||"SamsungBrowser"===T.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==T.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===T.browserName&&"function"==typeof(null===(e=x.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion>=71||"Firefox"===T.browserName&&T.browserMajorVersion>=69||"Safari"===T.browserName}},{key:"isMobile",get:function(){return T.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==T.browserName&&"Safari"!==T.browserName}}])}(),P=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),R=function(){return o()((function e(n,r,i){t()(this,e),a()(this,"_category",void 0),a()(this,"_appenders",void 0),a()(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>P.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?L.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}}])}(),E=function(){return o()((function e(){t()(this,e),a()(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}),[])}}])}(),D=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"}}}])}();a()(D,"_sendLocalCandidates",void 0),a()(D,"_sendLogs",void 0),a()(D,"_sendMetrics",void 0),a()(D,"_logToConsole",void 0),D.applyFeatures();var O=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return P[D.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return P[D.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return P.Info}}])}(),I=function(){return o()((function e(){t()(this,e),a()(this,"_threshold",O.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),a()(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(P[e],"] ").concat(t);e<P.Warn?console.log(i):console.error(i)}}}])}(),A=n(293),F=n.n(A),N=n(756),j=n.n(N),V=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}}])}(),U=function(){return o()((function e(){t()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2025-01-29T08:29:50.515Z (2025.0.2-beta.405)"}catch(e){return this._defaultVersion}}}])}();a()(U,"_defaultVersion",(new Date).toISOString());var B=function(){return o()((function e(n){var r;t()(this,e),a()(this,"_telemetryConfiguration",void 0),a()(this,"_logs",[]),a()(this,"_isSending",!1),a()(this,"_domain",(null===(r=x.value)||void 0===r?void 0:r.locationHostname)||""),this._telemetryConfiguration=n}),[{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:P[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:U.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<P.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=F()(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new x.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,x.value.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=F()(j().mark((function e(){var t,n,r,i,o,s=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)&&x.value){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?V.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.abrupt("return",this.sendLogs(o).then((function(e){return s._isSending=!1,s.sendLogsIfAble(),e})).catch((function(){s._isSending=!1,s.sendLogsIfAble()})));case 12:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,n}(),z=function(){return o()((function e(n){t()(this,e),a()(this,"_telemetryService",void 0),a()(this,"_tenancy",void 0),a()(this,"_sessionId",void 0),a()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new B(n)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),G=function(){return o()((function e(){t()(this,e),a()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),a()(this,"_tenancy","-"),a()(this,"_sessionId","-"),a()(this,"_environment","-"),a()(this,"_pageLoadTime",0),a()(this,"_threshold",O.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new x.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}}])}(),H=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},W=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case P.Off:return"Off";case P.Trace:return"Trace";case P.Debug:return"Debug";case P.Info:return"Trace";case P.Warn:return"Warn";case P.Error:return"Error";case P.Fatal:return"Fatal";case P.All:return"All";default:H(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return P.Off;case"Trace":return P.Trace;case"Debug":return P.Debug;case"Info":return P.Info;case"Warn":return P.Warn;case"Error":return P.Error;case"Fatal":return P.Fatal;case"All":return P.All;default:H(e)}}}])}(),J=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),q=function(){return o()((function e(){t()(this,e),a()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),a()(this,"_tenancy","-"),a()(this,"_sessionId","-"),a()(this,"_environment","-"),a()(this,"_threshold",K.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new x.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}}])}(),K=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return J[D.sendMetrics]}}])}(),Q=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case J.Off:return"Off";case J.Essential:return"Essential";case J.All:return"All";default:H(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return J.Off;case"Essential":return J.Essential;case"All":return J.All;default:H(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":Q.convertTelemetryLevelToTelemetryLevelType(K.defaultTelemetryLevel),"phenix-logging-level":W.convertLoggingLevelToLoggingLevelType(O.defaultLoggingLevel),"phenix-console-logging-level":W.convertLoggingLevelToLoggingLevelType(O.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":W.convertLoggingLevelToLoggingLevelType(O.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=x.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 x.value.URLSearchParams(x.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),$=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 R(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");P[e]&&this._threshold.setThreshold(P[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Y.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(P[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new M(e||O.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||O.defaultTelemetryLoggingLevel,this._appenders.add(new z(this._telemetryConfiguration))}}])}();a()($,"_loggers",{}),a()($,"_appenders",new E),a()($,"_threshold",new I),a()($,"_telemetryConfiguration",new G),$.applyLoggerConfigFromParameterConfiguration();var Z=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)}}])}(),X=function(){return o()((function e(n){var r,i;t()(this,e),a()(this,"_applicationId",void 0),a()(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 x.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}}])}(),ee=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 X(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new X(r)}catch(t){return e._logger.error("Cannot parse token value",t),new X(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();a()(ee,"_logger",$.getLogger("EdgeAuthParser"));var te=function(){return o()((function e(){t()(this,e),a()(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,"]")}}])}(),ne="visibilitychange",re=function(){return o()((function e(){t()(this,e),a()(this,"_disposables",new te),a()(this,"_readOnlyIsForeground",void 0),a()(this,"_isForeground",void 0),a()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new y(!0),this._readOnlyIsForeground=new _(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!x.value.documentIsHidden},n=!1;x.value.addDocumentEventListener(ne,t,n),this._disposables.add(new f((function(){return x.value.removeDocumentEventListener(ne,t,n)})))}}])}(),ie=n(981).A,oe=function(){return o()((function e(n){t()(this,e),a()(this,"_logger",$.getLogger("VanillaPeerConnection")),a()(this,"_peerConnection",void 0),L.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new x.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!L.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!L.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=F()(j().mark((function e(t){var n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!L.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new ie((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createOffer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=F()(j().mark((function e(t){var n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!L.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new ie((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createAnswer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=F()(j().mark((function e(t){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return e.abrupt("return",this._peerConnection.setLocalDescription(L.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=F()(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(L.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 5:case"end":return e.stop()}}),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 ie((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}(),se=n(981).A,ae=function(){return o()((function e(){t()(this,e)}),[{key:"createPeerConnection",value:(e=F()(j().mark((function e(t){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new se((function(e){x.subscribe((function(n){n&&e(new oe(t))}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ue=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(){L.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(r=F()(j().mark((function t(){return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=F()(j().mark((function t(){var n,r,i,o,s=arguments;return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]&&s[1],!e._cached||e._cached.direction!==n||r){t.next=6;break}return i=e._cached.peerConnection,e._cached=null,t.abrupt("return",i);case 6:return o=L.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=F()(j().mark((function e(t){var r,i,o;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:n}),r=t.addTransceiver("video",{direction:n}),e.t0=i,e.t1=r,e.t2=t,e.next=9,t.createOffer(void 0);case 9:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 11:return o="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(o);case 15:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})}]);var n,r}();a()(ue,"_logger",$.getLogger("PeerConnectionService")),a()(ue,"_peerConnectionFactory",new y(new ae)),a()(ue,"_cached",void 0),ue.initiateInitialPrecaching();var ce=function(){return o()((function e(){t()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new x.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}}}])}(),le=function(){return o()((function e(){t()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new x.value.URL(e).origin}catch(e){return""}}}])}(),de=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:""}}}}])}();a()(de,"_discoveryParameters",void 0),de.applyParameters();var he=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 x.value.URL(e.toString()),n=U.sdkVersion,r=de.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()}}])}();a()(he,"_discoveryUri",new y("https://pcast.phenixrts.com/pcast/endPoints"));var pe,fe,ve=n(738),ge=n.n(ve),me=n(132),ye=n.n(me),_e=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),a()(this,"_backoffIntervalInMillisecond",void 0),a()(this,"_minBackoffIntervalInMillisecond",void 0),a()(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)}}])}(),be=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}(be||{}),Ce=be,we=function(){return o()((function e(n){t()(this,e),a()(this,"_metrics",void 0),this._metrics=n}),[{key:"getName",value:function(){return Ce[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Ce.TimeToFirstFrame:case Ce.ChannelCreationTimeToFirstFrame:return J.Essential;case Ce.Stalled:case Ce.Buffering:case Ce.SetupCompleted:case Ce.SetupFailed:case Ce.RoundTripTime:case Ce.DownlinkThroughputCapacity:case Ce.NetworkType:case Ce.ResolutionChanged:case Ce.ApplicationForeground:case Ce.ApplicationBackground:return J.All;default:H(this._metrics)}}}])}(),ke=function(){return o()((function e(n){var r;t()(this,e),a()(this,"_logger",$.getLogger("MetricsService")),a()(this,"_metricsConfiguration",void 0),a()(this,"_exponentialBackoff",void 0),a()(this,"_metrics",[]),a()(this,"_isSending",!1),a()(this,"_failureCount",0),a()(this,"_domain",(null===(r=x.value)||void 0===r?void 0:r.locationHostname)||""),this._metricsConfiguration=n,this._exponentialBackoff=new _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,s=e.kind,a=new we(e.metricType);if(!(this._metricsConfiguration.threshold>a.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:a.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:U.sdkVersion,runtime:i,resource:o,kind:s};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=F()(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new x.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,x.value.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=F()(j().mark((function e(){var t,n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)&&x.value){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void x.value.setTimeout((function(){n._metrics=[].concat(ye()(t),ye()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()}),n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,n}(),Se=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(ge()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new q;return r.sessionId=Te.clientSessionId,r.tenancy=Te.tenancy.value,r.url=ce.getTelemetryUrl(t),r.environment=le.getEnvironmentFromUrl(t),r.threshold=Q.convertTelemetryLevelTypeToTelemetryLevel(Te.telemetryLevel),e._metricsServices[t]=new ke(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();a()(Se,"_metricsServices",{});var xe=(null===(pe=C.getInstance().value)||void 0===pe?void 0:pe.pageLoadTime)||Date.now(),Te=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 xe}},{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 W.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return Q.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return T}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=$.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 z}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new z(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof z}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new z(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Se.getMetricsService(he.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&&Se.setTelemetryLevel(J[t]),e._telemetryLevel.subscribe((function(e){Se.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=le.getEnvironmentFromUrl(t)}));var t=Y.getStringValue("phenix-channel-token");if(t){var n=ee.parseToken(t);return e._tenancy.value=n.tenancy,he.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 he.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(C.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",he.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 re,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&&C.setInstance(n.globalScope),t.discoveryUri&&(he.uri.value=t.discoveryUri),t.peerConnectionFactory&&(ue.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&J[t.telemetryLevel]&&(e._telemetryLevel.value=Q.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&P[t.loggingLevel]&&this._logger.threshold.setThreshold(W.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&P[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(W.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 ce.getTelemetryUrl(e)}}])}();fe=Te,a()(Te,"_automaticallyRetryOnFailure",Y.getBooleanValue("phenix-automatically-retry-on-failure")),a()(Te,"_automaticallyReconnectPeerConnection",Y.getBooleanValue("phenix-automatically-reconnect-peer-connection")),a()(Te,"_automaticallyPlayMediaStream",!0),a()(Te,"_automaticallyMuteVideoOnPlayFailure",!0),a()(Te,"_forceGarbageCollectionOnRestart",Y.getBooleanValue("phenix-force-garbage-collection-on-restart")),a()(Te,"_skipGarbageCollectionOnMobileDevices",Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),a()(Te,"_webPlayerLoader",void 0),a()(Te,"_shakaPlayerLoader",void 0),a()(Te,"_hlsJsLoader",void 0),a()(Te,"_applicationActivityMonitor",void 0),a()(Te,"_environment",new y("")),a()(Te,"_telemetryUrl",new y("https://telemetry.phenixrts.com/telemetry")),a()(Te,"_maximalNumberOfPeerConnectionReconnectAttempts",8),a()(Te,"_telemetryLevel",new y(K.defaultTelemetryLevel)),a()(Te,"_metricsService",void 0),a()(Te,"_metricsConfiguration",void 0),a()(Te,"_sendLocalCandidates",new y(D.sendLocalCandidates)),a()(Te,"_tenancy",new y("")),a()(Te,"_clientSessionId",Z.random(32)),a()(Te,"_loadedTimestamp",new Date),a()(Te,"_logger",$.getLogger("SDK")),a()(Te,"_initialized",new y(!1)),a()(Te,"_readOnlyInitialized",new _(fe._initialized)),a()(Te,"_readOnlyDiscoveryUri",new _(he.uri)),a()(Te,"_readOnlyPeerConnectionFactory",new _(ue.peerConnectionFactory)),C.subscribe(Te.onLoad.bind(Te));var Le=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(){L.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){L.isQueueMicrotaskSupported?x.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):x.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=x.value.documentCreateElement("img");e.src=x.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){x.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Pe=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}(Pe||{}),Re=Pe,Ee=function(){return o()((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),a()(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,s=(n=Math.floor(n/60))%24,a=["PT"];return e&&a.unshift("-"),s&&a.push(s+"H"),o&&a.push(o+"M"),(i||r)&&(a.push(String(i)),r&&a.push("."+this.padStart(r.toString(),3,"0")),a.push("S")),a.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)}}])}(),De=function(){return o()((function e(n){t()(this,e),a()(this,"_logger",$.getLogger("StreamSetupListener")),a()(this,"metricsService",Te.metricsService),a()(this,"_pageLoadTime",void 0),a()(this,"_startTime",void 0),a()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n}),[{key:"success",value:function(e){this.recordStreamMetric(Ce.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Ce.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new we(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 Ee(n-this._pageLoadTime).toIsoString(),t,i,new Ee(r).toIsoString())}}}])}(),Oe=function(){return o()((function e(){t()(this,e),a()(this,"_disposables",new te),a()(this,"_isSupported",void 0!==x.value.navigatorConnection),a()(this,"_rtt",new y(void 0)),a()(this,"_effectiveType",new y(void 0)),a()(this,"_downlinkThroughputCapacity",new y(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=x.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=x.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=x.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=x.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=x.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=x.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new f((function(){var e;return null===(e=x.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()}}])}(),Ie=function(){return o()((function e(n,r){var i=this;if(t()(this,e),a()(this,"_logger",$.getLogger("SessionTelemetry")),a()(this,"_metricsService",void 0),a()(this,"_applicationActivityMonitor",Te.applicationActivityMonitor),a()(this,"_networkMonitor",new Oe),a()(this,"_pageLoadTime",void 0),a()(this,"_disposables",new te),a()(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 De(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?Ce.ApplicationForeground:Ce.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 Ee(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Ce.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 Ee(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:Ce.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 Ee(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:Ce.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 Ee(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Me=o()((function e(n){t()(this,e),a()(this,"token",void 0),a()(this,"tokenExpiring",void 0),this.token=new y(n),this.tokenExpiring=new y(!1)})),Ae=function(){return o()((function e(n){t()(this,e),a()(this,"publisherInitialization",void 0),a()(this,"disposables",void 0),a()(this,"publisherDisposables",void 0),a()(this,"state",void 0),a()(this,"authorized",void 0),a()(this,"online",void 0),a()(this,"loading",void 0),a()(this,"publishing",void 0),a()(this,"standby",void 0),a()(this,"stopped",void 0),a()(this,"failureCount",void 0),a()(this,"endPoint",void 0),a()(this,"stream",void 0),a()(this,"rtcStatistics",void 0),a()(this,"clearFailureCountTimeout",void 0),a()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),a()(this,"name",void 0),this.disposables=new te,this.publisherDisposables=new te,this.publisherInitialization=new Date,this.state=new y(Re.Initializing),this.authorized=new y(!0),this.online=new y(!0),this.loading=new y(!1),this.publishing=new y(!1),this.standby=new y(!1),this.stopped=new y(!1),this.failureCount=new y(0),this.endPoint=new y(null),this.stream=new y(null),this.rtcStatistics=new y(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:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Re.Starting;case"not-found":return Re.NotFound;case"geo-restricted":return Re.GeoRestricted;case"geo-blocked":return Re.GeoBlocked;case"unauthorized":return Re.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Re.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Re.ConfigurationError;case"port-in-range-not-found":return Re.TransientConfigurationError;case"failed":return Re.Error;default:H(e)}}},{key:"generateScreenName",value:function(){return Z.random(12)}}])}(),Fe=o()((function e(){t()(this,e),a()(this,"mediaStream",void 0),a()(this,"peerConnection",void 0),a()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new y(null),this.peerConnection=new y(null),this.peerConnectionReconnectAttempts=0})),Ne=o()((function e(){t()(this,e),a()(this,"isStarting",void 0),a()(this,"isDisposed",void 0),this.isStarting=new y(!1),this.isDisposed=!1})),je=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ve=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ue=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ve.Normal:return"Normal";case Ve.Force:return"Force";case Ve.Reset:return"Reset";default:H(e)}}}])}(),Be=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case je.Keep:return"Keep";case je.Reset:return"Reset";default:H(e)}}}])}(),ze=n(981).A,Ge=function(){return o()((function e(n,r){if(t()(this,e),a()(this,"_logger",$.getLogger("EndPoint")),a()(this,"_uri",void 0),a()(this,"_timeout",void 0),a()(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:(v=F()(j().mark((function e(){var t,n,r,i,o=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,ze.race([x.value.fetch(t,{method:"GET",cache:"no-cache"}),new ze((function(e,n){return x.value.setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(f=F()(j().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f,v,g=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=ee.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([i,"stream","subscribe"]).toString(),s=new x.value.FormData,a=U.sdkVersion,0===r&&n?(u={apiVersion:7,clientVersion:a,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}},s.append("jsonBody",JSON.stringify(u))):(c={apiVersion:7,clientVersion:a,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},s.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,h=null,e.next=13,ze.race([x.value.fetch(o,{method:"POST",body:s}),new ze((function(e){return h=x.value.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){h&&x.value.clearTimeout(h)}));case 13:d=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(p=this.mapHttpStatusToSubscribeStatus(d))){e.next=23;break}return e.abrupt("return",{status:p});case 23:return f=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(i,d);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,f-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(p=F()(j().mark((function e(t,n,r,i){var o,s,a,u,c,l,d,h,p,f,v,g,m=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=ee.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return s=this.buildUrl([o,"stream","publish"]).toString(),a=new x.value.FormData,u=U.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}},a.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},a.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=9,p=null,e.next=13,ze.race([x.value.fetch(s,{method:"POST",body:a}),new ze((function(e){return p=x.value.setTimeout((function(){m._logger.error("Failed to publish",new Error("Publish timed out [".concat(s,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){p&&x.value.clearTimeout(p)}));case 13:h=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(f=this.mapHttpStatusToPublishStatus(h))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,h);case 26:return g=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-d),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=F()(j().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new x.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)),s=Date.now(),e.prev=5,u=null,e.next=9,ze.race([x.value.fetch(r,{method:"POST",body:i}),new ze((function(e){return u=x.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&&x.value.clearTimeout(u)}));case 9:a=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(a);case 22:return d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-s),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return h.apply(this,arguments)})},{key:"limitBitrate",value:(d=F()(j().mark((function e(t,n,r,i,o){var s,a,u,c,l,d,h,p,f=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),a=new x.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Be.convertBitrateStateToBitrateStateType(i),bitrateMode:Ue.convertBitrateModeToBitrateModeType(o)},a.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,ze.race([x.value.fetch(s,{method:"POST",body:a}),new ze((function(e){return d=x.value.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(s,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){d&&x.value.clearTimeout(d)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,p-c),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return d.apply(this,arguments)})},{key:"addIceCandidates",value:(l=F()(j().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f=this,v=arguments;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),s=new x.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},s.append("jsonBody",JSON.stringify(a)),u=Date.now(),e.prev=6,l=null,e.next=10,ze.race([x.value.fetch(o,{method:"POST",body:s}),new ze((function(e){return l=x.value.setTimeout((function(){f._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){l&&x.value.clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,h-u),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"destroyStream",value:(c=F()(j().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new x.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,ze.race([x.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new ze((function(e){return u=x.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&&x.value.clearTimeout(u)}));case 9:a=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(a);case 22:return d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-s),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return c.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=F()(j().mark((function e(t,n){var r,i,o,s;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new x.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(s)),navigator.sendBeacon(i,o);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new x.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,ye()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new x.value.URL(this._uri),t=U.sdkVersion,n=de.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:(s=F()(j().mark((function e(t,n){var r,i;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},lag:r.lag},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=F()(j().mark((function e(t,n){var r,i;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret}},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 6:case"end":return e.stop()}}),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=F()(j().mark((function e(t){var n,r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=F()(j().mark((function e(t){var n,r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=F()(j().mark((function e(t){var n,r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,s,u,c,l,d,h,p,f,v}(),He=n(981).A,We=function(){return o()((function e(n){if(t()(this,e),a()(this,"_logger",$.getLogger("Discovery")),a()(this,"_metricsService",void 0),a()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Se.getMetricsService(n.toString()),this._uri=n}),[{key:"discoverNearbyEndPoints",value:(n=F()(j().mark((function e(t,n){var r,i,o,s;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new Error("Discovery requires timeout");case 2:return r=t.toString(),e.next=5,He.race([x.value.fetch(r,{method:"GET",cache:"no-cache"}),new He((function(e,t){return x.value.setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,s=o.split(","),e.abrupt("return",s.map((function(e){return new Ge(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=F()(j().mark((function e(){var t,n,r,i,o,s,a=this,u=arguments;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=he.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new x.value.URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new He((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,He.race(r.map((function(e){return e.ping().catch((function(t){return a._logger.warn("Failed to ping end point [%s]",e,t),i++,o()})).then((function(t){var n=Date.now();return a._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),a._metricsService.push({metricType:Ce.RoundTripTime,runtime:(n-Te.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 9:return s=e.sent,e.abrupt("return",s);case 11:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,n}(),Je=n(981).A,qe=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=F()(j().mark((function t(){return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Je((function(t){x.subscribe((function(n){if(n){var r=new n.URL(Te.discoveryUri.value);return e.discoverClosestEndPointWithCaching(r).then(t)}}))})));case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=F()(j().mark((function t(n){var r,i,o;return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((r=n.toString())in e._cache)){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new We(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){x.value.setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),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}();a()(qe,"_cache",{}),qe.precacheClosestEndPointDiscovery();var Ke=n(715),Qe=n.n(Ke),Ye=function(){return o()((function e(n){t()(this,e),a()(this,"_sdp",void 0),a()(this,"_audioCodec",void 0),a()(this,"_videoCodec",void 0),a()(this,"_isAudioTrackEnabled",void 0),a()(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]}}])}(),$e=function(){return o()((function e(n,r){var i,o,s,u;if(t()(this,e),a()(this,"_estimatedRoundTripTime",void 0),a()(this,"_estimatedVideoCodec","unknown"),a()(this,"_estimatedAudioCodec","unknown"),a()(this,"_rtcStatistic",new y({})),a()(this,"_peerConnection",void 0),a()(this,"_isMonitorRunning",!0),a()(this,"_updateTimeout",null),a()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(i=this._peerConnection)&&void 0!==i&&null!==(o=i.currentLocalDescription)&&void 0!==o&&o.sdp&&null!==(s=this._peerConnection)&&void 0!==s&&null!==(u=s.currentRemoteDescription)&&void 0!==u&&u.sdp){var c=new Ye(this._peerConnection.currentLocalDescription.sdp),l=new Ye(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=l.audioCodec,this._estimatedVideoCodec=l.videoCodec,this._availableTracks={audio:c.isAudioTrackEnabled&&l.isAudioTrackEnabled,video:c.isVideoTrackEnabled&&l.isVideoTrackEnabled},this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(x.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(e=F()(j().mark((function e(){var t,n,r=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!L.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,null===(t=this._peerConnection)||void 0===t?void 0:t.getStats(null).then((function(e){var t={};if(e){var i,o=r._estimatedRoundTripTime;e.forEach((function(s){if("candidate-pair"===s.type&&s.currentRoundTripTime&&(o=1e3*s.currentRoundTripTime,t.audio&&(t.audio.roundTripTime=o),t.video&&(t.video.roundTripTime=o)),"candidate-pair"===s.type&&s.lastPacketSentTimestamp&&(i=s.lastPacketSentTimestamp,t.audio&&(t.audio.lastPacketSentTimestamp=i),t.video&&(t.video.lastPacketSentTimestamp=i)),"outbound-rtp"===s.type){var a,u=s.kind||s.mediaType||n(s),c="";if(e.forEach((function(e){e.id===s.codecId&&(c=e.mimeType)})),u&&null!==(a=r._availableTracks)&&void 0!==a&&a[u]){var l,d,h,p,f,v,g,m=(s.bytesSent||0)-(null!==(l=null===(d=r._rtcStatistic.value)||void 0===d||null===(h=d[u])||void 0===h?void 0:h.bytesSent)&&void 0!==l?l:0),y=s.timestamp-(null===(p=r._rtcStatistic.value)||void 0===p||null===(f=p[u])||void 0===f?void 0:f.timestamp),_=m&&y?Math.floor(8*m/y*1e3):0;if(t[u]={ssrc:s.ssrc,mediaType:u,timestamp:s.timestamp,bitrate:_,bytesSent:s.bytesSent,packetsSent:s.packetsSent,retransmittedBytesSent:s.retransmittedBytesSent,codec:c||r.getCodecByType(u),roundTripTime:o},(s.lastPacketSentTimestamp||i)&&(t[u].lastPacketSentTimestamp=s.lastPacketSentTimestamp||i),"video"===u&&(t[u].firCount=s.firCount,t[u].frameHeight=s.frameHeight,t[u].frameWidth=s.frameWidth,t[u].framesEncoded=s.framesEncoded,t[u].framesSent=s.framesSent,t[u].headerBytesSent=s.headerBytesSent,t[u].hugeFramesSent=s.hugeFramesSent,t[u].pliCount=s.pliCount,t[u].qpSum=s.qpSum,t[u].totalEncodeTime=s.totalEncodeTime,t[u].totalEncodedBytesTarget=s.totalEncodedBytesTarget,null!==(v=r._rtcStatistic.value)&&void 0!==v&&null!==(g=v.video)&&void 0!==g&&g.framesEncoded)){var b=(s.framesEncoded-r._rtcStatistic.value.video.framesEncoded)/(t[u].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[u].fps=b?Math.round(100*b)/100:0}}}}))}r._rtcStatistic.value=t})).then((function(){r._isMonitorRunning&&(r._updateTimeout=x.value.setTimeout((function(){return r.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),Ze=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}}])}(),Xe=n(981).A;function et(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 tt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?et(Object(n),!0).forEach((function(t){a()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):et(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var nt=function(){return o()((function e(n,r,i){t()(this,e),a()(this,"_logger",$.getLogger("RealTimePublisher")),a()(this,"_publisherContext",void 0),a()(this,"_peerConnectionContext",void 0),a()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i}),[{key:"start",value:function(e,t,n){var r=this;return x.value.navigatorIsOnLine?Xe.all([qe.discoverClosestEndPointWithCaching(e),ue.createPeerConnectionOffer("sendonly").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=Qe()(e,2),i=n[0],o=n[1],s=o.localOffer,a=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"+s.sdp),L.clientOfferDisabled||!a.supportsSetConfiguration||!a.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(a.close(),a.dispose(),!Te.forceGarbageCollectionOnRestart||L.isMobile&&Te.skipGarbageCollectionOnMobileDevices||Le.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,s,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(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,s=e.setRemoteDescriptionResponse,a=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,s,a,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(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||Te.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=x.value.setTimeout((function(){var e;r._publisherContext.stream.value!==i||o||null===(e=r._publisherContext.endPoint.value)||void 0===e||e.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,t)})).catch((function(e){r._logger.error("[%s] 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=Re.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:H(e.iceConnectionState)}}},new Xe((function(e){e()})).then((function(){if(s)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,s.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(a)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setRemoteDescription(a.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;return r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(r._publisherContext.publishing.value=!1,r._publisherContext.standby.value=!0,void(r._publisherContext.stopped.value=!1)):(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;n.success(r._publisherContext.streamId),r._publisherContext.state.value=Re.Publishing,r._publisherContext.publishing.value=!0;var i=new $e(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe((function(e){r._publisherContext.rtcStatistics.value=e})),Xe.resolve()}))}))})):(this._publisherContext.state.value=Re.Offline,Xe.resolve())}},{key:"applyRtcConfiguration",value:(e=F()(j().mark((function e(t,n){var r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Ze.truncateIceServers(n),e.abrupt("return",Te.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=tt(tt({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Re.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Te.maximalNumberOfPeerConnectionReconnectAttempts||!Te.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(L.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=x.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new f((function(){return x.value.clearTimeout(o)})))}this._logger.info("Reconnecting peer connection by restarting ICE");var s=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(r){return e.setLocalDescription(r).then((function(){return e.setLocalDescription(s).then((function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=x.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new f((function(){return x.value.clearTimeout(r)})))}else n._publisherContext.state.value=Re.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 Re.Starting;case"unauthorized":return Re.Unauthorized;case"not-found":return Re.NotFound;case"capacity":case"rate-limited":case"timeout":return Re.Recovering;case"failed":return Re.Error;default:H(e)}}}]);var e}(),rt=n(981).A,it=function(){return o()((function e(n,r,i){var o=this;t()(this,e),a()(this,"_logger",$.getLogger("Publisher")),a()(this,"_tokenContext",void 0),a()(this,"_publisherContext",void 0),a()(this,"_peerConnectionContext",void 0),a()(this,"_stateContext",void 0),a()(this,"_exponentialBackoff",void 0),a()(this,"_publisherStartTime",void 0),a()(this,"_readOnlyToken",void 0),a()(this,"_readOnlyPeerConnection",void 0),a()(this,"_readOnlyState",void 0),a()(this,"_readOnlyTokenExpiring",void 0),a()(this,"_readOnlyAuthorized",void 0),a()(this,"_readOnlyOnline",void 0),a()(this,"_readOnlyLoading",void 0),a()(this,"_readOnlyPublishing",void 0),a()(this,"_readOnlyStandby",void 0),a()(this,"_readOnlyStopped",void 0),a()(this,"_readOnlyFailureCount",void 0),a()(this,"_readOnlyEndPoint",void 0),a()(this,"_readOnlyStream",void 0),a()(this,"_readOnlyRtcStatistics",void 0),a()(this,"_readOnlyMediaStream",void 0),a()(this,"_metricsService",void 0),a()(this,"_sessionTelemetry",void 0),this._tokenContext=new Me(r),this._publisherContext=new Ae(i),this._peerConnectionContext=new Fe,this._stateContext=new Ne,this._exponentialBackoff=new _e,this._publisherStartTime=Date.now(),this._readOnlyToken=new _(this._tokenContext.token),this._readOnlyPeerConnection=new _(this._peerConnectionContext.peerConnection),this._readOnlyState=new _(this._publisherContext.state),this._readOnlyTokenExpiring=new _(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new _(this._publisherContext.authorized),this._readOnlyOnline=new _(this._publisherContext.online),this._readOnlyLoading=new _(this._publisherContext.loading),this._readOnlyPublishing=new _(this._publisherContext.publishing),this._readOnlyStandby=new _(this._publisherContext.standby),this._readOnlyStopped=new _(this._publisherContext.stopped),this._readOnlyFailureCount=new _(this._publisherContext.failureCount),this._readOnlyEndPoint=new _(this._publisherContext.endPoint),this._readOnlyStream=new _(this._publisherContext.stream),this._readOnlyRtcStatistics=new _(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new _(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var s=ee.parseToken(this._tokenContext.token.value),u=(s.uri||Te.discoveryUri.value).toString();Te.tenancy.value=s.tenancy||Te.tenancy.value,he.uri.value=u,this._metricsService=Se.getMetricsService(u),this._sessionTelemetry=new Ie(Te.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){o._publisherContext.clearFailureCountTimeout&&x.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Re.Publishing&&(o._publisherContext.clearFailureCountTimeout=x.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")};x.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new f((function(){x.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=ee.parseToken(this._tokenContext.token.value),n=(t.uri||Te.discoveryUri.value).toString();Te.tenancy.value=t.tenancy||Te.tenancy.value,he.uri.value=n,this._metricsService=Se.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:(s=F()(j().mark((function e(t){var n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new rt((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())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return s.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=Re.Stopped}},{key:"dispose",value:(i=F()(j().mark((function e(){var t=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return ee.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Te.discoveryUri.value),new x.value.URL(Te.discoveryUri.value))}},{key:"start",value:(r=F()(j().mark((function e(){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=F()(j().mark((function e(){var t,n,r,i,o,s=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publisherContext.state.value=Re.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),ee.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Re.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==Re.Error&&e!==Re.Recovering||qe.clearCachedClosestEndpoint(r)}))),i=function(){return new rt((function(e){return s._stateContext.isStarting.value=!1,e(s.handleStreamFailure())}))},o=new nt(this._publisherContext,this._peerConnectionContext,i),e.abrupt("return",o.start(r,t,n).then((function(){s._publisherContext.loading.value=!1})).catch((function(e){n.fail(),s._publisherContext.failureCount.value++,s._publisherContext.online.value=!1,s.cleanUpResources("client:cleanup-after-failed-setup"),s._publisherContext.state.value=Re.ClientStartError,s._logger.error("Failed to start publishing",e)})).finally((function(){if(s._stateContext.isStarting.value=!1,s._publisherContext.state.value!==Re.Publishing&&Te.automaticRetryOnFailure){var e=x.value.setTimeout((function(){s.handleStreamFailure().catch((function(e){s._logger.error("Failed handling stream failure",e)}))}),s.getRetryInterval());s._publisherContext.disposables.add(new f((function(){x.value.clearTimeout(e)})))}else s._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),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 Re.Offline:return 15e3;case Re.Initializing:case Re.NotFound:case Re.Error:case Re.Recovering:case Re.Unauthorized:case Re.GeoRestricted:case Re.GeoBlocked:case Re.Stopped:case Re.Starting:case Re.Publishing:case Re.Reconnecting:case Re.UnsupportedFeature:case Re.ConfigurationError:case Re.TransientConfigurationError:case Re.ConnectionError:case Re.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:H(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=F()(j().mark((function e(){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===Re.Error||e.t0===Re.Reconnecting||e.t0===Re.Offline||e.t0===Re.Recovering||e.t0===Re.TransientConfigurationError||e.t0===Re.ConnectionError||e.t0===Re.ClientStartError?4:e.t0===Re.Unauthorized?11:e.t0===Re.GeoRestricted?13:e.t0===Re.GeoBlocked?15:e.t0===Re.Stopped?17:e.t0===Re.Publishing?19:e.t0===Re.Initializing?21:e.t0===Re.Starting?23:e.t0===Re.UnsupportedFeature?25:e.t0===Re.NotFound?27:e.t0===Re.ConfigurationError?29:31;break;case 4:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.next=9;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Re[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Re[this._publisherContext.state.value]),e.abrupt("break",32);case 11:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 13:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 15:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 19:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Publisher is initializing, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 29:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 31:H(this._publisherContext.state.value);case 32:return e.abrupt("return",this.start());case 33:case"end":return e.stop()}}),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(),!Te.forceGarbageCollectionOnRestart||L.isMobile&&Te.skipGarbageCollectionOnMobileDevices||Le.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,s}(),ot=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(!Te.initialized.value)throw new Error("SDK is not loaded.");return new it(e.mediaStream,e.token,e.name)}}])}(),st={SDK:Te,Publishers:ot,PublisherState:Re}})(),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:()=>p});var r=n(738),i=n.n(r),o=n(383),s=n.n(o),a=n(579),u=n.n(a),c=n(693),l=n.n(c),d=u()((function e(t,n,r){s()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),h=function(){function e(t){if(s()(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,s=function(t,a){try{if(a&&("object"===i()(a)||"function"==typeof a)){var u=a.then;if("function"==typeof u)return void u.call(a,(function(e){return s(t,e)}),n)}r[t]=a,0==--o&&e(r)}catch(e){n(e)}},a=0;a<r.length;a++)s(a,r[a])}))}},{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)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new h((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){return this.then((function(t){return h.resolve(e()).then((function(){return t}),(function(){return null}))}),(function(t){return h.resolve(e()).then((function(){return h.reject(t)}),(function(){return null}))}))};var p=h},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,s,a){try{var u=e[s](a),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 s=e.apply(t,n);function a(e){i(s,r,o,a,u,"next",e)}function u(e){i(s,r,o,a,u,"throw",e)}a(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,s,a=[],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)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var r=n(981).A,i=n(738).default;function o(){"use strict";e.exports=o=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},s=Object.prototype,a=s.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof C?t:C,o=Object.create(i.prototype),s=new M(r||[]);return u(o,"_invoke",{value:E(e,n,s)}),o}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var g="suspendedStart",m="suspendedYield",y="executing",_="completed",b={};function C(){}function w(){}function k(){}var S={};p(S,l,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(A([])));T&&T!==s&&a.call(T,l)&&(S=T);var L=k.prototype=C.prototype=Object.create(S);function P(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(r,o,s,u){var c=v(e[r],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var r;u(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function E(e,n,r){var i=g;return function(o,s){if(i===y)throw Error("Generator is already running");if(i===_){if("throw"===o)throw s;return{value:t,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var u=D(a,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===g)throw i=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var c=v(e,n,r);if("normal"===c.type){if(i=r.done?_:m,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=_,r.method="throw",r.arg=c.arg)}}}function D(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,D(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=v(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var s=o.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function A(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(a.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return w.prototype=k,u(L,"constructor",{value:k,configurable:!0}),u(k,"constructor",{value:w,configurable:!0}),w.displayName=p(k,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,p(e,h,"GeneratorFunction")),e.prototype=Object.create(L),e},n.awrap=function(e){return{__await:e}},P(R.prototype),p(R.prototype,d,(function(){return this})),n.AsyncIterator=R,n.async=function(e,t,i,o,s){void 0===s&&(s=r);var a=new R(f(e,t,i,o),s);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},P(L),p(L,h,"Generator"),p(L,l,(function(){return this})),p(L,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=A,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;I(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:A(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},n}e.exports=o,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),s=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),s=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var 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:()=>De,Publishers:()=>at,SDK:()=>Pe,default:()=>ut});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),s=n(693),a=n.n(s),u=n(452),c=n.n(u),l=n(72),d=n.n(l),h=n(511),p=n.n(h),f=function(){return o()((function e(n){t()(this,e),a()(this,"_disposed",void 0),a()(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 v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(v=function(){return!!e})()}var g,m=function(e){function n(e,r){return t()(this,n),i=this,o=n,s=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=d()(o),c()(i,v()?Reflect.construct(o,s||[],d()(i).constructor):o.apply(i,s));var i,o,s}return p()(n,e),o()(n)}(f),y=function(){return o()((function e(n){t()(this,e),a()(this,"_listeners",void 0),a()(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))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new m(this._listeners,e)}}])}(),_=function(){return o()((function e(n){t()(this,e),a()(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)}}])}(),b={document,location,navigator,window},C=function(){function e(n){t()(this,e),a()(this,"_document",void 0),a()(this,"_location",void 0),a()(this,"_navigator",void 0),a()(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:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{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:"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)}}])}();g=C,a()(C,"_instance",new y(new g(b))),a()(C,"_readOnlyInstance",new _(g._instance));var w,k,S,x=C.getInstance(),T=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""}}])}();w=T,a()(T,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),a()(T,"_browserNameAndVersion",w.parseBrowserNameAndVersion()),a()(T,"_browserName",w.parseBrowserName()),a()(T,"_browserMajorVersion",w.parseBrowserMajorVersion()),a()(T,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(k=navigator)||void 0===k?void 0:k.userAgent)),a()(T,"_isAndroid",/Android/i.test(null===(S=navigator)||void 0===S?void 0:S.userAgent)),a()(T,"_isChrome69",w._browserNameAndVersion.includes("Chrome/69.")),a()(T,"_isChrome70",w._browserNameAndVersion.includes("Chrome/70.")),a()(T,"_isChrome71",w._browserNameAndVersion.includes("Chrome/71.")),a()(T,"_isChrome72",w._browserNameAndVersion.includes("Chrome/72.")),a()(T,"_isChrome74",w._browserNameAndVersion.includes("Chrome/74.")),a()(T,"_isChrome75",w._browserNameAndVersion.includes("Chrome/75.")),a()(T,"_isChrome76",w._browserNameAndVersion.includes("Chrome/76.")),a()(T,"_isChrome77",w._browserNameAndVersion.includes("Chrome/77."));var L=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return T.isChrome74||T.isChrome75||T.isChrome76||T.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return T.isChrome69||T.isChrome70||T.isChrome71||T.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=69||"Firefox"===T.browserName&&T.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=63||"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===T.browserName||"SamsungBrowser"===T.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==T.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===T.browserName&&"function"==typeof(null===(e=x.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion>=71||"Firefox"===T.browserName&&T.browserMajorVersion>=69||"Safari"===T.browserName}},{key:"isMobile",get:function(){return T.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==T.browserName&&"Safari"!==T.browserName}}])}(),P=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),R=function(){return o()((function e(n,r,i){t()(this,e),a()(this,"_category",void 0),a()(this,"_appenders",void 0),a()(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>P.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?L.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}}])}(),E=function(){return o()((function e(){t()(this,e),a()(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}),[])}}])}(),D=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"}}}])}();a()(D,"_sendLocalCandidates",void 0),a()(D,"_sendLogs",void 0),a()(D,"_sendMetrics",void 0),a()(D,"_logToConsole",void 0),D.applyFeatures();var O=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return P[D.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return P[D.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return P.Info}}])}(),I=function(){return o()((function e(){t()(this,e),a()(this,"_threshold",O.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),a()(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(P[e],"] ").concat(t);e<P.Warn?console.log(i):console.error(i)}}}])}(),A=n(293),F=n.n(A),N=n(756),j=n.n(N),V=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}}])}(),U=function(){return o()((function e(){t()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2025-02-05T23:09:47.932Z (2025.0.2)"}catch(e){return this._defaultVersion}}}])}();a()(U,"_defaultVersion",(new Date).toISOString());var B=n(981).A,z=function(){return o()((function e(n){var r=this;t()(this,e),a()(this,"_telemetryConfiguration",void 0),a()(this,"_logs",[]),a()(this,"_isSending",!1),a()(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:P[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:U.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<P.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new B((function(e){var t=x.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendLogs",value:(n=F()(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new x.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,x.value.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=F()(j().mark((function e(){var t,n,r,i,o,s=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)&&x.value){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?V.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.abrupt("return",this.sendLogs(o).then((function(e){return s._isSending=!1,s.sendLogsIfAble(),e})).catch((function(){s._isSending=!1,s.sendLogsIfAble()})));case 12:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,n}(),G=function(){return o()((function e(n){t()(this,e),a()(this,"_telemetryService",void 0),a()(this,"_tenancy",void 0),a()(this,"_sessionId",void 0),a()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new z(n)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),H=function(){return o()((function e(){t()(this,e),a()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),a()(this,"_tenancy","-"),a()(this,"_sessionId","-"),a()(this,"_environment","-"),a()(this,"_pageLoadTime",0),a()(this,"_threshold",O.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new x.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}}])}(),W=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},J=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case P.Off:return"Off";case P.Trace:return"Trace";case P.Debug:return"Debug";case P.Info:return"Trace";case P.Warn:return"Warn";case P.Error:return"Error";case P.Fatal:return"Fatal";case P.All:return"All";default:W(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return P.Off;case"Trace":return P.Trace;case"Debug":return P.Debug;case"Info":return P.Info;case"Warn":return P.Warn;case"Error":return P.Error;case"Fatal":return P.Fatal;case"All":return P.All;default:W(e)}}}])}(),q=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),K=function(){return o()((function e(){t()(this,e),a()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),a()(this,"_tenancy","-"),a()(this,"_sessionId","-"),a()(this,"_environment","-"),a()(this,"_threshold",Q.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new x.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}}])}(),Q=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return q[D.sendMetrics]}}])}(),Y=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:W(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return q.Off;case"Essential":return q.Essential;case"All":return q.All;default:W(e)}}}])}(),$=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":Y.convertTelemetryLevelToTelemetryLevelType(Q.defaultTelemetryLevel),"phenix-logging-level":J.convertLoggingLevelToLoggingLevelType(O.defaultLoggingLevel),"phenix-console-logging-level":J.convertLoggingLevelToLoggingLevelType(O.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":J.convertLoggingLevelToLoggingLevelType(O.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=x.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 x.value.URLSearchParams(x.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),Z=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 R(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=$.getStringValue("phenix-logging-level");P[e]&&this._threshold.setThreshold(P[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=$.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(P[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new M(e||O.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||O.defaultTelemetryLoggingLevel,this._appenders.add(new G(this._telemetryConfiguration))}}])}();a()(Z,"_loggers",{}),a()(Z,"_appenders",new E),a()(Z,"_threshold",new I),a()(Z,"_telemetryConfiguration",new H),Z.applyLoggerConfigFromParameterConfiguration();var X=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)}}])}(),ee=function(){return o()((function e(n){var r,i;t()(this,e),a()(this,"_applicationId",void 0),a()(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 x.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}}])}(),te=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 ee(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new ee(r)}catch(t){return e._logger.error("Cannot parse token value",t),new ee(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();a()(te,"_logger",Z.getLogger("EdgeAuthParser"));var ne=function(){return o()((function e(){t()(this,e),a()(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,"]")}}])}(),re="visibilitychange",ie=function(){return o()((function e(){t()(this,e),a()(this,"_disposables",new ne),a()(this,"_readOnlyIsForeground",void 0),a()(this,"_isForeground",void 0),a()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new y(!0),this._readOnlyIsForeground=new _(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!x.value.documentIsHidden},n=!1;x.value.addDocumentEventListener(re,t,n),this._disposables.add(new f((function(){return x.value.removeDocumentEventListener(re,t,n)})))}}])}(),oe=n(981).A,se=function(){return o()((function e(n){t()(this,e),a()(this,"_logger",Z.getLogger("VanillaPeerConnection")),a()(this,"_peerConnection",void 0),L.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new x.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!L.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!L.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=F()(j().mark((function e(t){var n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!L.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new oe((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createOffer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=F()(j().mark((function e(t){var n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!L.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new oe((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createAnswer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=F()(j().mark((function e(t){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return e.abrupt("return",this._peerConnection.setLocalDescription(L.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=F()(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(L.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 5:case"end":return e.stop()}}),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 oe((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}(),ae=n(981).A,ue=function(){return o()((function e(){t()(this,e)}),[{key:"createPeerConnection",value:(e=F()(j().mark((function e(t){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ae((function(e){x.subscribe((function(n){n&&e(new se(t))}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ce=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(){L.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(r=F()(j().mark((function t(){return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=F()(j().mark((function t(){var n,r,i,o,s=arguments;return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]&&s[1],!e._cached||e._cached.direction!==n||r){t.next=6;break}return i=e._cached.peerConnection,e._cached=null,t.abrupt("return",i);case 6:return o=L.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=F()(j().mark((function e(t){var r,i,o;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:n}),r=t.addTransceiver("video",{direction:n}),e.t0=i,e.t1=r,e.t2=t,e.next=9,t.createOffer(void 0);case 9:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 11:return o="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(o);case 15:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})}]);var n,r}();a()(ce,"_logger",Z.getLogger("PeerConnectionService")),a()(ce,"_peerConnectionFactory",new y(new ue)),a()(ce,"_cached",void 0),ce.initiateInitialPrecaching();var le=function(){return o()((function e(){t()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new x.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}}}])}(),de=function(){return o()((function e(){t()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new x.value.URL(e).origin}catch(e){return""}}}])}(),he=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:""}}}}])}();a()(he,"_discoveryParameters",void 0),he.applyParameters();var pe=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 x.value.URL(e.toString()),n=U.sdkVersion,r=he.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()}}])}();a()(pe,"_discoveryUri",new y("https://pcast.phenixrts.com/pcast/endPoints"));var fe,ve,ge=n(738),me=n.n(ge),ye=n(132),_e=n.n(ye),be=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),a()(this,"_backoffIntervalInMillisecond",void 0),a()(this,"_minBackoffIntervalInMillisecond",void 0),a()(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)}}])}(),Ce=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}(Ce||{}),we=Ce,ke=function(){return o()((function e(n){t()(this,e),a()(this,"_metrics",void 0),this._metrics=n}),[{key:"getName",value:function(){return we[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case we.TimeToFirstFrame:case we.ChannelCreationTimeToFirstFrame:return q.Essential;case we.Stalled:case we.Buffering:case we.SetupCompleted:case we.SetupFailed:case we.RoundTripTime:case we.DownlinkThroughputCapacity:case we.NetworkType:case we.ResolutionChanged:case we.ApplicationForeground:case we.ApplicationBackground:return q.All;default:W(this._metrics)}}}])}(),Se=n(981).A,xe=function(){return o()((function e(n){var r=this;t()(this,e),a()(this,"_logger",Z.getLogger("MetricsService")),a()(this,"_metricsConfiguration",void 0),a()(this,"_exponentialBackoff",void 0),a()(this,"_metrics",[]),a()(this,"_isSending",!1),a()(this,"_failureCount",0),a()(this,"_domain",""),this._metricsConfiguration=n,this._exponentialBackoff=new be,this.getLocationHostnameFromGlobalScope().then((function(e){r._domain=null!=e?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,s=e.kind,a=new ke(e.metricType);if(!(this._metricsConfiguration.threshold>a.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:a.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:U.sdkVersion,runtime:i,resource:o,kind:s};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Se((function(e){var t=x.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendMetrics",value:(n=F()(j().mark((function e(t){var n;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new x.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,x.value.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=F()(j().mark((function e(){var t,n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)&&x.value){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void x.value.setTimeout((function(){n._metrics=[].concat(_e()(t),_e()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()}),n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,n}(),Te=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(me()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new K;return r.sessionId=Pe.clientSessionId,r.tenancy=Pe.tenancy.value,r.url=le.getTelemetryUrl(t),r.environment=de.getEnvironmentFromUrl(t),r.threshold=Y.convertTelemetryLevelTypeToTelemetryLevel(Pe.telemetryLevel),e._metricsServices[t]=new xe(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();a()(Te,"_metricsServices",{});var Le=(null===(fe=C.getInstance().value)||void 0===fe?void 0:fe.pageLoadTime)||Date.now(),Pe=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 Le}},{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 J.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return Y.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return T}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=Z.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 G}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new G(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof G}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new G(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Te.getMetricsService(pe.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=$.getStringValue("phenix-metrics-level");t&&Te.setTelemetryLevel(q[t]),e._telemetryLevel.subscribe((function(e){Te.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=$.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=$.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=$.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=$.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=de.getEnvironmentFromUrl(t)}));var t=$.getStringValue("phenix-channel-token");if(t){var n=te.parseToken(t);return e._tenancy.value=n.tenancy,pe.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=$.getStringValue("phenix-uri");if(r)return pe.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=$.getStringValue("phenix-base-uri");if(i){var o=new(C.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",pe.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 ie,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&&C.setInstance(n.globalScope),t.discoveryUri&&(pe.uri.value=t.discoveryUri),t.peerConnectionFactory&&(ce.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&q[t.telemetryLevel]&&(e._telemetryLevel.value=Y.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&P[t.loggingLevel]&&this._logger.threshold.setThreshold(J.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&P[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(J.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 le.getTelemetryUrl(e)}}])}();ve=Pe,a()(Pe,"_automaticallyRetryOnFailure",$.getBooleanValue("phenix-automatically-retry-on-failure")),a()(Pe,"_automaticallyReconnectPeerConnection",$.getBooleanValue("phenix-automatically-reconnect-peer-connection")),a()(Pe,"_automaticallyPlayMediaStream",!0),a()(Pe,"_automaticallyMuteVideoOnPlayFailure",!0),a()(Pe,"_forceGarbageCollectionOnRestart",$.getBooleanValue("phenix-force-garbage-collection-on-restart")),a()(Pe,"_skipGarbageCollectionOnMobileDevices",$.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),a()(Pe,"_webPlayerLoader",void 0),a()(Pe,"_shakaPlayerLoader",void 0),a()(Pe,"_hlsJsLoader",void 0),a()(Pe,"_applicationActivityMonitor",void 0),a()(Pe,"_environment",new y("")),a()(Pe,"_telemetryUrl",new y("https://telemetry.phenixrts.com/telemetry")),a()(Pe,"_maximalNumberOfPeerConnectionReconnectAttempts",8),a()(Pe,"_telemetryLevel",new y(Q.defaultTelemetryLevel)),a()(Pe,"_metricsService",void 0),a()(Pe,"_metricsConfiguration",void 0),a()(Pe,"_sendLocalCandidates",new y(D.sendLocalCandidates)),a()(Pe,"_tenancy",new y("")),a()(Pe,"_clientSessionId",X.random(32)),a()(Pe,"_loadedTimestamp",new Date),a()(Pe,"_logger",Z.getLogger("SDK")),a()(Pe,"_initialized",new y(!1)),a()(Pe,"_readOnlyInitialized",new _(ve._initialized)),a()(Pe,"_readOnlyDiscoveryUri",new _(pe.uri)),a()(Pe,"_readOnlyPeerConnectionFactory",new _(ce.peerConnectionFactory)),C.subscribe(Pe.onLoad.bind(Pe));var Re=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(){L.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){L.isQueueMicrotaskSupported?x.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):x.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=x.value.documentCreateElement("img");e.src=x.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){x.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Ee=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}(Ee||{}),De=Ee,Oe=function(){return o()((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),a()(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,s=(n=Math.floor(n/60))%24,a=["PT"];return e&&a.unshift("-"),s&&a.push(s+"H"),o&&a.push(o+"M"),(i||r)&&(a.push(String(i)),r&&a.push("."+this.padStart(r.toString(),3,"0")),a.push("S")),a.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)}}])}(),Ie=function(){return o()((function e(n){t()(this,e),a()(this,"_logger",Z.getLogger("StreamSetupListener")),a()(this,"metricsService",Pe.metricsService),a()(this,"_pageLoadTime",void 0),a()(this,"_startTime",void 0),a()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n}),[{key:"success",value:function(e){this.recordStreamMetric(we.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(we.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new ke(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 Oe(n-this._pageLoadTime).toIsoString(),t,i,new Oe(r).toIsoString())}}}])}(),Me=function(){return o()((function e(){t()(this,e),a()(this,"_disposables",new ne),a()(this,"_isSupported",void 0!==x.value.navigatorConnection),a()(this,"_rtt",new y(void 0)),a()(this,"_effectiveType",new y(void 0)),a()(this,"_downlinkThroughputCapacity",new y(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=x.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=x.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=x.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=x.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=x.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=x.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new f((function(){var e;return null===(e=x.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()}}])}(),Ae=function(){return o()((function e(n,r){var i=this;if(t()(this,e),a()(this,"_logger",Z.getLogger("SessionTelemetry")),a()(this,"_metricsService",void 0),a()(this,"_applicationActivityMonitor",Pe.applicationActivityMonitor),a()(this,"_networkMonitor",new Me),a()(this,"_pageLoadTime",void 0),a()(this,"_disposables",new ne),a()(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 Ie(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?we.ApplicationForeground:we.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 Oe(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:we.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 Oe(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:we.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 Oe(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:we.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 Oe(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Fe=o()((function e(n){t()(this,e),a()(this,"token",void 0),a()(this,"tokenExpiring",void 0),this.token=new y(n),this.tokenExpiring=new y(!1)})),Ne=function(){return o()((function e(n){t()(this,e),a()(this,"publisherInitialization",void 0),a()(this,"disposables",void 0),a()(this,"publisherDisposables",void 0),a()(this,"state",void 0),a()(this,"authorized",void 0),a()(this,"online",void 0),a()(this,"loading",void 0),a()(this,"publishing",void 0),a()(this,"standby",void 0),a()(this,"stopped",void 0),a()(this,"failureCount",void 0),a()(this,"endPoint",void 0),a()(this,"stream",void 0),a()(this,"rtcStatistics",void 0),a()(this,"clearFailureCountTimeout",void 0),a()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),a()(this,"name",void 0),this.disposables=new ne,this.publisherDisposables=new ne,this.publisherInitialization=new Date,this.state=new y(De.Initializing),this.authorized=new y(!0),this.online=new y(!0),this.loading=new y(!1),this.publishing=new y(!1),this.standby=new y(!1),this.stopped=new y(!1),this.failureCount=new y(0),this.endPoint=new y(null),this.stream=new y(null),this.rtcStatistics=new y(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:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return De.Starting;case"not-found":return De.NotFound;case"geo-restricted":return De.GeoRestricted;case"geo-blocked":return De.GeoBlocked;case"unauthorized":return De.Unauthorized;case"capacity":case"rate-limited":case"timeout":return De.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return De.ConfigurationError;case"port-in-range-not-found":return De.TransientConfigurationError;case"failed":return De.Error;default:W(e)}}},{key:"generateScreenName",value:function(){return X.random(12)}}])}(),je=o()((function e(){t()(this,e),a()(this,"mediaStream",void 0),a()(this,"peerConnection",void 0),a()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new y(null),this.peerConnection=new y(null),this.peerConnectionReconnectAttempts=0})),Ve=o()((function e(){t()(this,e),a()(this,"isStarting",void 0),a()(this,"isDisposed",void 0),this.isStarting=new y(!1),this.isDisposed=!1})),Ue=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Be=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),ze=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Be.Normal:return"Normal";case Be.Force:return"Force";case Be.Reset:return"Reset";default:W(e)}}}])}(),Ge=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Ue.Keep:return"Keep";case Ue.Reset:return"Reset";default:W(e)}}}])}(),He=n(981).A,We=function(){return o()((function e(n,r){if(t()(this,e),a()(this,"_logger",Z.getLogger("EndPoint")),a()(this,"_uri",void 0),a()(this,"_timeout",void 0),a()(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:(v=F()(j().mark((function e(){var t,n,r,i,o=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,He.race([x.value.fetch(t,{method:"GET",cache:"no-cache"}),new He((function(e,n){return x.value.setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(f=F()(j().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f,v,g=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=te.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([i,"stream","subscribe"]).toString(),s=new x.value.FormData,a=U.sdkVersion,0===r&&n?(u={apiVersion:7,clientVersion:a,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}},s.append("jsonBody",JSON.stringify(u))):(c={apiVersion:7,clientVersion:a,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},s.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,h=null,e.next=13,He.race([x.value.fetch(o,{method:"POST",body:s}),new He((function(e){return h=x.value.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){h&&x.value.clearTimeout(h)}));case 13:d=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(p=this.mapHttpStatusToSubscribeStatus(d))){e.next=23;break}return e.abrupt("return",{status:p});case 23:return f=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(i,d);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,f-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(p=F()(j().mark((function e(t,n,r,i){var o,s,a,u,c,l,d,h,p,f,v,g,m=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=te.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return s=this.buildUrl([o,"stream","publish"]).toString(),a=new x.value.FormData,u=U.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}},a.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},a.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=9,p=null,e.next=13,He.race([x.value.fetch(s,{method:"POST",body:a}),new He((function(e){return p=x.value.setTimeout((function(){m._logger.error("Failed to publish",new Error("Publish timed out [".concat(s,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){p&&x.value.clearTimeout(p)}));case 13:h=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(f=this.mapHttpStatusToPublishStatus(h))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,h);case 26:return g=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-d),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=F()(j().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new x.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)),s=Date.now(),e.prev=5,u=null,e.next=9,He.race([x.value.fetch(r,{method:"POST",body:i}),new He((function(e){return u=x.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&&x.value.clearTimeout(u)}));case 9:a=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(a);case 22:return d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-s),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return h.apply(this,arguments)})},{key:"limitBitrate",value:(d=F()(j().mark((function e(t,n,r,i,o){var s,a,u,c,l,d,h,p,f=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),a=new x.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Ge.convertBitrateStateToBitrateStateType(i),bitrateMode:ze.convertBitrateModeToBitrateModeType(o)},a.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,He.race([x.value.fetch(s,{method:"POST",body:a}),new He((function(e){return d=x.value.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(s,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){d&&x.value.clearTimeout(d)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,p-c),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return d.apply(this,arguments)})},{key:"addIceCandidates",value:(l=F()(j().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f=this,v=arguments;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),s=new x.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},s.append("jsonBody",JSON.stringify(a)),u=Date.now(),e.prev=6,l=null,e.next=10,He.race([x.value.fetch(o,{method:"POST",body:s}),new He((function(e){return l=x.value.setTimeout((function(){f._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){l&&x.value.clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,h-u),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"destroyStream",value:(c=F()(j().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new x.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,He.race([x.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new He((function(e){return u=x.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&&x.value.clearTimeout(u)}));case 9:a=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(a);case 22:return d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-s),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return c.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=F()(j().mark((function e(t,n){var r,i,o,s;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new x.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(s)),navigator.sendBeacon(i,o);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new x.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,_e()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new x.value.URL(this._uri),t=U.sdkVersion,n=he.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:(s=F()(j().mark((function e(t,n){var r,i;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},lag:r.lag},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=F()(j().mark((function e(t,n){var r,i;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret}},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 6:case"end":return e.stop()}}),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=F()(j().mark((function e(t){var n,r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=F()(j().mark((function e(t){var n,r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=F()(j().mark((function e(t){var n,r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,s,u,c,l,d,h,p,f,v}(),Je=n(981).A,qe=function(){return o()((function e(n){if(t()(this,e),a()(this,"_logger",Z.getLogger("Discovery")),a()(this,"_metricsService",void 0),a()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Te.getMetricsService(n.toString()),this._uri=n}),[{key:"discoverNearbyEndPoints",value:(n=F()(j().mark((function e(t,n){var r,i,o,s;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new Error("Discovery requires timeout");case 2:return r=t.toString(),e.next=5,Je.race([x.value.fetch(r,{method:"GET",cache:"no-cache"}),new Je((function(e,t){return x.value.setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,s=o.split(","),e.abrupt("return",s.map((function(e){return new We(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=F()(j().mark((function e(){var t,n,r,i,o,s,a=this,u=arguments;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=pe.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new x.value.URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new Je((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Je.race(r.map((function(e){return e.ping().catch((function(t){return a._logger.warn("Failed to ping end point [%s]",e,t),i++,o()})).then((function(t){var n=Date.now();return a._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),a._metricsService.push({metricType:we.RoundTripTime,runtime:(n-Pe.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 9:return s=e.sent,e.abrupt("return",s);case 11:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,n}(),Ke=n(981).A,Qe=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=F()(j().mark((function t(){return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Ke((function(t){x.subscribe((function(n){if(n){var r=new n.URL(Pe.discoveryUri.value);return e.discoverClosestEndPointWithCaching(r).then(t)}}))})));case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=F()(j().mark((function t(n){var r,i,o;return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((r=n.toString())in e._cache)){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new qe(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){x.value.setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),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}();a()(Qe,"_cache",{}),Qe.precacheClosestEndPointDiscovery();var Ye=n(715),$e=n.n(Ye),Ze=function(){return o()((function e(n){t()(this,e),a()(this,"_sdp",void 0),a()(this,"_audioCodec",void 0),a()(this,"_videoCodec",void 0),a()(this,"_isAudioTrackEnabled",void 0),a()(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]}}])}(),Xe=function(){return o()((function e(n,r){var i,o,s,u;if(t()(this,e),a()(this,"_estimatedRoundTripTime",void 0),a()(this,"_estimatedVideoCodec","unknown"),a()(this,"_estimatedAudioCodec","unknown"),a()(this,"_rtcStatistic",new y({})),a()(this,"_peerConnection",void 0),a()(this,"_isMonitorRunning",!0),a()(this,"_updateTimeout",null),a()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(i=this._peerConnection)&&void 0!==i&&null!==(o=i.currentLocalDescription)&&void 0!==o&&o.sdp&&null!==(s=this._peerConnection)&&void 0!==s&&null!==(u=s.currentRemoteDescription)&&void 0!==u&&u.sdp){var c=new Ze(this._peerConnection.currentLocalDescription.sdp),l=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=l.audioCodec,this._estimatedVideoCodec=l.videoCodec,this._availableTracks={audio:c.isAudioTrackEnabled&&l.isAudioTrackEnabled,video:c.isVideoTrackEnabled&&l.isVideoTrackEnabled},this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(x.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(e=F()(j().mark((function e(){var t,n,r=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!L.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,null===(t=this._peerConnection)||void 0===t?void 0:t.getStats(null).then((function(e){var t={};if(e){var i,o=r._estimatedRoundTripTime;e.forEach((function(s){if("candidate-pair"===s.type&&s.currentRoundTripTime&&(o=1e3*s.currentRoundTripTime,t.audio&&(t.audio.roundTripTime=o),t.video&&(t.video.roundTripTime=o)),"candidate-pair"===s.type&&s.lastPacketSentTimestamp&&(i=s.lastPacketSentTimestamp,t.audio&&(t.audio.lastPacketSentTimestamp=i),t.video&&(t.video.lastPacketSentTimestamp=i)),"outbound-rtp"===s.type){var a,u=s.kind||s.mediaType||n(s),c="";if(e.forEach((function(e){e.id===s.codecId&&(c=e.mimeType)})),u&&null!==(a=r._availableTracks)&&void 0!==a&&a[u]){var l,d,h,p,f,v,g,m=(s.bytesSent||0)-(null!==(l=null===(d=r._rtcStatistic.value)||void 0===d||null===(h=d[u])||void 0===h?void 0:h.bytesSent)&&void 0!==l?l:0),y=s.timestamp-(null===(p=r._rtcStatistic.value)||void 0===p||null===(f=p[u])||void 0===f?void 0:f.timestamp),_=m&&y?Math.floor(8*m/y*1e3):0;if(t[u]={ssrc:s.ssrc,mediaType:u,timestamp:s.timestamp,bitrate:_,bytesSent:s.bytesSent,packetsSent:s.packetsSent,retransmittedBytesSent:s.retransmittedBytesSent,codec:c||r.getCodecByType(u),roundTripTime:o},(s.lastPacketSentTimestamp||i)&&(t[u].lastPacketSentTimestamp=s.lastPacketSentTimestamp||i),"video"===u&&(t[u].firCount=s.firCount,t[u].frameHeight=s.frameHeight,t[u].frameWidth=s.frameWidth,t[u].framesEncoded=s.framesEncoded,t[u].framesSent=s.framesSent,t[u].headerBytesSent=s.headerBytesSent,t[u].hugeFramesSent=s.hugeFramesSent,t[u].pliCount=s.pliCount,t[u].qpSum=s.qpSum,t[u].totalEncodeTime=s.totalEncodeTime,t[u].totalEncodedBytesTarget=s.totalEncodedBytesTarget,null!==(v=r._rtcStatistic.value)&&void 0!==v&&null!==(g=v.video)&&void 0!==g&&g.framesEncoded)){var b=(s.framesEncoded-r._rtcStatistic.value.video.framesEncoded)/(t[u].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[u].fps=b?Math.round(100*b)/100:0}}}}))}r._rtcStatistic.value=t})).then((function(){r._isMonitorRunning&&(r._updateTimeout=x.value.setTimeout((function(){return r.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),et=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 nt(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 rt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nt(Object(n),!0).forEach((function(t){a()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var it=function(){return o()((function e(n,r,i){t()(this,e),a()(this,"_logger",Z.getLogger("RealTimePublisher")),a()(this,"_publisherContext",void 0),a()(this,"_peerConnectionContext",void 0),a()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i}),[{key:"start",value:function(e,t,n){var r=this;return x.value.navigatorIsOnLine?tt.all([Qe.discoverClosestEndPointWithCaching(e),ce.createPeerConnectionOffer("sendonly").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=$e()(e,2),i=n[0],o=n[1],s=o.localOffer,a=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"+s.sdp),L.clientOfferDisabled||!a.supportsSetConfiguration||!a.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(a.close(),a.dispose(),!Pe.forceGarbageCollectionOnRestart||L.isMobile&&Pe.skipGarbageCollectionOnMobileDevices||Re.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,s,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(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,s=e.setRemoteDescriptionResponse,a=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,s,a,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(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||Pe.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=x.value.setTimeout((function(){var e;r._publisherContext.stream.value!==i||o||null===(e=r._publisherContext.endPoint.value)||void 0===e||e.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,t)})).catch((function(e){r._logger.error("[%s] 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=De.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:W(e.iceConnectionState)}}},new tt((function(e){e()})).then((function(){if(s)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,s.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(a)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setRemoteDescription(a.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;return r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(r._publisherContext.publishing.value=!1,r._publisherContext.standby.value=!0,void(r._publisherContext.stopped.value=!1)):(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;n.success(r._publisherContext.streamId),r._publisherContext.state.value=De.Publishing,r._publisherContext.publishing.value=!0;var i=new Xe(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe((function(e){r._publisherContext.rtcStatistics.value=e})),tt.resolve()}))}))})):(this._publisherContext.state.value=De.Offline,tt.resolve())}},{key:"applyRtcConfiguration",value:(e=F()(j().mark((function e(t,n){var r;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=et.truncateIceServers(n),e.abrupt("return",Pe.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=rt(rt({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=De.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Pe.maximalNumberOfPeerConnectionReconnectAttempts||!Pe.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(L.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=x.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new f((function(){return x.value.clearTimeout(o)})))}this._logger.info("Reconnecting peer connection by restarting ICE");var s=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(r){return e.setLocalDescription(r).then((function(){return e.setLocalDescription(s).then((function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=x.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new f((function(){return x.value.clearTimeout(r)})))}else n._publisherContext.state.value=De.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 De.Starting;case"unauthorized":return De.Unauthorized;case"not-found":return De.NotFound;case"capacity":case"rate-limited":case"timeout":return De.Recovering;case"failed":return De.Error;default:W(e)}}}]);var e}(),ot=n(981).A,st=function(){return o()((function e(n,r,i){var o=this;t()(this,e),a()(this,"_logger",Z.getLogger("Publisher")),a()(this,"_tokenContext",void 0),a()(this,"_publisherContext",void 0),a()(this,"_peerConnectionContext",void 0),a()(this,"_stateContext",void 0),a()(this,"_exponentialBackoff",void 0),a()(this,"_publisherStartTime",void 0),a()(this,"_readOnlyToken",void 0),a()(this,"_readOnlyPeerConnection",void 0),a()(this,"_readOnlyState",void 0),a()(this,"_readOnlyTokenExpiring",void 0),a()(this,"_readOnlyAuthorized",void 0),a()(this,"_readOnlyOnline",void 0),a()(this,"_readOnlyLoading",void 0),a()(this,"_readOnlyPublishing",void 0),a()(this,"_readOnlyStandby",void 0),a()(this,"_readOnlyStopped",void 0),a()(this,"_readOnlyFailureCount",void 0),a()(this,"_readOnlyEndPoint",void 0),a()(this,"_readOnlyStream",void 0),a()(this,"_readOnlyRtcStatistics",void 0),a()(this,"_readOnlyMediaStream",void 0),a()(this,"_metricsService",void 0),a()(this,"_sessionTelemetry",void 0),this._tokenContext=new Fe(r),this._publisherContext=new Ne(i),this._peerConnectionContext=new je,this._stateContext=new Ve,this._exponentialBackoff=new be,this._publisherStartTime=Date.now(),this._readOnlyToken=new _(this._tokenContext.token),this._readOnlyPeerConnection=new _(this._peerConnectionContext.peerConnection),this._readOnlyState=new _(this._publisherContext.state),this._readOnlyTokenExpiring=new _(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new _(this._publisherContext.authorized),this._readOnlyOnline=new _(this._publisherContext.online),this._readOnlyLoading=new _(this._publisherContext.loading),this._readOnlyPublishing=new _(this._publisherContext.publishing),this._readOnlyStandby=new _(this._publisherContext.standby),this._readOnlyStopped=new _(this._publisherContext.stopped),this._readOnlyFailureCount=new _(this._publisherContext.failureCount),this._readOnlyEndPoint=new _(this._publisherContext.endPoint),this._readOnlyStream=new _(this._publisherContext.stream),this._readOnlyRtcStatistics=new _(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new _(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var s=te.parseToken(this._tokenContext.token.value),u=(s.uri||Pe.discoveryUri.value).toString();Pe.tenancy.value=s.tenancy||Pe.tenancy.value,pe.uri.value=u,this._metricsService=Te.getMetricsService(u),this._sessionTelemetry=new Ae(Pe.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){o._publisherContext.clearFailureCountTimeout&&x.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===De.Publishing&&(o._publisherContext.clearFailureCountTimeout=x.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")};x.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new f((function(){x.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=te.parseToken(this._tokenContext.token.value),n=(t.uri||Pe.discoveryUri.value).toString();Pe.tenancy.value=t.tenancy||Pe.tenancy.value,pe.uri.value=n,this._metricsService=Te.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:(s=F()(j().mark((function e(t){var n=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ot((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())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return s.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=De.Stopped}},{key:"dispose",value:(i=F()(j().mark((function e(){var t=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return te.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Pe.discoveryUri.value),new x.value.URL(Pe.discoveryUri.value))}},{key:"start",value:(r=F()(j().mark((function e(){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=F()(j().mark((function e(){var t,n,r,i,o,s=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publisherContext.state.value=De.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),te.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=De.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==De.Error&&e!==De.Recovering||Qe.clearCachedClosestEndpoint(r)}))),i=function(){return new ot((function(e){return s._stateContext.isStarting.value=!1,e(s.handleStreamFailure())}))},o=new it(this._publisherContext,this._peerConnectionContext,i),e.abrupt("return",o.start(r,t,n).then((function(){s._publisherContext.loading.value=!1})).catch((function(e){n.fail(),s._publisherContext.failureCount.value++,s._publisherContext.online.value=!1,s.cleanUpResources("client:cleanup-after-failed-setup"),s._publisherContext.state.value=De.ClientStartError,s._logger.error("Failed to start publishing",e)})).finally((function(){if(s._stateContext.isStarting.value=!1,s._publisherContext.state.value!==De.Publishing&&Pe.automaticRetryOnFailure){var e=x.value.setTimeout((function(){s.handleStreamFailure().catch((function(e){s._logger.error("Failed handling stream failure",e)}))}),s.getRetryInterval());s._publisherContext.disposables.add(new f((function(){x.value.clearTimeout(e)})))}else s._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),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 De.Offline:return 15e3;case De.Initializing:case De.NotFound:case De.Error:case De.Recovering:case De.Unauthorized:case De.GeoRestricted:case De.GeoBlocked:case De.Stopped:case De.Starting:case De.Publishing:case De.Reconnecting:case De.UnsupportedFeature:case De.ConfigurationError:case De.TransientConfigurationError:case De.ConnectionError:case De.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:W(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=F()(j().mark((function e(){return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===De.Error||e.t0===De.Reconnecting||e.t0===De.Offline||e.t0===De.Recovering||e.t0===De.TransientConfigurationError||e.t0===De.ConnectionError||e.t0===De.ClientStartError?4:e.t0===De.Unauthorized?11:e.t0===De.GeoRestricted?13:e.t0===De.GeoBlocked?15:e.t0===De.Stopped?17:e.t0===De.Publishing?19:e.t0===De.Initializing?21:e.t0===De.Starting?23:e.t0===De.UnsupportedFeature?25:e.t0===De.NotFound?27:e.t0===De.ConfigurationError?29:31;break;case 4:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.next=9;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,De[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,De[this._publisherContext.state.value]),e.abrupt("break",32);case 11:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 13:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 15:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 19:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Publisher is initializing, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 29:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 31:W(this._publisherContext.state.value);case 32:return e.abrupt("return",this.start());case 33:case"end":return e.stop()}}),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(),!Pe.forceGarbageCollectionOnRestart||L.isMobile&&Pe.skipGarbageCollectionOnMobileDevices||Re.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,s}(),at=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(!Pe.initialized.value)throw new Error("SDK is not loaded.");return new st(e.mediaStream,e.token,e.name)}}])}(),ut={SDK:Pe,Publishers:at,PublisherState:De}})(),r})()));
3
3
  //# sourceMappingURL=publish.js.map