UNPKG

npaw-plugin-nwf

Version:
2 lines 604 kB
/*! For license information please see NpawPlugin-nwf.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.NpawPlugin=t():e.NpawPlugin=t()}(self,()=>(()=>{var e={72:(e,t,i)=>{var s=i(7380);const{default:n}=i(3582),{AnalyticsTag:r}=i(9982);var o={getPlayrate:function(){return this.flags.isPaused?0:1},getFramesPerSecond:function(){},getDroppedFrames:function(){},getThroughput:function(){},getRendition:function(){},getTitle2:function(){},getIsLive:function(){},getCdnTraffic:function(){},getP2PTraffic:function(){},getUploadTraffic:function(){},getIsP2PEnabled:function(){},getSegmentDuration:function(){},getHouseholdId:function(){},getLatency:function(){},getPacketLoss:function(){},getPacketSent:function(){},getMetrics:function(){},getAudioCodec:function(){},getVideoCodec:function(){},setUrlToParse:function(e){this._urlToParse=e},getURLToParse:function(){return this._urlToParse||void 0},fireSeekBegin:function(e,t,i){if(this._discardFalseBuffers(),!(this.getVideo()&&this.getVideo().getIsLive()&&this.plugin.options["content.isLive.noSeek"])&&this.flags.isJoined&&!this.flags.isSeeking){if(this.flags.isBuffering){if(!1===t)return;n.notice(r,"Converting current buffer to seek"),this.chronos.seek=this.chronos.buffer.clone(),this.chronos.buffer.reset(),this.flags.isBuffering=!1}else this.chronos.seek.start();try{this.fireEventsStruct.seek=[],i?this.fireEventsStruct.seek.push(i):this.fireEventsStruct.seek.push("undefinedEvent")}catch(e){}this.flags.isSeeking=!0,this.emit(s.Event.SEEK_BEGIN,{params:e})}},fireSeekEnd:function(e,t){if(!(this.getVideo()&&this.getVideo().getIsLive()&&this.plugin.options["content.isLive.noSeek"])&&this.flags.isJoined&&this.flags.isSeeking){try{t?this.fireEventsStruct.seek.push(t):this.fireEventsStruct.seek.push("undefinedEvent")}catch(e){}(e=e||{}).triggeredEvents=this.fireEventsStruct.seek,this.cancelSeek(),this.emit(s.Event.SEEK_END,{params:e});try{this.chronos.pause.getDeltaTime(!1)>0&&this.chronos.pause.resume()}catch(e){}}},cancelSeek:function(e){this.flags.isJoined&&this.flags.isSeeking&&(this.flags.isSeeking=!1,this.chronos.seek.stop(),this.monitor&&this.monitor.skipNextTick())},fireEvent:function(e,t,i,n,r){if("data"===e)this.emit(s.Event.DATA_OBJECT,{params:n});else{var o=n||{};o.name=e||"",o.dimensions=t||{},o.values=i||{},r&&(o.hasEndDatetime=r||!1),this.emit(s.Event.VIDEO_EVENT,{params:o})}},fireEventEnd:function(e){var t={};t.name=e||"",this.emit(s.Event.VIDEO_EVENT_END,{params:t})},storeNewRendition:function(e){this.getVideo().triggerUpdateRendition(e)}};e.exports=o},96:(e,t,i)=>{var s=i(8661);const{default:n}=i(99);var r={getFastDataConfig:function(){return this.fastDataTransform.response.msg},getHost:function(){let e=n.getInstance().getOptions().getFastDataHost();return this.fastDataTransform&&this.fastDataTransform.response&&this.fastDataTransform.response.host&&(e=this.fastDataTransform.response.host),s.addProtocol(s.stripProtocol(e),this.options["app.https"])},getFastDataHost:function(){return s.addProtocol(s.stripProtocol(n.getInstance().getOptions().getFastDataHost()),this.options["app.https"])},getSession:function(){var e=n.getInstance().getCoreStorage().getStorages("session");if("undefined"===e&&(e=void 0),!e){var t=this.getStoredData();if(t)try{e=JSON.parse(t).q.c}catch(e){}}return e},getStorageHost:function(){let e=null;const t=this.getStoredData();if(t)try{e=JSON.parse(t).q.h}catch(e){}return e?s.addProtocol(e,this.options["app.https"]):e},getStoredData:function(){return n.getInstance().getCoreStorage().getStorages("data")},getDataTime:function(){return n.getInstance().getCoreStorage().getStorages("dataTime")},setStoredData:function(e){this.storage.setStorages("data",e)},setSession:function(e){this.storage.setStorages("session",e)},setDataTime:function(e){this.storage.setStorages("dataTime",e)}};e.exports=r},99:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>T});var s=i(9794),n=i(9743),r=i(9982),o=i(3582),a=i(9907);class c{constructor(e,t,i,s,n){var r;this.response={},this._session="",this.sessionExpire=120,this.retries=0,this.isUsingLegacy=!1,this.options=e,this.npawPluginOptions=n,this.accountCode=t,this.coreStorage=i,this.browserStorage=s,this._fastDataHost=this.options.getFastDataHost();const o="true"===a.env.IS_STANDALONE;this.isUsingLegacy=o&&void 0!==(null===(r=null==n?void 0:n.legacyPlugin)||void 0===r?void 0:r.viewTransform),this._createConfigurationInterval()}init(){var e,t;if(this.options&&this.options.offline)return this.response.host="OFFLINE",this.response.code="OFFLINE",this.response.pingTime=60,this.response.beatTime=60,void(this._session=n.default.generateRandomString(15));if(this.isUsingLegacy)return;if(this.browserStorage&&this.browserStorage.isEnabled()&&(new Date).getTime()<1e3*(null!==(e=Number(this.browserStorage.getLocal("sessionExpire")))&&void 0!==e?e:this.sessionExpire)+(Number(this.coreStorage.getDataTime())||0)&&this.coreStorage.getStoredData())return void this.setData(null!==(t=this.coreStorage.getStoredData())&&void 0!==t?t:"");this.coreStorage.removeLocal("firstRequestTime"),this.coreStorage.removeLocal("lastRequestTime");const i=s.A.Service.DATA,a={system:this.accountCode,pluginVersion:T.getPluginVersion(),requestNumber:this.getRequestNumber()};this.loadConfiguration();try{o.default.notice(r.CoreTag,i+" "+a.system),"nicetest"===a.system&&o.default.error(r.CoreTag,"No accountCode has been set. Please set your accountCode inside plugin's options."),this.performRequestToFastData(i,a,this._receiveData.bind(this),this._failedData.bind(this))}catch(e){o.default.error(r.CoreTag,"Error doing get data request to FastData service.")}}updateOptions(e){this.options.updateOptions(e),this.options.offline&&(this.reset(),this.init())}getSessionExpireTime(){return this.sessionExpire}refreshSessionToken(){this._session="",this.browserStorage.removeStorages("data"),this.init()}loadConfiguration(){const e=s.A.Service.CONFIGURATION,t={system:this.accountCode,pluginVersion:T.getPluginVersion(),requestNumber:this.getRequestNumber()};this.performRequestToFastData(e,t,this._receiveConfiguration.bind(this),this._failedConfiguration.bind(this))}getSession(){var e,t;return this.isUsingLegacy?null===(t=null===(e=this.npawPluginOptions)||void 0===e?void 0:e.legacyPlugin)||void 0===t?void 0:t.viewTransform._session:this._session}setSession(e){this._session=e}setHost(e){this.response.host=e}getPingTime(){var e;return null!==(e=this.pingTime)&&void 0!==e?e:5}getBeatTime(){var e;return null!==(e=this.beatTime)&&void 0!==e?e:30}setData(e){try{let t=JSON.parse(e);this.options["parse.fdsResponseHost"]&&(e=e.replace(t.q.h,this.options["parse.fdsResponseHost"](t.q.h)),t=JSON.parse(e)),this.response={msg:e,host:t.q.h,code:t.q.c,pingTime:t.q.pt||5,beatTime:t.q.i&&t.q.i.bt||30,sessionExpire:t.q.st&&t.q.st||120},this._session=this.response.code,this.browserStorage.setLocal("sessionExpire",this.response.sessionExpire),this.browserStorage.setStorages("accCode",this.accountCode),this.browserStorage.setStorages("session",this.response.code),this.coreStorage.setStoredData(this.response.msg),this.coreStorage.setDataTime((new Date).getTime().toString()),this.pingTime=this.response.pingTime,this.beatTime=this.response.beatTime,this.sessionExpire=this.response.sessionExpire}catch(e){o.default.error(r.CoreTag,"Fastdata response is invalid.")}}setConfiguration(e){try{this.response.configurationOptions=JSON.parse(e)}catch(e){o.default.error(r.CoreTag,"Configuration response is invalid.")}}getFastDataResponse(){return this.response}getAccountCode(){return this.accountCode}getRequestNumber(){return Math.random()}reset(){this.coreStorage.removeStoredData(),this.coreStorage.removeSession(),this.browserStorage.removeLocal("sessionExpire"),this.browserStorage.removeStorages("accCode"),this.browserStorage.removeStorages("session")}performRequestToFastData(e,t,i,s){if(this.options.offline)return;t.timemark=(new Date).getTime(),t.outputFormat="json";const r=this,o=new XMLHttpRequest;o.open("GET",`https://${this._fastDataHost}${e}${n.default.toQueryString(t)}`),o.onload=function(e){r.options.offline||(o.status>=200&&o.status<400?i(this,e):s(this,e))},o.onerror=function(e){s(this,e)},o.send()}_createConfigurationInterval(){this.isUsingLegacy||!this.options.isRefreshLMAConfigurationEnabled()||this._refreshInterval||(this._refreshInterval=setInterval(this.loadConfiguration.bind(this),1e3*this.options.refreshLMAConfigurationSeconds()))}_receiveData(e,t){this.retries=0,this.setData(e.response)}_receiveConfiguration(e,t){this.setConfiguration(e.response)}_failedData(e,t){o.default.error(r.CoreTag,"Fastdata request has failed."),++this.retries<5?setTimeout(this.init.bind(this),5e3):setTimeout(this.init.bind(this),6e4)}_failedConfiguration(e,t){o.default.error(r.CoreTag,"Configuration request has failed.")}}var d=i(668);class l{constructor(){this.offline=!1,this.host="lma.npaw.com",this.disableCookies=!0,this.forceCookies=!1,this.disableStorage=!1,this.authToken=void 0,this.authType="Bearer",this["app.https"]=!0,this["lma.refresh.configuration.enabled"]=!1,this["lma.refresh.configuration.seconds"]=300,this["parse.fdsResponseHost"]=null}updateOptions(e){const t=new d.A;Object.keys(this).forEach(i=>{null==e[i]||Object.keys(t).includes(i)||(this[i]=e[i])})}setNpawPluginOptions(e){Object.keys(this).forEach(t=>{null!=e[t]&&(this[t]=e[t])})}isRefreshLMAConfigurationEnabled(){return this["lma.refresh.configuration.enabled"]}refreshLMAConfigurationSeconds(){return this["lma.refresh.configuration.seconds"]}getHost(){return this.host}getFastDataHost(){return this.host}}class u{constructor(e,t,i,s,n,o,a,c){this.method=r.Method.GET,this.headers={},this.xhr=new XMLHttpRequest,this.retries=0,this.hadBody=!1,this.isHttps=e,this.host=t,this.service=i,this.method=s,this.params=n,this.expirationManager=c,this.onSuccessCallback=o,this.onFailCallback=a}performHttps(){return this.isHttps}getHost(){return this.host}getService(){return this.service}getMethod(){return this.method}getParams(){return this.params}getBody(){return this.body}setBody(e){this.body=e}addHeader(e,t){this.headers[e]=t}getExpirationManager(){return this.expirationManager}getRetries(){return this.retries}send(e,t){if(this.params.timemark=Date.now(),this.params.sessionRoot=T.getInstance().getFastDataSessionToken(),this.params.system=T.getInstance().getFastDataService().getAccountCode(),this.body&&(this.hadBody=!0),this.method===r.Method.POST&&!this.body){const e={};e.timemark=this.params.timemark,this.params.code&&(e.code=this.params.code),e.sessionRoot=this.params.sessionRoot,e.system=this.params.system,e.sessionId=this.params.sessionId&&""!=this.params.sessionId?this.params.sessionId:T.getInstance().getFastDataSessionToken(),this.body=JSON.stringify(this.params),this.params=e}try{this.getUrl()}catch(e){}this.xhr.open(this.method,this.getUrl()),this.xhr.onreadystatechange=()=>{4===this.xhr.readyState&&this.xhr.status>=200&&this.xhr.status<400?(t&&t(),this.expirationManager&&this.expirationManager.onRequestSent(),this.onSuccessCallback&&this.onSuccessCallback()):4===this.xhr.readyState&&(this.retries++,!this.hadBody&&this.method===r.Method.POST&&this.body&&(this.params=JSON.parse(this.body),this.body=void 0),e(),this.onFailCallback&&this.onFailCallback())};for(const e in this.headers)this.xhr.setRequestHeader(e,this.headers[e]);this.xhr.send(this.body)}asyncSend(){return e=this,t=void 0,s=function*(){return new Promise((e,t)=>{this.send(t,e)})},new((i=void 0)||(i=Promise))(function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,a)}c((s=s.apply(e,t||[])).next())});var e,t,i,s}toLocalStorageString(){const e={},t=this.service.split("/");e.request=t[t.length-1],e.unixtime=this.params.timemark;for(const t in this.params)void 0!==this.params[t]&&("sessionId"===t||"sessionRoot"===t?e[t]="":"code"===t?e[t]="CODE_PLACEHOLDER":"object"==typeof this.params[t]?e[t]=JSON.stringify(this.params[t]):e[t]=this.params[t]);return JSON.stringify(e)}getUrl(){return`${this.isHttps?"https":"http"}://${this.host}${this.service}${n.default.toQueryString(this.params)}`}}var h=i(912);const p=[s.A.Service.START,s.A.Service.INIT,s.A.Service.JOIN,s.A.Service.STOP,s.A.Service.ERROR,s.A.Service.AD_ERROR];class f{constructor(e,t,i){this.freshRequests=[],this.retryRequests=[],this.databaseSendingInterval=12e4,this.isDestroyed=!1,this.servicesToWait=[s.A.Service.INIT,s.A.Service.START],this.sentStart=!1,this.options=e,this.coreStorage=t,this.fastDataService=i}destroy(){this.freshRequests=[],this.retryRequests=[],this.isDestroyed=!0,this.timeWhenLastSentFromDatabase=(new Date).getTime()}send(e,t,i,s,n,a){var c;if(this.isDestroyed)return;const d=new u(null===(c=this.options["app.https"])||void 0===c||c,this.coreStorage.getHost(),e,t,null!=i?i:{},s,n,a);void 0!==this.options.authToken&&void 0!==this.options.authType&&e!==h.xC.CDN&&(o.default.verbose(r.AnalyticsTag,"Adding Authorization header with type "+this.options.authType),d.addHeader("Authorization",this.options.authType+" "+this.options.authToken)),this.freshRequests.push(d),this._processRequests()}getTimeOfLastSentRequest(){return this.timeOfLastSentRequest}wasStartSent(){return this.sentStart}_processRequests(){return e=this,t=void 0,s=function*(){if(this.isDestroyed)return;const e=this.retryRequests.splice(0,this.retryRequests.length),t=this.freshRequests.splice(0,this.freshRequests.length);e.length>0&&o.default.verbose(r.CoreTag,"Retrying to send these requests:",...e.map(e=>e.getService()));const i=[];let s=!1;for(const t of e)if(s)i.push(t);else try{yield t.asyncSend(),this.timeOfLastSentRequest=(new Date).getTime(),this.coreStorage.setDataTime(this.timeOfLastSentRequest.toString())}catch(e){s=!0,i.push(t)}for(const e of t)try{yield e.asyncSend(),this.servicesToWait.includes(e.getService())&&(this.sentStart=!0),this.timeOfLastSentRequest=(new Date).getTime(),this.coreStorage.setDataTime(this.timeOfLastSentRequest.toString())}catch(t){p.includes(e.getService())&&i.push(e)}this.retryRequests.push(...i.slice(-25)),this.retryRequests.length&&this.retryRequests.sort((e,t)=>{var i,s,n,r;return(null!==(s=null===(i=e.getParams())||void 0===i?void 0:i.timemark)&&void 0!==s?s:0)-(null!==(r=null===(n=t.getParams())||void 0===n?void 0:n.timemark)&&void 0!==r?r:0)})},new((i=void 0)||(i=Promise))(function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,a)}c((s=s.apply(e,t||[])).next())});var e,t,i,s}}class g{constructor(e,t,i){this.prefix="npaw",this.disableCookies=e,this.forceCookies=t,this.disabled=i}updateStorageOptions(e,t,i){this.disableCookies=e,this.forceCookies=t,this.disabled=i}isEnabled(){if(this.disabled)return!1;let e=!0;if(!this.forceCookies)try{localStorage.setItem(this.prefix+".test","true"),localStorage.removeItem(this.prefix+".test")}catch(t){e=!1}return e}setLocal(e,t){if(!this.disabled)try{!this.forceCookies&&("undefined"!=typeof localStorage&&localStorage||this.disableCookies)?"undefined"!=typeof localStorage&&localStorage&&localStorage.setItem(this.prefix+"."+e,t):this._setCookie(this.prefix+".local."+e,t)}catch(e){o.default.debug(r.CoreTag,"App Analytics needs localStorage or cookies, not supported by your browser.")}}getLocal(e){if(!this.disabled)return this._localGetRemove("getItem","_getCookie",e)}removeLocal(e){if(!this.disabled)return this._localGetRemove("removeItem","_removeCookie",e)}_localGetRemove(e,t,i){try{if(this.forceCookies||!("undefined"!=typeof localStorage&&localStorage||this.disableCookies))return this[t](this.prefix+".local."+i);if("undefined"!=typeof localStorage&&localStorage)return localStorage[e](this.prefix+"."+i)}catch(e){o.default.debug(r.CoreTag,"App Analytics needs localStorage or cookies, not supported by your browser.")}}setSession(e,t){if(!this.disabled)try{!this.forceCookies&&("undefined"!=typeof sessionStorage&&sessionStorage||this.disableCookies)?"undefined"!=typeof sessionStorage&&sessionStorage&&sessionStorage.setItem(this.prefix+"."+e,t):this._setCookie(this.prefix+".session."+e,t)}catch(e){o.default.debug(r.CoreTag,"App Analytics needs sessionStorage or cookies, not supported by your browser.")}}getSession(e){if(!this.disabled)return this._sessionGetRemove("getItem","_getCookie",e)}removeSession(e){if(!this.disabled)return this._sessionGetRemove("removeItem","_removeCookie",e)}_sessionGetRemove(e,t,i){try{if(this.forceCookies||!("undefined"!=typeof sessionStorage&&sessionStorage||this.disableCookies))return this[t](this.prefix+".session."+i);if("undefined"!=typeof sessionStorage&&sessionStorage)return sessionStorage[e](this.prefix+"."+i)}catch(e){o.default.debug(r.CoreTag,"App Analytics needs sessionStorage or cookies, not supported by your browser.")}}getStorages(e){if(!this.disabled)return this.getSession(e)||this.getLocal(e)}setStorages(e,t){this.disabled||(this.setSession(e,t),this.setLocal(e,t))}removeStorages(e){this.disabled||(this.removeSession(e),this.removeLocal(e))}_setCookie(e,t){if("undefined"!=typeof document){let i=";";"undefined"!=typeof location&&(i+="domain="+location.host.split(".").reverse().splice(0,2).reverse().join(".")+";path=/;"),document.cookie=e+"="+t+i}}_getCookie(e){if("undefined"!=typeof document){let t=e+"=",i=decodeURIComponent(document.cookie).split(";");for(let e=0;e<i.length;e++){let s=i[e];for(;" "===s.charAt(0);)s=s.substring(1);if(0===s.indexOf(t))return s.substring(t.length,s.length)}}return null}_removeCookie(e){this._setCookie(e,"")}}class m{constructor(e,t){this.options=e,this.browserStorage=t}isEnabled(){return this.browserStorage.isEnabled()}setLocal(e,t){this.browserStorage.setLocal(e,t)}getLocal(e){return this.browserStorage.getLocal(e)}removeLocal(e){this.browserStorage.removeLocal(e)}getHost(){let e=this.options.getHost();const t=T.getInstance().getFastDataService();return!T.getInstance().isUsingLegacy()&&t&&t.getFastDataResponse()&&t.getFastDataResponse().host?e=t.getFastDataResponse().host:T.getInstance().isUsingLegacy()&&T.getInstance().getLegacyFastDataHost()&&(e=T.getInstance().getLegacyFastDataHost()),e}getSession(){let e=this.browserStorage.getStorages("session");if("undefined"===e&&(e=void 0),!e){const t=this.getStoredData();if(t)try{e=JSON.parse(t).q.c}catch(e){}}return e}getStorageHost(){let e=null;const t=this.getStoredData();if(t)try{e=JSON.parse(t).q.h}catch(e){}return e}getLocalAccountCode(){return this.browserStorage.getLocal("accCode")}getSessionAccountCode(){return this.browserStorage.getSession("accCode")}getAppAnalyticsRegisteredProperties(){return this.browserStorage.getLocal("appAnalyticsRegisteredProperties")}setAppAnalyticsRegisteredProperties(e){this.browserStorage.setLocal("appAnalyticsRegisteredProperties",e)}removeAppAnalyticsRegisteredProperties(){this.browserStorage.removeLocal("appAnalyticsRegisteredProperties")}getDataTime(){return this.browserStorage.getStorages("dataTime")}setDataTime(e){this.browserStorage.setStorages("dataTime",e)}getLastActive(){let e;return e=void 0===this.browserStorage.getLocal("lastactive")?0:Number(this.browserStorage.getLocal("lastactive")),e}setLastActive(e){this.browserStorage.setLocal("lastactive",e)}removeLastActive(){this.browserStorage.removeLocal("lastactive")}setSession(e){this.browserStorage.setStorages("session",e)}removeSession(){this.browserStorage.removeStorages("session")}getSessionExpire(){return 1e3*Number(this.browserStorage.getLocal("sessionExpire"))}getStoredData(){return this.browserStorage.getStorages("data")}setStoredData(e){this.browserStorage.setStorages("data",e)}removeStoredData(){this.browserStorage.removeStorages("data")}getStorages(e){return t=this,i=void 0,n=function*(){return this.browserStorage.getStorages(e)},new((s=void 0)||(s=Promise))(function(e,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s(function(e){e(i)})).then(o,a)}c((n=n.apply(t,i||[])).next())});var t,i,s,n}}var v=i(6443),y=i(9907);class T{static getInstance(e,t,i){return this._instance&&!i||(this._instance=new T(e||"",t)),this._instance}constructor(e,t){var i,s;if(this.options=new l,this.sendingOffline=!1,this.isDestroyed=!1,this.usingLegacy=!1,this.commonVariables=new Map,this.registeredPeriodicPushes=new Map,this.coreEventListeners=[],this.pluginOptions=t,this.pluginOptions){this.pluginOptions.host&&this.options.setNpawPluginOptions({host:this.pluginOptions.host});const e="true"===y.env.IS_STANDALONE;this.usingLegacy=e&&void 0!==(null===(s=null===(i=this.pluginOptions)||void 0===i?void 0:i.legacyPlugin)||void 0===s?void 0:s.viewTransform)}this.browserStorage=new g(this.options.disableCookies,this.options.forceCookies,this.options.disableStorage),this.coreStorage=new m(this.options,this.browserStorage),this.fastDataService=new c(this.options,e,this.coreStorage,this.browserStorage,this.pluginOptions),this.fastDataService.init(),this.nqsService=new f(this.options,this.coreStorage,this.fastDataService),this.deleteOldOfflineEntries()}destroy(){this.unregisterAllPeriodicPushes(),this.commonVariables.clear(),this.nqsService.destroy(),this.isDestroyed=!0}static getPluginVersion(){return`7.3.15${"true"===y.env.IS_STANDALONE?"-balancer":""}-nwf-js-sdk`}isUsingLegacy(){return this.usingLegacy}wasStartSent(){var e,t,i,s,n,r;return this.isUsingLegacy()?(null===(t=null===(e=this.pluginOptions)||void 0===e?void 0:e.legacyPlugin)||void 0===t?void 0:t._comm)&&(null===(s=null===(i=this.pluginOptions)||void 0===i?void 0:i.legacyPlugin)||void 0===s?void 0:s._comm.transforms)?!(null===(r=null===(n=this.pluginOptions)||void 0===n?void 0:n.legacyPlugin)||void 0===r?void 0:r._comm.transforms[0]._isBusy):void 0:this.nqsService.wasStartSent()}setLegacyPlugin(e){var t,i;if(this.pluginOptions){this.pluginOptions.legacyPlugin=e;const s="true"===y.env.IS_STANDALONE;this.usingLegacy=s&&void 0!==(null===(i=null===(t=this.pluginOptions)||void 0===t?void 0:t.legacyPlugin)||void 0===i?void 0:i.viewTransform)}}setActiveSwitchingOnLegacy(e){e&&this.pluginOptions&&this.pluginOptions.legacyPlugin&&this.pluginOptions.legacyPlugin.options&&(this.pluginOptions.legacyPlugin.options["content.cdn"]="ACTVSWIT")}getViewCode(){var e;return null===(e=this.pluginOptions)||void 0===e?void 0:e.legacyPlugin.viewTransform.getViewCode()}getLegacyFastDataHost(){var e;return null===(e=this.pluginOptions)||void 0===e?void 0:e.legacyPlugin.viewTransform.response.host}setOptions(e){this.options.updateOptions(e),this.browserStorage.updateStorageOptions(this.options.disableCookies,this.options.forceCookies,this.options.disableStorage),this.fastDataService.updateOptions(e)}getOptions(){return this.options}getCoreStorage(){return this.coreStorage}registerCommonVariable(e,t,i){var s,n;this.commonVariables.has(e)?null===(s=this.commonVariables.get(e))||void 0===s||s.set(t,i):(this.commonVariables.set(e,new Map),null===(n=this.commonVariables.get(e))||void 0===n||n.set(t,i))}unregisterCommonVariable(e,t){var i;null===(i=this.commonVariables.get(e))||void 0===i||i.delete(t)}getCommonVariable(e,t){var i;return null===(i=this.commonVariables.get(e))||void 0===i?void 0:i.get(t)}getFastDataService(){return this.fastDataService}getFastDataSessionToken(){return this.fastDataService.getSession()}getFastDataSessionHost(){return this.coreStorage.getHost()}refreshSessionToken(){return this.usingLegacy?void 0:this.fastDataService.refreshSessionToken()}isSessionTokenExpired(){var e;const t=(new Date).getTime();return!this.usingLegacy&&t-(null!==(e=this.nqsService.getTimeOfLastSentRequest())&&void 0!==e?e:t)>1e3*this.fastDataService.getSessionExpireTime()}pushData(e,t,i,s,n,r){this.handleDataToSend(e,t,i,s,n,r)}pushPeriodicDataFromCallback(e,t,i,s,n,r,o,a,c){const d=setInterval(()=>{const t=r();t&&this.handleDataToSend(e,i,n,t,o,a,c)},s<1e3?1e3:s);this.registeredPeriodicPushes.has(t)?(clearInterval(this.registeredPeriodicPushes.get(t)),this.registeredPeriodicPushes.set(t,d)):this.registeredPeriodicPushes.set(t,d)}unregisterPeriodicPush(e){clearInterval(this.registeredPeriodicPushes.get(e)),this.registeredPeriodicPushes.delete(e)}unregisterAllPeriodicPushes(){if(0===this.registeredPeriodicPushes.size)return;o.default.debug(r.CoreTag,`Unregistering ${this.registeredPeriodicPushes.size} periodic pushes`);const e=Array.from(this.registeredPeriodicPushes.keys());for(const t of e)clearInterval(this.registeredPeriodicPushes.get(t)),this.registeredPeriodicPushes.delete(t);o.default.debug(r.CoreTag,"Finished unregistering all pushes")}deleteOldOfflineEntries(){var e,t,i,s;const n=null!==(t=null===(e=this.coreStorage.getLocal("offlineViews"))||void 0===e?void 0:e.split(","))&&void 0!==t?t:[];for(const e of n){const t=null!==(s=null===(i=this.coreStorage.getLocal("offlineViews."+e))||void 0===i?void 0:i.split(","))&&void 0!==s?s:[],n=2592e6;t.length>0&&Date.now()-JSON.parse("["+t+"]")[0].timemark>n&&this.deleteViewDataFromLocalStorage(e)}}sendOfflineEvents(){var e,t,i,n,a,c;return i=this,n=void 0,c=function*(){if(this.options.offline)return void o.default.notice(r.AnalyticsTag,"Unable to send offline events because offline option is enabled");if(this.sendingOffline)return;this.sendingOffline=!0;let i=15,n=!1;for(;!n&&i-- >0;)""===this.getFastDataSessionToken()?yield new Promise(e=>setTimeout(e,100)):n=!0;if(i<1)return;const a=(null!==(t=null===(e=this.coreStorage.getLocal("offlineViews"))||void 0===e?void 0:e.split(","))&&void 0!==t?t:[]).map(e=>new Promise((t,i)=>{var n;let o=null!==(n=this.coreStorage.getLocal("offlineViews."+e))&&void 0!==n?n:"";if(o=o.replace(/CODE_PLACEHOLDER/g,T.getInstance().getFastDataSessionToken()+"_"+e.split("_")[1]),o.length>0){const i=new u(!0,this.coreStorage.getHost(),s.A.Service.OFFLINE_EVENTS,r.Method.POST,{code:T.getInstance().getFastDataSessionToken()+"_"+e.split("_")[1]},()=>{this.deleteViewDataFromLocalStorage(e),t()},()=>t());i.setBody("["+o+"]"),i.send(function(){})}}));yield Promise.all(a).finally(()=>{this.sendingOffline=!1})},new((a=void 0)||(a=Promise))(function(e,t){function s(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(s,r)}o((c=c.apply(i,n||[])).next())})}deleteViewDataFromLocalStorage(e){var t,i;this.coreStorage.removeLocal("offlineViews."+e);const s=null!==(i=null===(t=this.coreStorage.getLocal("offlineViews"))||void 0===t?void 0:t.split(","))&&void 0!==i?i:[],n=s.indexOf(e);-1!=n&&s.splice(n,1),this.coreStorage.setLocal("offlineViews",s.toString())}handleDataToSend(e,t,i,n,r,o,a){if(!this.isDestroyed)switch(e){case v.default.Consumer.NQS:this.nqsService.send(t,i,n,r,o,a);break;case v.default.Consumer.PERSISTENT:if(void 0!==r&&r(),t===s.A.Service.VIDEO_PLUGIN_LOGS)break;if(t===s.A.Service.INIT)break;n.timemark=Date.now();const e=new u(this.options["app.https"],"",t,i,n,r,o),c=this.coreStorage.getLocal("offlineViews");if(c){const e=c.split(",");e.includes(n.code)||(e.push(n.code),this.coreStorage.setLocal("offlineViews",e.toString()))}else this.coreStorage.setLocal("offlineViews",n.code);const d=this.coreStorage.getLocal("offlineViews."+n.code);if(d){const t=d.split(",");t.push(e.toLocalStorageString()),this.coreStorage.setLocal("offlineViews."+n.code,t.toString())}else this.coreStorage.setLocal("offlineViews."+n.code,e.toLocalStorageString());break;case v.default.Consumer.BLACK_HOLE:void 0!==r&&r()}}subscribeListener(e){this.coreEventListeners.push(e)}throwEvent(e){if(!this.isDestroyed)for(const t of this.coreEventListeners)t(e)}}},194:e=>{e.exports={parsers:[{element:"name",headerName:null,regex:/(.+)/},{element:"host",headerName:null,regex:/(.+)/}]}},211:(e,t,i)=>{var s=i(7380),n=i(3598),r={getPosition:function(){return null},getGivenBreaks:function(){return null},getExpectedBreaks:function(){return null},getExpectedPattern:function(){return null},getBreaksTime:function(){return null},getGivenAds:function(){return null},getExpectedAds:function(){return null},getIsVisible:function(){return!0},getAudioEnabled:function(){return null},getIsSkippable:function(){return null},getIsFullscreen:function(){return null},getCampaign:function(){return null},getCreativeId:function(){return null},getProvider:function(){return null},getAdInsertionType:function(){return null},fireClick:function(e){"string"==typeof e&&(e={url:e}),this.emit(s.Event.CLICK,{params:e})},fireQuartile:function(e){this.flags.isStarted&&"number"==typeof e&&e>this.flags.lastQuartileSent&&e<4&&(this.flags.lastQuartileSent++,this.emit(s.Event.QUARTILE,{params:{quartile:e}}))},startChronoView:function(){if(this.getIsVisible()&&this.plugin.backgroundDetector&&!this.plugin.backgroundDetector.isInBackground){var e=this.chronos.viewedMax;0!==e.length&&0===e[e.length-1].stopTime||(e.push(new n),e[e.length-1].start())}},stopChronoView:function(){var e=this.chronos.viewedMax;e[0]&&e.length>0&&0===e[e.length-1].stopTime&&e[e.length-1].stop()},fireManifest:function(e,t){var i={params:e};"string"==typeof e&&(i={params:{errorType:e,errorMessage:t}}),this.emit(s.Event.MANIFEST,i)},fireSkip:function(e){void 0===e&&(e={}),e.skipped=!0,this.fireStop(e)},fireBreakStart:function(e){this.fireAdBreakStart(e)},fireBreakStop:function(e){this.fireAdBreakStop(e)},fireAdBreakStart:function(e){this.emit(s.Event.PODSTART,{params:e})},fireAdBreakStop:function(e){this.emit(s.Event.PODSTOP,{params:e})}};e.exports=r},232:e=>{var t=function(e){var i,s,n=(e=e||window).document,r=function(t){var i=!1;if(t.getBoundingClientRect){var s=t.getBoundingClientRect();(i={top:Math.max(s.top,0),left:Math.max(s.left,0),bottom:Math.min(s.bottom,e.innerHeight||n.documentElement.clientHeight),right:Math.min(s.right,e.innerWidth||n.documentElement.clientWidth)}).bottom<=i.top||i.right<=i.left?i=!1:i.area=(i.bottom-i.top)*(i.right-i.left)}return i},o=function(e,t){if(t){var i=r(e);i&&a.push({url:t,area:i.area,rect:i})}},a=[],c=[];try{var d=e.performance.timing.navigationStart;!function(){for(var i=n.getElementsByTagName("*"),s=/url\(.*(http.*)\)/gi,c=0;c<i.length;c++){var d=i[c],l=e.getComputedStyle(d);if("IMG"===d.tagName&&o(d,d.src),l["background-image"]){s.lastIndex=0;var u=s.exec(l["background-image"]);u&&u.length>1&&o(d,u[1].replace('"',""))}if("IFRAME"===d.tagName)try{var h=r(d);if(h){var p=t(d.contentWindow);p&&a.push({tm:p,area:h.area,rect:h})}}catch(e){}}}(),function(){for(var t={},i=e.performance.getEntriesByType("resource"),s=0;s<i.length;s++)t[i[s].name]=i[s].responseEnd;for(var n=0;n<a.length;n++)"tm"in a[n]||(a[n].tm=void 0!==t[a[n].url]?t[a[n].url]:0)}(),function(){"msFirstPaint"in e.performance.timing&&(i=e.performance.timing.msFirstPaint-d);for(var t=e.performance.getEntriesByType("paint"),s=0;s<t.length;s++)"first-paint"===t[s].name&&(i=t[s].startTime);if(void 0===i||i<0||i>12e4){i=e.performance.timing.responseStart-d;for(var r={},o=n.getElementsByTagName("head")[0].children,a=0;a<o.length;a++){var c=o[a];"SCRIPT"===c.tagName&&c.src&&!c.async&&(r[c.src]=!0),"LINK"===c.tagName&&"stylesheet"===c.rel&&c.href&&(r[c.href]=!0)}for(var l=e.performance.getEntriesByType("resource"),u=!1,h=0;h<l.length;h++)if(u||!r[l[h].name]||"script"!==l[h].initiatorType&&"link"!==l[h].initiatorType)u=!0;else{var p=l[h].responseEnd;(void 0===i||p>i)&&(i=p)}}i=Math.max(i,0)}(),function(){for(var t={0:0},s=0,r=0;r<a.length;r++){var o=i;"tm"in a[r]&&a[r].tm>i&&(o=a[r].tm),void 0===t[o]&&(t[o]=0),t[o]+=a[r].area,s+=a[r].area}var d=Math.max(n.documentElement.clientWidth,e.innerWidth||0)*Math.max(n.documentElement.clientHeight,e.innerHeight||0);if(d>0&&(d=.1*Math.max(d-s,0),void 0===t[i]&&(t[i]=0),t[i]+=d,s+=d),s){for(var l in t)t.hasOwnProperty(l)&&c.push({tm:l,area:t[l]});c.sort(function(e,t){return e.tm-t.tm});for(var u=0,h=0;h<c.length;h++)u+=c[h].area,c[h].progress=u/s}}(),function(){if(c.length){s=0;for(var e=0,t=0,n=0;n<c.length;n++){var r=c[n].tm-e;r>0&&t<1&&(s+=(1-t)*r),e=c[n].tm,t=c[n].progress}}else s=i}()}catch(e){}return s};e.exports=t},525:(e,t)=>{"use strict";function i(e,t){return void 0===t&&(t=Object),t&&"function"==typeof t.freeze?t.freeze(e):e}var s=i({HTML:"text/html",isHTML:function(e){return e===s.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),n=i({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===n.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});t.assign=function(e,t){if(null===e||"object"!=typeof e)throw new TypeError("target is not an object");for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.find=function(e,t,i){if(void 0===i&&(i=Array.prototype),e&&"function"==typeof i.find)return i.find.call(e,t);for(var s=0;s<e.length;s++)if(Object.prototype.hasOwnProperty.call(e,s)){var n=e[s];if(t.call(void 0,n,s,e))return n}},t.freeze=i,t.MIME_TYPE=s,t.NAMESPACE=n},550:(e,t,i)=>{var s=i(1311),n=i(8538),r=function(){};r.prototype={constructor:function(){}},r.extend=function(e,t){var i,r=this;return i=e&&e.hasOwnProperty("constructor")?e.constructor:function(){return r.apply(this,arguments)},s(i,r,t),i.prototype=n(r.prototype),e&&s(i.prototype,e),i.prototype.constructor=i,i.__super__=r.prototype,i},e.exports=r},668:(e,t,i)=>{"use strict";i.d(t,{A:()=>s});class s{constructor(){this.host="lma.npaw.com",this.components={},this.host="lma.npaw.com",this.components={}}}},694:e=>{e.exports={cdnName:"EDGECAST",parsers:[{element:"host",headerName:"Server",regex:/\((.+)\/.+\)/},{element:"type",headerName:"X-Cache",regex:/(.+)/}],parseType:function(e){return"HIT"===e?1:2}}},829:(e,t,i)=>{var s=i(1075);const{default:n}=i(3582),{AnalyticsTag:r}=i(9982);var o=s.extend({constructor:function(e){this.plugin=e,this.videos={}},existsVideo:function(e){return e=e||"default",!!this.videos[e]},getVideo:function(e){if(e=e||"default",this.videos[e])return this.videos[e]},setVideo:function(e){this.videos[this._parseVideoKey(e.getVideoKey())]=e},getVideoKeys:function(){return Object.keys(this.videos)},existsAdapter:function(e){return e=e||"default",!(!this.videos[e]||!this.videos[e]._adapter)},getAdapter:function(e){if(e=e||"default",this.videos[e])return this.videos[e].getAdapter()},setAdapter:function(e,t){t=t||"default",this.videos[t]&&this.videos[t].setAdapter(e,this.plugin)},getAdsAdapter:function(e){if(e=e||"default",this.videos[e])return this.videos[e].getAdsAdapter()},removeAdapter:function(e,t){t=t||"default";try{this.videos[t]&&this.videos[t].removeAdapter()}catch(e){n.error(r,"Is not possible to remove adapter for video: "+t)}},removeAllAdapters:function(){for(const e of Object.keys(this.videos))this.videos[e].removeAdapter(),this.videos[e].removeAdsAdapter()},sendRequest:function(e,t,i,s,o,a,c,d){e=e||"default",this.videos[e]?this.videos._send(this._key,t,i,s,o,a,c,d):n.error(r,"Can't send request for not existent video object")},updateAllOptions:function(e){for(const t in this.videos)for(const i in e)this.videos[t].options[i]=e[i];e["adapters.templates"]&&(this.plugin._setAdapterTemplates(e["adapters.templates"]),this.updateAdapterTemplates(e["adapters.templates"]))},updatePingInterval:function(e){for(var t in this.videos)this.videos[t]._ping.interval=e},updateAdapterTemplates:function(e){if(e&&this.videos)for(var t in this.videos)this.videos[t]._adapter&&this.videos[t]._adapter.updateAdapterTemplates(e)},resetVideo:function(e){e=e||"default",this.video[e]&&this.video[e]._reset()},_parseVideoKey:function(e){return e||"default"}});e.exports=o},859:e=>{e.exports={GET:"GET",POST:"POST"}},912:(e,t,i)=>{"use strict";i.d(t,{CE:()=>y,Ji:()=>w,LI:()=>S,Lg:()=>p,Ow:()=>m,Y4:()=>d,Zq:()=>I,_C:()=>A,b3:()=>T,dR:()=>b,df:()=>c,hj:()=>u,jQ:()=>E,m:()=>g,mH:()=>v,w2:()=>l,wc:()=>_,xC:()=>n,yL:()=>r,yl:()=>a,zU:()=>h});const s=o;!function(e){const t=o,i=e();for(;;)try{if(732303==-parseInt(t(350))/1*(parseInt(t(371))/2)+-parseInt(t(360))/3*(-parseInt(t(370))/4)+-parseInt(t(359))/5*(parseInt(t(338))/6)+-parseInt(t(331))/7*(parseInt(t(349))/8)+-parseInt(t(367))/9+-parseInt(t(353))/10*(-parseInt(t(340))/11)+parseInt(t(332))/12)break;i.push(i.shift())}catch(e){i.push(i.shift())}}(f);const n={CDN:s(346)},r={Success:"ok",Fail:s(325),Progress:"pr"};function o(e,t){const i=f();return(o=function(e,t){return i[e-=315]})(e,t)}const a={Updated:s(327),Success:"ok",Fail:s(325)},c={host:s(364),devHost:s(369),devDomains:[s(335),s(368)],service:s(347),decisionCallWaitTime:3e4,decisionReloadIntervalPerManifestMilliseconds:3e4},d=[s(343),s(333),s(316),s(365),s(318),s(358),s(342)],l=[".m3u8",s(319)],u=[s(337),s(328)],h=[".srt",".vtt",s(366),s(362),s(352)],p={connect:s(334),close:s(326),error:s(329),data:"data",ping:"ping",pong:"pong"};function f(){const e=["updated",".cmfa","error","identifier","14atsqiB","8525880WpoOHy",".m4s","connect","stage.npaw.com","SEGMENT_DATA",".aac","6WdbOJM","PONG","11672518JsmELh","size",".cmfv",".mp4","optimizedFeedback","optimizedScore","/cdn","/decision","bestScore","345416SkNOge","109WwNFqE","default",".webvtt","10BazorN","cdnPriority","random","SEGMENT_ABSENT","qualityPriority",".m4f","1110145XcAmYJ","373227ipSfXb","splits",".ass","command","gnsnpaw.com",".cmf",".ssa","1940868xGeaqU","qa.npaw.com","stage-smartswitchv2.youbora.com","28uXDnEV","25434dhoWsC","GET_RETRY_HEAD",".ts","keys",".dash",".mpd","NEW_SEGMENT_AVAILABLE","SEGMENT_REQUEST","wss://p2p-tracker.youbora.com/webrtc","data_spec_key","PING","nok","close"];return(f=function(){return e})()}const g={optimizedScore:s(345),optimizedFeedback:s(344),bestScore:s(348),qualityPriority:s(357),cdnPriority:s(354)},m={max:25e6,min:2e5,default:2e5},v=(s(355),s(351),{data:s(336),absent:s(356),map:"SEGMENTS_MAP",newSegmentAvailable:s(320),request:s(321),cancel:"CANCEL_SEGMENT_REQUEST",ping:s(324),pong:s(339)}),y={command:s(363),id:s(323),size:s(341),storageSize:"ss",map:s(317),identifier:s(330),splits:s(361),time:0,simpleMapKeys:"k",simpleMapSize:"s",dateTime:"dt",createdAt:"ca"},T={bandwidth_test:2,message:1,data:0},S={maxMessageSize:65532,probability:1,timeout:2500,maxConcurrency:6,maxConnectedPeers:40,tracker:s(322),upload:!1},E={version:2},b={expiration:3e5,count:60,safeMaxCount:300},A={retries:5,retryDelay:100,defaultBwThreshold:2e5,connectTimeoutMilliseconds:1e4,readTimeoutMilliseconds:3e3,minRequestSizeForBwEstimateKB:100},w={totalDataInterval:6e4},_={callTimeoutMilliseconds:500,timeBetweenCallsMilliseconds:1e3,timeBetweenBurstsMilliseconds:5e3},I={lastMeasurementWeight:.5,maximumRelativeDeltaForTrial:.2,minimumDurationSinceLastUsedForTrialMilliseconds:3e4,chunkExpirationProbingMs:3e4,probingPolicy:s(315)}},948:(e,t,i)=>{var s=i(5100);i(2839);const{default:n}=i(3582);var r=i(8661);i(2176);const{AnalyticsTag:o}=i(9982),{default:a}=i(6443),{default:c}=i(99);var d={_startListener:function(e){!this.plugin.options.enableExtraMetricCollection||this.lastKnownLocation||this.isFetchingLocation||this.fetchLocation(),this.isInitiated?0!==this.initChrono.startTime&&(this._adapter.chronos.join.startTime=this.initChrono.startTime):(this._viewIndex||this.plugin.getNextViewIndex(this),this._startPings());var t=e.data.params||{},i=this.getResource()&&"boolean"==typeof this.getIsLive()&&(this.getIsLive()||"number"==typeof this.getDuration()&&this.getDuration()>0)&&this.getTitle(),r=c.getInstance().getCommonVariable(a.Products.BALANCER,a.BalancerVariables.DECISION_FINISHED);void 0===r&&(r=!0);var d=this.getChronosEventParam()||{};if(d&&Object.keys(d).length>0&&(t.chronos=d),this.plugin.resourceTransform&&this.getResource())try{if(this.plugin.resourceTransform.init(this.getResource()),this.plugin.resourceTransform.isBlocking()){var l=this.plugin.resourceTransform.getWaitParams();if(this.options.waitForMetadata=!0,l&&l.length>0){for(var u=this.options.pendingMetadata||[],h=0;h<l.length;h++)-1===u.indexOf(l[h])&&u.push(l[h]);this.options.pendingMetadata=u}else this.options.pendingMetadata=[]}}catch(e){}(i=!this.options.forceInit&&i&&this._isExtraMetadataReady()&&r&&this._isRequiredMetadataReady())&&!this.isInitiated?(this._send(s.WillSendEvent.WILL_SEND_START,s.Service.START,t,void 0,void 0,()=>{}),this._adSavedError(),this._adSavedManifest(),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.START+", title/res: "+(t.title||t.mediaResource)+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:"")),this.isStarted=!0):this.isInitiated||(this.isInitiated=!0,this._adapter.chronos.join.start(),this._send(s.WillSendEvent.WILL_SEND_INIT,s.Service.INIT,t,void 0,void 0,()=>{}),this._adSavedError(),this._adSavedManifest(),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.INIT+", title/res: "+(t.title||t.mediaResource)+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:""))),this.options.enableExtraMetricCollection&&this.shouldStartRenditionTimer()},_retryStart:function(e){var t=c.getInstance().getCommonVariable(a.Products.BALANCER,a.BalancerVariables.DECISION_FINISHED);void 0===t&&(t=!0),this._isExtraMetadataReady()&&t&&this._isRequiredMetadataReady()&&(this._send(s.WillSendEvent.WILL_SEND_START,s.Service.START,{triggeredEvents:["retryStart"]}),this.startDelayed=!1)},_joinListener:function(e){var t={};if(r.assign(t,e.data.params||{}),this._adsAdapter&&this._adsAdapter.flags.isStarted)this._adapter.monitor&&this._adapter.monitor.stop(),this._adapter.flags.isJoined=!1,this._adapter.chronos.join.stopTime=0;else{if(this._adapter&&(this._adapter.chronos.join.startTime=Math.min(this._adapter.chronos.join.startTime+(this._totalPrerollsTime||0),(new Date).getTime()),this._totalPrerollsTime=0),this.isInitiated&&!this.isStarted){var i=c.getInstance().getCommonVariable(a.Products.BALANCER,a.BalancerVariables.DECISION_FINISHED);if(void 0===i&&(i=!0),this._isExtraMetadataReady()&&i&&this._isRequiredMetadataReady()){var d=this.getChronosEventParam()||{};d&&Object.keys(d).length>0&&(t.chronos=d),this._send(s.WillSendEvent.WILL_SEND_START,s.Service.START,t,void 0,void 0,()=>{})}else this.startDelayed=!0;this._adSavedError(),this._adSavedManifest(),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.START+", title/res: "+(t.title||t.mediaResource)+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:"")),this.isStarted=!0}t=e.data.params||{},this._adsAdapter&&this.isBreakStarted&&this._adsAdapter.fireAdBreakStop(),this._send(s.WillSendEvent.WILL_SEND_JOIN,s.Service.JOIN,t,void 0,void 0,()=>{}),this.resetChronos(),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.JOIN+", duration: "+t.joinDuration+"ms"+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:""))}},_advancedDataListener:function(e){var t=e.data.params||{};this._send(s.WillSendEvent.WILL_SEND_DATA_OBJECT,s.Service.DATA_OBJECT,t),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.DATA_OBJECT+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:""))},_pauseListener:function(e){this._adapter&&(this._adapter.flags.isBuffering||this._adapter.flags.isSeeking||this._adsAdapter&&this._adsAdapter.flags.isStarted)&&this._adapter.chronos.pause.reset();var t=e.data.params||{};this._send(s.WillSendEvent.WILL_SEND_PAUSE,s.Service.PAUSE,t),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.PAUSE+" at "+t.playhead+"s"+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:""))},_resumeListener:function(e){this._adsAdapter&&this.isBreakStarted&&!this._adsAdapter.flags.isStarted&&this._adsAdapter.fireAdBreakStop();var t=e.data.params||{};this._send(s.WillSendEvent.WILL_SEND_RESUME,s.Service.RESUME,t),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.RESUME+", duration: "+t.pauseDuration+"ms"+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:"")),this._adapter.chronos.pause.reset()},_seekBufferBeginListener:function(e){this._adapter&&this._adapter.flags.isPaused&&this._adapter.chronos.pause.pause(),e.type&&e.type.includes("buffer")?n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+e.type+", eventsTriggered: "+this._adapter.fireEventsStruct.buffer):n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+e.type+", eventsTriggered: "+this._adapter.fireEventsStruct.seek)},_seekEndListener:function(e){var t=e.data.params||{};this._send(s.WillSendEvent.WILL_SEND_SEEK,s.Service.SEEK,t),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.SEEK+" to "+t.playhead+" in "+t.seekDuration+"ms"+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:""))},_bufferEndListener:function(e){var t=e.data.params||{};(t=this.requestBuilder.fetchParams(t,["throughput"],!1,[this,this.plugin],this.options)).entities=this.requestBuilder.getChangedEntities([this,this.plugin],this.options),this._send(s.WillSendEvent.WILL_SEND_BUFFER,s.Service.BUFFER,t),n.notice(o,"["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") "+s.Service.BUFFER+" to "+t.playhead+" in "+t.bufferDuration+"ms"+(t.triggeredEvents?", eventsTriggered: "+t.triggeredEvents:""))},_errorListener:function(e){this._blockError(e.data.params)||(this.fireError(e.data.params||{}),this._adSavedError(),this._adSavedManifest())},_blockError:function(e){var t=Date.now(),i=this.getResource();return this._lastErrorParams&&this._lastErrorParams.errorCode===e.errorCode&&this._lastErrorParams.msg===e.msg&&this._lastErrorResource===i&&this._lastErrorTime+5e3>t?(this._lastErrorTime=t,!0):(this._lastErrorTime=t,this._lastErrorParams=e,this._lastErrorResource=i,!1)},_stopListener:function(e){try{this.resetChronos(this._viewIndex||0)}catch(e){}this.fireStop(e.data.params||{})},_isStopReady:function(e){let t=!1;if(!this.requestBuilder.lastSent.live&&this._adsAdapter&&this._adapter&&(!this._adapter.getPlayhead()||this._adapter.getPlayhead()>=this.requestBuilder.lastSent.mediaDuration-1)){let e=0;const i=this.options["ad.expectedPattern"];if(i&&i.post&&i.post[0])e=i.post[0];else if(this.requestBuilder.lastSent.breaksTime){if(this.requestBuilder.lastSent.position===s.AdPosition.Postroll&&(e=this.requestBuilder.lastSent.givenAds),!e&&this.requestBuilder.lastSent.breaksTime){const t=this.requestBuilder.lastSent.breaksTime;t.length>0&&this.requestBuilder.lastSent.mediaDuration&&Math.round(t[t.length-1])+1>=this.requestBuilder.lastSent.mediaDuration&&(e=1)}}else t=!0;e<=this.playedPostrolls&&(t=!0)}else t=!0;return t},_videoEventListener:function(e){this._send(s.WillSendEvent.WILL_SEND_VIDEO_EVENT,s.Service.VIDEO_EVENT,e.data.params)},_videoEventEndListener:function(e){this._send(s.WillSendEvent.WILL_SEND_VIDEO_EVENT_END,s.Service.VIDEO_EVENT_END,e.data.params)},_isExtraMetadataReady:function(e){if(!this.options.waitForMetadata||this.options.pendingMetadata.length<1)return!0;try{if(this._adapter.chronos.join.startTime>0)if((new Date).getTime()-this._adapter.chronos.join.startTime>=("number"==typeof this.options["waitForMetadata.timeout.milliseconds"]?this.options["waitForMetadata.timeout.milliseconds"]:s.Metadata.REQUIRED_METADATA_TIMEOUT))return!0;const e=this.requestBuilder.getGetters();return this.options.pendingMetadata.map(function(t){if(e.hasOwnProperty(t)){if(this[e[t]])return!!this[e[t]]();if(this.plugin[e[t]])return!!this.plugin[e[t]]()}}.bind(this)).indexOf(!1)<0}catch(e){n.warn("["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") Error processing isExtraMetadataReady method.")}return!0},_isRequiredMetadataReady:function(){if((new Date).getTime()-this._adapter.chronos.join.startTime<("number"==typeof this.options["waitForMetadata.timeout.milliseconds"]?this.options["waitForMetadata.timeout.milliseconds"]:s.Metadata.REQUIRED_METADATA_TIMEOUT)){try{const e=this.requestBuilder.getGetters();return this.requestBuilder.getRequiredMetadataParams().every(function(t){if(e.hasOwnProperty(t))if("function"==typeof this[e[t]]){const i=this[e[t]]();if(null!=i&&!Number.isNaN(i))return!0}else if(this.plugin&&"function"==typeof this.plugin[e[t]]){const i=this.plugin[e[t]]();if(null!=i&&!Number.isNaN(i))return!0}return!1}.bind(this))}catch(e){n.warn("["+this.getViewCode()+"] (Video Space "+this.getVideoKey()+") Error processing _isRequiredMetadataReady method.")}return!1}return!0}};e.exports=d},1048:(e,t,i)=>{"use strict";const s=i(7991),n=i(9318),r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=c,t.IS=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,i){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return d(e,t,i)}function d(e,t,i){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const i=0|g(e,t);let s=a(i);const n=s.write(e,t);return n!==i&&(s=s.slice(0,n)),s}(e,t);if(ArrayBuffer.isView(e))return function(e){if(z(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(z(e,ArrayBuffer)||e&&z(e.buffer,ArrayBuffer))return p(e,t,i);if("undefined"!=typeof SharedArrayBuffer&&(z(e,SharedArrayBuffer)||e&&z(e.buffer,SharedArrayBuffer)))return p(e,t,i);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const s=e.valueOf&&e.valueOf();if(null!=s&&s!==e)return c.from(s,t,i);const n=func