@phenixrts/sdk 2023.2.17 → 2023.2.18-beta.136

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 (38) hide show
  1. package/channels/debug/channels.js +226 -357
  2. package/channels/debug/package.json +1 -1
  3. package/channels/debug.private/channels.js +221 -348
  4. package/channels/debug.private/package.json +1 -1
  5. package/channels/es5.debug.private/channels.js +221 -348
  6. package/channels/es5.debug.private/package.json +1 -1
  7. package/channels/min/channels.js +1 -1
  8. package/channels/min/channels.js.map +1 -1
  9. package/channels/min/package.json +1 -1
  10. package/channels/min.private/channels.js +1 -1
  11. package/channels/min.private/channels.js.map +1 -1
  12. package/channels/min.private/package.json +1 -1
  13. package/channels/package.json +1 -1
  14. package/full/debug/full.js +257 -416
  15. package/full/debug/package.json +1 -1
  16. package/full/debug.private/full.js +252 -407
  17. package/full/debug.private/package.json +1 -1
  18. package/full/min/full.js +1 -1
  19. package/full/min/full.js.map +1 -1
  20. package/full/min/package.json +1 -1
  21. package/full/min.private/full.js +1 -1
  22. package/full/min.private/full.js.map +1 -1
  23. package/full/min.private/package.json +1 -1
  24. package/full/package.json +1 -1
  25. package/package.json +1 -1
  26. package/publish/debug/package.json +1 -1
  27. package/publish/debug/publish.js +158 -300
  28. package/publish/debug.private/package.json +1 -1
  29. package/publish/debug.private/publish.js +158 -300
  30. package/publish/min/package.json +1 -1
  31. package/publish/min/publish.js +1 -1
  32. package/publish/min/publish.js.map +1 -1
  33. package/publish/min.private/package.json +1 -1
  34. package/publish/min.private/publish.js +1 -1
  35. package/publish/min.private/publish.js.map +1 -1
  36. package/publish/package.json +1 -1
  37. package/types/sdk/transformation/EncodedStreamSink.d.ts +1 -1
  38. package/types/sdk/transformation/InsertableStreams.d.ts +1 -1
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see publish.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(function(){return(()=>{var e={228:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},858:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},646:(e,t,n)=>{var r=n(228);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},506: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},926:(e,t,n)=>{var r=n(202).default;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},575: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},913:(e,t,n)=>{var r=n(696);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},713:(e,t,n)=>{var r=n(696);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},754: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},205:(e,t,n)=>{var r=n(489);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},860: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},884: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},521:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},206: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},585:(e,t,n)=>{var r=n(8).default,i=n(506);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},591:(e,t,n)=>{var r=n(202).default,i=n(8).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 I(r||[]);return u(o,"_invoke",{value:O(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",y="suspendedYield",m="executing",_="completed",b={};function C(){}function k(){}function w(){}var S={};p(S,l,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(M([])));T&&T!==s&&a.call(T,l)&&(S=T);var L=w.prototype=C.prototype=Object.create(S);function R(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function P(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 O(e,n,r){var i=g;return function(o,s){if(i===m)throw new 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=m;var c=v(e,n,r);if("normal"===c.type){if(i=r.done?_:y,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 E(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 F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function M(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 k.prototype=w,u(L,"constructor",{value:w,configurable:!0}),u(w,"constructor",{value:k,configurable:!0}),k.displayName=p(w,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,p(e,h,"GeneratorFunction")),e.prototype=Object.create(L),e},n.awrap=function(e){return{__await:e}},R(P.prototype),p(P.prototype,d,(function(){return this})),n.AsyncIterator=P,n.async=function(e,t,i,o,s){void 0===s&&(s=r);var a=new P(f(e,t,i,o),s);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(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=M,I.prototype={constructor:I,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(F),!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 new 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),F(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;F(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:M(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},489: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},38:(e,t,n)=>{var r=n(858),i=n(884),o=n(379),s=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},319:(e,t,n)=>{var r=n(646),i=n(860),o=n(379),s=n(206);e.exports=function(e){return r(e)||i(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},868:(e,t,n)=>{var r=n(8).default;e.exports=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},696:(e,t,n)=>{var r=n(8).default,i=n(868);e.exports=function(e){var t=i(e,"string");return"symbol"===r(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},8:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},379:(e,t,n)=>{var r=n(228);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},757:(e,t,n)=>{var r=n(591)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>p});var r=n(8),i=n.n(r),o=n(575),s=n.n(o),a=n(913),u=n.n(a),c=n(713),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=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,s=function t(s,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 t(s,e)}),n)}r[s]=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){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var p=h},462:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PublisherState:()=>Ce,Publishers:()=>Ye,SDK:()=>me,default:()=>$e});var r=n(575),i=n.n(r),o=n(913),s=n.n(o),a=n(713),u=n.n(a),c=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),l=function(){function e(t,n,r){i()(this,e),u()(this,"_category",void 0),u()(this,"_appenders",void 0),u()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return s()(e,[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?e+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}]),e}(),d=function(){function e(){i()(this,e),u()(this,"_appenders",[])}return s()(e,[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}]),e}(),h=function(){function e(){i()(this,e)}return s()(e,null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}]),e}();u()(h,"_sendLocalCandidates",void 0),u()(h,"_sendLogs",void 0),u()(h,"_sendMetrics",void 0),u()(h,"_logToConsole",void 0),h.applyFeatures();var p=function(){function e(){i()(this,e)}return s()(e,null,[{key:"defaultLoggingLevel",get:function(){return c[h.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return c[h.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return c.Info}}]),e}(),f=function(){function e(){i()(this,e),u()(this,"_threshold",p.defaultLoggingLevel)}return s()(e,[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}]),e}(),v=function(){function e(t){i()(this,e),u()(this,"_threshold",void 0),this._threshold=t}return s()(e,[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(c[e],"] ").concat(t);e<c.Warn?console.log(i):console.error(i)}}}]),e}(),g=n(926),y=n.n(g),m=n(757),_=n.n(m),b=function(){function e(){i()(this,e)}return s()(e,null,[{key:"sdkVersion",get:function(){try{return"2023-08-31T12:01:28.500Z (2023.2.17)"}catch(e){return this._defaultVersion}}}]),e}();u()(b,"_defaultVersion",(new Date).toISOString());var C=function(){function e(t){i()(this,e),u()(this,"_telemetryConfiguration",void 0),u()(this,"_logs",[]),u()(this,"_isSending",void 0),u()(this,"_domain",location.hostname),this._telemetryConfiguration=t}var t,n;return s()(e,[{key:"push",value:function(e,t,n,r){var i={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:c[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:b.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<c.Error?this._logs.push(i):this._logs.unshift(i),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(t=y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return Object.values(e).reduce((function(e,t){return e+(t?t.length:0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),i=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(i).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),k=function(){function e(t){i()(this,e),u()(this,"_telemetryService",void 0),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new C(t)}return s()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}(),w=function(){function e(){i()(this,e),u()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_environment",void 0),u()(this,"_threshold",p.defaultTelemetryLoggingLevel)}return s()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),S=function(){function e(){i()(this,e)}return s()(e,null,[{key:"defaultTelemetryLevel",get:function(){return x[h.sendMetrics]}}]),e}(),x=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),T=function(){function e(){i()(this,e),u()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_environment",void 0),u()(this,"_threshold",S.defaultTelemetryLevel)}return s()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),L=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},R=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case x.Off:return"Off";case x.Essential:return"Essential";case x.All:return"All";default:L(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return x.Off;case"Essential":return x.Essential;case"All":return x.All;default:L(e)}}}]),e}(),P=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case c.Off:return"Off";case c.Trace:return"Trace";case c.Debug:return"Debug";case c.Info:return"Trace";case c.Warn:return"Warn";case c.Error:return"Error";case c.Fatal:return"Fatal";case c.All:return"All";default:L(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return c.Off;case"Trace":return c.Trace;case"Debug":return c.Debug;case"Info":return c.Info;case"Warn":return c.Warn;case"Error":return c.Error;case"Fatal":return c.Fatal;case"All":return c.All;default:L(e)}}}]),e}(),O=function(){function e(){i()(this,e)}return s()(e,[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":R.convertTelemetryLevelToTelemetryLevelType(S.defaultTelemetryLevel),"phenix-logging-level":P.convertLoggingLevelToLoggingLevelType(p.defaultLoggingLevel),"phenix-console-logging-level":P.convertLoggingLevelToLoggingLevelType(p.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":P.convertLoggingLevelToLoggingLevelType(p.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}}}]),e}(),D=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return s()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new l(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");c[e]&&this._threshold.setThreshold(c[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(c[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new v(e||p.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||p.defaultTelemetryLoggingLevel,this._appenders.add(new k(this._telemetryConfiguration))}}]),e}();u()(D,"_configurationParameterReader",new O),u()(D,"_loggers",{}),u()(D,"_appenders",new d),u()(D,"_threshold",new f),u()(D,"_telemetryConfiguration",new w),D.applyLoggerConfigFromParameterConfiguration();var E=function(){function e(){throw i()(this,e),new Error("Strings is a static class that may not be instantiated")}return s()(e,null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill((function(){return Math.random().toString(16).substring(2,15)})).reduce((function(e,t){return e+t()}),"").substring(0,e)}}]),e}(),F=n(205),I=n.n(F),M=n(585),A=n.n(M),j=n(754),N=n.n(j),V=function(){function e(t){i()(this,e),u()(this,"_disposed",void 0),u()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}return s()(e,[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}]),e}();var U,B=function(e){I()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=N()(t);if(n){var i=N()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return A()(this,e)});function o(e,t){return i()(this,o),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return s()(o)}(V),G=function(){function e(t){i()(this,e),u()(this,"_listeners",void 0),u()(this,"_value",void 0),this._listeners=[],this._value=t}return s()(e,[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new B(this._listeners,e)}}]),e}(),z=function(){function e(t){i()(this,e),u()(this,"_subject",void 0),this._subject=t}return s()(e,[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}]),e}(),H=function(){function e(t){var n,r;i()(this,e),u()(this,"_applicationId",void 0),u()(this,"_token",void 0),this._applicationId=(null==t?void 0:t.applicationId)||"",this._token={uri:null!=t&&null!==(n=t.token)&&void 0!==n&&n.uri?new URL(t.token.uri):null,capabilities:(null==t||null===(r=t.token)||void 0===r?void 0:r.capabilities)||[]}}return s()(e,[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}]),e}(),W=function(){function e(){i()(this,e)}return s()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new H(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new H(r)}catch(t){return e._logger.error("Cannot parse token value",t),new H(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}]),e}();u()(W,"_logger",D.getLogger("EdgeAuthParser"));var J=function(){function e(){i()(this,e)}return s()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){var e;return/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(e=navigator)||void 0===e?void 0:e.userAgent)}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}]),e}();U=J,u()(J,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),u()(J,"_browserNameAndVersion",U.parseBrowserNameAndVersion()),u()(J,"_browserName",U.parseBrowserName()),u()(J,"_browserMajorVersion",U.parseBrowserMajorVersion()),u()(J,"_isChrome69",U._browserNameAndVersion.includes("Chrome/69.")),u()(J,"_isChrome70",U._browserNameAndVersion.includes("Chrome/70.")),u()(J,"_isChrome71",U._browserNameAndVersion.includes("Chrome/71.")),u()(J,"_isChrome72",U._browserNameAndVersion.includes("Chrome/72.")),u()(J,"_isChrome74",U._browserNameAndVersion.includes("Chrome/74.")),u()(J,"_isChrome75",U._browserNameAndVersion.includes("Chrome/75.")),u()(J,"_isChrome76",U._browserNameAndVersion.includes("Chrome/76.")),u()(J,"_isChrome77",U._browserNameAndVersion.includes("Chrome/77."));var K=n(8),q=n.n(K),Q=function(){function e(){i()(this,e),u()(this,"_list",[])}return s()(e,[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach((function(e){return e.dispose()})),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}]),e}(),Y=function(){function e(){i()(this,e),u()(this,"_disposables",new Q),u()(this,"_readOnlyIsForeground",void 0),u()(this,"_isForeground",void 0),u()(this,"_timeOfLastTabFocusChange",Date.now()),u()(this,"_documentFocusInterval",void 0),this._isForeground=new G(!0),this._readOnlyIsForeground=new z(this._isForeground),this.detectTabFocusChange()}return s()(e,[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":q()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new V((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new V((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}]),e}(),$=function(){function e(){i()(this,e)}return s()(e,null,[{key:"clientOfferDisabled",get:function(){return J.isChrome74||J.isChrome75||J.isChrome76||J.isChrome77}},{key:"addTranceiverDisabled",get:function(){return J.isChrome69||J.isChrome70||J.isChrome71||J.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=69||"Firefox"===J.browserName&&J.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=63||"Firefox"===J.browserName&&J.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===J.browserName&&J.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===J.browserName||"SamsungBrowser"===J.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==J.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===J.browserName&&"function"==typeof(null===(e=document)||void 0===e?void 0:e.createElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion>=71||"Firefox"===J.browserName&&J.browserMajorVersion>=69||"Safari"===J.browserName}},{key:"isMobile",get:function(){return J.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){var e,t;return void 0!==(null===(e=RTCRtpReceiver)||void 0===e||null===(t=e.prototype)||void 0===t?void 0:t.createEncodedStreams)}}]),e}(),Z=n(202).default,X=function(){function e(t){i()(this,e),u()(this,"_logger",D.getLogger("VanillaPeerConnection")),u()(this,"_peerConnection",void 0),$.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,o;return s()(e,[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"connectionState",get:function(){return this._peerConnection.connectionState}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsAddTransceiver",get:function(){return!$.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(o=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new Z((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"createAnswer",value:(r=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new Z((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription($.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(t=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription($.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new Z((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){return this._peerConnection.onconnectionstatechange},set:function(e){this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]),e}(),ee=X,te=function(){function e(){i()(this,e)}var t;return s()(e,[{key:"createPeerConnection",value:(t=y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ee(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}(),ne=te,re=function(){function e(){throw i()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}var t,n;return s()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){$.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=y()(_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=y()(_().mark((function t(){var n,r,i,o,s=arguments;return _().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={encodedInsertableStreams:r},t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=y()(_().mark((function e(t){var r,i,o;return _().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 t.apply(this,arguments)})}]),e}();u()(re,"_logger",D.getLogger("PeerConnectionService")),u()(re,"_peerConnectionFactory",new G(new ne)),u()(re,"_cached",void 0),re.initiateInitialPrecaching();var ie=function(){function e(){i()(this,e)}return s()(e,null,[{key:"getTelemetryUrl",value:function(e){try{var t=new URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}]),e}(),oe=function(){function e(){i()(this,e)}return s()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}(),se=function(){function e(){i()(this,e)}return s()(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:""}}}}]),e}();u()(se,"_discoveryParameters",void 0),se.applyParameters();var ae=function(){function e(){throw i()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return s()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=b.sdkVersion,r=se.discoveryParameters.intentions;return t.search="?".concat(new URLSearchParams([["version",n],["intentions",r],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}]),e}();u()(ae,"_discoveryUri",new G("https://pcast.phenixrts.com/pcast/endPoints"));var ue,ce=n(319),le=n.n(ce),de=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;i()(this,e),u()(this,"_backoffIntervalInMillisecond",void 0),u()(this,"_minBackoffIntervalInMillisecond",void 0),u()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=t,this._minBackoffIntervalInMillisecond=n,this._maxBackoffIntervalInMillisecond=r}return s()(e,[{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)}}]),e}(),he=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}(he||{}),pe=he,fe=function(){function e(t){i()(this,e),u()(this,"_metrics",void 0),this._metrics=t}return s()(e,[{key:"getName",value:function(){return pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case pe.TimeToFirstFrame:case pe.ChannelCreationTimeToFirstFrame:return x.Essential;case pe.Stalled:case pe.Buffering:case pe.SetupCompleted:case pe.SetupFailed:case pe.RoundTripTime:case pe.DownlinkThroughputCapacity:case pe.NetworkType:case pe.ResolutionChanged:case pe.ApplicationForeground:case pe.ApplicationBackground:return x.All;default:L(this._metrics)}}}]),e}(),ve=function(){function e(t){i()(this,e),u()(this,"_logger",D.getLogger("MetricsService")),u()(this,"_metricsConfiguration",void 0),u()(this,"_exponentialBackoff",void 0),u()(this,"_metrics",[]),u()(this,"_isSending",void 0),u()(this,"_failureCount",0),u()(this,"_domain",location.hostname),this._metricsConfiguration=t,this._exponentialBackoff=new de}var t,n;return s()(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 fe(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:b.sdkVersion,runtime:i,resource:o,kind:s};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(t=y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void setTimeout((function(){n._metrics=[].concat(le()(t),le()(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 t.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]),e}(),ge=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return s()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var r=new T;return r.sessionId=me.clientSessionId,r.tenancy=me.tenancy.value,r.url=ie.getTelemetryUrl(t),r.environment=oe.getEnvironmentFromUrl(t),r.threshold=R.convertTelemetryLevelTypeToTelemetryLevel(me.telemetryLevel),e._metricsServices[t]=new ve(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();u()(ge,"_metricsServices",{});var ye=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),me=function(){function e(){throw i()(this,e),new Error("SDK is a static class that may not be instantiated")}return s()(e,null,[{key:"pageLoadTime",get:function(){return ye}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return P.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return R.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return J}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=D.telemetryConfiguration;n.sessionId=e.clientSessionId,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof k}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(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 k}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ge.getMetricsService(ae.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ge.setTelemetryLevel(x[t]),e._telemetryLevel.subscribe((function(e){ge.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=this._configurationParameterReader.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=this._configurationParameterReader.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=oe.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=W.parseToken(t);return e._tenancy.value=n.tenancy,ae.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return ae.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");return i?(ae.uri.value="".concat(i,"/pcast/endPoints"),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)):void 0}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new Y),t){if(t.discoveryUri&&(ae.uri.value=t.discoveryUri),t.peerConnectionFactory&&(re.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&x[t.telemetryLevel]&&(e._telemetryLevel.value=R.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&c[t.loggingLevel]&&this._logger.threshold.setThreshold(P.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&c[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof v}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new v(P.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ie.getTelemetryUrl(e)}}]),e}();ue=me,u()(me,"_automaticallyRetryOnFailure",!0),u()(me,"_automaticallyReconnectPeerConnection",!0),u()(me,"_automaticallyPlayMediaStream",!0),u()(me,"_automaticallyMuteVideoOnPlayFailure",!0),u()(me,"_forceGarbageCollectionOnRestart",!0),u()(me,"_skipGarbageCollectionOnMobileDevices",!0),u()(me,"_webPlayerLoader",null),u()(me,"_shakaPlayerLoader",null),u()(me,"_hlsJsLoader",null),u()(me,"_configurationParameterReader",new O),u()(me,"_applicationActivityMonitor",void 0),u()(me,"_environment",new G("")),u()(me,"_telemetryUrl",new G("https://telemetry.phenixrts.com/telemetry")),u()(me,"_maximalNumberOfPeerConnectionReconnectAttempts",8),u()(me,"_telemetryLevel",new G(S.defaultTelemetryLevel)),u()(me,"_metricsService",void 0),u()(me,"_metricsConfiguration",void 0),u()(me,"_sendLocalCandidates",new G(h.sendLocalCandidates)),u()(me,"_tenancy",new G("")),u()(me,"_clientSessionId",E.random(32)),u()(me,"_loadedTimestamp",new Date),u()(me,"_logger",D.getLogger("SDK")),u()(me,"_initialized",new G(!1)),u()(me,"_readOnlyInitialized",new z(ue._initialized)),u()(me,"_readOnlyDiscoveryUri",new z(ae.uri)),u()(me,"_readOnlyPeerConnectionFactory",new z(re.peerConnectionFactory)),window.addEventListener("unload",(function(){me.dispose()})),me.applyDiscoveryUriDefaultFromParameterConfiguration(),me.applyMetricsConfiguration(),me.applyTelemetryConfiguration(),me.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),me.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),me.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),me.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),me.init();var _e=function(){function e(){throw i()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}return s()(e,null,[{key:"forceGarbageCollection",value:function(){$.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){var e=this;$.isQueueMicrotaskSupported?queueMicrotask((function(){e.overloadMemoryToInvokeGarbageCollection()})):setTimeout((function(){e.overloadMemoryToInvokeGarbageCollection()}))}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=document.createElement("img");e.src=window.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){window.URL.revokeObjectURL(this.src),e=null}}}]),e}(),be=function(e){return 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}(be||{}),Ce=be,ke=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;i()(this,e),u()(this,"_duration",void 0),this._duration=t}return s()(e,[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,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)}}]),e}(),we=function(){function e(t){i()(this,e),u()(this,"_logger",D.getLogger("StreamSetupListener")),u()(this,"metricsService",me.metricsService),u()(this,"_pageLoadTime",void 0),u()(this,"_startTime",void 0),u()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return s()(e,[{key:"success",value:function(e){this.recordStreamMetric(pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new fe(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 ke(n-this._pageLoadTime).toIsoString(),t,i,new ke(r).toIsoString())}}}]),e}(),Se=function(){function e(){i()(this,e),u()(this,"_disposables",new Q),u()(this,"_isSupported",navigator&&navigator.connection),u()(this,"_rtt",new G(void 0)),u()(this,"_effectiveType",new G(void 0)),u()(this,"_downlinkThroughputCapacity",new G(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return s()(e,[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new V((function(){navigator.connection.removeEventListener("change",t)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}]),e}(),xe=function(){function e(t,n){var r=this;i()(this,e),u()(this,"_logger",D.getLogger("SessionTelemetry")),u()(this,"_metricsService",void 0),u()(this,"_applicationActivityMonitor",me.applicationActivityMonitor),u()(this,"_networkMonitor",new Se),u()(this,"_pageLoadTime",void 0),u()(this,"_disposables",new Q),u()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}return s()(e,[{key:"listenOnStreamSetup",value:function(){return new we(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?pe.ApplicationForeground:pe.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new ke(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:pe.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new ke(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:pe.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new ke(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:pe.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new ke(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}(),Te=s()((function e(t){i()(this,e),u()(this,"token",void 0),u()(this,"tokenExpiring",void 0),this.token=new G(t),this.tokenExpiring=new G(!1)})),Le=function(){function e(t){i()(this,e),u()(this,"publisherInitialization",void 0),u()(this,"disposables",void 0),u()(this,"publisherDisposables",void 0),u()(this,"state",void 0),u()(this,"authorized",void 0),u()(this,"online",void 0),u()(this,"loading",void 0),u()(this,"publishing",void 0),u()(this,"standby",void 0),u()(this,"stopped",void 0),u()(this,"failureCount",void 0),u()(this,"endPoint",void 0),u()(this,"stream",void 0),u()(this,"rtcStatistics",void 0),u()(this,"clearFailureCountTimeout",void 0),u()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),u()(this,"name",void 0),this.disposables=new Q,this.publisherDisposables=new Q,this.publisherInitialization=new Date,this.state=new G(Ce.Starting),this.authorized=new G(!0),this.online=new G(!0),this.loading=new G(!1),this.publishing=new G(!1),this.standby=new G(!1),this.stopped=new G(!1),this.failureCount=new G(0),this.endPoint=new G(null),this.stream=new G(null),this.rtcStatistics=new G(null),this.name=t&&t.length?t:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0}return s()(e,[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"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 Ce.Starting;case"not-found":return Ce.NotFound;case"geo-restricted":return Ce.GeoRestricted;case"geo-blocked":return Ce.GeoBlocked;case"unauthorized":return Ce.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ce.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Ce.ConfigurationError;case"port-in-range-not-found":return Ce.TransientConfigurationError;case"failed":return Ce.Error;default:L(e)}}},{key:"generateScreenName",value:function(){return E.random(12)}}]),e}(),Re=s()((function e(){i()(this,e),u()(this,"mediaStream",void 0),u()(this,"peerConnection",void 0),u()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new G(null),this.peerConnection=new G(null),this.peerConnectionReconnectAttempts=0})),Pe=s()((function e(){i()(this,e),u()(this,"isStarting",void 0),u()(this,"isDisposed",void 0),this.isStarting=new G(!1),this.isDisposed=!1})),Oe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),De=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ee=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case De.Normal:return"Normal";case De.Force:return"Force";case De.Reset:return"Reset";default:L(e)}}}]),e}(),Fe=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Oe.Keep:return"Keep";case Oe.Reset:return"Reset";default:L(e)}}}]),e}(),Ie=n(202).default,Me=function(){function e(t,n){if(i()(this,e),u()(this,"_logger",D.getLogger("EndPoint")),u()(this,"_uri",void 0),u()(this,"_timeout",void 0),u()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}var t,n,r,o,a,c,l,d,h,p,f,v,g;return s()(e,[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(g=y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Ie.race([fetch(t,{method:"GET",cache:"no-cache"}),new Ie((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"subscribe",value:(v=y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f,v,g=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=W.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 FormData,a=b.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,Ie.race([fetch(o,{method:"POST",body:s}),new Ie((function(e){return h=window.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){h&&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 v.apply(this,arguments)})},{key:"publish",value:(f=y()(_().mark((function e(t,n,r,i){var o,s,a,u,c,l,d,h,p,f,v,g,y=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=W.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 FormData,u=b.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,Ie.race([fetch(s,{method:"POST",body:a}),new Ie((function(e){return p=window.setTimeout((function(){y._logger.error("Failed to publish",new Error("Publish timed out [".concat(s,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&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 f.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret: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,Ie.race([fetch(r,{method:"POST",body:i}),new Ie((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9: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 p.apply(this,arguments)})},{key:"limitBitrate",value:(h=y()(_().mark((function e(t,n,r,i,o){var s,a,u,c,l,d,h,p,f=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),a=new FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Fe.convertBitrateStateToBitrateStateType(i),bitrateMode:Ee.convertBitrateModeToBitrateModeType(o)},a.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Ie.race([fetch(s,{method:"POST",body:a}),new Ie((function(e){return d=window.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&&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 h.apply(this,arguments)})},{key:"addIceCandidates",value:(d=y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f=this,v=arguments;return _().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 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,Ie.race([fetch(o,{method:"POST",body:s}),new Ie((function(e){return l=window.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&&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 d.apply(this,arguments)})},{key:"destroyStream",value:(l=y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,Ie.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Ie((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9: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 l.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(c=y()(_().mark((function e(t,n){var r,i,o,s;return _().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 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 c.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,le()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=b.sdkVersion,n=se.discoveryParameters.intentions;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["intentions",n],["_","".concat(Date.now())]]).toString()),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=y()(_().mark((function e(t,n){var r,i;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(o=y()(_().mark((function e(t,n){var r,i;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.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=y()(_().mark((function e(t){var n,r;return _().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=y()(_().mark((function e(t){var n,r;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(t=y()(_().mark((function e(t){var n,r;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}(),Ae=n(202).default,je=function(){function e(t){if(i()(this,e),u()(this,"_logger",D.getLogger("Discovery")),u()(this,"_metricsService",void 0),u()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ge.getMetricsService(t.toString()),this._uri=t}var t,n;return s()(e,[{key:"discoverNearbyEndPoints",value:(n=y()(_().mark((function e(t,n){var r,i,o,s;return _().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,Ae.race([fetch(r,{method:"GET",cache:"no-cache"}),new Ae((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,s=o.split(","),e.abrupt("return",s.map((function(e){return new Me(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=y()(_().mark((function e(){var t,n,r,i,o,s,a=this,u=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ae.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new Ae((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Ae.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:pe.RoundTripTime,runtime:(n-me.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 t.apply(this,arguments)})}]),e}(),Ne=function(){function e(){throw i()(this,e),new Error("Discovery is a static class that may not be instantiated")}var t,n;return s()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=y()(_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(me.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=y()(_().mark((function t(n){var r,i,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new je(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();e._cache[n]&&delete e._cache[n]}}]),e}();u()(Ne,"_cache",{}),Ne.precacheClosestEndPointDiscovery();var Ve=n(38),Ue=n.n(Ve),Be=function(){function e(t){i()(this,e),u()(this,"_sdp",void 0),u()(this,"_audioCodec",void 0),u()(this,"_videoCodec",void 0),u()(this,"_isAudioTrackEnabled",void 0),u()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split("m=");this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}return s()(e,[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}]),e}(),Ge=function(){function e(t,n,r){if(i()(this,e),u()(this,"_estimatedRoundTripTime",void 0),u()(this,"_estimatedVideoCodec",void 0),u()(this,"_estimatedAudioCodec",void 0),u()(this,"_rtcStatistic",new G({})),u()(this,"_peerConnection",void 0),u()(this,"_isMonitorRunning",!0),u()(this,"_updateTimeout",void 0),u()(this,"_availableTracks",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._peerConnection){var o=new Be(this._peerConnection.currentLocalDescription.sdp),s=new Be(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=s.audioCodec,this._estimatedVideoCodec=s.videoCodec,this._availableTracks={audio:o.isAudioTrackEnabled&&s.isAudioTrackEnabled,video:o.isVideoTrackEnabled&&s.isVideoTrackEnabled},this.updateStatistic()}}var t;return s()(e,[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(s){if("candidate-pair"===s.type&&s.currentRoundTripTime&&(o=1e3*s.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===s.type&&s.lastPacketSentTimestamp&&(i=s.lastPacketSentTimestamp,r.audio&&(r.audio.lastPacketSentTimestamp=i),r.video&&(r.video.lastPacketSentTimestamp=i)),"outbound-rtp"===s.type){var a=s.kind||s.mediaType||t(s),u="";if(e.forEach((function(e){e.id===s.codecId&&(u=e.mimeType)})),a&&n._availableTracks[a]){var c,l,d,h,p,f=(s.bytesSent||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[a])||void 0===d?void 0:d.bytesSent)&&void 0!==c?c:0),v=s.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[a])||void 0===p?void 0:p.timestamp),g=f&&v?Math.floor(8*f/v*1e3):0;if(r[a]={ssrc:s.ssrc,mediaType:a,timestamp:s.timestamp,bitrate:g,bytesSent:s.bytesSent,packetsSent:s.packetsSent,retransmittedBytesSent:s.retransmittedBytesSent,codec:u||n.getCodecByType(a),roundTripTime:o},(s.lastPacketSentTimestamp||i)&&(r[a].lastPacketSentTimestamp=s.lastPacketSentTimestamp||i),"video"===a&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[a].firCount=s.firCount,r[a].frameHeight=s.frameHeight,r[a].frameWidth=s.frameWidth,r[a].framesEncoded=s.framesEncoded,r[a].framesSent=s.framesSent,r[a].headerBytesSent=s.headerBytesSent,r[a].hugeFramesSent=s.hugeFramesSent,r[a].pliCount=s.pliCount,r[a].qpSum=s.qpSum,r[a].totalEncodeTime=s.totalEncodeTime,r[a].totalEncodedBytesTarget=s.totalEncodedBytesTarget;var y=(s.framesEncoded-n._rtcStatistic.value.video.framesEncoded)/(r[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[a].fps=y?Math.round(100*y)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeout=window.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]),e}(),ze=function(){function e(){throw i()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}return s()(e,null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}]),e}(),He=n(202).default;function We(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 Je(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?We(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):We(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ke=function(){function e(t,n,r){i()(this,e),u()(this,"_logger",D.getLogger("RealTimePublisher")),u()(this,"_publisherContext",void 0),u()(this,"_peerConnectionContext",void 0),u()(this,"_handleStreamFailure",void 0),this._publisherContext=t,this._peerConnectionContext=n,this._handleStreamFailure=r}var t;return s()(e,[{key:"start",value:function(e,t,n){var r=this;return navigator.onLine?He.all([Ne.discoverClosestEndPointWithCaching(e),re.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=Ue()(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),($.clientOfferDisabled||!a.supportsSetConfiguration||!a.supportsGetConfiguration||r._publisherContext.failureCount.value>0)&&(a.close(),a.dispose(),!me.forceGarbageCollectionOnRestart||$.isMobile&&me.skipGarbageCollectionOnMobileDevices||_e.forceGarbageCollection(),a=null,s=null,r._peerConnectionContext.peerConnection.value=a),i.publish(r._publisherContext.name,t,s,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status,i=e.stream,o=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,a=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;if(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),"ok"===t)return 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||me.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=setTimeout((function(){r._publisherContext.stream.value!==i||o||r._publisherContext.endPoint.value.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(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=Ce.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:L(e.iceConnectionState)}}},new He((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(){if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,u.sessionDescription.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,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,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){return r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp),r._publisherContext.endPoint.value.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,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(){n.success(r._publisherContext.streamId),r._publisherContext.state.value=Ce.Publishing,r._publisherContext.publishing.value=!0;var t=new Ge(e,r._peerConnectionContext.mediaStream.value,r._publisherContext.endPoint.value.roundTripTime/4);return r._publisherContext.disposables.add(t),t.rtcStatistic.subscribe((function(e){r._publisherContext.rtcStatistics.value=e})),He.resolve()}))}))})):(this._publisherContext.state.value=Ce.Offline,He.resolve())}},{key:"applyRtcConfiguration",value:(t=y()(_().mark((function e(t,n){var r;return _().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",me.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=Je(Je({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Ce.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<me.maximalNumberOfPeerConnectionReconnectAttempts||!me.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if($.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new V((function(){return 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=setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new V((function(){return clearTimeout(r)})))}else n._publisherContext.state.value=Ce.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 Ce.Starting;case"unauthorized":return Ce.Unauthorized;case"not-found":return Ce.NotFound;case"capacity":case"rate-limited":case"timeout":return Ce.Recovering;case"failed":return Ce.Error;default:L(e)}}}]),e}(),qe=n(202).default,Qe=function(){function e(t,n,r){var o=this;i()(this,e),u()(this,"_logger",D.getLogger("Publisher")),u()(this,"_tokenContext",void 0),u()(this,"_publisherContext",void 0),u()(this,"_peerConnectionContext",void 0),u()(this,"_stateContext",void 0),u()(this,"_exponentialBackoff",void 0),u()(this,"_publisherStartTime",void 0),u()(this,"_readOnlyToken",void 0),u()(this,"_readOnlyPeerConnection",void 0),u()(this,"_readOnlyState",void 0),u()(this,"_readOnlyTokenExpiring",void 0),u()(this,"_readOnlyAuthorized",void 0),u()(this,"_readOnlyOnline",void 0),u()(this,"_readOnlyLoading",void 0),u()(this,"_readOnlyPublishing",void 0),u()(this,"_readOnlyStandby",void 0),u()(this,"_readOnlyStopped",void 0),u()(this,"_readOnlyFailureCount",void 0),u()(this,"_readOnlyEndPoint",void 0),u()(this,"_readOnlyStream",void 0),u()(this,"_readOnlyRtcStatistics",void 0),u()(this,"_readOnlyMediaStream",void 0),u()(this,"_metricsService",void 0),u()(this,"_sessionTelemetry",void 0),this._tokenContext=new Te(n),this._publisherContext=new Le(r),this._peerConnectionContext=new Re,this._stateContext=new Pe,this._exponentialBackoff=new de,this._publisherStartTime=Date.now(),this._readOnlyToken=new z(this._tokenContext.token),this._readOnlyPeerConnection=new z(this._peerConnectionContext.peerConnection),this._readOnlyState=new z(this._publisherContext.state),this._readOnlyTokenExpiring=new z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new z(this._publisherContext.authorized),this._readOnlyOnline=new z(this._publisherContext.online),this._readOnlyLoading=new z(this._publisherContext.loading),this._readOnlyPublishing=new z(this._publisherContext.publishing),this._readOnlyStandby=new z(this._publisherContext.standby),this._readOnlyStopped=new z(this._publisherContext.stopped),this._readOnlyFailureCount=new z(this._publisherContext.failureCount),this._readOnlyEndPoint=new z(this._publisherContext.endPoint),this._readOnlyStream=new z(this._publisherContext.stream),this._readOnlyRtcStatistics=new z(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new z(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=t;var s=W.parseToken(this._tokenContext.token.value),a=(s.uri||me.discoveryUri.value).toString();me.tenancy.value=s.tenancy||me.tenancy.value,ae.uri.value=a,this._metricsService=ge.getMetricsService(a),this._sessionTelemetry=new xe(me.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){o._publisherContext.clearFailureCountTimeout&&clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Ce.Publishing&&(o._publisherContext.clearFailureCountTimeout=window.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")};window.addEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new V((function(){window.removeEventListener("beforeunload",c)}))),this.start()}var t,n,r,o,a;return s()(e,[{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=W.parseToken(this._tokenContext.token.value),n=(t.uri||me.discoveryUri.value).toString();me.tenancy.value=t.tenancy||me.tenancy.value,ae.uri.value=n,this._metricsService=ge.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new qe((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 a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=Ce.Stopped}},{key:"dispose",value:(o=y()(_().mark((function e(){var t=this;return _().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 o.apply(this,arguments)})},{key:"getUri",value:function(e){return W.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",me.discoveryUri.value),new URL(me.discoveryUri.value))}},{key:"start",value:(r=y()(_().mark((function e(){return _().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:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach((function(e){t._peerConnectionContext.peerConnection.value.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:"processStart",value:(n=y()(_().mark((function e(){var t,n,r,i,o,s=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),W.isEncodedEdgeTokenValid(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Ce.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:return this.cleanUpResources("client:start"),this._publisherContext.state.value=Ce.Starting,this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==Ce.Error&&e!==Ce.Recovering||Ne.clearCachedClosestEndpoint(r)}))),i=function(){return new qe((function(e){return s._stateContext.isStarting.value=!1,e(s.handleStreamFailure())}))},o=new Ke(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=Ce.ClientStartError,s._logger.error("Failed to start publishing",e)})).finally((function(){if(s._stateContext.isStarting.value=!1,s._publisherContext.state.value!==Ce.Publishing&&me.automaticRetryOnFailure){var e=setTimeout((function(){s.handleStreamFailure().catch((function(e){s._logger.error("Failed handling stream failure",e)}))}),s.getRetryInterval());s._publisherContext.disposables.add(new V((function(){clearTimeout(e)})))}else s._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case Ce.Offline:return 15e3;case Ce.NotFound:case Ce.Error:case Ce.Recovering:case Ce.Unauthorized:case Ce.GeoRestricted:case Ce.GeoBlocked:case Ce.Stopped:case Ce.Starting:case Ce.Publishing:case Ce.Reconnecting:case Ce.UnsupportedFeature:case Ce.ConfigurationError:case Ce.TransientConfigurationError:case Ce.ConnectionError:case Ce.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:L(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(t=y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===Ce.Error||e.t0===Ce.Reconnecting||e.t0===Ce.Offline||e.t0===Ce.Recovering||e.t0===Ce.TransientConfigurationError||e.t0===Ce.ConnectionError||e.t0===Ce.ClientStartError?4:e.t0===Ce.Unauthorized?11:e.t0===Ce.GeoRestricted?13:e.t0===Ce.GeoBlocked?15:e.t0===Ce.Stopped?17:e.t0===Ce.Publishing?19:e.t0===Ce.Starting?21:e.t0===Ce.UnsupportedFeature?23:e.t0===Ce.NotFound?25:e.t0===Ce.ConfigurationError?27:29;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,Ce[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Ce[this._publisherContext.state.value]),e.abrupt("break",30);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 already starting, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 29:L(this._publisherContext.state.value);case 30:return e.abrupt("return",this.start());case 31:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!me.forceGarbageCollectionOnRestart||$.isMobile&&me.skipGarbageCollectionOnMobileDevices||_e.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}}]),e}(),Ye=function(){function e(){throw i()(this,e),new Error("Publishers is a static class that may not be instantiated")}return s()(e,null,[{key:"createPublisher",value:function(e){if(!me.initialized.value)throw new Error("SDK is not loaded.");return new Qe(e.mediaStream,e.token,e.name)}}]),e}(),$e={SDK:me,Publishers:Ye,PublisherState:Ce}}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(462)})()}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(function(){return(()=>{var e={228:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},858:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},646:(e,t,n)=>{var r=n(228);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},506: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},926:(e,t,n)=>{var r=n(202).default;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},575: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},913:(e,t,n)=>{var r=n(696);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},713:(e,t,n)=>{var r=n(696);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},754: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},205:(e,t,n)=>{var r=n(489);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},860: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},884: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},521:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},206: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},585:(e,t,n)=>{var r=n(8).default,i=n(506);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},591:(e,t,n)=>{var r=n(202).default,i=n(8).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 I(r||[]);return u(o,"_invoke",{value:O(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",y="suspendedYield",m="executing",_="completed",b={};function C(){}function k(){}function w(){}var S={};p(S,l,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(M([])));T&&T!==s&&a.call(T,l)&&(S=T);var L=w.prototype=C.prototype=Object.create(S);function R(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function P(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 O(e,n,r){var i=g;return function(o,s){if(i===m)throw new 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=m;var c=v(e,n,r);if("normal"===c.type){if(i=r.done?_:y,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 E(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 F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function M(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 k.prototype=w,u(L,"constructor",{value:w,configurable:!0}),u(w,"constructor",{value:k,configurable:!0}),k.displayName=p(w,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,p(e,h,"GeneratorFunction")),e.prototype=Object.create(L),e},n.awrap=function(e){return{__await:e}},R(P.prototype),p(P.prototype,d,(function(){return this})),n.AsyncIterator=P,n.async=function(e,t,i,o,s){void 0===s&&(s=r);var a=new P(f(e,t,i,o),s);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(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=M,I.prototype={constructor:I,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(F),!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 new 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),F(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;F(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:M(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},489: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},38:(e,t,n)=>{var r=n(858),i=n(884),o=n(379),s=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},319:(e,t,n)=>{var r=n(646),i=n(860),o=n(379),s=n(206);e.exports=function(e){return r(e)||i(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},868:(e,t,n)=>{var r=n(8).default;e.exports=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},696:(e,t,n)=>{var r=n(8).default,i=n(868);e.exports=function(e){var t=i(e,"string");return"symbol"===r(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},8:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},379:(e,t,n)=>{var r=n(228);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},757:(e,t,n)=>{var r=n(591)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>p});var r=n(8),i=n.n(r),o=n(575),s=n.n(o),a=n(913),u=n.n(a),c=n(713),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=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,s=function t(s,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 t(s,e)}),n)}r[s]=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){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var p=h},462:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PublisherState:()=>Ce,Publishers:()=>Ye,SDK:()=>me,default:()=>$e});var r=n(575),i=n.n(r),o=n(913),s=n.n(o),a=n(713),u=n.n(a),c=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),l=function(){function e(t,n,r){i()(this,e),u()(this,"_category",void 0),u()(this,"_appenders",void 0),u()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return s()(e,[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>c.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(c.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?e+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}]),e}(),d=function(){function e(){i()(this,e),u()(this,"_appenders",[])}return s()(e,[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}]),e}(),h=function(){function e(){i()(this,e)}return s()(e,null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}]),e}();u()(h,"_sendLocalCandidates",void 0),u()(h,"_sendLogs",void 0),u()(h,"_sendMetrics",void 0),u()(h,"_logToConsole",void 0),h.applyFeatures();var p=function(){function e(){i()(this,e)}return s()(e,null,[{key:"defaultLoggingLevel",get:function(){return c[h.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return c[h.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return c.Info}}]),e}(),f=function(){function e(){i()(this,e),u()(this,"_threshold",p.defaultLoggingLevel)}return s()(e,[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}]),e}(),v=function(){function e(t){i()(this,e),u()(this,"_threshold",void 0),this._threshold=t}return s()(e,[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(c[e],"] ").concat(t);e<c.Warn?console.log(i):console.error(i)}}}]),e}(),g=n(926),y=n.n(g),m=n(757),_=n.n(m),b=function(){function e(){i()(this,e)}return s()(e,null,[{key:"sdkVersion",get:function(){try{return"2023-09-14T19:20:08.023Z (2023.2.18-beta.136)"}catch(e){return this._defaultVersion}}}]),e}();u()(b,"_defaultVersion",(new Date).toISOString());var C=function(e,t){function n(e){i()(this,n),u()(this,"_telemetryConfiguration",void 0),u()(this,"_logs",[]),u()(this,"_isSending",void 0),u()(this,"_domain",location.hostname),this._telemetryConfiguration=e}return s()(n,[{key:"push",value:function(e,t,n,r){var i={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:c[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:b.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<c.Error?this._logs.push(i):this._logs.unshift(i),this.sendLogsIfAble()}},{key:"sendLogs",value:function(t){return(e=e||y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"sendLogsIfAble",value:function(){return(t=t||y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return Object.values(e).reduce((function(e,t){return e+(t?t.length:0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),i=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(i).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 11:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}}]),n}(),k=function(){function e(t){i()(this,e),u()(this,"_telemetryService",void 0),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new C(t)}return s()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}(),w=function(){function e(){i()(this,e),u()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_environment",void 0),u()(this,"_threshold",p.defaultTelemetryLoggingLevel)}return s()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),S=function(){function e(){i()(this,e)}return s()(e,null,[{key:"defaultTelemetryLevel",get:function(){return x[h.sendMetrics]}}]),e}(),x=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),T=function(){function e(){i()(this,e),u()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),u()(this,"_tenancy",void 0),u()(this,"_sessionId",void 0),u()(this,"_environment",void 0),u()(this,"_threshold",S.defaultTelemetryLevel)}return s()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),L=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},R=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case x.Off:return"Off";case x.Essential:return"Essential";case x.All:return"All";default:L(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return x.Off;case"Essential":return x.Essential;case"All":return x.All;default:L(e)}}}]),e}(),P=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case c.Off:return"Off";case c.Trace:return"Trace";case c.Debug:return"Debug";case c.Info:return"Trace";case c.Warn:return"Warn";case c.Error:return"Error";case c.Fatal:return"Fatal";case c.All:return"All";default:L(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return c.Off;case"Trace":return c.Trace;case"Debug":return c.Debug;case"Info":return c.Info;case"Warn":return c.Warn;case"Error":return c.Error;case"Fatal":return c.Fatal;case"All":return c.All;default:L(e)}}}]),e}(),O=function(){function e(){i()(this,e)}return s()(e,[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":R.convertTelemetryLevelToTelemetryLevelType(S.defaultTelemetryLevel),"phenix-logging-level":P.convertLoggingLevelToLoggingLevelType(p.defaultLoggingLevel),"phenix-console-logging-level":P.convertLoggingLevelToLoggingLevelType(p.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":P.convertLoggingLevelToLoggingLevelType(p.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}}}]),e}(),D=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return s()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new l(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");c[e]&&this._threshold.setThreshold(c[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(c[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new v(e||p.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||p.defaultTelemetryLoggingLevel,this._appenders.add(new k(this._telemetryConfiguration))}}]),e}();u()(D,"_configurationParameterReader",new O),u()(D,"_loggers",{}),u()(D,"_appenders",new d),u()(D,"_threshold",new f),u()(D,"_telemetryConfiguration",new w),D.applyLoggerConfigFromParameterConfiguration();var E=function(){function e(){throw i()(this,e),new Error("Strings is a static class that may not be instantiated")}return s()(e,null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill((function(){return Math.random().toString(16).substring(2,15)})).reduce((function(e,t){return e+t()}),"").substring(0,e)}}]),e}(),F=n(205),I=n.n(F),M=n(585),A=n.n(M),j=n(754),N=n.n(j),V=function(){function e(t){i()(this,e),u()(this,"_disposed",void 0),u()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}return s()(e,[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}]),e}();var U,B=function(e){I()(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=N()(t);if(n){var i=N()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return A()(this,e)});function o(e,t){return i()(this,o),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return s()(o)}(V),G=function(){function e(t){i()(this,e),u()(this,"_listeners",void 0),u()(this,"_value",void 0),this._listeners=[],this._value=t}return s()(e,[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new B(this._listeners,e)}}]),e}(),z=function(){function e(t){i()(this,e),u()(this,"_subject",void 0),this._subject=t}return s()(e,[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}]),e}(),H=function(){function e(t){var n,r;i()(this,e),u()(this,"_applicationId",void 0),u()(this,"_token",void 0),this._applicationId=(null==t?void 0:t.applicationId)||"",this._token={uri:null!=t&&null!==(n=t.token)&&void 0!==n&&n.uri?new URL(t.token.uri):null,capabilities:(null==t||null===(r=t.token)||void 0===r?void 0:r.capabilities)||[]}}return s()(e,[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}]),e}(),W=function(){function e(){i()(this,e)}return s()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new H(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new H(r)}catch(t){return e._logger.error("Cannot parse token value",t),new H(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}]),e}();u()(W,"_logger",D.getLogger("EdgeAuthParser"));var J=function(){function e(){i()(this,e)}return s()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){var e;return/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(e=navigator)||void 0===e?void 0:e.userAgent)}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}]),e}();U=J,u()(J,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),u()(J,"_browserNameAndVersion",U.parseBrowserNameAndVersion()),u()(J,"_browserName",U.parseBrowserName()),u()(J,"_browserMajorVersion",U.parseBrowserMajorVersion()),u()(J,"_isChrome69",U._browserNameAndVersion.includes("Chrome/69.")),u()(J,"_isChrome70",U._browserNameAndVersion.includes("Chrome/70.")),u()(J,"_isChrome71",U._browserNameAndVersion.includes("Chrome/71.")),u()(J,"_isChrome72",U._browserNameAndVersion.includes("Chrome/72.")),u()(J,"_isChrome74",U._browserNameAndVersion.includes("Chrome/74.")),u()(J,"_isChrome75",U._browserNameAndVersion.includes("Chrome/75.")),u()(J,"_isChrome76",U._browserNameAndVersion.includes("Chrome/76.")),u()(J,"_isChrome77",U._browserNameAndVersion.includes("Chrome/77."));var K=n(8),q=n.n(K),Q=function(){function e(){i()(this,e),u()(this,"_list",[])}return s()(e,[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach((function(e){return e.dispose()})),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}]),e}(),Y=function(){function e(){i()(this,e),u()(this,"_disposables",new Q),u()(this,"_readOnlyIsForeground",void 0),u()(this,"_isForeground",void 0),u()(this,"_timeOfLastTabFocusChange",Date.now()),u()(this,"_documentFocusInterval",void 0),this._isForeground=new G(!0),this._readOnlyIsForeground=new z(this._isForeground),this.detectTabFocusChange()}return s()(e,[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":q()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new V((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new V((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}]),e}(),$=function(){function e(){i()(this,e)}return s()(e,null,[{key:"clientOfferDisabled",get:function(){return J.isChrome74||J.isChrome75||J.isChrome76||J.isChrome77}},{key:"addTranceiverDisabled",get:function(){return J.isChrome69||J.isChrome70||J.isChrome71||J.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=69||"Firefox"===J.browserName&&J.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=63||"Firefox"===J.browserName&&J.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===J.browserName&&J.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===J.browserName||"SamsungBrowser"===J.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==J.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===J.browserName&&"function"==typeof(null===(e=document)||void 0===e?void 0:e.createElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===J.browserName&&J.browserMajorVersion>=71||"Firefox"===J.browserName&&J.browserMajorVersion>=69||"Safari"===J.browserName}},{key:"isMobile",get:function(){return J.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){var e,t;return void 0!==(null===(e=RTCRtpReceiver)||void 0===e||null===(t=e.prototype)||void 0===t?void 0:t.createEncodedStreams)}}]),e}(),Z=n(202).default,X=function(e,t,n,r){function o(e){i()(this,o),u()(this,"_logger",D.getLogger("VanillaPeerConnection")),u()(this,"_peerConnection",void 0),$.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(e):this._peerConnection=new RTCPeerConnection(e)}return s()(o,[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"connectionState",get:function(){return this._peerConnection.connectionState}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsAddTransceiver",get:function(){return!$.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:function(t){return(e=e||y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new Z((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"createAnswer",value:function(e){return(t=t||y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new Z((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"setLocalDescription",value:function(e){return(n=n||y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription($.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"setRemoteDescription",value:function(e){return(r=r||y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription($.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new Z((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){return this._peerConnection.onconnectionstatechange},set:function(e){this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]),o}(),ee=X,te=function(e){function t(){i()(this,t)}return s()(t,[{key:"createPeerConnection",value:function(t){return(e=e||y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ee(t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}}]),t}(),ne=te,re=function(e,t){function n(){throw i()(this,n),new Error("PeerConnectionService is a static class that may not be instantiated")}return s()(n,null,[{key:"peerConnectionFactory",get:function(){return n._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){$.isPrecachingEnabled&&n.precacheCreatePeerConnectionOffer().catch((function(e){return n._logger.error("Failed to pre-cache peer connection offer",e)}))}},{key:"precacheCreatePeerConnectionOffer",value:function(){return(e=e||y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._cached={direction:"recvonly",peerConnection:n.createPeerConnectionOffer().catch((function(e){throw n._cached=null,e}))});case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},{key:"createPeerConnectionOffer",value:function(){return(t=t||y()(_().mark((function e(){var t,r,i,o,s,a=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>0&&void 0!==a[0]?a[0]:"recvonly",i=a.length>1&&void 0!==a[1]&&a[1],!n._cached||n._cached.direction!==r||i){e.next=6;break}return o=n._cached.peerConnection,n._cached=null,e.abrupt("return",o);case 6:return s={encodedInsertableStreams:i},e.abrupt("return",n._peerConnectionFactory.value.createPeerConnection(s).then((function(e){return(t=t||y()(_().mark((function e(t){var n,i,o;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:r}),n=t.addTransceiver("video",{direction:r}),e.t0=i,e.t1=n,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"===r?{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)})))).apply(this,arguments)})));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}}]),n}();u()(re,"_logger",D.getLogger("PeerConnectionService")),u()(re,"_peerConnectionFactory",new G(new ne)),u()(re,"_cached",void 0),re.initiateInitialPrecaching();var ie=function(){function e(){i()(this,e)}return s()(e,null,[{key:"getTelemetryUrl",value:function(e){try{var t=new URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}]),e}(),oe=function(){function e(){i()(this,e)}return s()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}(),se=function(){function e(){i()(this,e)}return s()(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:""}}}}]),e}();u()(se,"_discoveryParameters",void 0),se.applyParameters();var ae=function(){function e(){throw i()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return s()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=b.sdkVersion,r=se.discoveryParameters.intentions;return t.search="?".concat(new URLSearchParams([["version",n],["intentions",r],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}]),e}();u()(ae,"_discoveryUri",new G("https://pcast.phenixrts.com/pcast/endPoints"));var ue,ce=n(319),le=n.n(ce),de=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;i()(this,e),u()(this,"_backoffIntervalInMillisecond",void 0),u()(this,"_minBackoffIntervalInMillisecond",void 0),u()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=t,this._minBackoffIntervalInMillisecond=n,this._maxBackoffIntervalInMillisecond=r}return s()(e,[{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)}}]),e}(),he=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}(he||{}),pe=he,fe=function(){function e(t){i()(this,e),u()(this,"_metrics",void 0),this._metrics=t}return s()(e,[{key:"getName",value:function(){return pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case pe.TimeToFirstFrame:case pe.ChannelCreationTimeToFirstFrame:return x.Essential;case pe.Stalled:case pe.Buffering:case pe.SetupCompleted:case pe.SetupFailed:case pe.RoundTripTime:case pe.DownlinkThroughputCapacity:case pe.NetworkType:case pe.ResolutionChanged:case pe.ApplicationForeground:case pe.ApplicationBackground:return x.All;default:L(this._metrics)}}}]),e}(),ve=function(e,t){function n(e){i()(this,n),u()(this,"_logger",D.getLogger("MetricsService")),u()(this,"_metricsConfiguration",void 0),u()(this,"_exponentialBackoff",void 0),u()(this,"_metrics",[]),u()(this,"_isSending",void 0),u()(this,"_failureCount",0),u()(this,"_domain",location.hostname),this._metricsConfiguration=e,this._exponentialBackoff=new de}return s()(n,[{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 fe(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:b.sdkVersion,runtime:i,resource:o,kind:s};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:function(t){return(e=e||y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"sendMetricsIfAble",value:function(){return(t=t||y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void setTimeout((function(){n._metrics=[].concat(le()(t),le()(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)})))).apply(this,arguments)}},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]),n}(),ge=function(){function e(){throw i()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return s()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var r=new T;return r.sessionId=me.clientSessionId,r.tenancy=me.tenancy.value,r.url=ie.getTelemetryUrl(t),r.environment=oe.getEnvironmentFromUrl(t),r.threshold=R.convertTelemetryLevelTypeToTelemetryLevel(me.telemetryLevel),e._metricsServices[t]=new ve(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();u()(ge,"_metricsServices",{});var ye=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),me=function(){function e(){throw i()(this,e),new Error("SDK is a static class that may not be instantiated")}return s()(e,null,[{key:"pageLoadTime",get:function(){return ye}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return P.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return R.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return J}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=D.telemetryConfiguration;n.sessionId=e.clientSessionId,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof k}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(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 k}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ge.getMetricsService(ae.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ge.setTelemetryLevel(x[t]),e._telemetryLevel.subscribe((function(e){ge.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=this._configurationParameterReader.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=this._configurationParameterReader.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=oe.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=W.parseToken(t);return e._tenancy.value=n.tenancy,ae.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return ae.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");return i?(ae.uri.value="".concat(i,"/pcast/endPoints"),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)):void 0}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new Y),t){if(t.discoveryUri&&(ae.uri.value=t.discoveryUri),t.peerConnectionFactory&&(re.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&x[t.telemetryLevel]&&(e._telemetryLevel.value=R.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&c[t.loggingLevel]&&this._logger.threshold.setThreshold(P.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&c[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof v}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new v(P.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ie.getTelemetryUrl(e)}}]),e}();ue=me,u()(me,"_automaticallyRetryOnFailure",!0),u()(me,"_automaticallyReconnectPeerConnection",!0),u()(me,"_automaticallyPlayMediaStream",!0),u()(me,"_automaticallyMuteVideoOnPlayFailure",!0),u()(me,"_forceGarbageCollectionOnRestart",!0),u()(me,"_skipGarbageCollectionOnMobileDevices",!0),u()(me,"_webPlayerLoader",null),u()(me,"_shakaPlayerLoader",null),u()(me,"_hlsJsLoader",null),u()(me,"_configurationParameterReader",new O),u()(me,"_applicationActivityMonitor",void 0),u()(me,"_environment",new G("")),u()(me,"_telemetryUrl",new G("https://telemetry.phenixrts.com/telemetry")),u()(me,"_maximalNumberOfPeerConnectionReconnectAttempts",8),u()(me,"_telemetryLevel",new G(S.defaultTelemetryLevel)),u()(me,"_metricsService",void 0),u()(me,"_metricsConfiguration",void 0),u()(me,"_sendLocalCandidates",new G(h.sendLocalCandidates)),u()(me,"_tenancy",new G("")),u()(me,"_clientSessionId",E.random(32)),u()(me,"_loadedTimestamp",new Date),u()(me,"_logger",D.getLogger("SDK")),u()(me,"_initialized",new G(!1)),u()(me,"_readOnlyInitialized",new z(ue._initialized)),u()(me,"_readOnlyDiscoveryUri",new z(ae.uri)),u()(me,"_readOnlyPeerConnectionFactory",new z(re.peerConnectionFactory)),window.addEventListener("unload",(function(){me.dispose()})),me.applyDiscoveryUriDefaultFromParameterConfiguration(),me.applyMetricsConfiguration(),me.applyTelemetryConfiguration(),me.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),me.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),me.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),me.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),me.init();var _e=function(){function e(){throw i()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}return s()(e,null,[{key:"forceGarbageCollection",value:function(){$.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){var e=this;$.isQueueMicrotaskSupported?queueMicrotask((function(){e.overloadMemoryToInvokeGarbageCollection()})):setTimeout((function(){e.overloadMemoryToInvokeGarbageCollection()}))}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=document.createElement("img");e.src=window.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){window.URL.revokeObjectURL(this.src),e=null}}}]),e}(),be=function(e){return 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}(be||{}),Ce=be,ke=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;i()(this,e),u()(this,"_duration",void 0),this._duration=t}return s()(e,[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,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)}}]),e}(),we=function(){function e(t){i()(this,e),u()(this,"_logger",D.getLogger("StreamSetupListener")),u()(this,"metricsService",me.metricsService),u()(this,"_pageLoadTime",void 0),u()(this,"_startTime",void 0),u()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return s()(e,[{key:"success",value:function(e){this.recordStreamMetric(pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new fe(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 ke(n-this._pageLoadTime).toIsoString(),t,i,new ke(r).toIsoString())}}}]),e}(),Se=function(){function e(){i()(this,e),u()(this,"_disposables",new Q),u()(this,"_isSupported",navigator&&navigator.connection),u()(this,"_rtt",new G(void 0)),u()(this,"_effectiveType",new G(void 0)),u()(this,"_downlinkThroughputCapacity",new G(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return s()(e,[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new V((function(){navigator.connection.removeEventListener("change",t)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}]),e}(),xe=function(){function e(t,n){var r=this;i()(this,e),u()(this,"_logger",D.getLogger("SessionTelemetry")),u()(this,"_metricsService",void 0),u()(this,"_applicationActivityMonitor",me.applicationActivityMonitor),u()(this,"_networkMonitor",new Se),u()(this,"_pageLoadTime",void 0),u()(this,"_disposables",new Q),u()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}return s()(e,[{key:"listenOnStreamSetup",value:function(){return new we(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?pe.ApplicationForeground:pe.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new ke(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:pe.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new ke(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:pe.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new ke(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:pe.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new ke(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}(),Te=s()((function e(t){i()(this,e),u()(this,"token",void 0),u()(this,"tokenExpiring",void 0),this.token=new G(t),this.tokenExpiring=new G(!1)})),Le=function(){function e(t){i()(this,e),u()(this,"publisherInitialization",void 0),u()(this,"disposables",void 0),u()(this,"publisherDisposables",void 0),u()(this,"state",void 0),u()(this,"authorized",void 0),u()(this,"online",void 0),u()(this,"loading",void 0),u()(this,"publishing",void 0),u()(this,"standby",void 0),u()(this,"stopped",void 0),u()(this,"failureCount",void 0),u()(this,"endPoint",void 0),u()(this,"stream",void 0),u()(this,"rtcStatistics",void 0),u()(this,"clearFailureCountTimeout",void 0),u()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),u()(this,"name",void 0),this.disposables=new Q,this.publisherDisposables=new Q,this.publisherInitialization=new Date,this.state=new G(Ce.Starting),this.authorized=new G(!0),this.online=new G(!0),this.loading=new G(!1),this.publishing=new G(!1),this.standby=new G(!1),this.stopped=new G(!1),this.failureCount=new G(0),this.endPoint=new G(null),this.stream=new G(null),this.rtcStatistics=new G(null),this.name=t&&t.length?t:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0}return s()(e,[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"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 Ce.Starting;case"not-found":return Ce.NotFound;case"geo-restricted":return Ce.GeoRestricted;case"geo-blocked":return Ce.GeoBlocked;case"unauthorized":return Ce.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ce.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Ce.ConfigurationError;case"port-in-range-not-found":return Ce.TransientConfigurationError;case"failed":return Ce.Error;default:L(e)}}},{key:"generateScreenName",value:function(){return E.random(12)}}]),e}(),Re=s()((function e(){i()(this,e),u()(this,"mediaStream",void 0),u()(this,"peerConnection",void 0),u()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new G(null),this.peerConnection=new G(null),this.peerConnectionReconnectAttempts=0})),Pe=s()((function e(){i()(this,e),u()(this,"isStarting",void 0),u()(this,"isDisposed",void 0),this.isStarting=new G(!1),this.isDisposed=!1})),Oe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),De=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ee=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case De.Normal:return"Normal";case De.Force:return"Force";case De.Reset:return"Reset";default:L(e)}}}]),e}(),Fe=function(){function e(){i()(this,e)}return s()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Oe.Keep:return"Keep";case Oe.Reset:return"Reset";default:L(e)}}}]),e}(),Ie=n(202).default,Me=function(e,t,n,r,o,a,c,l,d,h,p,f,v){function g(e,t){if(i()(this,g),u()(this,"_logger",D.getLogger("EndPoint")),u()(this,"_uri",void 0),u()(this,"_timeout",void 0),u()(this,"_roundTripTime",void 0),this._uri=e,this._timeout=t,!t)throw new Error("End point requires a timeout")}return s()(g,[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:function(){return(e=e||y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Ie.race([fetch(t,{method:"GET",cache:"no-cache"}),new Ie((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"subscribe",value:function(e,n,r){return(t=t||y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f,v,g=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=W.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 FormData,a=b.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,Ie.race([fetch(o,{method:"POST",body:s}),new Ie((function(e){return h=window.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){h&&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]])})))).apply(this,arguments)}},{key:"publish",value:function(e,t,r,i){return(n=n||y()(_().mark((function e(t,n,r,i){var o,s,a,u,c,l,d,h,p,f,v,g,y=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=W.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 FormData,u=b.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,Ie.race([fetch(s,{method:"POST",body:a}),new Ie((function(e){return p=window.setTimeout((function(){y._logger.error("Failed to publish",new Error("Publish timed out [".concat(s,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&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]])})))).apply(this,arguments)}},{key:"setRemoteDescription",value:function(e,t){return(r=r||y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret: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,Ie.race([fetch(r,{method:"POST",body:i}),new Ie((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9: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]])})))).apply(this,arguments)}},{key:"limitBitrate",value:function(e,t,n,r,i){return(o=o||y()(_().mark((function e(t,n,r,i,o){var s,a,u,c,l,d,h,p,f=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),a=new FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Fe.convertBitrateStateToBitrateStateType(i),bitrateMode:Ee.convertBitrateModeToBitrateModeType(o)},a.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Ie.race([fetch(s,{method:"POST",body:a}),new Ie((function(e){return d=window.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&&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]])})))).apply(this,arguments)}},{key:"addIceCandidates",value:function(e,t,n){return(a=a||y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,d,h,p,f=this,v=arguments;return _().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 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,Ie.race([fetch(o,{method:"POST",body:s}),new Ie((function(e){return l=window.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&&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]])})))).apply(this,arguments)}},{key:"destroyStream",value:function(e,t){return(c=c||y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,d,h=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,Ie.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Ie((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9: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]])})))).apply(this,arguments)}},{key:"destroyStreamOnUnmount",value:function(e,t){return(l=l||y()(_().mark((function e(t,n){var r,i,o,s;return _().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 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)})))).apply(this,arguments)}},{key:"buildUrl",value:function(e){var t=new URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,le()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=b.sdkVersion,n=se.discoveryParameters.intentions;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["intentions",n],["_","".concat(Date.now())]]).toString()),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 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:function(e,t){return(d=d||y()(_().mark((function e(t,n){var r,i;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"convertHttpResponseToPublishResponse",value:function(e,t){return(h=h||y()(_().mark((function e(t,n){var r,i;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})))).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:function(e){return(p=p||y()(_().mark((function e(t){var n,r;return _().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)})))).apply(this,arguments)}},{key:"convertHttpResponseToAddIceCandidatesResponse",value:function(e){return(f=f||y()(_().mark((function e(t){var n,r;return _().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)})))).apply(this,arguments)}},{key:"convertHttpResponseToDestroyStreamResponse",value:function(e){return(v=v||y()(_().mark((function e(t){var n,r;return _().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)})))).apply(this,arguments)}}]),g}(),Ae=n(202).default,je=function(e,t){function n(e){if(i()(this,n),u()(this,"_logger",D.getLogger("Discovery")),u()(this,"_metricsService",void 0),u()(this,"_uri",void 0),!e)throw new Error("Discovery requires uri");this._metricsService=ge.getMetricsService(e.toString()),this._uri=e}return s()(n,[{key:"discoverNearbyEndPoints",value:function(t,n){return(e=e||y()(_().mark((function e(t,n){var r,i,o,s;return _().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,Ae.race([fetch(r,{method:"GET",cache:"no-cache"}),new Ae((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,s=o.split(","),e.abrupt("return",s.map((function(e){return new Me(e,n)})));case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},{key:"discoverClosestEndPoint",value:function(){return(t=t||y()(_().mark((function e(){var t,n,r,i,o,s,a=this,u=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ae.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new Ae((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Ae.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:pe.RoundTripTime,runtime:(n-me.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)})))).apply(this,arguments)}}]),n}(),Ne=function(e,t){function n(){throw i()(this,n),new Error("Discovery is a static class that may not be instantiated")}return s()(n,null,[{key:"precacheClosestEndPointDiscovery",value:function(){return(e=e||y()(_().mark((function e(){var t;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new URL(me.discoveryUri.value),e.abrupt("return",n.discoverClosestEndPointWithCaching(t));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},{key:"discoverClosestEndPointWithCaching",value:function(e){return(t=t||y()(_().mark((function e(t){var r,i,o;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.toString(),!n._cache[r]){e.next=3;break}return e.abrupt("return",n._cache[r]);case 3:return i=new je(t),o=n._cache[r]=i.discoverClosestEndPoint(),n._cache[r].then((function(){setTimeout((function(){n._cache[r]===o&&delete n._cache[r]}),6e4)})).catch((function(){delete n._cache[r]})),e.abrupt("return",o);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},{key:"clearCachedClosestEndpoint",value:function(e){var t=e.toString();n._cache[t]&&delete n._cache[t]}}]),n}();u()(Ne,"_cache",{}),Ne.precacheClosestEndPointDiscovery();var Ve=n(38),Ue=n.n(Ve),Be=function(){function e(t){i()(this,e),u()(this,"_sdp",void 0),u()(this,"_audioCodec",void 0),u()(this,"_videoCodec",void 0),u()(this,"_isAudioTrackEnabled",void 0),u()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split("m=");this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}return s()(e,[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}]),e}(),Ge=function(e){function t(e,n,r){if(i()(this,t),u()(this,"_estimatedRoundTripTime",void 0),u()(this,"_estimatedVideoCodec",void 0),u()(this,"_estimatedAudioCodec",void 0),u()(this,"_rtcStatistic",new G({})),u()(this,"_peerConnection",void 0),u()(this,"_isMonitorRunning",!0),u()(this,"_updateTimeout",void 0),u()(this,"_availableTracks",void 0),this._peerConnection=e,this._estimatedRoundTripTime=r,this._peerConnection){var o=new Be(this._peerConnection.currentLocalDescription.sdp),s=new Be(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=s.audioCodec,this._estimatedVideoCodec=s.videoCodec,this._availableTracks={audio:o.isAudioTrackEnabled&&s.isAudioTrackEnabled,video:o.isVideoTrackEnabled&&s.isVideoTrackEnabled},this.updateStatistic()}}return s()(t,[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:function(){return(e=e||y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(s){if("candidate-pair"===s.type&&s.currentRoundTripTime&&(o=1e3*s.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===s.type&&s.lastPacketSentTimestamp&&(i=s.lastPacketSentTimestamp,r.audio&&(r.audio.lastPacketSentTimestamp=i),r.video&&(r.video.lastPacketSentTimestamp=i)),"outbound-rtp"===s.type){var a=s.kind||s.mediaType||t(s),u="";if(e.forEach((function(e){e.id===s.codecId&&(u=e.mimeType)})),a&&n._availableTracks[a]){var c,l,d,h,p,f=(s.bytesSent||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[a])||void 0===d?void 0:d.bytesSent)&&void 0!==c?c:0),v=s.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[a])||void 0===p?void 0:p.timestamp),g=f&&v?Math.floor(8*f/v*1e3):0;if(r[a]={ssrc:s.ssrc,mediaType:a,timestamp:s.timestamp,bitrate:g,bytesSent:s.bytesSent,packetsSent:s.packetsSent,retransmittedBytesSent:s.retransmittedBytesSent,codec:u||n.getCodecByType(a),roundTripTime:o},(s.lastPacketSentTimestamp||i)&&(r[a].lastPacketSentTimestamp=s.lastPacketSentTimestamp||i),"video"===a&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[a].firCount=s.firCount,r[a].frameHeight=s.frameHeight,r[a].frameWidth=s.frameWidth,r[a].framesEncoded=s.framesEncoded,r[a].framesSent=s.framesSent,r[a].headerBytesSent=s.headerBytesSent,r[a].hugeFramesSent=s.hugeFramesSent,r[a].pliCount=s.pliCount,r[a].qpSum=s.qpSum,r[a].totalEncodeTime=s.totalEncodeTime,r[a].totalEncodedBytesTarget=s.totalEncodedBytesTarget;var y=(s.framesEncoded-n._rtcStatistic.value.video.framesEncoded)/(r[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[a].fps=y?Math.round(100*y)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeout=window.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]),t}(),ze=function(){function e(){throw i()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}return s()(e,null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}]),e}(),He=n(202).default;function We(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 Je(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?We(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):We(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ke=function(e){function t(e,n,r){i()(this,t),u()(this,"_logger",D.getLogger("RealTimePublisher")),u()(this,"_publisherContext",void 0),u()(this,"_peerConnectionContext",void 0),u()(this,"_handleStreamFailure",void 0),this._publisherContext=e,this._peerConnectionContext=n,this._handleStreamFailure=r}return s()(t,[{key:"start",value:function(e,t,n){var r=this;return navigator.onLine?He.all([Ne.discoverClosestEndPointWithCaching(e),re.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=Ue()(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),($.clientOfferDisabled||!a.supportsSetConfiguration||!a.supportsGetConfiguration||r._publisherContext.failureCount.value>0)&&(a.close(),a.dispose(),!me.forceGarbageCollectionOnRestart||$.isMobile&&me.skipGarbageCollectionOnMobileDevices||_e.forceGarbageCollection(),a=null,s=null,r._peerConnectionContext.peerConnection.value=a),i.publish(r._publisherContext.name,t,s,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status,i=e.stream,o=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,a=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;if(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),"ok"===t)return 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||me.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=setTimeout((function(){r._publisherContext.stream.value!==i||o||r._publisherContext.endPoint.value.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(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=Ce.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:L(e.iceConnectionState)}}},new He((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(){if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,u.sessionDescription.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,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,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){return r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp),r._publisherContext.endPoint.value.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,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(){n.success(r._publisherContext.streamId),r._publisherContext.state.value=Ce.Publishing,r._publisherContext.publishing.value=!0;var t=new Ge(e,r._peerConnectionContext.mediaStream.value,r._publisherContext.endPoint.value.roundTripTime/4);return r._publisherContext.disposables.add(t),t.rtcStatistic.subscribe((function(e){r._publisherContext.rtcStatistics.value=e})),He.resolve()}))}))})):(this._publisherContext.state.value=Ce.Offline,He.resolve())}},{key:"applyRtcConfiguration",value:function(t,n){return(e=e||y()(_().mark((function e(t,n){var r;return _().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",me.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=Je(Je({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Ce.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<me.maximalNumberOfPeerConnectionReconnectAttempts||!me.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if($.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new V((function(){return 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=setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new V((function(){return clearTimeout(r)})))}else n._publisherContext.state.value=Ce.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 Ce.Starting;case"unauthorized":return Ce.Unauthorized;case"not-found":return Ce.NotFound;case"capacity":case"rate-limited":case"timeout":return Ce.Recovering;case"failed":return Ce.Error;default:L(e)}}}]),t}(),qe=n(202).default,Qe=function(e,t,n,r,o){function a(e,t,n){var r=this;i()(this,a),u()(this,"_logger",D.getLogger("Publisher")),u()(this,"_tokenContext",void 0),u()(this,"_publisherContext",void 0),u()(this,"_peerConnectionContext",void 0),u()(this,"_stateContext",void 0),u()(this,"_exponentialBackoff",void 0),u()(this,"_publisherStartTime",void 0),u()(this,"_readOnlyToken",void 0),u()(this,"_readOnlyPeerConnection",void 0),u()(this,"_readOnlyState",void 0),u()(this,"_readOnlyTokenExpiring",void 0),u()(this,"_readOnlyAuthorized",void 0),u()(this,"_readOnlyOnline",void 0),u()(this,"_readOnlyLoading",void 0),u()(this,"_readOnlyPublishing",void 0),u()(this,"_readOnlyStandby",void 0),u()(this,"_readOnlyStopped",void 0),u()(this,"_readOnlyFailureCount",void 0),u()(this,"_readOnlyEndPoint",void 0),u()(this,"_readOnlyStream",void 0),u()(this,"_readOnlyRtcStatistics",void 0),u()(this,"_readOnlyMediaStream",void 0),u()(this,"_metricsService",void 0),u()(this,"_sessionTelemetry",void 0),this._tokenContext=new Te(t),this._publisherContext=new Le(n),this._peerConnectionContext=new Re,this._stateContext=new Pe,this._exponentialBackoff=new de,this._publisherStartTime=Date.now(),this._readOnlyToken=new z(this._tokenContext.token),this._readOnlyPeerConnection=new z(this._peerConnectionContext.peerConnection),this._readOnlyState=new z(this._publisherContext.state),this._readOnlyTokenExpiring=new z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new z(this._publisherContext.authorized),this._readOnlyOnline=new z(this._publisherContext.online),this._readOnlyLoading=new z(this._publisherContext.loading),this._readOnlyPublishing=new z(this._publisherContext.publishing),this._readOnlyStandby=new z(this._publisherContext.standby),this._readOnlyStopped=new z(this._publisherContext.stopped),this._readOnlyFailureCount=new z(this._publisherContext.failureCount),this._readOnlyEndPoint=new z(this._publisherContext.endPoint),this._readOnlyStream=new z(this._publisherContext.stream),this._readOnlyRtcStatistics=new z(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new z(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=e;var o=W.parseToken(this._tokenContext.token.value),s=(o.uri||me.discoveryUri.value).toString();me.tenancy.value=o.tenancy||me.tenancy.value,ae.uri.value=s,this._metricsService=ge.getMetricsService(s),this._sessionTelemetry=new xe(me.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){r._publisherContext.clearFailureCountTimeout&&clearTimeout(r._publisherContext.clearFailureCountTimeout),r._publisherContext.failureCount.value&&e===Ce.Publishing&&(r._publisherContext.clearFailureCountTimeout=window.setTimeout((function(){r._publisherContext.failureCount.value=0}),3e3))})));var c=function(){r._publisherContext.stream.value&&r._publisherContext.endPoint.value&&r._publisherContext.endPoint.value.destroyStreamOnUnmount(r._publisherContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new V((function(){window.removeEventListener("beforeunload",c)}))),this.start()}return s()(a,[{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=W.parseToken(this._tokenContext.token.value),n=(t.uri||me.discoveryUri.value).toString();me.tenancy.value=t.tenancy||me.tenancy.value,ae.uri.value=n,this._metricsService=ge.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:function(t){return(e=e||y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new qe((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)})))).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=Ce.Stopped}},{key:"dispose",value:function(){return(t=t||y()(_().mark((function e(){var t=this;return _().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)})))).apply(this,arguments)}},{key:"getUri",value:function(e){return W.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",me.discoveryUri.value),new URL(me.discoveryUri.value))}},{key:"start",value:function(){return(n=n||y()(_().mark((function e(){return _().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)})))).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){t._peerConnectionContext.peerConnection.value.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:"processStart",value:function(){return(r=r||y()(_().mark((function e(){var t,n,r,i,o,s=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),W.isEncodedEdgeTokenValid(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Ce.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:return this.cleanUpResources("client:start"),this._publisherContext.state.value=Ce.Starting,this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==Ce.Error&&e!==Ce.Recovering||Ne.clearCachedClosestEndpoint(r)}))),i=function(){return new qe((function(e){return s._stateContext.isStarting.value=!1,e(s.handleStreamFailure())}))},o=new Ke(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=Ce.ClientStartError,s._logger.error("Failed to start publishing",e)})).finally((function(){if(s._stateContext.isStarting.value=!1,s._publisherContext.state.value!==Ce.Publishing&&me.automaticRetryOnFailure){var e=setTimeout((function(){s.handleStreamFailure().catch((function(e){s._logger.error("Failed handling stream failure",e)}))}),s.getRetryInterval());s._publisherContext.disposables.add(new V((function(){clearTimeout(e)})))}else s._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case Ce.Offline:return 15e3;case Ce.NotFound:case Ce.Error:case Ce.Recovering:case Ce.Unauthorized:case Ce.GeoRestricted:case Ce.GeoBlocked:case Ce.Stopped:case Ce.Starting:case Ce.Publishing:case Ce.Reconnecting:case Ce.UnsupportedFeature:case Ce.ConfigurationError:case Ce.TransientConfigurationError:case Ce.ConnectionError:case Ce.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:L(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:function(){return(o=o||y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===Ce.Error||e.t0===Ce.Reconnecting||e.t0===Ce.Offline||e.t0===Ce.Recovering||e.t0===Ce.TransientConfigurationError||e.t0===Ce.ConnectionError||e.t0===Ce.ClientStartError?4:e.t0===Ce.Unauthorized?11:e.t0===Ce.GeoRestricted?13:e.t0===Ce.GeoBlocked?15:e.t0===Ce.Stopped?17:e.t0===Ce.Publishing?19:e.t0===Ce.Starting?21:e.t0===Ce.UnsupportedFeature?23:e.t0===Ce.NotFound?25:e.t0===Ce.ConfigurationError?27:29;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,Ce[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Ce[this._publisherContext.state.value]),e.abrupt("break",30);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 already starting, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 29:L(this._publisherContext.state.value);case 30:return e.abrupt("return",this.start());case 31:case"end":return e.stop()}}),e,this)})))).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(),!me.forceGarbageCollectionOnRestart||$.isMobile&&me.skipGarbageCollectionOnMobileDevices||_e.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}}]),a}(),Ye=function(){function e(){throw i()(this,e),new Error("Publishers is a static class that may not be instantiated")}return s()(e,null,[{key:"createPublisher",value:function(e){if(!me.initialized.value)throw new Error("SDK is not loaded.");return new Qe(e.mediaStream,e.token,e.name)}}]),e}(),$e={SDK:me,Publishers:Ye,PublisherState:Ce}}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(462)})()}));
3
3
  //# sourceMappingURL=publish.js.map