@phenixrts/sdk 2022.0.2 → 2022.0.5
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.
- package/dist/debug/channels.js +277 -135
- package/dist/debug/full.js +277 -135
- package/dist/debug/groups.js +1 -1
- package/dist/debug/messaging.js +1 -1
- package/dist/debug/publish.js +1 -1
- package/dist/debug.private/channels.js +277 -135
- package/dist/debug.private/full.js +277 -135
- package/dist/debug.private/groups.js +1 -1
- package/dist/debug.private/messaging.js +1 -1
- package/dist/debug.private/publish.js +1 -1
- package/dist/es5.debug.private/channels.js +276 -135
- package/dist/es5.debug.private/full.js +276 -135
- package/dist/es5.debug.private/groups.js +1 -1
- package/dist/es5.debug.private/messaging.js +1 -1
- package/dist/es5.debug.private/publish.js +1 -1
- package/dist/legacy.debug/channels.js +277 -135
- package/dist/legacy.debug/full.js +277 -135
- package/dist/legacy.debug/groups.js +1 -1
- package/dist/legacy.debug/messaging.js +1 -1
- package/dist/legacy.debug/publish.js +1 -1
- package/dist/legacy.debug.private/channels.js +276 -135
- package/dist/legacy.debug.private/full.js +276 -135
- package/dist/legacy.debug.private/groups.js +1 -1
- package/dist/legacy.debug.private/messaging.js +1 -1
- package/dist/legacy.debug.private/publish.js +1 -1
- package/dist/legacy.min/channels.js +1 -1
- package/dist/legacy.min/channels.js.map +1 -1
- package/dist/legacy.min/full.js +1 -1
- package/dist/legacy.min/full.js.map +1 -1
- package/dist/legacy.min/groups.js +1 -1
- package/dist/legacy.min/messaging.js +1 -1
- package/dist/legacy.min/publish.js +1 -1
- package/dist/min/channels.js +1 -1
- package/dist/min/channels.js.map +1 -1
- package/dist/min/full.js +1 -1
- package/dist/min/full.js.map +1 -1
- package/dist/min/groups.js +1 -1
- package/dist/min/messaging.js +1 -1
- package/dist/min/publish.js +1 -1
- package/dist/min.private/channels.js +1 -1
- package/dist/min.private/channels.js.map +1 -1
- package/dist/min.private/full.js +1 -1
- package/dist/min.private/full.js.map +1 -1
- package/dist/min.private/groups.js +1 -1
- package/dist/min.private/messaging.js +1 -1
- package/dist/min.private/publish.js +1 -1
- package/dist/types/rtc/RtcConnectionMonitor.d.ts +1 -0
- package/dist/types/sdk/channels/Channel.d.ts +4 -2
- package/dist/types/sdk/channels/ChannelContext.d.ts +1 -0
- package/package.json +1 -1
package/dist/min.private/full.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!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}},858:e=>{e.exports=function(e){if(Array.isArray(e))return e}},646:(e,t,n)=>{var r=n(228);e.exports=function(e){if(Array.isArray(e))return r(e)}},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}},926:(e,t,n)=>{var r=n(202).default;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}}},575:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},913:e=>{function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}},713:e=>{e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},754:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(n)}e.exports=t},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}}),t&&r(e,t)}},860:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},884:e=>{e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}}},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.")}},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.")}},585:(e,t,n)=>{var r=n(8),i=n(506);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},489:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(n,r)}e.exports=t},38:(e,t,n)=>{var r=n(858),i=n(884),o=n(379),a=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()}},319:(e,t,n)=>{var r=n(646),i=n(860),o=n(379),a=n(206);e.exports=function(e){return r(e)||i(e)||o(e)||a()}},8:e=>{function t(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=t=function(e){return typeof e}:e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(n)}e.exports=t},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}}},757:(e,t,n)=>{e.exports=n(666)},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),a=n.n(o),s=n(913),u=n.n(s),c=n(713),l=n.n(c),d=function e(t,n,r){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r},h=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function t(a,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return t(a,e)}),n)}r[a]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var p=h},190:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ChannelState:()=>fe,Channels:()=>ze,SDK:()=>ce,default:()=>He});var r,i=n(575),o=n.n(i),a=n(913),s=n.n(a),u=n(713),c=n.n(u);!function(e){e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off"}(r||(r={}));var l=function(){function e(t,n,r){o()(this,e),c()(this,"_category",void 0),c()(this,"_appenders",void 0),c()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return s()(e,[{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?e+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}},{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}}]),e}(),d=function(){function e(){o()(this,e),c()(this,"_appenders",[])}return s()(e,[{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}),[])}},{key:"value",get:function(){return this._appenders}}]),e}(),h=function(){function e(){o()(this,e)}return s()(e,null,[{key:"applyIsPrivate",value:function(){try{this._isPrivate=!0}catch(e){this._isPrivate=!1}}},{key:"isPrivate",get:function(){return this._isPrivate}}]),e}();c()(h,"_isPrivate",void 0),h.applyIsPrivate();var p=function(){function e(){o()(this,e)}return s()(e,null,[{key:"defaultLoggingLevel",get:function(){return h.isPrivate?r.Off:r.All}},{key:"defaultConsoleLoggingLevel",get:function(){return h.isPrivate?r.Off:r.All}},{key:"defaultTelemetryLoggingLevel",get:function(){return r.Info}}]),e}(),f=function(){function e(){o()(this,e),c()(this,"_threshold",p.defaultLoggingLevel)}return s()(e,[{key:"setThreshold",value:function(e){this._threshold=e}},{key:"value",get:function(){return this._threshold}}]),e}(),v=function(){function e(t){o()(this,e),c()(this,"_threshold",void 0),this._threshold=t}return s()(e,[{key:"log",value:function(e,t,n,i){if(!(e<this._threshold)){var o="".concat(i.toISOString()," [").concat(n,"] [").concat(r[e],"] ").concat(t);e<r.Warn?console.log(o):console.error(o)}}}]),e}(),g=n(757),m=n.n(g),y=n(926),_=n.n(y),w=function(){function e(){o()(this,e)}return s()(e,null,[{key:"sdkVersion",get:function(){try{return"2022-01-10T19:09:12.604Z (2022.0.2)"}catch(e){return this._defaultVersion}}}]),e}();c()(w,"_defaultVersion",(new Date).toISOString());var b,k=function(){function e(t){o()(this,e),c()(this,"_telemetryConfiguration",void 0),c()(this,"_logs",[]),c()(this,"_isSending",void 0),c()(this,"_domain",location.hostname),this._telemetryConfiguration=t}var t,n;return s()(e,[{key:"push",value:function(e,t,n,i){var o={timestamp:i.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:r[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:w.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<r.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=_()(m().mark((function e(t){var n;return m().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=_()(m().mark((function e(){var t,n,r,i,o=this;return m().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}(),S=function(){function e(t){o()(this,e),c()(this,"_telemetryService",void 0),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new k(t)}return s()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}(),C=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(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}(),x=function(){function e(){o()(this,e)}return s()(e,null,[{key:"defaultTelemetryLevel",get:function(){return h.isPrivate?b.Essential:b.All}}]),e}();!function(e){e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All"}(b||(b={}));var T=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",x.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"))},P=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case b.Off:return"Off";case b.Essential:return"Essential";case b.All:return"All";default:L(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return b.Off;case"Essential":return b.Essential;case"All":return b.All;default:L(e)}}}]),e}(),R=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case r.Off:return"Off";case r.Trace:return"Trace";case r.Debug:return"Debug";case r.Info:return"Trace";case r.Warn:return"Warn";case r.Error:return"Error";case r.Fatal:return"Fatal";case r.All:return"All";default:L(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return r.Off;case"Trace":return r.Trace;case"Debug":return r.Debug;case"Info":return r.Info;case"Warn":return r.Warn;case"Error":return r.Error;case"Fatal":return r.Fatal;case"All":return r.All;default:L(e)}}}]),e}(),E=function(){function e(){o()(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":P.convertTelemetryLevelToTelemetryLevelType(x.defaultTelemetryLevel),"phenix-logging-level":R.convertLoggingLevelToLoggingLevelType(p.defaultLoggingLevel),"phenix-console-logging-level":R.convertLoggingLevelToLoggingLevelType(p.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":R.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}}}]),e}(),F=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return s()(e,null,[{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");r[e]&&this._threshold.setThreshold(r[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(r[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 S(this._telemetryConfiguration))}},{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}}]),e}();c()(F,"_configurationParameterReader",new E),c()(F,"_loggers",{}),c()(F,"_appenders",new d),c()(F,"_threshold",new f),c()(F,"_telemetryConfiguration",new C),F.applyLoggerConfigFromParameterConfiguration();var D=function(){function e(){throw o()(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}(),O=n(205),I=n.n(O),A=n(585),M=n.n(A),j=n(754),V=n.n(j),N=function(){function e(t){o()(this,e),c()(this,"_disposed",void 0),c()(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=function(e){I()(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=V()(t);if(n){var i=V()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return M()(this,e)});function i(e,t){return o()(this,i),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return i}(N),B=function(){function e(t){o()(this,e),c()(this,"_listeners",void 0),c()(this,"_value",void 0),this._listeners=[],this._value=t}return s()(e,[{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new U(this._listeners,e)}},{key:"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)})))},get:function(){return this._value}}]),e}(),z=function(){function e(t){o()(this,e),c()(this,"_subject",void 0),this._subject=t}return s()(e,[{key:"subscribe",value:function(e){return this._subject.subscribe(e)}},{key:"value",get:function(){return this._subject.value}}]),e}(),H=function(){function e(){o()(this,e)}return s()(e,null,[{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""}},{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}}]),e}();c()(H,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),c()(H,"_browserNameAndVersion",H.parseBrowserNameAndVersion()),c()(H,"_browserName",H.parseBrowserName()),c()(H,"_browserMajorVersion",H.parseBrowserMajorVersion()),c()(H,"_isChrome69",H._browserNameAndVersion.includes("Chrome/69.")),c()(H,"_isChrome70",H._browserNameAndVersion.includes("Chrome/70.")),c()(H,"_isChrome71",H._browserNameAndVersion.includes("Chrome/71.")),c()(H,"_isChrome72",H._browserNameAndVersion.includes("Chrome/72.")),c()(H,"_isChrome74",H._browserNameAndVersion.includes("Chrome/74.")),c()(H,"_isChrome75",H._browserNameAndVersion.includes("Chrome/75.")),c()(H,"_isChrome76",H._browserNameAndVersion.includes("Chrome/76.")),c()(H,"_isChrome77",H._browserNameAndVersion.includes("Chrome/77."));var G=function(){function e(){o()(this,e)}return s()(e,null,[{key:"clientOfferDisabled",get:function(){return H.isChrome74||H.isChrome75||H.isChrome76||H.isChrome77}},{key:"addTranceiverDisabled",get:function(){return H.isChrome69||H.isChrome70||H.isChrome71||H.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=69||"Firefox"===H.browserName&&H.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=63||"Firefox"===H.browserName&&H.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===H.browserName&&H.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===H.browserName||"SamsungBrowser"===H.browserName}},{key:"isRTMPEnabled",get:function(){return"Firefox"===H.browserName&&H.browserMajorVersion<84||"Chrome"===H.browserName&&H.browserMajorVersion<70||"Edge"===H.browserName||"IE"===H.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==H.browserName}}]),e}(),W=n(202).default,J=function(){function e(t){o()(this,e),c()(this,"_logger",F.getLogger("VanillaPeerConnection")),c()(this,"_peerConnection",void 0),G.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,i;return s()(e,[{key:"createOffer",value:(i=_()(m().mark((function e(t){var n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!G.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((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 i.apply(this,arguments)})},{key:"createAnswer",value:(r=_()(m().mark((function e(t){var n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!G.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((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=_()(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(G.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=_()(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.sdp.match(/a=crypto:/i)&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(G.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new W((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:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"close",value:function(){this._peerConnection.close()}},{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsAddTransceiver",get:function(){return!G.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"ontrack",set:function(e){this._peerConnection.ontrack=e},get:function(){return this._peerConnection.ontrack}},{key:"onicecandidate",set:function(e){this._peerConnection.onicecandidate=e},get:function(){return this._peerConnection.onicecandidate}},{key:"oniceconnectionstatechange",set:function(e){this._peerConnection.oniceconnectionstatechange=e},get:function(){return this._peerConnection.oniceconnectionstatechange}}]),e}(),q=function(){function e(){o()(this,e)}var t;return s()(e,[{key:"createPeerConnection",value:(t=_()(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new J(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}(),K="DIGEST:",Q=function(){function e(){o()(this,e)}return s()(e,null,[{key:"parseToken",value:function(t){if(this.isValidToken(t))try{var n=atob(t.substr(K.length)),r=JSON.parse(n);return r.token=JSON.parse(r.token),r}catch(t){return void e._logger.error("Cannot parse token value",t)}else e._logger.error("Token is not valid [%s]",t)}},{key:"getUri",value:function(e){return e&&e.token&&e.token.uri?new URL(e.token.uri):null}},{key:"getTenancy",value:function(e){return e&&e.applicationId?e.applicationId:""}},{key:"isValidToken",value:function(e){return!!e&&e.startsWith(K)}}]),e}();c()(Q,"_logger",F.getLogger("EdgeAuth"));var Y,Z=n(8),$=n.n(Z),X=function(){function e(){o()(this,e),c()(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}(),ee=function(){function e(){o()(this,e),c()(this,"_disposables",new X),c()(this,"_readOnlyIsForeground",void 0),c()(this,"_isForeground",void 0),c()(this,"_timeOfLastTabFocusChange",Date.now()),c()(this,"_documentFocusInterval",void 0),this._isForeground=new B(!0),this._readOnlyIsForeground=new z(this._isForeground),this.detectTabFocusChange()}return s()(e,[{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":$()(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 N((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 N((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}},{key:"isForeground",get:function(){return this._readOnlyIsForeground}}]),e}(),te=function(){function e(){o()(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}(),ne=function(){function e(){o()(this,e)}return s()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}(),re=function(){function e(){throw o()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return s()(e,null,[{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=w.sdkVersion;return t.search="?".concat(new URLSearchParams([["version",n],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}},{key:"uri",get:function(){return e._discoveryUri}}]),e}();c()(re,"_discoveryUri",new B("https://pcast.phenixrts.com/pcast/endPoints")),function(e){e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground"}(Y||(Y={}));var ie=Y,oe=function(){function e(t){o()(this,e),c()(this,"_metrics",void 0),this._metrics=t}return s()(e,[{key:"getName",value:function(){return ie[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case ie.TimeToFirstFrame:case ie.ChannelCreationTimeToFirstFrame:return b.Essential;case ie.Stalled:case ie.Buffering:case ie.SetupCompleted:case ie.SetupFailed:case ie.RoundTripTime:case ie.DownlinkThroughputCapacity:case ie.NetworkType:case ie.ResolutionChanged:case ie.ApplicationForeground:case ie.ApplicationBackground:return b.All;default:L(this._metrics)}}}]),e}(),ae=function(){function e(t){o()(this,e),c()(this,"_metricsConfiguration",void 0),c()(this,"_metrics",[]),c()(this,"_isSending",void 0),c()(this,"_domain",location.hostname),this._metricsConfiguration=t}var t,n;return s()(e,[{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new oe(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:w.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=_()(m().mark((function e(t){var n;return m().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=_()(m().mark((function e(){var t,n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){return n._isSending=!1,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}}]),e}(),se=function(){function e(){throw o()(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=ce.clientSessionId,r.tenancy=ce.tenancy.value,r.url=te.getTelemetryUrl(t),r.environment=ne.getEnvironmentFromUrl(t),r.threshold=P.convertTelemetryLevelTypeToTelemetryLevel(ce.telemetryLevel),e._metricsServices[t]=new ae(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();c()(se,"_metricsServices",{});var ue=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),ce=function(){function e(){throw o()(this,e),new Error("SDK is a static class that may not be instantiated")}return s()(e,null,[{key:"applyTelemetryConfiguration",value:function(){var t=this,n=F.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 S}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new S(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 S}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new S(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=se.getMetricsService(re.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&&se.setTelemetryLevel(b[t]),e._telemetryLevel.subscribe((function(e){se.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=ne.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=Q.parseToken(t);return e._tenancy.value=Q.getTenancy(n),re.uri.value=(Q.getUri(n)||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return re.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?(re.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 ee),t){if(t.discoveryUri&&(re.uri.value=t.discoveryUri),t.peerConnectionFactory&&(e._peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&b[t.telemetryLevel]&&(e._telemetryLevel.value=P.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&r[t.loggingLevel]&&this._logger.threshold.setThreshold(R.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&r[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(R.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 te.getTelemetryUrl(e)}},{key:"pageLoadTime",get:function(){return ue}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return R.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return P.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return H}}]),e}();c()(ce,"_automaticallyRetryOnFailure",!0),c()(ce,"_automaticallyReconnectPeerConnection",!0),c()(ce,"_automaticallyPlayMediaStream",!0),c()(ce,"_automaticallyMuteVideoOnPlayFailure",!0),c()(ce,"_webPlayerLoader",null),c()(ce,"_shakaPlayerLoader",null),c()(ce,"_hlsJsLoader",null),c()(ce,"_configurationParameterReader",new E),c()(ce,"_applicationActivityMonitor",void 0),c()(ce,"_environment",new B("")),c()(ce,"_telemetryUrl",new B("https://telemetry.phenixrts.com/telemetry")),c()(ce,"_maximalNumberOfPeerConnectionReconnectAttempts",8),c()(ce,"_telemetryLevel",new B(x.defaultTelemetryLevel)),c()(ce,"_metricsService",void 0),c()(ce,"_metricsConfiguration",void 0),c()(ce,"_sendLocalCandidates",new B(!h.isPrivate)),c()(ce,"_tenancy",new B("")),c()(ce,"_clientSessionId",D.random(32)),c()(ce,"_loadedTimestamp",new Date),c()(ce,"_logger",F.getLogger("SDK")),c()(ce,"_initialized",new B(!1)),c()(ce,"_peerConnectionFactory",new B(new q)),c()(ce,"_readOnlyInitialized",new z(ce._initialized)),c()(ce,"_readOnlyDiscoveryUri",new z(re.uri)),c()(ce,"_readOnlyPeerConnectionFactory",new z(ce._peerConnectionFactory)),window.addEventListener("unload",(function(){ce.dispose()})),ce.applyDiscoveryUriDefaultFromParameterConfiguration(),ce.applyMetricsConfiguration(),ce.applyTelemetryConfiguration(),ce.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),ce.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),ce.init();var le,de=function(){function e(t,n){o()(this,e),c()(this,"width",void 0),c()(this,"height",void 0),this.width=t,this.height=n}return s()(e,null,[{key:"empty",get:function(){return new e(0,0)}}]),s()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}]),e}();!function(e){e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.Error=12]="Error",e[e.UnsupportedFeature=13]="UnsupportedFeature"}(le||(le={}));var he,pe,fe=le,ve=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;o()(this,e),c()(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,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t>>=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}]),e}(),ge=function(){function e(t,n,r,i){o()(this,e),c()(this,"_pageLoadTime",void 0),c()(this,"_channelStartTime",void 0),c()(this,"_logger",F.getLogger("StreamTelemetry")),c()(this,"_disposables",new X),c()(this,"_streamId",void 0),c()(this,"_metricsService",void 0),c()(this,"_listenToFirstTime",void 0),c()(this,"_listenForStall",void 0),c()(this,"_listenForContinuation",void 0),c()(this,"_timeToFirstFrame",void 0),c()(this,"_channelCreationTimeToFirstFrame",void 0),c()(this,"_startRecordingFirstFrame",void 0),c()(this,"_videoStalled",void 0),c()(this,"_lastProgress",void 0),c()(this,"_videoResolution",void 0),c()(this,"_clearTimeToFirstFrameListener",void 0),c()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=r,this._metricsService=i}return s()(e,[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new N((function(){e.removeEventListener("loadeddata",t._listenToFirstTime),e.removeEventListener("loadedmetadata",t._listenToFirstTime)})),this._disposables.add(this._clearTimeToFirstFrameListener)}},{key:"setupListenerForRebuffering",value:function(e){var t=this;this._listenForStall=function(){return t.onStall()},this._listenForContinuation=function(n){return t.onContinuation(n,e)},e.addEventListener("stalled",this._listenForStall),e.addEventListener("pause",this._listenForStall),e.addEventListener("suspend",this._listenForStall),e.addEventListener("play",this._listenForContinuation),e.addEventListener("playing",this._listenForContinuation),e.addEventListener("progress",this._listenForContinuation),e.addEventListener("timeupdate",this._listenForContinuation),this._clearRebufferingListener=new N((function(){e.removeEventListener("stalled",t._listenForStall),e.removeEventListener("pause",t._listenForStall),e.removeEventListener("suspend",t._listenForStall),e.removeEventListener("play",t._listenForContinuation),e.removeEventListener("playing",t._listenForContinuation),e.removeEventListener("progress",t._listenForContinuation),e.removeEventListener("timeupdate",t._listenForContinuation)})),this._disposables.add(this._clearRebufferingListener)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"callTimeToFirstFrame",value:function(){var e=Date.now();this.pushTimeToFirstFrame(e),this.pushChannelCreationTimeToFirstFrame(e),this._clearTimeToFirstFrameListener.dispose()}},{key:"pushTimeToFirstFrame",value:function(e){this._timeToFirstFrame=e-this._startRecordingFirstFrame,this._metricsService.push({metricType:ie.TimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._timeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] First frame [%s]",this.durationSincePageLoad,this._streamId,new ve(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:ie.ChannelCreationTimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._channelCreationTimeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] Channel creation to first frame [%s]",this.durationSincePageLoad,this._streamId,new ve(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:ie.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:ie.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new ve(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:ie.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}},{key:"durationSincePageLoad",get:function(){var e=Date.now();return new ve(e-this._pageLoadTime).toIsoString()}}]),e}(),me=function(){function e(t){o()(this,e),c()(this,"_logger",F.getLogger("StreamSetupListener")),c()(this,"metricsService",ce.metricsService),c()(this,"_pageLoadTime",void 0),c()(this,"_startTime",void 0),c()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return s()(e,[{key:"success",value:function(e){this.recordStreamMetric(ie.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(ie.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new oe(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 ve(n-this._pageLoadTime).toIsoString(),t,i,new ve(r).toIsoString())}}}]),e}(),ye=function(){function e(){o()(this,e),c()(this,"_disposables",new X),c()(this,"_isSupported",navigator&&navigator.connection),c()(this,"_rtt",new B(void 0)),c()(this,"_effectiveType",new B(void 0)),c()(this,"_downlinkThroughputCapacity",new B(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return s()(e,[{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 N((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()}},{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}}]),e}(),_e=function(){function e(t,n){var r=this;o()(this,e),c()(this,"_logger",F.getLogger("SessionTelemetry")),c()(this,"_metricsService",void 0),c()(this,"_applicationActivityMonitor",ce.applicationActivityMonitor),c()(this,"_networkMonitor",new ye),c()(this,"_pageLoadTime",void 0),c()(this,"_disposables",new X),c()(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 me(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?ie.ApplicationForeground:ie.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 ve(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:ie.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 ve(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:ie.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 ve(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:ie.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 ve(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}();!function(e){e[e.Keep=0]="Keep",e[e.Reset=1]="Reset"}(he||(he={})),function(e){e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset"}(pe||(pe={}));var we=function(){function e(t,n){o()(this,e),c()(this,"channelInitialization",void 0),c()(this,"disposables",void 0),c()(this,"channelDisposables",void 0),c()(this,"rendererDisposables",void 0),c()(this,"videoElement",void 0),c()(this,"token",void 0),c()(this,"peerConnection",void 0),c()(this,"mediaStream",void 0),c()(this,"state",void 0),c()(this,"autoMuted",void 0),c()(this,"autoPaused",void 0),c()(this,"tokenExpiring",void 0),c()(this,"authorized",void 0),c()(this,"online",void 0),c()(this,"loading",void 0),c()(this,"playing",void 0),c()(this,"standby",void 0),c()(this,"stopped",void 0),c()(this,"targetLag",void 0),c()(this,"lag",void 0),c()(this,"bitrateLimit",void 0),c()(this,"resolution",void 0),c()(this,"failureCount",void 0),c()(this,"endPoint",void 0),c()(this,"stream",void 0),c()(this,"rtcStatistics",void 0),c()(this,"peerConnectionReconnectAttempts",void 0),c()(this,"isDisposed",void 0),c()(this,"videoTelemetry",void 0),c()(this,"sessionTelemetry",void 0),c()(this,"rtcAudioStatistic",void 0),c()(this,"rtcVideoStatistic",void 0),c()(this,"clearFailureCountTimeout",void 0),this.isDisposed=!1,this.disposables=new X,this.channelDisposables=new X,this.rendererDisposables=new X,this.channelInitialization=new Date,this.videoElement=new B(null),this.token=new B(t),this.peerConnection=new B(null),this.mediaStream=new B(null),this.state=new B(fe.Starting),this.autoMuted=new B(!1),this.autoPaused=new B(!1),this.tokenExpiring=new B(!1),this.authorized=new B(!0),this.online=new B(!0),this.loading=new B(!1),this.playing=new B(!1),this.standby=new B(!1),this.stopped=new B(!1),this.targetLag=new B(n),this.lag=new B(0),this.bitrateLimit=new B(0),this.resolution=new B(de.empty),this.failureCount=new B(0),this.endPoint=new B(null),this.stream=new B(null),this.rtcStatistics=new B(null),this.peerConnectionReconnectAttempts=0}return s()(e,[{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null,void(this.state.value=fe.Error)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=ce.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return fe.Starting;case"no-stream":case"not-found":return fe.StandBy;case"geo-restricted":return fe.GeoRestricted;case"geo-blocked":return fe.GeoBlocked;case"unauthorized":return fe.Unauthorized;case"capacity":case"rate-limited":case"timeout":return fe.Recovering;case"failed":return fe.Error;default:L(e)}}},{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}}]),e}(),be=n(38),ke=n.n(be),Se=function(){var e,t;function n(){throw o()(this,n),new Error("PeerConnectionService is a static class that may not be instantiated")}return s()(n,null,[{key:"initiateInitialPrecaching",value:function(){G.isPrecachingEnabled&&n.precacheCreatePeerConnectionOffer().catch((function(e){return n._logger.error('Failed to pre-cache peer connection offer"',e)}))}},{key:"precacheCreatePeerConnectionOffer",value:(t=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._cached=n.createPeerConnectionOffer().catch((function(e){throw n._cached=null,e})));case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(e=_()(m().mark((function e(){var t,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n._cached){e.next=4;break}return t=n._cached,n._cached=null,e.abrupt("return",t);case 4:return r=ce.peerConnectionFactory.value,e.abrupt("return",r.createPeerConnection().then(function(){var e=_()(m().mark((function e(t){var n,r,i;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.supportsAddTransceiver)&&(i=t.addTransceiver("audio",{direction:"recvonly"}),r=t.addTransceiver("video",{direction:"recvonly"})),e.t0=i,e.t1=r,e.t2=t,e.next=7,t.createOffer(n?void 0:{offerToReceiveAudio:!0,offerToReceiveVideo:!0});case 7:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 6:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)})}]),n}();c()(Se,"_logger",F.getLogger("PeerConnectionService")),c()(Se,"_cached",void 0),Se.initiateInitialPrecaching();var Ce=n(319),xe=n.n(Ce),Te=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case pe.Normal:return"Normal";case pe.Force:return"Force";case pe.Reset:return"Reset";default:L(e)}}}]),e}(),Le=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case he.Keep:return"Keep";case he.Reset:return"Reset";default:L(e)}}}]),e}(),Pe=n(202).default,Re=function(){function e(t,n){if(o()(this,e),c()(this,"_logger",F.getLogger("EndPoint")),c()(this,"_uri",void 0),c()(this,"_timeout",void 0),c()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}var t,n,r,i,a,u,l,d,h,p;return s()(e,[{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(p=_()(m().mark((function e(){var t,n,r,i,o=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Pe.race([fetch(t,{method:"GET",cache:"no-cache"}),new Pe((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 p.apply(this,arguments)})},{key:"subscribe",value:(h=_()(m().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f,v,g,y=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((i=Q.parseToken(t))&&i.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=i.applicationId,a=this.buildUrl([o,"stream","subscribe"]).toString(),s=new FormData,u=w.sdkVersion,0===r&&n?(c={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},createAnswerDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,createOfferDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=10,p=null,e.next=14,Pe.race([fetch(a,{method:"POST",body:s}),new Pe((function(e){return p=window.setTimeout((function(){y._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(a,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&clearTimeout(p)}));case 14:h=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(f=this.mapHttpStatusToSubscribeStatus(h))){e.next=24;break}return e.abrupt("return",{status:f});case 24:return v=Date.now(),e.next=27,this.convertHttpResponseToSubscribeResponse(o,h);case 27:return g=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",g,v-d),e.abrupt("return",g);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n){return h.apply(this,arguments)})},{key:"setRemoteDescription",value:(d=_()(m().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Pe.race([fetch(r,{method:"POST",body:i}),new Pe((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 22:return d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return d.apply(this,arguments)})},{key:"limitBitrate",value:(l=_()(m().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,f=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new FormData,u={apiVersion:6,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Le.convertBitrateStateToBitrateStateType(i),bitrateMode:Te.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Pe.race([fetch(a,{method:"POST",body:s}),new Pe((function(e){return d=window.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),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 l.apply(this,arguments)})},{key:"addIceCandidates",value:(u=_()(m().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f=this,v=arguments;return m().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(),a=new FormData,s={apiVersion:6,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,Pe.race([fetch(o,{method:"POST",body:a}),new Pe((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 u.apply(this,arguments)})},{key:"destroyStream",value:(a=_()(m().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Pe.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Pe((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(s);case 22:return d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return a.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,xe()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=w.sdkVersion;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["_","".concat(Date.now())]]).toString()),e.toString()}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(i=_()(m().mark((function e(t,n){var r,i,o,a,s;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:if(r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,!r){e.next=46;break}if(!r.rtcConfiguration){e.next=43;break}if(o={},!r.rtcConfiguration.bundlePolicy){e.next=20;break}e.t0=r.rtcConfiguration.bundlePolicy,e.next="BundlePolicyBalanced"===e.t0?13:"BundlePolicyMaxCompat"===e.t0?15:"BundlePolicyMaxBundle"===e.t0?17:19;break;case 13:return o.bundlePolicy="balanced",e.abrupt("break",20);case 15:return o.bundlePolicy="max-compat",e.abrupt("break",20);case 17:return o.bundlePolicy="max-bundle",e.abrupt("break",20);case 19:L(r.rtcConfiguration.bundlePolicy);case 20:if("number"==typeof r.rtcConfiguration.iceCandidatePoolSize&&(o.iceCandidatePoolSize=r.rtcConfiguration.iceCandidatePoolSize),r.rtcConfiguration.iceServers){for(a=[],s=0;s<r.rtcConfiguration.iceServers.length;s++)a.push({urls:r.rtcConfiguration.iceServers[s].urls,username:r.rtcConfiguration.iceServers[s].username,credential:r.rtcConfiguration.iceServers[s].credential});o.iceServers=a}if(!r.rtcConfiguration.iceTransportPolicy){e.next=32;break}e.t1=r.rtcConfiguration.iceTransportPolicy,e.next="IceTransportPolicyAll"===e.t1?26:"IceTransportPolicyRelay"===e.t1?28:"IceTransportPolicyPublic"===e.t1?30:31;break;case 26:return o.iceTransportPolicy="all",e.abrupt("break",32);case 28:return o.iceTransportPolicy="relay",e.abrupt("break",32);case 30:return e.abrupt("break",32);case 31:L(r.rtcConfiguration.iceTransportPolicy);case 32:if(r.rtcConfiguration.peerIdentity&&(o.peerIdentity=r.rtcConfiguration.peerIdentity),!r.rtcConfiguration.rtcpMuxPolicy){e.next=42;break}e.t2=r.rtcConfiguration.rtcpMuxPolicy,e.next="RtcpMuxPolicyNegotiate"===e.t2?37:"RtcpMuxPolicyRequire"===e.t2?39:41;break;case 37:return o.rtcpMuxPolicy="negotiate",e.abrupt("break",42);case 39:return o.rtcpMuxPolicy="require",e.abrupt("break",42);case 41:L(r.rtcConfiguration.rtcpMuxPolicy);case 42:i.rtcConfiguration=o;case 43:r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)});case 46:return e.abrupt("return",i);case 47:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertISessionDescriptionToRTCSessionDescription",value:function(e){var t={sdp:e.sdp};switch(e.type){case"Offer":t.type="offer";break;case"Answer":t.type="answer";break;default:L(e.type)}return t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=_()(m().mark((function e(t){var n,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=this.convertISessionDescriptionToRTCSessionDescription(n.sessionDescription)),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=_()(m().mark((function e(t){var n,r;return m().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=_()(m().mark((function e(t){var n,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertRTCSdpTypeToSdpType",value:function(e){switch(e){case"answer":return"Answer";case"offer":return"Offer";case"pranswer":case"rollback":throw new Error("SDP type [".concat(e,"] is not supported"));default:L(e)}}},{key:"roundTripTime",get:function(){return this._roundTripTime}}]),e}(),Ee=n(202).default,Fe=function(){function e(t){if(o()(this,e),c()(this,"_logger",F.getLogger("Discovery")),c()(this,"_metricsService",void 0),c()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=se.getMetricsService(t.toString()),this._uri=t}var t,n;return s()(e,[{key:"discoverNearbyEndPoints",value:(n=_()(m().mark((function e(t,n){var r,i,o,a;return m().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,Ee.race([fetch(r,{method:"GET",cache:"no-cache"}),new Ee((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new Re(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=_()(m().mark((function e(){var t,n,r,i,o,a=this,s=arguments;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.length>0&&void 0!==s[0]?s[0]:2e4,n=re.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=function(){return new Ee((function(){a._logger.info("Request [%s] failed, preventing it from completing",n)}))},e.next=8,Ee.race(r.map((function(e){return e.ping().catch((function(t){return a._logger.warn("Failed to ping end point [%s]",e,t),i()})).then((function(t){var n=Date.now();return a._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),a._metricsService.push({metricType:ie.RoundTripTime,runtime:(n-ce.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 8:return o=e.sent,e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),De=function(){var e,t;function n(){throw o()(this,n),new Error("Discovery is a static class that may not be instantiated")}return s()(n,null,[{key:"precacheClosestEndPointDiscovery",value:(t=_()(m().mark((function e(){var t;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new URL(ce.discoveryUri.value),e.abrupt("return",n.discoverClosestEndPointWithCaching(t));case 2:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(e=_()(m().mark((function e(t){var r,i,o;return m().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 Fe(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(e){throw delete n._cache[r],e})),e.abrupt("return",o);case 7:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]),n}();c()(De,"_cache",{}),De.precacheClosestEndPointDiscovery();var Oe=function(){function e(t){o()(this,e),c()(this,"_sdp",void 0),c()(this,"_audioCodec",void 0),c()(this,"_videoCodec",void 0),this._sdp=t,this._audioCodec=this.applyCodec("audio"),this._videoCodec=this.applyCodec("video")}return s()(e,[{key:"applyCodec",value:function(e){var t=this._sdp.split(/(\r\n|\r|\n)/);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]}},{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}}]),e}(),Ie=function(){function e(t,n,r){if(o()(this,e),c()(this,"_estimatedRoundTripTime",void 0),c()(this,"_estimatedVideoCodec",void 0),c()(this,"_estimatedAudioCodec",void 0),c()(this,"_rtcStatistic",new B({})),c()(this,"_peerConnection",void 0),c()(this,"_isMonitorRunning",!0),c()(this,"_updateTimeOut",void 0),c()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!G.getCurrentOfferDisabled){var i=new Oe(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}var t,n;return s()(e,[{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeOut&&(clearTimeout(this._updateTimeOut),this._updateTimeOut=null)}},{key:"updateStatistic",value:(n=_()(m().mark((function e(){var t,n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!G.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i=n._estimatedRoundTripTime;e.forEach((function(o){if("candidate-pair"===o.type&&o.currentRoundTripTime&&(i=1e3*o.currentRoundTripTime),"inbound-rtp"===o.type){var a=o.kind||o.mediaType||t(o),s="";e.forEach((function(e){e.id===o.codecId&&(s=e.mimeType)})),a&&n._tracksToMonitor.includes(a)&&(r[a]={ssrc:o.ssrc,mediaType:a,timestamp:o.timestamp,bytesReceived:o.bytesReceived,packetsLost:o.packetsLost,packetsReceived:o.packetsReceived,codec:s||n.getCodecByType(a),roundTripTime:i},"video"===a&&n._rtcStatistic.value&&n._rtcStatistic.value.video&&(r[a].framesDecoded=o.framesDecoded,r[a].fps=(o.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(r[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3||0))}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeOut=window.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(t=_()(m().mark((function e(){var t=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},r=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i=e.stat("mediaType").toString();n[i]={timestamp:Date.now()},n[i].ssrc=e.stat("ssrc").toString(),n[i].mediaType=i,n[i].bytesReceived=e.stat("bytesReceived"),n[i].packetsLost=e.stat("packetsLost"),n[i].packetsReceived=e.stat("packetsReceived"),n[i].codec=e.stat("googCodecName").toString()||t.getCodecByType(i),n[i].roundTripTime=r,"video"===i&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[i].framesDecoded=e.stat("framesDecoded"),n[i].fps=(n[i].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[i].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeOut=window.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}},{key:"rtcStatistic",get:function(){return this._rtcStatistic}}]),e}(),Ae=n(202).default;function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function je(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Me(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ve=function(){function e(t,n){o()(this,e),c()(this,"_logger",F.getLogger("RealTimeStream")),c()(this,"_channelContext",void 0),c()(this,"_handleStreamFailure",void 0),this._channelContext=t,this._handleStreamFailure=n}var t;return s()(e,[{key:"start",value:function(e,t,n,r){var i=this;return Ae.all([De.discoverClosestEndPointWithCaching(e),Se.createPeerConnectionOffer()]).then((function(e){var n=ke()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp),!G.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s=null,a=null),i._channelContext.peerConnection.value=s,r.subscribe(t,a,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,a=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,u=e.createOfferDescriptionResponse,c=e.createAnswerDescriptionResponse,l=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=l,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,a,s,u,c),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._channelContext.peerConnection.value,a).then((function(e){var t,a=!1,l=!1,d=[];e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._channelContext.peerConnection.value===e&&(a||ce.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?d.push(n.candidate):l=!0,t||(t=setTimeout((function(){i._channelContext.stream.value!==o||a||i._channelContext.endPoint.value.addIceCandidates(o,d,l).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(a=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===o&&i._channelContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=fe.Error,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(navigator.onLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:L(e.iceConnectionState)}}};var h=new Ae((function(t,n){if(G.onTrackDisabled){var r=function n(r){clearTimeout(i),e.removeEventListener("track",n),e.removeEventListener("addstream",n),r.streams?t(r.streams[0]):t(r.stream)},i=setTimeout((function(){e.removeEventListener("track",r),e.removeEventListener("addstream",r),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",r),e.addEventListener("addstream",r)}else{var o=setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){clearTimeout(o),t(e.streams[0])}}}));return new Ae((function(e){e()})).then((function(){if(s)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription)})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription)})).then((function(){if(u)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(o,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r)}))})).then((function(){return n.success(i._channelContext.streamId),h})).then((function(t){i._channelContext.mediaStream.value=t;var n=new Ie(e,t,i._channelContext.endPoint.value.roundTripTime/4);return i._channelContext.disposables.add(n),n.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var r=!1,o=!1;t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((r=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new ve(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((o=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new ve(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),(o||r)&&navigator.onLine?i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=fe.Error,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,n.dispose(),i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))})):i._channelContext.peerConnectionReconnectAttempts=0})),ce.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=fe.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(t=_()(m().mark((function e(t,n){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=this.truncateIceServers(n),e.abrupt("return",ce.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,this)}))),function(e,n){return t.apply(this,arguments)})},{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}},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=fe.Reconnecting,this._channelContext.peerConnectionReconnectAttempts<ce.maximalNumberOfPeerConnectionReconnectAttempts||!ce.automaticallyReconnectPeerConnection){if(this._channelContext.peerConnectionReconnectAttempts++,G.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||this._channelContext.failureCount.value)return;this._logger.info("Reconnecting peer connection by restarting ICE");var r=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(r)}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._channelContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._channelContext.peerConnectionReconnectAttempts),this._channelContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return fe.Starting;case"unauthorized":return fe.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return fe.Recovering;case"failed":return fe.Error;default:L(e)}}}]),e}(),Ne=function(){function e(){throw o()(this,e),new Error("RealTimeStreamFactory is a static class that may not be instantiated")}return s()(e,null,[{key:"create",value:function(e,t,n){var r=Q.parseToken(e);return r&&r.token&&r.token.capabilities&&r.token.capabilities.includes("rtmp")?(this._logger.error("This build does not support RTMP playback."),void(t.state.value=fe.UnsupportedFeature)):r&&r.token&&r.token.capabilities&&r.token.capabilities.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=fe.UnsupportedFeature)):new Ve(t,n)}}]),e}();c()(Ne,"_logger",F.getLogger("Streaming"));var Ue="client:termination",Be=function(){function e(t,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;o()(this,e),c()(this,"_logger",F.getLogger("Channel")),c()(this,"_context",void 0),c()(this,"_channelStartTime",void 0),c()(this,"_readOnlyVideoElement",void 0),c()(this,"_readOnlyToken",void 0),c()(this,"_readOnlyPeerConnection",void 0),c()(this,"_readOnlyState",void 0),c()(this,"_readOnlyAutoMuted",void 0),c()(this,"_readOnlyAutoPaused",void 0),c()(this,"_readOnlyTokenExpiring",void 0),c()(this,"_readOnlyAuthorized",void 0),c()(this,"_readOnlyOnline",void 0),c()(this,"_readOnlyLoading",void 0),c()(this,"_readOnlyPlaying",void 0),c()(this,"_readOnlyStandby",void 0),c()(this,"_readOnlyStopped",void 0),c()(this,"_readOnlyTargetLag",void 0),c()(this,"_readOnlyLag",void 0),c()(this,"_readOnlyBitrateLimit",void 0),c()(this,"_readOnlyResolution",void 0),c()(this,"_readOnlyFailureCount",void 0),c()(this,"_readOnlyEndPoint",void 0),c()(this,"_readOnlyStream",void 0),c()(this,"_readOnlyRtcStatistics",void 0),c()(this,"_readOnlyMediaStream",void 0),c()(this,"_metricsService",void 0),c()(this,"_videoMetaDataChangedHandler",void 0),this._context=new we(n,i),this._channelStartTime=Date.now(),this._readOnlyVideoElement=new z(this._context.videoElement),this._readOnlyToken=new z(this._context.token),this._readOnlyPeerConnection=new z(this._context.peerConnection),this._readOnlyState=new z(this._context.state),this._readOnlyAutoMuted=new z(this._context.autoMuted),this._readOnlyAutoPaused=new z(this._context.autoPaused),this._readOnlyTokenExpiring=new z(this._context.tokenExpiring),this._readOnlyAuthorized=new z(this._context.authorized),this._readOnlyOnline=new z(this._context.online),this._readOnlyLoading=new z(this._context.loading),this._readOnlyPlaying=new z(this._context.playing),this._readOnlyStandby=new z(this._context.standby),this._readOnlyStopped=new z(this._context.stopped),this._readOnlyTargetLag=new z(this._context.targetLag),this._readOnlyLag=new z(this._context.lag),this._readOnlyBitrateLimit=new z(this._context.bitrateLimit),this._readOnlyResolution=new z(this._context.resolution),this._readOnlyFailureCount=new z(this._context.failureCount),this._readOnlyEndPoint=new z(this._context.endPoint),this._readOnlyStream=new z(this._context.stream),this._readOnlyRtcStatistics=new z(this._context.rtcStatistics),this._readOnlyMediaStream=new z(this._context.mediaStream);var a=Q.parseToken(this._context.token.value),s=(Q.getUri(a)||ce.discoveryUri.value).toString();ce.tenancy.value=Q.getTenancy(a)||ce.tenancy.value,re.uri.value=s,this._metricsService=se.getMetricsService(s),this._context.sessionTelemetry=new _e(ce.pageLoadTime,this._metricsService),this._context.channelDisposables.add(this._context.sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._context.channelDisposables.add(this._context.videoElement.subscribe((function(e){r._context.rendererDisposables.dispose(),e&&(r._context.rendererDisposables.add(r._context.stream.subscribe((function(e){r._context.videoTelemetry&&r._context.videoTelemetry.dispose(),e&&r.videoElement&&(r.videoElement.dataset&&(r.videoElement.dataset.sessionId=ce.clientSessionId,r.videoElement.dataset.streamId=r.streamId),r._context.videoTelemetry=new ge(r.streamId,ce.pageLoadTime,r._channelStartTime,r._metricsService),r._context.videoTelemetry.setupListenerForTimeToFirstTime(r.videoElement),r._context.videoTelemetry.setupListenerForRebuffering(r.videoElement),r._context.state.value===fe.Stopped)&&r.restartAfterStop()}))),r._context.channelDisposables.add(r._context.rendererDisposables))}))),this._context.channelDisposables.add(this._context.state.subscribe((function(e){r._context.clearFailureCountTimeout&&clearTimeout(r._context.clearFailureCountTimeout),r._context.failureCount.value&&e===fe.Playing&&(r._context.clearFailureCountTimeout=window.setTimeout((function(){r._context.failureCount.value=0}),3e3))}))),this._context.channelDisposables.add(this._context.resolution.subscribe((function(e){r._context.videoTelemetry&&r._context.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._context.channelDisposables.add(this._context.bitrateLimit.subscribe((function(e){if(e&&r._context.endPoint.value&&r._context.stream.value){var t=Date.now()-r._context.channelInitialization.getTime();r._context.endPoint.value.limitBitrate(r._context.stream.value,t,e,he.Keep,pe.Normal).catch((function(e){r._logger.error("Error while setting limit bitrate",e)}))}}))),this.start()}var t,n,r,i,a,u;return s()(e,[{key:"handleVideoMetaDataChanged",value:function(){var e=this._context.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._context.resolution.value=new de(e.videoWidth,e.videoHeight)):this._context.resolution.value=de.empty}},{key:"setBitrateLimit",value:function(e){this._context.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._context.bitrateLimit.value&&this._context.endPoint.value&&this._context.stream.value){var t=Date.now()-this._context.channelInitialization.getTime();this._context.endPoint.value.limitBitrate(this._context.stream.value,t,0,he.Keep,pe.Reset).then((function(t){"ok"===t.status&&(e._context.bitrateLimit.value=0)})).catch((function(t){e._logger.error("Error while setting limit bitrate",t)}))}}},{key:"updateTargetLag",value:function(e){this._context.targetLag.value=e}},{key:"stop",value:function(e){this._context.videoElement.value&&(this._context.videoElement.value.pause(),this._context.videoElement.value.srcObject=null),this._context.rendererDisposables.dispose(),this.cleanUpResources(e),this._context.state.value=fe.Stopped}},{key:"resume",value:(u=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._context.mediaStream.value){e.next=3;break}return this._context.autoPaused.value=!1,e.abrupt("return",this.playMediaStreamInVideoElement(this._context.mediaStream.value));case 3:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"mute",value:function(){var e=this._context.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._context.videoElement.value;e&&(e.muted=!1,this._context.autoMuted.value=!1)}},{key:"dispose",value:function(){this.stop("client:channel-dispose"),this._context.channelDisposables.dispose(),this._context.isDisposed=!0}},{key:"getUri",value:function(e){var t=Q.parseToken(e);return Q.getUri(t)||(this._logger.info("Fall back to the default discover URI [%s]",ce.discoveryUri.value),new URL(ce.discoveryUri.value))}},{key:"start",value:(a=_()(m().mark((function e(){var t,n,r,i,o=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._context.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(t=this._context.token.value,n=this._context.sessionTelemetry.listenOnStreamSetup(),Q.isValidToken(t)){e.next=9;break}return this._logger.error("Failed to parse token [%s]",t),this._context.state.value=fe.Unauthorized,this._context.authorized.value=!1,e.abrupt("return");case 9:if(this.cleanUpResources("client:start"),this._context.state.value=fe.Starting,this._context.loading.value=!0,r=this.getUri(t),i=Ne.create(t,this._context,this.handleStreamFailure.bind(this))){e.next=16;break}return e.abrupt("return");case 16:return e.abrupt("return",i.start(r,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){o._context.loading.value=!1})).then((function(){o._context.loading.value=!1})).catch((function(e){n.fail(),o._context.failureCount.value++,o._context.online.value=!1,o.cleanUpResources("client:cleanup-after-failed-setup"),o._context.state.value=fe.Error,o._logger.error("Failed to discover end point, marking as offline",e)})).finally((function(){if(o._context.state.value!==fe.Playing&&ce.automaticRetryOnFailure){var e=setTimeout((function(){o.handleStreamFailure().catch((function(e){o._logger.error("Failed handling stream failure",e)}))}),o.getRetryInterval());o._context.disposables.add(new N((function(){clearTimeout(e)})))}})));case 17:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._context.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._context.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._context.mediaStream.value));case 4:this._context.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"play",value:(r=_()(m().mark((function e(){var t;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._context.mediaStream.value){e.next=3;break}return e.abrupt("return",this.start());case 3:return e.abrupt("return",this.playMediaStreamInVideoElement(t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._context.state.value){case fe.StandBy:case fe.Offline:return 15e3;case fe.Error:case fe.Recovering:case fe.Unauthorized:case fe.GeoRestricted:case fe.GeoBlocked:case fe.Stopped:case fe.Starting:case fe.Playing:case fe.Paused:case fe.Reconnecting:case fe.UnsupportedFeature:return Math.min(3e5,Math.pow(2e3,Math.max(0,this._context.failureCount.value-1)));default:L(this._context.state.value)}}},{key:"handleStreamFailure",value:(n=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._context.state.value,e.next=e.t0===fe.Error||e.t0===fe.Reconnecting||e.t0===fe.StandBy||e.t0===fe.Offline||e.t0===fe.Recovering?3:e.t0===fe.Unauthorized?5:e.t0===fe.GeoRestricted?7:e.t0===fe.GeoBlocked?9:e.t0===fe.Stopped?11:e.t0===fe.Playing?13:e.t0===fe.Paused?15:e.t0===fe.Starting?17:e.t0===fe.UnsupportedFeature?19:21;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._context.state.value,fe[this._context.state.value]),e.abrupt("break",22);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 17:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 19:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 21:L(this._context.state.value);case 22:return e.abrupt("return",this.start());case 23:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ue;this._context.disposables.dispose();var n=this._context.peerConnection.value;n&&(this._context.peerConnection.value=null,n.close()),this._context.mediaStream.value&&(this._context.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._context.mediaStream.value=null),this._context.autoPaused.value=!1,this._context.autoMuted.value=!1,this._context.playing.value=!1,this._context.stopped.value=!0,this._context.standby.value=!1,this._context.stream.value&&this._context.endPoint.value&&this._context.endPoint.value.destroyStream(this._context.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._context.stream.value=null,this._context.endPoint.value=null}},{key:"playMediaStreamInVideoElement",value:(t=_()(m().mark((function e(t){var n,r,i=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this._context.videoElement.value){e.next=8;break}return this._context.autoMuted.value=!1,this._context.autoPaused.value=!1,this._context.loading.value=!1,this._context.playing.value=!1,this._context.state.value=fe.Stopped,e.abrupt("return");case 8:if(n.srcObject=t,void 0!==(r=n.play())){e.next=17;break}return this._context.autoMuted.value=!1,this._context.autoPaused.value=!1,this._context.loading.value=!1,this._context.playing.value=!0,this._context.state.value=fe.Playing,e.abrupt("return");case 17:return e.abrupt("return",r.then((function(){i._context.autoMuted.value=!1,i._context.autoPaused.value=!1,i._context.loading.value=!1,i._context.playing.value=!0,i._context.state.value=fe.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})),o=!ce.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(i._context.autoMuted.value=!1,i._context.autoPaused.value=!0,i._context.loading.value=!1,i._context.playing.value=!1,i._context.state.value=fe.Paused,o?(i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e),void(n.srcObject=null)):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then((function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._context.autoMuted.value=!0,i._context.autoPaused.value=!1,i._context.loading.value=!1,i._context.playing.value=!0,i._context.state.value=fe.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),i._context.autoMuted.value=!1,i._context.autoPaused.value=!0,i._context.loading.value=!1,i._context.playing.value=!1,i._context.state.value=fe.Playing})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"videoElement",get:function(){return this._context.videoElement.value},set:function(e){this._context.videoElement.value&&(this._context.videoElement.value.removeEventListener("loadeddata",this._videoMetaDataChangedHandler),this._context.videoElement.value.removeEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._context.videoElement.value.removeEventListener("resize",this._videoMetaDataChangedHandler),this._context.videoElement.value.dataset&&(this._context.videoElement.value.dataset.sessionId="",this._context.videoElement.value.dataset.streamId=""),this._context.rendererDisposables.dispose(),this._context.videoElement.value.pause(),this._context.videoElement.value.srcObject=null),this._context.autoMuted.value=!1,this._context.autoPaused.value=!1,this._context.loading.value=!1,this._context.playing.value=!1,this._context.state.value=fe.Stopped,this._context.videoElement.value=e,this._context.videoElement.value&&(this._context.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._context.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._context.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"token",get:function(){return this._context.token.value},set:function(e){this._context.disposables.dispose(),this._context.token.value=e,this._context.tokenExpiring.value=!1;var t=Q.parseToken(this._context.token.value),n=(Q.getUri(t)||ce.discoveryUri.value).toString();ce.tenancy.value=Q.getTenancy(t)||ce.tenancy.value,re.uri.value=n,this._metricsService=se.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._context.streamId}},{key:"rtcStats",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}}]),e}(),ze=function(){function e(){throw o()(this,e),new Error("Channels is a static class that may not be instantiated")}return s()(e,null,[{key:"createChannel",value:function(e){if(!ce.initialized.value)throw new Error("SDK is not loaded.");return new Be(e.videoElement,e.token,e.targetLag)}}]),e}(),He={SDK:ce,Channels:ze,ChannelState:fe}},666:(e,t,n)=>{var r=n(202).default,i=function(e){"use strict";var t,n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),a=new P(r||[]);return o._invoke=function(e,t,n){var r=d;return function(i,o){if(r===p)throw new Error("Generator is already running");if(r===f){if("throw"===i)throw o;return E()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=x(a,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===d)throw r=f,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=p;var u=l(e,t,n);if("normal"===u.type){if(r=n.done?f:h,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=f,n.method="throw",n.arg=u.arg)}}}(e,n,a),o}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",h="suspendedYield",p="executing",f="completed",v={};function g(){}function m(){}function y(){}var _={};_[a]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w(R([])));b&&b!==n&&i.call(b,a)&&(_=b);var k=y.prototype=g.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function C(e,t){function n(r,o,a,s){var u=l(e[r],e,o);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var r;this._invoke=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 x(e,n){var r=e.iterator[n.method];if(r===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method))return v;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var i=l(r,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var o=i.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,v):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function T(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 L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function R(e){if(e){var n=e[a];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(i.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}return{next:E}}function E(){return{value:t,done:!0}}return m.prototype=k.constructor=y,y.constructor=m,y[u]=m.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,u in e||(e[u]="GeneratorFunction")),e.prototype=Object.create(k),e},e.awrap=function(e){return{__await:e}},S(C.prototype),C.prototype[s]=function(){return this},e.AsyncIterator=C,e.async=function(t,n,i,o,a){void 0===a&&(a=r);var s=new C(c(t,n,i,o),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},S(k),k[u]="Generator",k[a]=function(){return this},k.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=R,P.prototype={constructor:P,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(L),!e)for(var n in this)"t"===n.charAt(0)&&i.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 o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=i}catch(e){Function("r","regeneratorRuntime = r")(i)}}},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(190)})()}));
|
|
1
|
+
!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}},858:e=>{e.exports=function(e){if(Array.isArray(e))return e}},646:(e,t,n)=>{var r=n(228);e.exports=function(e){if(Array.isArray(e))return r(e)}},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}},926:(e,t,n)=>{var r=n(202).default;function i(e,t,n,i,o,a,s){try{var c=e[a](s),u=c.value}catch(e){return void n(e)}c.done?t(u):r.resolve(u).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)}))}}},575:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},913:e=>{function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}},713:e=>{e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},754:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(n)}e.exports=t},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}}),t&&r(e,t)}},860:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},884:e=>{e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}}},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.")}},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.")}},585:(e,t,n)=>{var r=n(8),i=n(506);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},489:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(n,r)}e.exports=t},38:(e,t,n)=>{var r=n(858),i=n(884),o=n(379),a=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()}},319:(e,t,n)=>{var r=n(646),i=n(860),o=n(379),a=n(206);e.exports=function(e){return r(e)||i(e)||o(e)||a()}},8:e=>{function t(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=t=function(e){return typeof e}:e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(n)}e.exports=t},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}}},757:(e,t,n)=>{e.exports=n(666)},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),a=n.n(o),s=n(913),c=n.n(s),u=n(713),l=n.n(u),d=function e(t,n,r){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r},h=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],this.doResolve(t)}return c()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function t(a,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var c=s.then;if("function"==typeof c)return void c.call(s,(function(e){return t(a,e)}),n)}r[a]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var p=h},190:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ChannelState:()=>fe,Channels:()=>He,SDK:()=>ue,default:()=>Ge});var r,i=n(575),o=n.n(i),a=n(913),s=n.n(a),c=n(713),u=n.n(c);!function(e){e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off"}(r||(r={}));var l=function(){function e(t,n,r){o()(this,e),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:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?e+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}},{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}}]),e}(),d=function(){function e(){o()(this,e),u()(this,"_appenders",[])}return s()(e,[{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}),[])}},{key:"value",get:function(){return this._appenders}}]),e}(),h=function(){function e(){o()(this,e)}return s()(e,null,[{key:"applyIsPrivate",value:function(){try{this._isPrivate=!0}catch(e){this._isPrivate=!1}}},{key:"isPrivate",get:function(){return this._isPrivate}}]),e}();u()(h,"_isPrivate",void 0),h.applyIsPrivate();var p=function(){function e(){o()(this,e)}return s()(e,null,[{key:"defaultLoggingLevel",get:function(){return h.isPrivate?r.Off:r.All}},{key:"defaultConsoleLoggingLevel",get:function(){return h.isPrivate?r.Off:r.All}},{key:"defaultTelemetryLoggingLevel",get:function(){return r.Info}}]),e}(),f=function(){function e(){o()(this,e),u()(this,"_threshold",p.defaultLoggingLevel)}return s()(e,[{key:"setThreshold",value:function(e){this._threshold=e}},{key:"value",get:function(){return this._threshold}}]),e}(),v=function(){function e(t){o()(this,e),u()(this,"_threshold",void 0),this._threshold=t}return s()(e,[{key:"log",value:function(e,t,n,i){if(!(e<this._threshold)){var o="".concat(i.toISOString()," [").concat(n,"] [").concat(r[e],"] ").concat(t);e<r.Warn?console.log(o):console.error(o)}}}]),e}(),g=n(757),m=n.n(g),y=n(926),_=n.n(y),w=function(){function e(){o()(this,e)}return s()(e,null,[{key:"sdkVersion",get:function(){try{return"2022-05-05T18:02:55.793Z (2022.0.5)"}catch(e){return this._defaultVersion}}}]),e}();u()(w,"_defaultVersion",(new Date).toISOString());var b,k=function(){function e(t){o()(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,i){var o={timestamp:i.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:r[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:w.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<r.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=_()(m().mark((function e(t){var n;return m().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=_()(m().mark((function e(){var t,n,r,i,o=this;return m().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}(),S=function(){function e(t){o()(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 k(t)}return s()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}(),C=function(){function e(){o()(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}(),x=function(){function e(){o()(this,e)}return s()(e,null,[{key:"defaultTelemetryLevel",get:function(){return h.isPrivate?b.Essential:b.All}}]),e}();!function(e){e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All"}(b||(b={}));var T=function(){function e(){o()(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",x.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"))},P=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case b.Off:return"Off";case b.Essential:return"Essential";case b.All:return"All";default:L(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return b.Off;case"Essential":return b.Essential;case"All":return b.All;default:L(e)}}}]),e}(),R=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case r.Off:return"Off";case r.Trace:return"Trace";case r.Debug:return"Debug";case r.Info:return"Trace";case r.Warn:return"Warn";case r.Error:return"Error";case r.Fatal:return"Fatal";case r.All:return"All";default:L(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return r.Off;case"Trace":return r.Trace;case"Debug":return r.Debug;case"Info":return r.Info;case"Warn":return r.Warn;case"Error":return r.Error;case"Fatal":return r.Fatal;case"All":return r.All;default:L(e)}}}]),e}(),E=function(){function e(){o()(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":P.convertTelemetryLevelToTelemetryLevelType(x.defaultTelemetryLevel),"phenix-logging-level":R.convertLoggingLevelToLoggingLevelType(p.defaultLoggingLevel),"phenix-console-logging-level":R.convertLoggingLevelToLoggingLevelType(p.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":R.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}}}]),e}(),F=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return s()(e,null,[{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");r[e]&&this._threshold.setThreshold(r[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(r[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 S(this._telemetryConfiguration))}},{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}}]),e}();u()(F,"_configurationParameterReader",new E),u()(F,"_loggers",{}),u()(F,"_appenders",new d),u()(F,"_threshold",new f),u()(F,"_telemetryConfiguration",new C),F.applyLoggerConfigFromParameterConfiguration();var D=function(){function e(){throw o()(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}(),O=n(205),I=n.n(O),A=n(585),M=n.n(A),j=n(754),V=n.n(j),N=function(){function e(t){o()(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=function(e){I()(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=V()(t);if(n){var i=V()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return M()(this,e)});function i(e,t){return o()(this,i),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return i}(N),B=function(){function e(t){o()(this,e),u()(this,"_listeners",void 0),u()(this,"_value",void 0),this._listeners=[],this._value=t}return s()(e,[{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new U(this._listeners,e)}},{key:"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)})))},get:function(){return this._value}}]),e}(),z=function(){function e(t){o()(this,e),u()(this,"_subject",void 0),this._subject=t}return s()(e,[{key:"subscribe",value:function(e){return this._subject.subscribe(e)}},{key:"value",get:function(){return this._subject.value}}]),e}(),H=function(){function e(){o()(this,e)}return s()(e,null,[{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""}},{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}}]),e}();u()(H,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),u()(H,"_browserNameAndVersion",H.parseBrowserNameAndVersion()),u()(H,"_browserName",H.parseBrowserName()),u()(H,"_browserMajorVersion",H.parseBrowserMajorVersion()),u()(H,"_isChrome69",H._browserNameAndVersion.includes("Chrome/69.")),u()(H,"_isChrome70",H._browserNameAndVersion.includes("Chrome/70.")),u()(H,"_isChrome71",H._browserNameAndVersion.includes("Chrome/71.")),u()(H,"_isChrome72",H._browserNameAndVersion.includes("Chrome/72.")),u()(H,"_isChrome74",H._browserNameAndVersion.includes("Chrome/74.")),u()(H,"_isChrome75",H._browserNameAndVersion.includes("Chrome/75.")),u()(H,"_isChrome76",H._browserNameAndVersion.includes("Chrome/76.")),u()(H,"_isChrome77",H._browserNameAndVersion.includes("Chrome/77."));var G=function(){function e(){o()(this,e)}return s()(e,null,[{key:"clientOfferDisabled",get:function(){return H.isChrome74||H.isChrome75||H.isChrome76||H.isChrome77}},{key:"addTranceiverDisabled",get:function(){return H.isChrome69||H.isChrome70||H.isChrome71||H.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=69||"Firefox"===H.browserName&&H.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=63||"Firefox"===H.browserName&&H.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===H.browserName&&H.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===H.browserName&&H.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===H.browserName||"SamsungBrowser"===H.browserName}},{key:"isRTMPEnabled",get:function(){return"Firefox"===H.browserName&&H.browserMajorVersion<84||"Chrome"===H.browserName&&H.browserMajorVersion<70||"Edge"===H.browserName||"IE"===H.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==H.browserName}}]),e}(),W=n(202).default,J=function(){function e(t){o()(this,e),u()(this,"_logger",F.getLogger("VanillaPeerConnection")),u()(this,"_peerConnection",void 0),G.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,i;return s()(e,[{key:"createOffer",value:(i=_()(m().mark((function e(t){var n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!G.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((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 i.apply(this,arguments)})},{key:"createAnswer",value:(r=_()(m().mark((function e(t){var n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!G.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((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=_()(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(G.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=_()(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.sdp.match(/a=crypto:/i)&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(G.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new W((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:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"close",value:function(){this._peerConnection.close()}},{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsAddTransceiver",get:function(){return!G.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"ontrack",set:function(e){this._peerConnection.ontrack=e},get:function(){return this._peerConnection.ontrack}},{key:"onicecandidate",set:function(e){this._peerConnection.onicecandidate=e},get:function(){return this._peerConnection.onicecandidate}},{key:"oniceconnectionstatechange",set:function(e){this._peerConnection.oniceconnectionstatechange=e},get:function(){return this._peerConnection.oniceconnectionstatechange}}]),e}(),q=function(){function e(){o()(this,e)}var t;return s()(e,[{key:"createPeerConnection",value:(t=_()(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new J(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}(),K="DIGEST:",Q=function(){function e(){o()(this,e)}return s()(e,null,[{key:"parseToken",value:function(t){if(this.isValidToken(t))try{var n=atob(t.substr(K.length)),r=JSON.parse(n);return r.token=JSON.parse(r.token),r}catch(t){return void e._logger.error("Cannot parse token value",t)}else e._logger.error("Token is not valid [%s]",t)}},{key:"getUri",value:function(e){return e&&e.token&&e.token.uri?new URL(e.token.uri):null}},{key:"getTenancy",value:function(e){return e&&e.applicationId?e.applicationId:""}},{key:"isValidToken",value:function(e){return!!e&&e.startsWith(K)}}]),e}();u()(Q,"_logger",F.getLogger("EdgeAuth"));var Y,Z=n(8),$=n.n(Z),X=function(){function e(){o()(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}(),ee=function(){function e(){o()(this,e),u()(this,"_disposables",new X),u()(this,"_readOnlyIsForeground",void 0),u()(this,"_isForeground",void 0),u()(this,"_timeOfLastTabFocusChange",Date.now()),u()(this,"_documentFocusInterval",void 0),this._isForeground=new B(!0),this._readOnlyIsForeground=new z(this._isForeground),this.detectTabFocusChange()}return s()(e,[{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":$()(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 N((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 N((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}},{key:"isForeground",get:function(){return this._readOnlyIsForeground}}]),e}(),te=function(){function e(){o()(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}(),ne=function(){function e(){o()(this,e)}return s()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}(),re=function(){function e(){throw o()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return s()(e,null,[{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=w.sdkVersion;return t.search="?".concat(new URLSearchParams([["version",n],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}},{key:"uri",get:function(){return e._discoveryUri}}]),e}();u()(re,"_discoveryUri",new B("https://pcast.phenixrts.com/pcast/endPoints")),function(e){e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground"}(Y||(Y={}));var ie=Y,oe=function(){function e(t){o()(this,e),u()(this,"_metrics",void 0),this._metrics=t}return s()(e,[{key:"getName",value:function(){return ie[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case ie.TimeToFirstFrame:case ie.ChannelCreationTimeToFirstFrame:return b.Essential;case ie.Stalled:case ie.Buffering:case ie.SetupCompleted:case ie.SetupFailed:case ie.RoundTripTime:case ie.DownlinkThroughputCapacity:case ie.NetworkType:case ie.ResolutionChanged:case ie.ApplicationForeground:case ie.ApplicationBackground:return b.All;default:L(this._metrics)}}}]),e}(),ae=function(){function e(t){o()(this,e),u()(this,"_metricsConfiguration",void 0),u()(this,"_metrics",[]),u()(this,"_isSending",void 0),u()(this,"_domain",location.hostname),this._metricsConfiguration=t}var t,n;return s()(e,[{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new oe(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var c={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:w.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(c),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=_()(m().mark((function e(t){var n;return m().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=_()(m().mark((function e(){var t,n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){return n._isSending=!1,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}}]),e}(),se=function(){function e(){throw o()(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=ue.clientSessionId,r.tenancy=ue.tenancy.value,r.url=te.getTelemetryUrl(t),r.environment=ne.getEnvironmentFromUrl(t),r.threshold=P.convertTelemetryLevelTypeToTelemetryLevel(ue.telemetryLevel),e._metricsServices[t]=new ae(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()(se,"_metricsServices",{});var ce=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),ue=function(){function e(){throw o()(this,e),new Error("SDK is a static class that may not be instantiated")}return s()(e,null,[{key:"applyTelemetryConfiguration",value:function(){var t=this,n=F.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 S}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new S(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 S}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new S(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=se.getMetricsService(re.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&&se.setTelemetryLevel(b[t]),e._telemetryLevel.subscribe((function(e){se.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=ne.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=Q.parseToken(t);return e._tenancy.value=Q.getTenancy(n),re.uri.value=(Q.getUri(n)||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return re.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?(re.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 ee),t){if(t.discoveryUri&&(re.uri.value=t.discoveryUri),t.peerConnectionFactory&&(e._peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&b[t.telemetryLevel]&&(e._telemetryLevel.value=P.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&r[t.loggingLevel]&&this._logger.threshold.setThreshold(R.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&r[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(R.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 te.getTelemetryUrl(e)}},{key:"pageLoadTime",get:function(){return ce}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return R.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return P.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return H}}]),e}();u()(ue,"_automaticallyRetryOnFailure",!0),u()(ue,"_automaticallyReconnectPeerConnection",!0),u()(ue,"_automaticallyPlayMediaStream",!0),u()(ue,"_automaticallyMuteVideoOnPlayFailure",!0),u()(ue,"_webPlayerLoader",null),u()(ue,"_shakaPlayerLoader",null),u()(ue,"_hlsJsLoader",null),u()(ue,"_configurationParameterReader",new E),u()(ue,"_applicationActivityMonitor",void 0),u()(ue,"_environment",new B("")),u()(ue,"_telemetryUrl",new B("https://telemetry.phenixrts.com/telemetry")),u()(ue,"_maximalNumberOfPeerConnectionReconnectAttempts",8),u()(ue,"_telemetryLevel",new B(x.defaultTelemetryLevel)),u()(ue,"_metricsService",void 0),u()(ue,"_metricsConfiguration",void 0),u()(ue,"_sendLocalCandidates",new B(!h.isPrivate)),u()(ue,"_tenancy",new B("")),u()(ue,"_clientSessionId",D.random(32)),u()(ue,"_loadedTimestamp",new Date),u()(ue,"_logger",F.getLogger("SDK")),u()(ue,"_initialized",new B(!1)),u()(ue,"_peerConnectionFactory",new B(new q)),u()(ue,"_readOnlyInitialized",new z(ue._initialized)),u()(ue,"_readOnlyDiscoveryUri",new z(re.uri)),u()(ue,"_readOnlyPeerConnectionFactory",new z(ue._peerConnectionFactory)),window.addEventListener("unload",(function(){ue.dispose()})),ue.applyDiscoveryUriDefaultFromParameterConfiguration(),ue.applyMetricsConfiguration(),ue.applyTelemetryConfiguration(),ue.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),ue.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),ue.init();var le,de=function(){function e(t,n){o()(this,e),u()(this,"width",void 0),u()(this,"height",void 0),this.width=t,this.height=n}return s()(e,null,[{key:"empty",get:function(){return new e(0,0)}}]),s()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}]),e}();!function(e){e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.Error=12]="Error",e[e.UnsupportedFeature=13]="UnsupportedFeature"}(le||(le={}));var he,pe,fe=le,ve=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;o()(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,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t>>=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}]),e}(),ge=function(){function e(t,n,r,i){o()(this,e),u()(this,"_pageLoadTime",void 0),u()(this,"_channelStartTime",void 0),u()(this,"_logger",F.getLogger("StreamTelemetry")),u()(this,"_disposables",new X),u()(this,"_streamId",void 0),u()(this,"_metricsService",void 0),u()(this,"_listenToFirstTime",void 0),u()(this,"_listenForStall",void 0),u()(this,"_listenForContinuation",void 0),u()(this,"_timeToFirstFrame",void 0),u()(this,"_channelCreationTimeToFirstFrame",void 0),u()(this,"_startRecordingFirstFrame",void 0),u()(this,"_videoStalled",void 0),u()(this,"_lastProgress",void 0),u()(this,"_videoResolution",void 0),u()(this,"_clearTimeToFirstFrameListener",void 0),u()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=r,this._metricsService=i}return s()(e,[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new N((function(){e.removeEventListener("loadeddata",t._listenToFirstTime),e.removeEventListener("loadedmetadata",t._listenToFirstTime)})),this._disposables.add(this._clearTimeToFirstFrameListener)}},{key:"setupListenerForRebuffering",value:function(e){var t=this;this._listenForStall=function(){return t.onStall()},this._listenForContinuation=function(n){return t.onContinuation(n,e)},e.addEventListener("stalled",this._listenForStall),e.addEventListener("pause",this._listenForStall),e.addEventListener("suspend",this._listenForStall),e.addEventListener("play",this._listenForContinuation),e.addEventListener("playing",this._listenForContinuation),e.addEventListener("progress",this._listenForContinuation),e.addEventListener("timeupdate",this._listenForContinuation),this._clearRebufferingListener=new N((function(){e.removeEventListener("stalled",t._listenForStall),e.removeEventListener("pause",t._listenForStall),e.removeEventListener("suspend",t._listenForStall),e.removeEventListener("play",t._listenForContinuation),e.removeEventListener("playing",t._listenForContinuation),e.removeEventListener("progress",t._listenForContinuation),e.removeEventListener("timeupdate",t._listenForContinuation)})),this._disposables.add(this._clearRebufferingListener)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"callTimeToFirstFrame",value:function(){var e=Date.now();this.pushTimeToFirstFrame(e),this.pushChannelCreationTimeToFirstFrame(e),this._clearTimeToFirstFrameListener.dispose()}},{key:"pushTimeToFirstFrame",value:function(e){this._timeToFirstFrame=e-this._startRecordingFirstFrame,this._metricsService.push({metricType:ie.TimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._timeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] First frame [%s]",this.durationSincePageLoad,this._streamId,new ve(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:ie.ChannelCreationTimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._channelCreationTimeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] Channel creation to first frame [%s]",this.durationSincePageLoad,this._streamId,new ve(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:ie.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:ie.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new ve(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:ie.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}},{key:"durationSincePageLoad",get:function(){var e=Date.now();return new ve(e-this._pageLoadTime).toIsoString()}}]),e}(),me=function(){function e(t){o()(this,e),u()(this,"_logger",F.getLogger("StreamSetupListener")),u()(this,"metricsService",ue.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(ie.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(ie.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new oe(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 ve(n-this._pageLoadTime).toIsoString(),t,i,new ve(r).toIsoString())}}}]),e}(),ye=function(){function e(){o()(this,e),u()(this,"_disposables",new X),u()(this,"_isSupported",navigator&&navigator.connection),u()(this,"_rtt",new B(void 0)),u()(this,"_effectiveType",new B(void 0)),u()(this,"_downlinkThroughputCapacity",new B(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return s()(e,[{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 N((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()}},{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}}]),e}(),_e=function(){function e(t,n){var r=this;o()(this,e),u()(this,"_logger",F.getLogger("SessionTelemetry")),u()(this,"_metricsService",void 0),u()(this,"_applicationActivityMonitor",ue.applicationActivityMonitor),u()(this,"_networkMonitor",new ye),u()(this,"_pageLoadTime",void 0),u()(this,"_disposables",new X),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 me(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?ie.ApplicationForeground:ie.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 ve(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:ie.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 ve(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:ie.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 ve(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:ie.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 ve(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}();!function(e){e[e.Keep=0]="Keep",e[e.Reset=1]="Reset"}(he||(he={})),function(e){e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset"}(pe||(pe={}));var we=function(){function e(t,n){o()(this,e),u()(this,"channelInitialization",void 0),u()(this,"disposables",void 0),u()(this,"channelDisposables",void 0),u()(this,"rendererDisposables",void 0),u()(this,"videoElement",void 0),u()(this,"token",void 0),u()(this,"peerConnection",void 0),u()(this,"mediaStream",void 0),u()(this,"state",void 0),u()(this,"autoMuted",void 0),u()(this,"autoPaused",void 0),u()(this,"tokenExpiring",void 0),u()(this,"authorized",void 0),u()(this,"online",void 0),u()(this,"loading",void 0),u()(this,"playing",void 0),u()(this,"standby",void 0),u()(this,"stopped",void 0),u()(this,"targetLag",void 0),u()(this,"lag",void 0),u()(this,"bitrateLimit",void 0),u()(this,"resolution",void 0),u()(this,"failureCount",void 0),u()(this,"endPoint",void 0),u()(this,"stream",void 0),u()(this,"rtcStatistics",void 0),u()(this,"peerConnectionReconnectAttempts",void 0),u()(this,"isDisposed",void 0),u()(this,"isStarting",void 0),u()(this,"videoTelemetry",void 0),u()(this,"sessionTelemetry",void 0),u()(this,"rtcAudioStatistic",void 0),u()(this,"rtcVideoStatistic",void 0),u()(this,"clearFailureCountTimeout",void 0),this.isDisposed=!1,this.isStarting=new B(!1),this.disposables=new X,this.channelDisposables=new X,this.rendererDisposables=new X,this.channelInitialization=new Date,this.videoElement=new B(null),this.token=new B(t),this.peerConnection=new B(null),this.mediaStream=new B(null),this.state=new B(fe.Starting),this.autoMuted=new B(!1),this.autoPaused=new B(!1),this.tokenExpiring=new B(!1),this.authorized=new B(!0),this.online=new B(!0),this.loading=new B(!1),this.playing=new B(!1),this.standby=new B(!1),this.stopped=new B(!1),this.targetLag=new B(n),this.lag=new B(0),this.bitrateLimit=new B(0),this.resolution=new B(de.empty),this.failureCount=new B(0),this.endPoint=new B(null),this.stream=new B(null),this.rtcStatistics=new B(null),this.peerConnectionReconnectAttempts=0}return s()(e,[{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null,void(this.state.value=fe.Error)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=ue.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return fe.Starting;case"no-stream":case"not-found":return fe.StandBy;case"geo-restricted":return fe.GeoRestricted;case"geo-blocked":return fe.GeoBlocked;case"unauthorized":return fe.Unauthorized;case"capacity":case"rate-limited":case"timeout":return fe.Recovering;case"failed":return fe.Error;default:L(e)}}},{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}}]),e}(),be=n(38),ke=n.n(be),Se=function(){var e,t;function n(){throw o()(this,n),new Error("PeerConnectionService is a static class that may not be instantiated")}return s()(n,null,[{key:"initiateInitialPrecaching",value:function(){G.isPrecachingEnabled&&n.precacheCreatePeerConnectionOffer().catch((function(e){return n._logger.error('Failed to pre-cache peer connection offer"',e)}))}},{key:"precacheCreatePeerConnectionOffer",value:(t=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._cached=n.createPeerConnectionOffer().catch((function(e){throw n._cached=null,e})));case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(e=_()(m().mark((function e(){var t,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n._cached){e.next=4;break}return t=n._cached,n._cached=null,e.abrupt("return",t);case 4:return r=ue.peerConnectionFactory.value,e.abrupt("return",r.createPeerConnection().then(function(){var e=_()(m().mark((function e(t){var n,r,i;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.supportsAddTransceiver)&&(i=t.addTransceiver("audio",{direction:"recvonly"}),r=t.addTransceiver("video",{direction:"recvonly"})),e.t0=i,e.t1=r,e.t2=t,e.next=7,t.createOffer(n?void 0:{offerToReceiveAudio:!0,offerToReceiveVideo:!0});case 7:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 6:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)})}]),n}();u()(Se,"_logger",F.getLogger("PeerConnectionService")),u()(Se,"_cached",void 0),Se.initiateInitialPrecaching();var Ce=n(319),xe=n.n(Ce),Te=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case pe.Normal:return"Normal";case pe.Force:return"Force";case pe.Reset:return"Reset";default:L(e)}}}]),e}(),Le=function(){function e(){o()(this,e)}return s()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case he.Keep:return"Keep";case he.Reset:return"Reset";default:L(e)}}}]),e}(),Pe=n(202).default,Re=function(){function e(t,n){if(o()(this,e),u()(this,"_logger",F.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,i,a,c,l,d,h,p;return s()(e,[{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(p=_()(m().mark((function e(){var t,n,r,i,o=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Pe.race([fetch(t,{method:"GET",cache:"no-cache"}),new Pe((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 p.apply(this,arguments)})},{key:"subscribe",value:(h=_()(m().mark((function e(t,n,r){var i,o,a,s,c,u,l,d,h,p,f,v,g,y=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((i=Q.parseToken(t))&&i.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=i.applicationId,a=this.buildUrl([o,"stream","subscribe"]).toString(),s=new FormData,c=w.sdkVersion,0===r&&n?(u={apiVersion:6,clientVersion:c,edgeAuthToken:t,failureCount:r,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},createAnswerDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(u))):(l={apiVersion:6,clientVersion:c,edgeAuthToken:t,failureCount:r,createOfferDescription:{apiVersion:6}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=10,p=null,e.next=14,Pe.race([fetch(a,{method:"POST",body:s}),new Pe((function(e){return p=window.setTimeout((function(){y._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(a,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){p&&clearTimeout(p)}));case 14:h=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(f=this.mapHttpStatusToSubscribeStatus(h))){e.next=24;break}return e.abrupt("return",{status:f});case 24:return v=Date.now(),e.next=27,this.convertHttpResponseToSubscribeResponse(o,h);case 27:return g=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",g,v-d),e.abrupt("return",g);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n){return h.apply(this,arguments)})},{key:"setRemoteDescription",value:(d=_()(m().mark((function e(t,n){var r,i,o,a,s,c,u,l,d,h=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,c=null,e.next=9,Pe.race([fetch(r,{method:"POST",body:i}),new Pe((function(e){return c=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(){c&&clearTimeout(c)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(u=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.next=19;break}return e.abrupt("return",{status:u});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 22:return d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return d.apply(this,arguments)})},{key:"limitBitrate",value:(l=_()(m().mark((function e(t,n,r,i,o){var a,s,c,u,l,d,h,p,f=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new FormData,c={apiVersion:6,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Le.convertBitrateStateToBitrateStateType(i),bitrateMode:Te.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(c)),u=Date.now(),e.prev=5,d=null,e.next=9,Pe.race([fetch(a,{method:"POST",body:s}),new Pe((function(e){return d=window.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),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-u),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return l.apply(this,arguments)})},{key:"addIceCandidates",value:(c=_()(m().mark((function e(t,n,r){var i,o,a,s,c,u,l,d,h,p,f=this,v=arguments;return m().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(),a=new FormData,s={apiVersion:6,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),c=Date.now(),e.prev=6,l=null,e.next=10,Pe.race([fetch(o,{method:"POST",body:a}),new Pe((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:u=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(u))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(u);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,h-c),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(a=_()(m().mark((function e(t,n){var r,i,o,a,s,c,u,l,d,h=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,c=null,e.next=9,Pe.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Pe((function(e){return c=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){c&&clearTimeout(c)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(u=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.next=19;break}return e.abrupt("return",{status:u});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(s);case 22:return d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return a.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,xe()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=w.sdkVersion;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["_","".concat(Date.now())]]).toString()),e.toString()}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(i=_()(m().mark((function e(t,n){var r,i,o,a,s;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:if(r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,!r){e.next=46;break}if(!r.rtcConfiguration){e.next=43;break}if(o={},!r.rtcConfiguration.bundlePolicy){e.next=20;break}e.t0=r.rtcConfiguration.bundlePolicy,e.next="BundlePolicyBalanced"===e.t0?13:"BundlePolicyMaxCompat"===e.t0?15:"BundlePolicyMaxBundle"===e.t0?17:19;break;case 13:return o.bundlePolicy="balanced",e.abrupt("break",20);case 15:return o.bundlePolicy="max-compat",e.abrupt("break",20);case 17:return o.bundlePolicy="max-bundle",e.abrupt("break",20);case 19:L(r.rtcConfiguration.bundlePolicy);case 20:if("number"==typeof r.rtcConfiguration.iceCandidatePoolSize&&(o.iceCandidatePoolSize=r.rtcConfiguration.iceCandidatePoolSize),r.rtcConfiguration.iceServers){for(a=[],s=0;s<r.rtcConfiguration.iceServers.length;s++)a.push({urls:r.rtcConfiguration.iceServers[s].urls,username:r.rtcConfiguration.iceServers[s].username,credential:r.rtcConfiguration.iceServers[s].credential});o.iceServers=a}if(!r.rtcConfiguration.iceTransportPolicy){e.next=32;break}e.t1=r.rtcConfiguration.iceTransportPolicy,e.next="IceTransportPolicyAll"===e.t1?26:"IceTransportPolicyRelay"===e.t1?28:"IceTransportPolicyPublic"===e.t1?30:31;break;case 26:return o.iceTransportPolicy="all",e.abrupt("break",32);case 28:return o.iceTransportPolicy="relay",e.abrupt("break",32);case 30:return e.abrupt("break",32);case 31:L(r.rtcConfiguration.iceTransportPolicy);case 32:if(r.rtcConfiguration.peerIdentity&&(o.peerIdentity=r.rtcConfiguration.peerIdentity),!r.rtcConfiguration.rtcpMuxPolicy){e.next=42;break}e.t2=r.rtcConfiguration.rtcpMuxPolicy,e.next="RtcpMuxPolicyNegotiate"===e.t2?37:"RtcpMuxPolicyRequire"===e.t2?39:41;break;case 37:return o.rtcpMuxPolicy="negotiate",e.abrupt("break",42);case 39:return o.rtcpMuxPolicy="require",e.abrupt("break",42);case 41:L(r.rtcConfiguration.rtcpMuxPolicy);case 42:i.rtcConfiguration=o;case 43:r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)});case 46:return e.abrupt("return",i);case 47:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertISessionDescriptionToRTCSessionDescription",value:function(e){var t={sdp:e.sdp};switch(e.type){case"Offer":t.type="offer";break;case"Answer":t.type="answer";break;default:L(e.type)}return t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=_()(m().mark((function e(t){var n,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=this.convertISessionDescriptionToRTCSessionDescription(n.sessionDescription)),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=_()(m().mark((function e(t){var n,r;return m().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=_()(m().mark((function e(t){var n,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertRTCSdpTypeToSdpType",value:function(e){switch(e){case"answer":return"Answer";case"offer":return"Offer";case"pranswer":case"rollback":throw new Error("SDP type [".concat(e,"] is not supported"));default:L(e)}}},{key:"roundTripTime",get:function(){return this._roundTripTime}}]),e}(),Ee=n(202).default,Fe=function(){function e(t){if(o()(this,e),u()(this,"_logger",F.getLogger("Discovery")),u()(this,"_metricsService",void 0),u()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=se.getMetricsService(t.toString()),this._uri=t}var t,n;return s()(e,[{key:"discoverNearbyEndPoints",value:(n=_()(m().mark((function e(t,n){var r,i,o,a;return m().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,Ee.race([fetch(r,{method:"GET",cache:"no-cache"}),new Ee((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new Re(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=_()(m().mark((function e(){var t,n,r,i,o,a=this,s=arguments;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=s.length>0&&void 0!==s[0]?s[0]:2e4,n=re.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=function(){return new Ee((function(){a._logger.info("Request [%s] failed, preventing it from completing",n)}))},e.next=8,Ee.race(r.map((function(e){return e.ping().catch((function(t){return a._logger.warn("Failed to ping end point [%s]",e,t),i()})).then((function(t){var n=Date.now();return a._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),a._metricsService.push({metricType:ie.RoundTripTime,runtime:(n-ue.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 8:return o=e.sent,e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),De=function(){var e,t;function n(){throw o()(this,n),new Error("Discovery is a static class that may not be instantiated")}return s()(n,null,[{key:"precacheClosestEndPointDiscovery",value:(t=_()(m().mark((function e(){var t;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new URL(ue.discoveryUri.value),e.abrupt("return",n.discoverClosestEndPointWithCaching(t));case 2:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(e=_()(m().mark((function e(t){var r,i,o;return m().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 Fe(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(e){throw delete n._cache[r],e})),e.abrupt("return",o);case 7:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]),n}();u()(De,"_cache",{}),De.precacheClosestEndPointDiscovery();var Oe=function(){function e(t){o()(this,e),u()(this,"_sdp",void 0),u()(this,"_audioCodec",void 0),u()(this,"_videoCodec",void 0),this._sdp=t,this._audioCodec=this.applyCodec("audio"),this._videoCodec=this.applyCodec("video")}return s()(e,[{key:"applyCodec",value:function(e){var t=this._sdp.split(/(\r\n|\r|\n)/);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]}},{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}}]),e}(),Ie=function(){function e(t,n,r){if(o()(this,e),u()(this,"_estimatedRoundTripTime",void 0),u()(this,"_estimatedVideoCodec",void 0),u()(this,"_estimatedAudioCodec",void 0),u()(this,"_rtcStatistic",new B({})),u()(this,"_peerConnection",void 0),u()(this,"_isMonitorRunning",!0),u()(this,"_updateTimeOut",void 0),u()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!G.getCurrentOfferDisabled){var i=new Oe(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}var t,n;return s()(e,[{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeOut&&(clearTimeout(this._updateTimeOut),this._updateTimeOut=null)}},{key:"updateStatistic",value:(n=_()(m().mark((function e(){var t,n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!G.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),c="";e.forEach((function(e){e.id===a.codecId&&(c=e.mimeType)})),s&&n._tracksToMonitor.includes(s)&&(r[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:c||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video&&(r[s].framesDecoded=a.framesDecoded,r[s].fps=(a.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(r[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3||0))}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeOut=window.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(t=_()(m().mark((function e(){var t=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},r=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i=e.stat("mediaType").toString();n[i]={timestamp:Date.now()},n[i].ssrc=e.stat("ssrc").toString(),n[i].mediaType=i,n[i].bytesReceived=e.stat("bytesReceived"),n[i].packetsLost=e.stat("packetsLost"),n[i].packetsReceived=e.stat("packetsReceived"),n[i].codec=e.stat("googCodecName").toString()||t.getCodecByType(i),n[i].roundTripTime=r,"video"===i&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[i].framesDecoded=e.stat("framesDecoded"),n[i].fps=(n[i].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[i].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeOut=window.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}},{key:"rtcStatistic",get:function(){return this._rtcStatistic}}]),e}(),Ae=n(202).default;function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function je(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Me(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ve=function(){function e(t,n){o()(this,e),u()(this,"_logger",F.getLogger("RealTimeStream")),u()(this,"_channelContext",void 0),u()(this,"_handleStreamFailure",void 0),this._channelContext=t,this._handleStreamFailure=n}var t;return s()(e,[{key:"start",value:function(e,t,n,r){var i=this;return Ae.all([De.discoverClosestEndPointWithCaching(e),Se.createPeerConnectionOffer()]).then((function(e){var n=ke()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp),!G.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s=null,a=null),i._channelContext.peerConnection.value=s,r.subscribe(t,a,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,a=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse,l=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=l,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,a,s,c,u),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._channelContext.peerConnection.value,a).then((function(e){var t,a=!1,l=!1,d=[];i._channelContext.peerConnection.value||(i._channelContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._channelContext.peerConnection.value===e&&(a||ue.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?d.push(n.candidate):l=!0,t||(t=setTimeout((function(){i._channelContext.stream.value!==o||a||i._channelContext.endPoint.value.addIceCandidates(o,d,l).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(a=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===o&&i._channelContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=fe.Error,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(navigator.onLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:L(e.iceConnectionState)}}};var h=new Ae((function(t,n){if(G.onTrackDisabled){var r=function n(r){clearTimeout(i),e.removeEventListener("track",n),e.removeEventListener("addstream",n),r.streams?t(r.streams[0]):t(r.stream)},i=setTimeout((function(){e.removeEventListener("track",r),e.removeEventListener("addstream",r),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",r),e.addEventListener("addstream",r)}else{var o=setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){clearTimeout(o),t(e.streams[0])}}}));return new Ae((function(e){e()})).then((function(){if(s)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription)})).then((function(){if(u)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription)})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(o,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r)}))})).then((function(){return n.success(i._channelContext.streamId),h})).then((function(t){i._channelContext.mediaStream.value=t;var n=new Ie(e,t,i._channelContext.endPoint.value.roundTripTime/4);return i._channelContext.disposables.add(n),n.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var r=!1,o=!1;t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((r=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new ve(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((o=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new ve(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),(o||r)&&navigator.onLine?i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=fe.Error,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,n.dispose(),i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))})):i._channelContext.peerConnectionReconnectAttempts=0})),ue.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=fe.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(t=_()(m().mark((function e(t,n){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=this.truncateIceServers(n),e.abrupt("return",ue.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,this)}))),function(e,n){return t.apply(this,arguments)})},{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}},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=fe.Reconnecting,this._channelContext.peerConnectionReconnectAttempts<ue.maximalNumberOfPeerConnectionReconnectAttempts||!ue.automaticallyReconnectPeerConnection){if(this._channelContext.peerConnectionReconnectAttempts++,G.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||this._channelContext.failureCount.value)return;this._logger.info("Reconnecting peer connection by restarting ICE");var r=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(r)}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._channelContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._channelContext.peerConnectionReconnectAttempts),this._channelContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return fe.Starting;case"unauthorized":return fe.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return fe.Recovering;case"failed":return fe.Error;default:L(e)}}}]),e}(),Ne=function(){function e(){throw o()(this,e),new Error("RealTimeStreamFactory is a static class that may not be instantiated")}return s()(e,null,[{key:"create",value:function(e,t,n){var r=Q.parseToken(e);return r&&r.token&&r.token.capabilities&&r.token.capabilities.includes("rtmp")?(this._logger.error("This build does not support RTMP playback."),void(t.state.value=fe.UnsupportedFeature)):r&&r.token&&r.token.capabilities&&r.token.capabilities.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=fe.UnsupportedFeature)):new Ve(t,n)}}]),e}();u()(Ne,"_logger",F.getLogger("Streaming"));var Ue=n(202).default,Be="client:termination",ze=function(){function e(t,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;o()(this,e),u()(this,"_logger",F.getLogger("Channel")),u()(this,"_context",void 0),u()(this,"_channelStartTime",void 0),u()(this,"_readOnlyVideoElement",void 0),u()(this,"_readOnlyToken",void 0),u()(this,"_readOnlyPeerConnection",void 0),u()(this,"_readOnlyState",void 0),u()(this,"_readOnlyAutoMuted",void 0),u()(this,"_readOnlyAutoPaused",void 0),u()(this,"_readOnlyTokenExpiring",void 0),u()(this,"_readOnlyAuthorized",void 0),u()(this,"_readOnlyOnline",void 0),u()(this,"_readOnlyLoading",void 0),u()(this,"_readOnlyPlaying",void 0),u()(this,"_readOnlyStandby",void 0),u()(this,"_readOnlyStopped",void 0),u()(this,"_readOnlyTargetLag",void 0),u()(this,"_readOnlyLag",void 0),u()(this,"_readOnlyBitrateLimit",void 0),u()(this,"_readOnlyResolution",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,"_videoMetaDataChangedHandler",void 0),this._context=new we(n,i),this._channelStartTime=Date.now(),this._readOnlyVideoElement=new z(this._context.videoElement),this._readOnlyToken=new z(this._context.token),this._readOnlyPeerConnection=new z(this._context.peerConnection),this._readOnlyState=new z(this._context.state),this._readOnlyAutoMuted=new z(this._context.autoMuted),this._readOnlyAutoPaused=new z(this._context.autoPaused),this._readOnlyTokenExpiring=new z(this._context.tokenExpiring),this._readOnlyAuthorized=new z(this._context.authorized),this._readOnlyOnline=new z(this._context.online),this._readOnlyLoading=new z(this._context.loading),this._readOnlyPlaying=new z(this._context.playing),this._readOnlyStandby=new z(this._context.standby),this._readOnlyStopped=new z(this._context.stopped),this._readOnlyTargetLag=new z(this._context.targetLag),this._readOnlyLag=new z(this._context.lag),this._readOnlyBitrateLimit=new z(this._context.bitrateLimit),this._readOnlyResolution=new z(this._context.resolution),this._readOnlyFailureCount=new z(this._context.failureCount),this._readOnlyEndPoint=new z(this._context.endPoint),this._readOnlyStream=new z(this._context.stream),this._readOnlyRtcStatistics=new z(this._context.rtcStatistics),this._readOnlyMediaStream=new z(this._context.mediaStream);var a=Q.parseToken(this._context.token.value),s=(Q.getUri(a)||ue.discoveryUri.value).toString();ue.tenancy.value=Q.getTenancy(a)||ue.tenancy.value,re.uri.value=s,this._metricsService=se.getMetricsService(s),this._context.sessionTelemetry=new _e(ue.pageLoadTime,this._metricsService),this._context.channelDisposables.add(this._context.sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._context.channelDisposables.add(this._context.videoElement.subscribe((function(e){r._context.rendererDisposables.dispose(),e&&(r._context.rendererDisposables.add(r._context.stream.subscribe((function(e){r._context.videoTelemetry&&r._context.videoTelemetry.dispose(),e&&r.videoElement&&(r.videoElement.dataset&&(r.videoElement.dataset.sessionId=ue.clientSessionId,r.videoElement.dataset.streamId=r.streamId),r._context.videoTelemetry=new ge(r.streamId,ue.pageLoadTime,r._channelStartTime,r._metricsService),r._context.videoTelemetry.setupListenerForTimeToFirstTime(r.videoElement),r._context.videoTelemetry.setupListenerForRebuffering(r.videoElement),r._context.state.value===fe.Stopped)&&r.restartAfterStop()}))),r._context.channelDisposables.add(r._context.rendererDisposables))}))),this._context.channelDisposables.add(this._context.state.subscribe((function(e){r._context.clearFailureCountTimeout&&clearTimeout(r._context.clearFailureCountTimeout),r._context.failureCount.value&&e===fe.Playing&&(r._context.clearFailureCountTimeout=window.setTimeout((function(){r._context.failureCount.value=0}),3e3))}))),this._context.channelDisposables.add(this._context.resolution.subscribe((function(e){r._context.videoTelemetry&&r._context.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._context.channelDisposables.add(this._context.bitrateLimit.subscribe((function(e){if(e&&r._context.endPoint.value&&r._context.stream.value){var t=Date.now()-r._context.channelInitialization.getTime();r._context.endPoint.value.limitBitrate(r._context.stream.value,t,e,he.Keep,pe.Normal).catch((function(e){r._logger.error("Error while setting limit bitrate",e)}))}}))),this.start()}var t,n,r,i,a,c,l,d,h;return s()(e,[{key:"handleVideoMetaDataChanged",value:function(){var e=this._context.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._context.resolution.value=new de(e.videoWidth,e.videoHeight)):this._context.resolution.value=de.empty}},{key:"setBitrateLimit",value:function(e){this._context.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._context.bitrateLimit.value&&this._context.endPoint.value&&this._context.stream.value){var t=Date.now()-this._context.channelInitialization.getTime();this._context.endPoint.value.limitBitrate(this._context.stream.value,t,0,he.Keep,pe.Reset).then((function(t){"ok"===t.status&&(e._context.bitrateLimit.value=0)})).catch((function(t){e._logger.error("Error while setting limit bitrate",t)}))}}},{key:"updateTargetLag",value:function(e){this._context.targetLag.value=e}},{key:"stop",value:(h=_()(m().mark((function e(t){var n=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ue((function(e){if(!n._context.isStarting.value)return n.processStop(t),void e();n._context.rendererDisposables.add(n._context.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return h.apply(this,arguments)})},{key:"processStop",value:function(e){this._context.videoElement.value&&(this._context.videoElement.value.pause(),this._context.videoElement.value.srcObject=null),this._context.rendererDisposables.dispose(),this.cleanUpResources(e),this._context.state.value=fe.Stopped}},{key:"resume",value:(d=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._context.mediaStream.value){e.next=3;break}return this._context.autoPaused.value=!1,e.abrupt("return",this.playMediaStreamInVideoElement(this._context.mediaStream.value));case 3:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"mute",value:function(){var e=this._context.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._context.videoElement.value;e&&(e.muted=!1,this._context.autoMuted.value=!1)}},{key:"dispose",value:(l=_()(m().mark((function e(){var t=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._context.channelDisposables.dispose(),t._context.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getUri",value:function(e){var t=Q.parseToken(e);return Q.getUri(t)||(this._logger.info("Fall back to the default discover URI [%s]",ue.discoveryUri.value),new URL(ue.discoveryUri.value))}},{key:"start",value:(c=_()(m().mark((function e(){var t=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._context.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._context.isStarting.value){e.next=5;break}return this._logger.info("Channel is already starting, skipping start"),e.abrupt("return");case 5:return this._context.isStarting.value=!0,e.abrupt("return",this.processStart().finally((function(){t._context.isStarting.value=!1})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"processStart",value:(a=_()(m().mark((function e(){var t,n,r,i,o,a=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._context.token.value,n=this._context.sessionTelemetry.listenOnStreamSetup(),Q.isValidToken(t)){e.next=7;break}return this._logger.error("Failed to parse token [%s]",t),this._context.state.value=fe.Unauthorized,this._context.authorized.value=!1,e.abrupt("return");case 7:if(this.cleanUpResources("client:start"),this._context.state.value=fe.Starting,this._context.loading.value=!0,r=this.getUri(t),i=function(){return new Ue((function(e){return a._context.isStarting.value=!1,e(a.handleStreamFailure())}))},o=Ne.create(t,this._context,i)){e.next=15;break}return e.abrupt("return");case 15:return e.abrupt("return",o.start(r,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){a._context.loading.value=!1})).catch((function(e){n.fail(),a._context.failureCount.value++,a._context.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._context.state.value=fe.Error,a._logger.error("Failed to start channel",e)})).finally((function(){if(a._context.state.value!==fe.Playing&&ue.automaticRetryOnFailure){var e=setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._context.disposables.add(new N((function(){clearTimeout(e)})))}})));case 16:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._context.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._context.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._context.mediaStream.value));case 4:this._context.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"play",value:(r=_()(m().mark((function e(){var t;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._context.mediaStream.value){e.next=3;break}return e.abrupt("return",this.start());case 3:return e.abrupt("return",this.playMediaStreamInVideoElement(t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._context.state.value){case fe.StandBy:case fe.Offline:return 15e3;case fe.Error:case fe.Recovering:case fe.Unauthorized:case fe.GeoRestricted:case fe.GeoBlocked:case fe.Stopped:case fe.Starting:case fe.Playing:case fe.Paused:case fe.Reconnecting:case fe.UnsupportedFeature:return Math.min(3e5,Math.pow(2e3,Math.max(0,this._context.failureCount.value-1)));default:L(this._context.state.value)}}},{key:"handleStreamFailure",value:(n=_()(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._context.state.value,e.next=e.t0===fe.Error||e.t0===fe.Reconnecting||e.t0===fe.StandBy||e.t0===fe.Offline||e.t0===fe.Recovering?3:e.t0===fe.Unauthorized?5:e.t0===fe.GeoRestricted?7:e.t0===fe.GeoBlocked?9:e.t0===fe.Stopped?11:e.t0===fe.Playing?13:e.t0===fe.Paused?15:e.t0===fe.Starting?17:e.t0===fe.UnsupportedFeature?19:21;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._context.state.value,fe[this._context.state.value]),e.abrupt("break",22);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 17:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 19:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 21:L(this._context.state.value);case 22:return e.abrupt("return",this.start());case 23:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Be;this._context.disposables.dispose();var n=this._context.peerConnection.value;n&&(this._context.peerConnection.value=null,n.close()),this._context.mediaStream.value&&(this._context.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._context.mediaStream.value=null),this._context.autoPaused.value=!1,this._context.autoMuted.value=!1,this._context.playing.value=!1,this._context.stopped.value=!0,this._context.standby.value=!1,this._context.stream.value&&this._context.endPoint.value&&this._context.endPoint.value.destroyStream(this._context.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._context.stream.value=null,this._context.endPoint.value=null,this._context.peerConnectionReconnectAttempts=0}},{key:"playMediaStreamInVideoElement",value:(t=_()(m().mark((function e(t){var n,r,i=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this._context.videoElement.value){e.next=8;break}return this._context.autoMuted.value=!1,this._context.autoPaused.value=!1,this._context.loading.value=!1,this._context.playing.value=!1,this._context.state.value=fe.Stopped,e.abrupt("return");case 8:if(n.srcObject=t,void 0!==(r=n.play())){e.next=17;break}return this._context.autoMuted.value=!1,this._context.autoPaused.value=!1,this._context.loading.value=!1,this._context.playing.value=!0,this._context.state.value=fe.Playing,e.abrupt("return");case 17:return e.abrupt("return",r.then((function(){i._context.autoMuted.value=!1,i._context.autoPaused.value=!1,i._context.loading.value=!1,i._context.playing.value=!0,i._context.state.value=fe.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})),o=!ue.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(i._context.autoMuted.value=!1,i._context.autoPaused.value=!0,i._context.loading.value=!1,i._context.playing.value=!1,i._context.state.value=fe.Paused,o?(i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e),void(n.srcObject=null)):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then((function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._context.autoMuted.value=!0,i._context.autoPaused.value=!1,i._context.loading.value=!1,i._context.playing.value=!0,i._context.state.value=fe.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),i._context.autoMuted.value=!1,i._context.autoPaused.value=!0,i._context.loading.value=!1,i._context.playing.value=!1,i._context.state.value=fe.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"videoElement",get:function(){return this._context.videoElement.value},set:function(e){this._context.videoElement.value&&(this._context.videoElement.value.removeEventListener("loadeddata",this._videoMetaDataChangedHandler),this._context.videoElement.value.removeEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._context.videoElement.value.removeEventListener("resize",this._videoMetaDataChangedHandler),this._context.videoElement.value.dataset&&(this._context.videoElement.value.dataset.sessionId="",this._context.videoElement.value.dataset.streamId=""),this._context.rendererDisposables.dispose(),this._context.videoElement.value.pause(),this._context.videoElement.value.srcObject=null),this._context.autoMuted.value=!1,this._context.autoPaused.value=!1,this._context.loading.value=!1,this._context.playing.value=!1,this._context.state.value=fe.Stopped,this._context.videoElement.value=e,this._context.videoElement.value&&(this._context.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._context.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._context.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"token",get:function(){return this._context.token.value},set:function(e){this._context.disposables.dispose(),this._context.token.value=e,this._context.tokenExpiring.value=!1;var t=Q.parseToken(this._context.token.value),n=(Q.getUri(t)||ue.discoveryUri.value).toString();ue.tenancy.value=Q.getTenancy(t)||ue.tenancy.value,re.uri.value=n,this._metricsService=se.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._context.streamId}},{key:"rtcStats",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}}]),e}(),He=function(){function e(){throw o()(this,e),new Error("Channels is a static class that may not be instantiated")}return s()(e,null,[{key:"createChannel",value:function(e){if(!ue.initialized.value)throw new Error("SDK is not loaded.");return new ze(e.videoElement,e.token,e.targetLag)}}]),e}(),Ge={SDK:ue,Channels:He,ChannelState:fe}},666:(e,t,n)=>{var r=n(202).default,i=function(e){"use strict";var t,n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),a=new P(r||[]);return o._invoke=function(e,t,n){var r=d;return function(i,o){if(r===p)throw new Error("Generator is already running");if(r===f){if("throw"===i)throw o;return E()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=x(a,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===d)throw r=f,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=p;var c=l(e,t,n);if("normal"===c.type){if(r=n.done?f:h,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=f,n.method="throw",n.arg=c.arg)}}}(e,n,a),o}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d="suspendedStart",h="suspendedYield",p="executing",f="completed",v={};function g(){}function m(){}function y(){}var _={};_[a]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w(R([])));b&&b!==n&&i.call(b,a)&&(_=b);var k=y.prototype=g.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function C(e,t){function n(r,o,a,s){var c=l(e[r],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var r;this._invoke=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 x(e,n){var r=e.iterator[n.method];if(r===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method))return v;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var i=l(r,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var o=i.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,v):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function T(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 L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function R(e){if(e){var n=e[a];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(i.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}return{next:E}}function E(){return{value:t,done:!0}}return m.prototype=k.constructor=y,y.constructor=m,y[c]=m.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,c in e||(e[c]="GeneratorFunction")),e.prototype=Object.create(k),e},e.awrap=function(e){return{__await:e}},S(C.prototype),C.prototype[s]=function(){return this},e.AsyncIterator=C,e.async=function(t,n,i,o,a){void 0===a&&(a=r);var s=new C(u(t,n,i,o),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},S(k),k[c]="Generator",k[a]=function(){return this},k.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=R,P.prototype={constructor:P,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(L),!e)for(var n in this)"t"===n.charAt(0)&&i.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 o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),u=i.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=i}catch(e){Function("r","regeneratorRuntime = r")(i)}}},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(190)})()}));
|
|
2
2
|
//# sourceMappingURL=full.js.map
|