@newrelic/video-core 5.0.1 → 5.1.0
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/CHANGELOG.md +20 -2
- package/README.md +13 -0
- package/__mock__.js +8 -4
- package/dist/cjs/browser/index.js +1 -1
- package/dist/cjs/browser/index.js.LICENSE.txt +1 -1
- package/dist/cjs/browser/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.LICENSE.txt +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/vega/index.js +1 -1
- package/dist/cjs/vega/index.js.LICENSE.txt +1 -1
- package/dist/cjs/vega/index.js.map +1 -1
- package/dist/esm/browser/index.js +1 -1
- package/dist/esm/browser/index.js.LICENSE.txt +1 -1
- package/dist/esm/browser/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.LICENSE.txt +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/vega/index.js +1 -1
- package/dist/esm/vega/index.js.LICENSE.txt +1 -1
- package/dist/esm/vega/index.js.map +1 -1
- package/dist/types/browser/agent.d.ts +46 -0
- package/dist/types/browser/harvestScheduler.d.ts +125 -0
- package/dist/types/browser/index.d.ts +34 -0
- package/dist/types/chrono.d.ts +52 -0
- package/dist/types/connectedDevice/connectedDeviceAgent.d.ts +63 -0
- package/dist/types/connectedDevice/connectedDeviceConstants.d.ts +51 -0
- package/dist/types/connectedDevice/connectedDeviceHarvester.d.ts +198 -0
- package/dist/types/connectedDevice/index.d.ts +30 -0
- package/dist/types/constants.d.ts +30 -0
- package/dist/types/core.d.ts +54 -0
- package/dist/types/emitter.d.ts +42 -0
- package/dist/types/eventAggregator.d.ts +97 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/log.d.ts +61 -0
- package/dist/types/obfuscate.d.ts +13 -0
- package/dist/types/optimizedHttpClient.d.ts +83 -0
- package/dist/types/recordEvent.d.ts +30 -0
- package/dist/types/retryQueueHandler.d.ts +46 -0
- package/dist/types/tracker.d.ts +176 -0
- package/dist/types/utils/eventBuilder.d.ts +69 -0
- package/dist/types/utils/harvestTimer.d.ts +45 -0
- package/dist/types/utils/index.d.ts +38 -0
- package/dist/types/utils/qoeFilters.d.ts +88 -0
- package/dist/types/videoConfiguration.d.ts +90 -0
- package/dist/types/videotracker.d.ts +366 -0
- package/dist/types/videotrackerstate.d.ts +228 -0
- package/dist/umd/nrvideo.min.js +1 -1
- package/dist/umd/nrvideo.min.js.LICENSE.txt +1 -1
- package/dist/umd/nrvideo.min.js.map +1 -1
- package/package.json +15 -2
- package/src/browser/{agent.js → agent.ts} +21 -16
- package/src/browser/{harvestScheduler.js → harvestScheduler.ts} +51 -24
- package/src/{chrono.js → chrono.ts} +29 -24
- package/src/connectedDevice/{connectedDeviceAgent.js → connectedDeviceAgent.ts} +14 -10
- package/src/connectedDevice/{connectedDeviceConstants.js → connectedDeviceConstants.ts} +5 -3
- package/src/connectedDevice/{connectedDeviceHarvester.js → connectedDeviceHarvester.ts} +71 -34
- package/src/constants.ts +62 -0
- package/src/{core.js → core.ts} +31 -18
- package/src/{emitter.js → emitter.ts} +16 -5
- package/src/{eventAggregator.js → eventAggregator.ts} +33 -19
- package/src/global.d.ts +25 -0
- package/src/{log.js → log.ts} +23 -17
- package/src/{obfuscate.js → obfuscate.ts} +6 -1
- package/src/{optimizedHttpClient.js → optimizedHttpClient.ts} +37 -13
- package/src/{recordEvent.js → recordEvent.ts} +11 -9
- package/src/{retryQueueHandler.js → retryQueueHandler.ts} +17 -12
- package/src/{tracker.js → tracker.ts} +56 -23
- package/src/utils/{eventBuilder.js → eventBuilder.ts} +31 -14
- package/src/utils/{harvestTimer.js → harvestTimer.ts} +21 -4
- package/src/utils/{index.js → index.ts} +14 -14
- package/src/utils/{qoeFilters.js → qoeFilters.ts} +19 -8
- package/src/{videoConfiguration.js → videoConfiguration.ts} +44 -10
- package/src/{videotracker.js → videotracker.ts} +119 -78
- package/src/{videotrackerstate.js → videotrackerstate.ts} +113 -49
- package/src/constants.js +0 -63
- /package/src/browser/{index.js → index.ts} +0 -0
- /package/src/connectedDevice/{index.js → index.ts} +0 -0
- /package/src/{index.js → index.ts} +0 -0
package/dist/umd/nrvideo.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see nrvideo.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.nrvideo=e():t.nrvideo=e()}(self,()=>(()=>{"use strict";const t={d:(e,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var i=r[n++],a=r[n++];t.o(e,i)?0===a&&n++:0===a?Object.defineProperty(e,i,{enumerable:!0,value:r[n++]}):Object.defineProperty(e,i,{enumerable:!0,get:a})}else for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};let e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}t.d(e,{default:()=>ke});var a=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return e=t,r=[{key:"error",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];o(r,t.Levels.ERROR,"darkred")}},{key:"warn",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];o(r,t.Levels.WARNING,"darkorange")}},{key:"notice",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];o([].slice.call(arguments),t.Levels.NOTICE,"darkcyan")}},{key:"debug",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];o(r,t.Levels.DEBUG,"indigo")}},{key:"debugCommonVideoEvents",value:function(e,r,n){try{if(t.level<=t.Levels.DEBUG){n=n||function(e){t.debug("Event: "+e.type)};var i=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];r&&(null===r[0]?(r.shift(),i=r):i=i.concat(r));for(var a=0;a<i.length;a++)"function"==typeof e?e.call(window,i[a],n):e.on?e.on(i[a],n):e.addEventListener?e.addEventListener(i[a],n):e.addEventHandler?e.addEventHandler(i[a],n):t.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){t.warn(e)}}}],null&&n(e.prototype,null),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();function o(t,e,r){e=e||a.Levels.NOTICE,r=r||"darkcyan";var n,i,o=a.prefix;a.includeTime&&(o+="["+("0"+(n=new Date).getDate()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+"] "),o+=function(t){return u[t]}(e)+":",a.level<=e&&e!==a.Levels.SILENT&&(!a.colorful||"undefined"!=typeof document&&document.documentMode?s(t,o):(i=e===a.Levels.ERROR&&console.error?console.error:e===a.Levels.WARNING&&console.warn?console.warn:e===a.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,o="%c"+o,t.splice(0,0,o,"color: "+r),i.apply(console,t)))}function s(t,e){if(t instanceof Array)for(var r in t)s(t[r],e);else"string"==typeof t?console.log(e+" "+t):(console.log(e+"↵"),console.log(t))}a.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},a.level=a.Levels.ERROR,a.colorful=!0,a.includeTime=!0,a.prefix="[nrvideo]";var u={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var t=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==t&&("true"===t[1]?a.level=a.Levels.ALL:a.level=t[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(a.colorful=!1)}}();const c=a;function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function f(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,h(n.key),n)}}function d(t,e,r){return e&&f(t.prototype,e),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}var y=d(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)});y.AdPositions={PRE:"pre",MID:"mid",POST:"post"},y.COLLECTOR={US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",JP:"bam.jp.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},y.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],y.MAX_PAYLOAD_SIZE=1048576,y.MAX_BEACON_SIZE=61440,y.MAX_EVENTS_PER_BATCH=1e3,y.INTERVAL=1e4,y.DEFAULT_QOE_INTERVAL_FACTOR=2,y.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],y.QOE_AGGREGATE_KEYS=["coreVersion","instrumentation.name","instrumentation.provider","instrumentation.version","isBackgroundEvent","playerName","playerVersion","src","viewId","viewSession","contentIsAutoplayed","contentIsMuted","contentRenditionHeight","contentRenditionWidth","contentSrc","numberOfVideos","pageUrl","trackerName","trackerVersion","contentDuration","contentPlayrate","contentPlayhead","contentPreload","elapsedTime","contentTitle","contentId","contentIsLive","deviceType","deviceGroup","deviceManufacturer","deviceModel","deviceName","deviceSize","deviceUuid","contentRenditionName","contentIsFullscreen","contentCdn","contentFps","asnOrganization","asnLongitude","asnLatitude","asn","timeSinceRequested","timeSinceStarted"];const v=y,p="5.0.1";function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function g(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,b(n.key),n)}}function b(t){var e=function(t){if("object"!=m(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}const S=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},(e=[{key:"on",value:function(t,e){if(this._listeners=this._listeners||{},"function"==typeof e)return this._listeners[t]=this._listeners[t]||[],this._listeners[t].push(e),this}},{key:"off",value:function(t,e){if(this._listeners=this._listeners||{},this._listeners[t]){var r=this._listeners[t].indexOf(e);-1!==r&&this._listeners[t].splice(r,1)}return this}},{key:"emit",value:function(t,e,r){var n=this;return this._listeners=this._listeners||{},r=r||{},Array.isArray(this._listeners[e])&&this._listeners[e].forEach(function(i){i.call(n,{eventType:t,type:e,data:r,target:n})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(function(i){i.call(n,{eventType:t,type:e,data:r,target:n})}),this}}])&&g(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function T(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function A(t){var e=function(t){if("object"!=E(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==E(e)?e:e+""}var w=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.reset()}return e=t,r=[{key:"reset",value:function(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}},{key:"getDeltaTime",value:function(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}},{key:"start",value:function(){this.startTime=(new Date).getTime(),this.stopTime=0}},{key:"stop",value:function(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}},{key:"getDuration",value:function(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(null!==(t=this.getDeltaTime())&&void 0!==t?t:0);var t}},{key:"clone",value:function(){var e=new t;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e.accumulator=this.accumulator,e}}],r&&T(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();const k=w;function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,P(n.key),n)}}function P(t){var e=function(t){if("object"!=O(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=O(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==O(e)?e:e+""}function R(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(R=function(){return!!t})()}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},D(t,e)}var j=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=function(t,e,r){return e=B(e),function(t,e){if(e&&("object"==O(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,R()?Reflect.construct(e,r||[],B(t).constructor):e.apply(t,r))}(this,e)).customData={},r.heartbeat=null,r.parentTracker=null,r._trackerReadyChrono=new k,r._trackerReadyChrono.start(),r._actionTable=v.ACTION_TABLE,r._actionAdTable=v.ACTION_AD_TABLE,t=t||{},r.setOptions(t),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&D(t,e)}(e,t),r=e,(n=[{key:"setOptions",value:function(t){t&&(t.parentTracker&&(this.parentTracker=t.parentTracker),t.customData&&(this.customData=t.customData),t.heartbeat&&(this.heartbeat=t.heartbeat))}},{key:"dispose",value:function(){this.unregisterListeners()}},{key:"registerListeners",value:function(){}},{key:"unregisterListeners",value:function(){}},{key:"getHeartbeat",value:function(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}},{key:"startHeartbeat",value:function(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}},{key:"stopHeartbeat",value:function(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}},{key:"sendHeartbeat",value:function(t){this.sendVideoAction(e.Events.HEARTBEAT,t)}},{key:"getAttributes",value:function(t,e){for(var r in(t=t||{}).trackerName=this.getTrackerName(),t.trackerVersion=this.getTrackerVersion(),t.coreVersion=p,t.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime(),this.customData)t[r]=this.customData[r];return null!=document.hidden&&(t.isBackgroundEvent=document.hidden),t}},{key:"getTrackerVersion",value:function(){return p}},{key:"getTrackerName",value:function(){return"base-tracker"}},{key:"sendVideoAction",value:function(t,e){this.emit("VideoAction",t,this.getAttributes(e))}},{key:"sendVideoAdAction",value:function(t,e){this.emit("VideoAdAction",t,this.getAttributes(e))}},{key:"sendVideoErrorAction",value:function(t,e){var r=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",t,this.getAttributes(e,r))}},{key:"sendVideoCustomAction",value:function(t,e){this.emit("VideoCustomAction",t,this.getAttributes(e,"customAction"))}},{key:"setHarvestInterval",value:function(t){var e,r=null===(e=this.getHarvester)||void 0===e?void 0:e.call(this);if(r)try{r.setHarvestInterval(t)}catch(t){return void c.error("Failed to set harvest interval:",t.message)}else c.error("Tracker has no harvester; setHarvestInterval ignored")}},{key:"getHarvester",value:function(){return null}}])&&_(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(S);j.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const N=j;function C(t){return C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C(t)}function I(t){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");var e=window.NRVIDEO.info,r=e.beacon,n=e.licenseKey,i=e.applicationID;if(!r||!n)throw new Error("Options object provided by New Relic is not correctly initialized");return i?"https://".concat(t||r,"/ins/1/").concat(n,"?a=").concat(i,"&v=").concat(p,"&ref=").concat(window.location.href,"&ca=VA"):"https://".concat(t||r,"/ins/1/").concat(n,"?&v=").concat(p,"&ref=").concat(window.location.href,"&ca=VA")}catch(t){return console.error(t.message),null}}function L(t){if("string"==typeof t&&t.length)return t.length;if("object"===C(t)){if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&t.byteLength)return t.byteLength;if("undefined"!=typeof Blob&&t instanceof Blob&&t.size)return t.size;if(!("undefined"!=typeof FormData&&t instanceof FormData))try{return function(t){try{var e;return null!==(e=JSON.stringify(t,(r=new WeakSet,function(t,e){if("object"===C(e)&&null!==e){if(r.has(e))return;r.add(e)}return e})))&&void 0!==e?e:""}catch(t){return c.error("Error stringifying value:",t.message),""}var r}(t).length}catch(t){return}}}function V(t){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},V(t)}var H=["qoe"];function F(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function x(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?F(Object(r),!0).forEach(function(e){Q(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Q(t,e,r){return(e=function(t){var e=function(t){if("object"!=V(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=V(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==V(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var q=Object.create(null);function U(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{var r,n,i,a;if(!v.VALID_EVENT_TYPES.includes(t))return c.warn("Invalid event type provided to recordEvent",{eventType:t}),!1;var o="Vega"===e.src,s=o?"Vega":"Browser",u="undefined"!=typeof window?window:void 0,l=o?null===(r=globalThis.__NRVIDEO_CD__)||void 0===r?void 0:r.info:null==u||null===(n=u.NRVIDEO)||void 0===n?void 0:n.info;if(!l)return;var f=q[s];return f?function(t,e,r,n,i){var a=(arguments.length>5&&void 0!==arguments[5]?arguments[5]:{}).addTimeSinceLoad;if(!n)return!1;var o=function(t,e,r){var n,i,a=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).addTimeSinceLoad,o=void 0!==a&&a,s=r.appName,u=r.applicationID,c=e.qoe,l=function(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(n=0;n<a.length;n++)r=a[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}(e,H),f=c?x({},c):{},d=x(x({},u?{}:{appName:s}),{},{timestamp:Date.now()},o?{timeSinceLoad:"undefined"!=typeof window&&window.performance?window.performance.now()/1e3:null}:{}),h=x(x({},l),{},{eventType:t},d),y=null;if("VideoAction"===t){var p=(n=v.QOE_AGGREGATE_KEYS,i=e,n&&Array.isArray(n)&&0!==n.length?i&&"object"===C(i)?n.reduce(function(t,e){return e in i&&(t[e]=i[e]),t},{}):{}:i);y=x(x(x({eventType:"VideoAction",actionName:N.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0"},f),p),d)}return{eventObject:h,qoeEventObject:y}}(t,e,r,{addTimeSinceLoad:void 0!==a&&a}),s=o.eventObject,u=o.qoeEventObject,c=n.addEvent(s);return u&&i?c&&n.addEvent(u):c}(t,e,l,f,o?null===(i=globalThis.__NRVIDEO_CD__)||void 0===i||null===(i=i.config)||void 0===i?void 0:i.qoeAggregate:null==u||null===(a=u.NRVIDEO)||void 0===a||null===(a=a.config)||void 0===a?void 0:a.qoeAggregate,{addTimeSinceLoad:!o}):(c.warn("No harvester registered for routing key",{routingKey:s}),!1)}catch(t){return c.error("Failed to record event:",t.message),!1}}var G={us:"https://mobile-collector.newrelic.com/mobile",eu:"https://mobile-collector.eu01.nr-data.net/mobile",staging:"https://staging-mobile-collector.newrelic.com/mobile",gov:"https://gov-mobile-collector.newrelic.com/mobile",jp:"https://mobile-collector.jp.nr-data.net/mobile"};function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function z(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach(function(e){K(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function K(t,e,r){return(e=X(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function Y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,X(n.key),n)}}function X(t){var e=function(t){if("object"!=W(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(e)?e:e+""}var Z=v.COLLECTOR,$=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"setConfiguration",value:function(t,e,r){return!!("Vega"===r?this.validateVegaFields(t):this.validateRequiredFields(t))&&!!this.validateConfigFields(e)&&(this.initializeGlobalConfig(t,e,r),c.notice("Video analytics configuration initialized successfully"),!0)}},{key:"validateVegaFields",value:function(t){var e;return t&&"object"===W(t)?t.applicationToken?(null===(e=t.endpoint)||void 0===e?void 0:e.toLowerCase())in G||(c.error("Invalid endpoint (must be us, eu, staging, gov, or jp)"),!1):(c.error("applicationToken is required"),!1):(c.error("Configuration must be an object"),!1)}},{key:"validateRequiredFields",value:function(t){if(!t||"object"!==W(t))return c.error("Configuration must be an object"),!1;var e=t.licenseKey,r=t.appName,n=t.region,i=t.applicationID,a=t.beacon;if(!e)return c.error("licenseKey is required"),!1;if(i){if(!a)return c.error("beacon is required when applicationID is provided"),!1;if(!Object.values(Z).flatMap(function(t){return t}).includes(a))return c.error("Invalid beacon: ".concat(a)),!1}else{if(!r||!n)return c.error("appName and region are required when applicationID is not provided"),!1;if(!Z[n])return c.error("Invalid region: ".concat(n,". Valid regions are: ").concat(Object.keys(Z).join(", "))),!1}return!0}},{key:"validateConfigFields",value:function(t){if(null==t)return!0;if("object"!==W(t)||Array.isArray(t))return c.error("config must be an object"),!1;var e=t.qoeAggregate,r=t.obfuscate;return void 0!==e&&"boolean"!=typeof e?(c.error("qoeAggregate must be a boolean"),!1):!(void 0!==r&&!Array.isArray(r)&&(c.error("obfuscate must be an array"),1))}},{key:"filterObfuscateRules",value:function(t){return t?t.filter(function(t){var e=void 0!==t.regex&&("string"==typeof t.regex||t.regex instanceof RegExp),r=void 0!==t.replacement&&"string"==typeof t.replacement;return!(!e||!r)||(c.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",t),!1)}):[]}},{key:"sanitizeQoeIntervalFactor",value:function(t){return null==t?v.DEFAULT_QOE_INTERVAL_FACTOR:"number"==typeof t&&Number.isInteger(t)&&t>=1?t:(c.warn('Invalid qoeIntervalFactor "'.concat(t,'" — must be a positive integer. Defaulting to ').concat(v.DEFAULT_QOE_INTERVAL_FACTOR,".")),v.DEFAULT_QOE_INTERVAL_FACTOR)}},{key:"initializeGlobalConfig",value:function(t,e,r){var n;if("Vega"!==r){var i=t.licenseKey,a=t.appName,o=t.region,s=t.beacon,u=t.applicationID;s="US"===o?v.COLLECTOR.US[0]:s||Z[o],window.NRVIDEO={info:z(z({},o?{region:o}:{}),{},{beacon:s,licenseKey:i,applicationID:u},u?{}:{appName:a}),config:{qoeAggregate:null===(n=null==e?void 0:e.qoeAggregate)||void 0===n||n,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(null==e?void 0:e.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(null==e?void 0:e.obfuscate)}}}else{var c,l;globalThis.__NRVIDEO_CD__={info:z(z(z({accountId:t.accountId,applicationToken:t.applicationToken,endpoint:null===(c=t.endpoint)||void 0===c?void 0:c.toLowerCase()},t.appName?{appName:t.appName}:{}),t.applicationID?{applicationID:t.applicationID}:{}),t.deviceInfo?{deviceInfo:t.deviceInfo}:{}),config:{qoeAggregate:null===(l=null==e?void 0:e.qoeAggregate)||void 0===l||l,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(null==e?void 0:e.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(null==e?void 0:e.obfuscate)}}}}}],e&&Y(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),J=new $;function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function rt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?et(Object(r),!0).forEach(function(e){nt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):et(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function nt(t,e,r){return(e=at(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function it(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function at(t){var e=function(t){if("object"!=tt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=tt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tt(e)?e:e+""}var ot=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"addTracker",value:function(t,e){null!=e&&e.info&&function(t,e,r){J.setConfiguration(t,e,r)}(e.info,null==e?void 0:e.config,null==e?void 0:e.src),t.on&&t.emit?(st.push(t),t.on("*",ut),"function"==typeof t.trackerInit&&t.trackerInit()):c.error("Tried to load a non-tracker.",t)}},{key:"removeTracker",value:function(t){t.off("*",ut),t.dispose();var e=st.indexOf(t);-1!==e&&st.splice(e,1)}},{key:"getTrackers",value:function(){return st}},{key:"send",value:function(t,e,r){return U(t,rt({actionName:e},r))}},{key:"sendError",value:function(t){return U("VideoErrorAction",rt({actionName:"ERROR"},t))}}],null&&it(t.prototype,null),e&&it(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),st=[];function ut(t){try{var e=function(t){var e={};for(var r in t)null!==t[r]&&void 0!==t[r]&&(e[r]=t[r]);return e}(t.data);c.level<=c.Levels.DEBUG?c.notice("Sent",t.type,e):c.notice("Sent",t.type),ot.send(t.eventType,t.type,e)}catch(t){c.error("Error in event handler:",t.message)}}const ct=ot;function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ft(t){return function(t){if(Array.isArray(t))return yt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ht(t)||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.")}()}function dt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,s=[],u=!0,c=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(t,e)||ht(t,e)||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.")}()}function ht(t,e){if(t){if("string"==typeof t)return yt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yt(t,e):void 0}}function yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,pt(n.key),n)}}function pt(t){var e=function(t){if("object"!=lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lt(e)?e:e+""}const mt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0},(e=[{key:"reset",value:function(){this._viewSession=null,this._viewCount=0,this._isAd=!1,this.numberOfErrors=0,this.numberOfAds=0,this.numberOfVideos=0,this.totalPlaytime=0,this.weightedAverageBitrate=0,this.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,this.startupTime=null,this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.weightedBitrate=0,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this._downloadBitrates=[],this._lastDownloadBitrate=null,this.totalSwitchUps=0,this.totalSwitchDowns=0,this.totalPauseTime=0,this._playedRenditions=new Set,this.hadStartupError=!1,this.hadPlaybackError=!1,this.totalRebufferingTime=0,this.resetFlags(),this.resetChronos()}},{key:"resetFlags",value:function(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}},{key:"resetChronos",value:function(){this.timeSinceRequested=new k,this.timeSinceStarted=new k,this.timeSincePaused=new k,this.timeSinceSeekBegin=new k,this.timeSinceBufferBegin=new k,this.timeSinceAdBreakStart=new k,this.timeSinceLastDownload=new k,this.timeSinceLastHeartbeat=new k,this.timeSinceLastRenditionChange=new k,this.timeSinceLastAdQuartile=new k,this.timeSinceLastAd=new k,this.timeSinceLastError=new k,this.timeSinceLastAdError=new k,this.timeSinceResumed=new k,this.timeSinceSeekEnd=new k,this.playtimeSinceLastEvent=new k,this.customTimeSinceAttributes={},this.elapsedTime=new k,this.bufferElapsedTime=new k,this._totalAdPlaytime=new k}},{key:"isAd",value:function(){return this._isAd}},{key:"setIsAd",value:function(t){this._isAd=t}},{key:"setTimeSinceAttribute",value:function(t){this.customTimeSinceAttributes[t]=new k,this.customTimeSinceAttributes[t].start()}},{key:"removeTimeSinceAttribute",value:function(t){delete this.customTimeSinceAttributes[t]}},{key:"getViewSession",value:function(){if(!this._viewSession){var t=(new Date).getTime(),e=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=t+"-"+e}return this._viewSession}},{key:"getViewId",value:function(){return this.getViewSession()+"-"+this._viewCount}},{key:"getStateAttributes",value:function(t){t=t||{},this.isAd()?(this.isRequested&&(t.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),t.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(t.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(t.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(t.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(t.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(t.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),this.numberOfErrors>0&&this.timeSinceLastAdError.startTime>0&&(t.timeSinceLastAdError=this.timeSinceLastAdError.getDeltaTime()),t.numberOfAds=this.numberOfAds):(this.isRequested&&(t.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),t.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(t.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(t.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(t.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(t.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),t.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),this.numberOfErrors>0&&this.timeSinceLastError.startTime>0&&(t.timeSinceLastError=this.timeSinceLastError.getDeltaTime()),t.numberOfVideos=this.numberOfVideos),t.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?t.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():t.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=t.playtimeSinceLastEvent,t.totalPlaytime=this.totalPlaytime);for(var e=0,r=Object.entries(this.customTimeSinceAttributes);e<r.length;e++){var n=dt(r[e],2),i=n[0],a=n[1];t[i]=a.getDeltaTime()}return t}},{key:"getQoeAttributes",value:function(t){t=t||{};var e={};try{if(null!==this.startupTime&&(e.startupTime=this.startupTime),this.peakBitrate>0&&(e.peakBitrate=this.peakBitrate),e.hadStartupError=this.hadStartupError,e.hadPlaybackError=this.hadPlaybackError,e.totalRebufferingTime=this.totalRebufferingTime,e.rebufferingRatio=this.totalPlaytime>0?this.totalRebufferingTime/this.totalPlaytime*100:0,e.totalPlaytime=this.totalPlaytime,e.averageBitrate=this.weightedBitrate,e.numberOfErrors=this.numberOfErrors,this._downloadBitrates.length>0){var r=this._downloadBitrates.reduce(function(t,e){return t+e},0);e.avgDownloadRate=Math.round(r/this._downloadBitrates.length),e.minDownloadRate=Math.min.apply(Math,ft(this._downloadBitrates)),e.maxDownloadRate=Math.max.apply(Math,ft(this._downloadBitrates))}e.totalSwitchUps=this.totalSwitchUps,e.totalSwitchDowns=this.totalSwitchDowns,e.totalPauseTime=this.timeSincePaused.getDuration(),e.totalViewSessionTime=this.totalPlaytime,e.totalRenditions=this._playedRenditions.size,e.qoeAggregateVersion="1.1.0"}catch(t){c.error("Failed to add attributes for QOE KPIs",t.message)}return t.qoe=e,t}},{key:"calculateBufferType",value:function(t){var e;return e=t?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",c.debug("Buffer Type = "+e),e}},{key:"goViewCountUp",value:function(){this._viewCount++}},{key:"goPlayerReady",value:function(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}},{key:"goRequest",value:function(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}},{key:"goStart",value:function(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}},{key:"goEnd",value:function(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}},{key:"goPause",value:function(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}},{key:"goResume",value:function(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}},{key:"goBufferStart",value:function(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}},{key:"goBufferEnd",value:function(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),!this.isAd()&&this.initialBufferingHappened&&(this.totalRebufferingTime+=this.timeSinceBufferBegin.stopTime-this.timeSinceBufferBegin.startTime),0))}},{key:"goSeekStart",value:function(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}},{key:"goSeekEnd",value:function(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}},{key:"goAdBreakStart",value:function(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}},{key:"goAdBreakEnd",value:function(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}},{key:"goDownload",value:function(){this.timeSinceLastDownload.start()}},{key:"goHeartbeat",value:function(){this.timeSinceLastHeartbeat.start()}},{key:"goRenditionChange",value:function(){this.timeSinceLastRenditionChange.start()}},{key:"goAdQuartile",value:function(){this.timeSinceLastAdQuartile.start()}},{key:"goError",value:function(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}},{key:"goLastAd",value:function(){this.timeSinceLastAd.start()}},{key:"trackContentBitrateState",value:function(t){if(t&&"number"==typeof t){this.peakBitrate=Math.max(this.peakBitrate,t);var e=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){var r=e-this._lastBitrateChangeTimestamp;r>0&&(this.partialAverageBitrate+=this._lastBitrate*r,this._totalBitrateDuration+=r),this._lastBitrateChangeTimestamp=null}return void(this._lastBitrate=t)}if(null===this._lastBitrateChangeTimestamp&&null!==this._lastBitrate&&(this._lastBitrateChangeTimestamp=e),null!==this._lastBitrate&&this._lastBitrate!==t&&null!==this._lastBitrateChangeTimestamp){var n=e-this._lastBitrateChangeTimestamp;n>0&&(this.partialAverageBitrate+=this._lastBitrate*n,this._totalBitrateDuration+=n),this._lastBitrateChangeTimestamp=e}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=e),this._lastBitrate=t;var i=this.partialAverageBitrate,a=this._totalBitrateDuration,o=e-this._lastBitrateChangeTimestamp;o>0&&(i+=t*o,a+=o),this.weightedBitrate=a>0?Math.round(i/a):t}}},{key:"trackDownloadRate",value:function(t){!t||"number"!=typeof t||t<=0||t!==this._lastDownloadBitrate&&(this._downloadBitrates.push(t),this._lastDownloadBitrate=t)}},{key:"addPlayedRendition",value:function(t,e){t&&e&&this._playedRenditions.add("".concat(t,"x").concat(e))}},{key:"resetViewIdTrackedState",value:function(){this.peakBitrate=0,this.startupTime=null,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.weightedBitrate=0,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this._downloadBitrates=[],this._lastDownloadBitrate=null,this.totalSwitchUps=0,this.totalSwitchDowns=0,this.timeSincePaused.reset(),this._playedRenditions=new Set}},{key:"clearTotalAdsTime",value:function(){c.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}},{key:"totalAdTime",value:function(){return this._totalAdPlaytime.getDuration()}},{key:"startAdsTime",value:function(){return c.debug("startAdsTime"),this._totalAdPlaytime.start()}},{key:"stopAdsTime",value:function(){return c.debug("stopAdsTime"),this._totalAdPlaytime.stop()}},{key:"setStartupTime",value:function(t){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-t,0))}}])&&vt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function gt(t){return gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gt(t)}function bt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function St(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?bt(Object(r),!0).forEach(function(e){Et(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):bt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Et(t,e,r){return(e=At(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Tt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,At(n.key),n)}}function At(t){var e=function(t){if("object"!=gt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=gt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}function wt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(wt=function(){return!!t})()}function kt(t){return kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},kt(t)}function Ot(t,e){return Ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ot(t,e)}var _t=function(t){function e(t,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=function(t,e,r){return e=kt(e),function(t,e){if(e&&("object"==gt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,wt()?Reflect.construct(e,r||[],kt(t).constructor):e.apply(t,r))}(this,e)).state=new mt,n.adsTracker=null,n._lastBufferType=null,n._userId=null,n._src=null,r=r||{},n.setOptions(r),t&&n.setPlayer(t,r.tag),c.notice("Tracker "+n.getTrackerName()+" v"+n.getTrackerVersion()+" is ready."),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ot(t,e)}(e,t),r=e,n=[{key:"setUserId",value:function(t){this._userId=t}},{key:"setOptions",value:function(t){t&&(t.adsTracker&&this.setAdsTracker(t.adsTracker),"boolean"==typeof t.isAd&&this.setIsAd(t.isAd),void 0!==t.src&&(null!==this._src&&this._src!==t.src?c.warn("setOptions: src is locked to '".concat(this._src,"'. Ignoring override '").concat(t.src,"'.")):(this._src=t.src,this.adsTracker&&null==this.adsTracker._src&&(this.adsTracker._src=this._src))),N.prototype.setOptions.apply(this,arguments))}},{key:"setPlayer",value:function(t,e){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof t&&(t=document.getElementById(t)),"string"==typeof e&&(e=document.getElementById(e))),e=e||t,this.player=t,this.tag=e,this.registerListeners()}},{key:"isAd",value:function(){return this.state.isAd()}},{key:"setIsAd",value:function(t){this.state.setIsAd(t)}},{key:"setAdsTracker",value:function(t){this.disposeAdsTracker(),t&&(this.adsTracker=t,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,null!=this._src&&null==t._src&&(t._src=this._src),this.adsTracker.on("*",Pt.bind(this)))}},{key:"disposeAdsTracker",value:function(){this.adsTracker&&(this.adsTracker.off("*",Pt),this.adsTracker.dispose())}},{key:"dispose",value:function(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}},{key:"registerListeners",value:function(){}},{key:"unregisterListeners",value:function(){}},{key:"getViewId",value:function(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}},{key:"getViewSession",value:function(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}},{key:"getVideoId",value:function(){return null}},{key:"getTitle",value:function(){return null}},{key:"isLive",value:function(){return null}},{key:"getBitrate",value:function(){return null}},{key:"getManifestBitrate",value:function(){return null}},{key:"getSegmentDownloadBitrate",value:function(){return null}},{key:"getNetworkDownloadBitrate",value:function(){return null}},{key:"getWebkitBitrate",value:function(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){var t;if(this._lastWebkitBitrate){var e=(t=this.tag.webkitVideoDecodedByteCount)-this._lastWebkitBitrate,r=this.getHeartbeat()/1e3;t=Math.round(e/r*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,t||null}}},{key:"getRenditionName",value:function(){return null}},{key:"getRenditionBitrate",value:function(){return null}},{key:"getRenditionShift",value:function(t){var e,r=this.getManifestBitrate();return this.isAd()?(e=this._lastAdRendition,t&&(this._lastAdRendition=r)):(e=this._lastRendition,t&&(this._lastRendition=r)),r&&e?r>e?"up":r<e?"down":null:null}},{key:"getRenditionHeight",value:function(){return this.tag?this.tag.videoHeight:null}},{key:"getRenditionWidth",value:function(){return this.tag?this.tag.videoWidth:null}},{key:"getDuration",value:function(){return this.tag?this.tag.duration:null}},{key:"getPlayhead",value:function(){return this.tag?this.tag.currentTime:null}},{key:"getLanguage",value:function(){return null}},{key:"getSrc",value:function(){return this.tag?this.tag.currentSrc:null}},{key:"getPlayrate",value:function(){return this.tag?this.tag.playbackRate:null}},{key:"isMuted",value:function(){return this.tag?this.tag.muted:null}},{key:"isFullscreen",value:function(){return null}},{key:"getCdn",value:function(){return null}},{key:"getPlayerName",value:function(){return this.getTrackerName()}},{key:"getPlayerVersion",value:function(){return p}},{key:"getFps",value:function(){return null}},{key:"isAutoplayed",value:function(){return this.tag?this.tag.autoplay:null}},{key:"getPreload",value:function(){return this.tag?this.tag.preload:null}},{key:"getAdQuartile",value:function(){return null}},{key:"getAdPosition",value:function(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}},{key:"getAdPartner",value:function(){return null}},{key:"getAdCreativeId",value:function(){return null}},{key:"getInstrumentationProvider",value:function(){return null}},{key:"getInstrumentationName",value:function(){return null}},{key:"getInstrumentationVersion",value:function(){return null}},{key:"getAttributes",value:function(t,e){if(void 0===(t=N.prototype.getAttributes.apply(this,arguments)).isAd&&(t.isAd=this.isAd()),t.viewSession=this.getViewSession(),t.viewId=this.getViewId(),t.playerName=this.getPlayerName(),t.playerVersion=this.getPlayerVersion(),t["instrumentation.provider"]=this.getInstrumentationProvider(),t["instrumentation.name"]=this.getInstrumentationName(),t["instrumentation.version"]=this.getInstrumentationVersion(),t["enduser.id"]=this._userId,t.src=this._src||"Browser","customAction"===e)return t;try{t.pageUrl=window.location.href}catch(t){}for(var r in this.isAd()?(t.adId=this.getVideoId(),t.adTitle=this.getTitle(),t.adSrc=this.getSrc(),t.adCdn=this.getCdn(),this.state.isStarted&&(t.adBitrate=this.getBitrate()||0),t.adRenditionName=this.getRenditionName(),t.adRenditionHeight=this.getRenditionHeight(),t.adRenditionWidth=this.getRenditionWidth(),t.adDuration=this.getDuration(),t.adPlayhead=this.getPlayhead(),t.adLanguage=this.getLanguage(),t.adIsMuted=this.isMuted(),t.adFps=this.getFps(),t.adPosition=this.getAdPosition(),t.adCreativeId=this.getAdCreativeId(),t.adPartner=this.getAdPartner()):(t.contentId=this.getVideoId(),t.contentTitle=this.getTitle(),t.contentSrc=this.getSrc(),t.contentCdn=this.getCdn(),t.contentPlayhead=this.getPlayhead(),t.contentIsLive=this.isLive(),this.state.isStarted&&(t.contentBitrate=this.getBitrate()||0,t.contentManifestBitrate=this.getManifestBitrate()||0,t.contentSegmentDownloadBitrate=this.getSegmentDownloadBitrate()||0,t.contentNetworkDownloadBitrate=this.getNetworkDownloadBitrate()||0),t.contentRenditionName=this.getRenditionName(),t.contentRenditionHeight=this.getRenditionHeight(),t.contentRenditionWidth=this.getRenditionWidth(),t.contentDuration=this.getDuration(),t.contentLanguage=this.getLanguage(),t.contentPlayrate=this.getPlayrate(),t.contentIsFullscreen=this.isFullscreen(),t.contentIsMuted=this.isMuted(),t.contentIsAutoplayed=this.isAutoplayed(),t.contentPreload=this.getPreload(),t.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(t.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(t),this.state.isStarted&&!this.isAd()&&(this.state.trackContentBitrateState(t.contentBitrate),this.state.trackDownloadRate(t.contentNetworkDownloadBitrate),this.state.addPlayedRendition(t.contentRenditionHeight,t.contentRenditionWidth)),this.customData)t[r]=this.customData[r];if(!this.isAd()){this.state.getQoeAttributes(t);var n=t.qoe;for(var i in this.customData)n[i]=this.customData[i]}return t}},{key:"sendCustom",value:function(t,e,r){r=r||{},this.sendVideoCustomAction(t,r),this.state.setTimeSinceAttribute(e)}},{key:"sendPlayerReady",value:function(t){this.state.goPlayerReady()&&(t=t||{},this.sendVideoAction(e.Events.PLAYER_READY,t))}},{key:"sendRequest",value:function(t){var r;this.state.goRequest()&&(this.isAd()?(r=e.Events.AD_REQUEST,this.sendVideoAdAction(r,t)):(r=e.Events.CONTENT_REQUEST,this.sendVideoAction(r,t)))}},{key:"sendStart",value:function(t){var r=this;if(this.state.goStart()){var n;if(this.isAd())n=e.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(n,t),this.state.startAdsTime();else{var i;n=e.Events.CONTENT_START;var a,o=0;this.adsTracker&&((this.adsTracker.state.isPlaying||this.adsTracker.state.isBuffering)&&(this.adsTracker.state.stopAdsTime(),this.adsTracker.state.isPlaying=!1,this.adsTracker.state.isBuffering=!1),o=null!==(a=this.adsTracker.state.totalAdTime())&&void 0!==a?a:0),this.state.setStartupTime(o),this.sendVideoAction(n,t);var s=null===(i=this.getHarvester)||void 0===i?void 0:i.call(this);null==s||s.setBeforeDrainCallback(function(){if(r.state){var t=r.state.getQoeAttributes({}).qoe;s.refreshQoeKpis(t,r.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}},{key:"sendEnd",value:function(t){var r;if(this.state.goEnd()&&(t=t||{},this.isAd()?(r=e.Events.AD_END,t.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0,this.parentTracker.state.timeSincePaused.reset()),this.state.stopAdsTime()):(r=e.Events.CONTENT_END,t.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0,!this.isAd())){var n,i,a,o=null===(n=this.getHarvester)||void 0===n?void 0:n.call(this);null==o||null===(i=o.forceNextQoeCycle)||void 0===i||i.call(o),null==o||null===(a=o.setBeforeDrainCallback)||void 0===a||a.call(o,null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState()}}},{key:"sendPause",value:function(t){if(this.state.goPause()){var r=this.isAd()?e.Events.AD_PAUSE:e.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t)}}},{key:"sendResume",value:function(t){var r;this.state.goResume()&&(t=t||{},this.isAd()?(r=e.Events.AD_RESUME,t.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(r=e.Events.CONTENT_RESUME,t.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t))}},{key:"sendBufferStart",value:function(t){var r;this.state.goBufferStart()&&(t=t||{},r=this.isAd()?e.Events.AD_BUFFER_START:e.Events.CONTENT_BUFFER_START,t=this.buildBufferAttributes(t),this._lastBufferType=t.bufferType,this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t))}},{key:"sendBufferEnd",value:function(t){var r;this.state.goBufferEnd()&&(t=t||{},this.isAd()?(r=e.Events.AD_BUFFER_END,t.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(r=e.Events.CONTENT_BUFFER_END,t.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),t=this.buildBufferAttributes(t),null!=this._lastBufferType&&(t.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t),this.state.initialBufferingHappened=!0)}},{key:"buildBufferAttributes",value:function(t){return null==t.timeSinceStarted||t.timeSinceStarted<100?t.isInitialBuffering=!this.state.initialBufferingHappened:t.isInitialBuffering=!1,t.bufferType=this.state.calculateBufferType(t.isInitialBuffering),t.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),t.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),t}},{key:"sendSeekStart",value:function(t){var r;this.state.goSeekStart()&&(r=this.isAd()?e.Events.AD_SEEK_START:e.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t))}},{key:"sendSeekEnd",value:function(t){var r;this.state.goSeekEnd()&&(t=t||{},this.isAd()?(r=e.Events.AD_SEEK_END,t.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(r=e.Events.CONTENT_SEEK_END,t.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t))}},{key:"sendDownload",value:function(t){(t=t||{}).state||c.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(e.Events.DOWNLOAD,t),this.state.goDownload()}},{key:"sendError",value:function(t){(t=t||{}).isAd=this.isAd(),this.state.goError();var r=this.isAd()?e.Events.AD_ERROR:e.Events.CONTENT_ERROR;this.sendVideoErrorAction(r,t)}},{key:"sendRenditionChanged",value:function(t){(t=t||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime();var r,n=t,i=n.oldBitrate,a=n.newBitrate;this.isAd()||void 0===i||void 0===a||(a>i?(t.shift="up",this.state.totalSwitchUps+=1):a<i?(t.shift="down",this.state.totalSwitchDowns+=1):t.shift=null),delete t.oldBitrate,delete t.newBitrate,r=this.isAd()?e.Events.AD_RENDITION_CHANGE:e.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(r,t):this.sendVideoAction(r,t),this.state.goRenditionChange()}},{key:"sendHeartbeat",value:function(t){if(this.state.isRequested){var r,n=this.getHeartbeat();this.state._hb=!0,n=this.adjustElapsedTimeForPause(n),this.isAd()?(r=e.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(r,t):this.sendVideoAdAction(r,St({elapsedTime:n},t))):(r=e.Events.CONTENT_HEARTBEAT,this.sendVideoAction(r,St({elapsedTime:n},t))),this.state.goHeartbeat()}}},{key:"adjustElapsedTimeForPause",value:function(t){return this.state._acc&&(t-=this.state._acc,this.state._acc=0),this.state.isPaused&&((t-=this.state.elapsedTime.getDeltaTime())<10&&(t=0),this.state.elapsedTime.start()),this.state._bufferAcc?(t-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((t-=this.state.bufferElapsedTime.getDeltaTime())<5&&(t=0),this.state.bufferElapsedTime.start()),Math.max(0,t)}},{key:"sendAdBreakStart",value:function(t){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(e.Events.AD_BREAK_START,t))}},{key:"sendAdBreakEnd",value:function(t){this.isAd()&&this.state.goAdBreakEnd()&&((t=t||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(e.Events.AD_BREAK_END,t),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}},{key:"sendAdQuartile",value:function(t){this.isAd()&&((t=t||{}).quartile||c.warn("Called sendAdQuartile without { quartile: xxxxx }."),t.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(e.Events.AD_QUARTILE,t),this.state.goAdQuartile())}},{key:"sendAdClick",value:function(t){this.isAd()&&((t=t||{}).url||c.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(e.Events.AD_CLICK,t))}}],n&&Tt(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(N);function Pt(t){t.type!==_t.Events.AD_ERROR?this.sendVideoAdAction(t.type,t.data):this.sendVideoErrorAction(t.type,t.data)}_t.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"};const Rt=_t;function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function jt(t){var e=function(t){if("object"!=Bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}var Nt=v.MAX_PAYLOAD_SIZE,Ct=v.MAX_EVENTS_PER_BATCH,It=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.buffer=[],this.maxPayloadSize=Nt,this.maxEventsPerBatch=Ct,this.currentPayloadSize=0,this.totalEvents=0,this.smartHarvestPayloadThreshold=Math.floor(.6*this.maxPayloadSize),this.overflowPayloadThreshold=Math.floor(.9*this.maxPayloadSize),this.smartHarvestEventThreshold=Math.floor(.6*this.maxEventsPerBatch),this.overflowEventThreshold=Math.floor(.9*this.maxEventsPerBatch),this.onSmartHarvestTrigger=null},e=[{key:"addOrReplaceByActionName",value:function(t,e){var r=this.buffer.findIndex(function(e){return e.actionName===t});try{return-1===r?this.add(e):this.add(e,r),!0}catch(t){return c.error("Failed to set or replace the event to buffer:",t.message),!1}}},{key:"addOrReplaceByActionNameAndViewId",value:function(t,e,r){var n=this.buffer.findIndex(function(r){return r.actionName===t&&r.viewId===e});try{return-1===n?this.add(r):this.add(r,n),!0}catch(t){return c.error("Failed to set or replace the event to buffer:",t.message),!1}}},{key:"findByActionNameAndViewId",value:function(t,e){return this.buffer.find(function(r){return r.actionName===t&&r.viewId===e})||null}},{key:"findByActionName",value:function(t){return this.buffer.find(function(e){return e.actionName===t})||null}},{key:"add",value:function(t,e){try{var r=L(t),n=this.currentPayloadSize+r>=this.maxPayloadSize,i=this.totalEvents+1>=this.maxEventsPerBatch;if((n||i)&&this.makeRoom(r),null!=e&&e>-1){var a=L(this.buffer[e]);this.buffer[e]=t,this.currentPayloadSize+=r-a}else this.buffer.push(t),this.totalEvents++,this.currentPayloadSize+=r;return this.checkSmartHarvestTrigger(),!0}catch(t){return c.error("Failed to add event to buffer:",t.message),!1}}},{key:"checkSmartHarvestTrigger",value:function(){var t=this.currentPayloadSize/this.maxPayloadSize,e=this.totalEvents/this.maxEventsPerBatch,r=this.currentPayloadSize>=this.overflowPayloadThreshold,n=this.totalEvents>=this.overflowEventThreshold;if(r||n){var i=r?"payload ".concat(this.currentPayloadSize,"/").concat(this.maxPayloadSize," bytes (").concat(Math.round(100*t),"%)"):"events ".concat(this.totalEvents,"/").concat(this.maxEventsPerBatch," (").concat(Math.round(100*e),"%)");c.warn("OVERFLOW PREVENTION: ".concat(i," - Emergency harvest triggered")),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{var a=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,o=this.totalEvents>=this.smartHarvestEventThreshold;(a||o)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}},{key:"setSmartHarvestCallback",value:function(t){this.onSmartHarvestTrigger=t}},{key:"drain",value:function(){try{var t=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,t}catch(t){return c.error("Failed to drain events from buffer:",t.message),[]}}},{key:"isEmpty",value:function(){return 0===this.totalEvents}},{key:"size",value:function(){return this.totalEvents}},{key:"clear",value:function(){this.buffer=[],this.totalEvents=0}},{key:"makeRoom",value:function(t){if(t>this.maxPayloadSize)c.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+t>=this.maxPayloadSize)&&this.buffer.length>0;){var e=L(this.buffer.shift());this.totalEvents--,this.currentPayloadSize-=e,c.warn("Event buffer full, oldest event removed.")}}}],e&&Dt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}function Vt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Ht(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Vt(Object(r),!0).forEach(function(e){Ft(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Vt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Ft(t,e,r){return(e=qt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Qt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qt(n.key),n)}}function qt(t){var e=function(t){if("object"!=Lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Lt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}var Ut=v.MAX_PAYLOAD_SIZE,Gt=v.MAX_EVENTS_PER_BATCH,Mt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.retryQueue=[],this.maxQueueSize=Gt,this.maxQueueSizeBytes=Ut},(e=[{key:"addFailedEvents",value:function(t){try{var e=Array.isArray(t)?t:[t];c.notice("Adding ".concat(e.length," failed events to retry queue"),{queueSizeBefore:this.retryQueue.length});var r,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return xt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();for(var a=L(i);L(this.retryQueue)+a>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push(Ht({},i))}}catch(t){n.e(t)}finally{n.f()}}catch(t){c.error("Failed to add events to retry queue:",t.message)}}},{key:"discardEvent",value:function(t,e){c.warn("Discarded event",{reason:e,eventType:t.eventType})}},{key:"evictOldestEvent",value:function(){if(this.retryQueue.length>0){var t=this.retryQueue.shift();this.discardEvent(t,"Queue full - evicted oldest")}}},{key:"getRetryEventsToFit",value:function(t,e){for(var r=[],n=0,i=0,a=this.retryQueue.length-1;a>=0;a--){var o=this.retryQueue[a];if(i>=e)break;var s=L(o);if(n+s>t)break;r.unshift(o),n+=s,i++,this.retryQueue.splice(a,1)}return r}},{key:"getQueueSize",value:function(){return this.retryQueue.length}},{key:"clear",value:function(){this.retryQueue=[]}}])&&Qt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function zt(t,e){return e&&0!==e.length?e.reduce(function(t,e){var r;try{if(e.regex instanceof RegExp){var n=e.regex.flags.includes("g")?e.regex.flags:e.regex.flags+"g";r=new RegExp(e.regex.source,n)}else r=new RegExp(e.regex,"g")}catch(r){return c.warn("applyObfuscationRules: invalid regex, skipping rule:",e.regex,r.message),t}return t.replace(r,e.replacement)},t):t}function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Wt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Yt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Wt(Object(r),!0).forEach(function(e){Xt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Wt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Xt(t,e,r){return(e=re(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zt(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return $t(c,"_invoke",function(r,n,i){var a,s,u,c=0,l=i||[],f=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return a=e,s=0,u=t,d.n=r,o}};function h(r,n){for(s=r,u=n,e=0;!f&&c&&!i&&e<l.length;e++){var i,a=l[e],h=d.p,y=a[2];r>3?(i=y===n)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((i=r<2&&h<a[1])?(s=0,d.v=n,d.n=a[1]):h<y&&(i=r<3||a[0]>n||n>y)&&(a[4]=r,a[5]=n,d.n=y,s=0))}if(i||r>1)return o;throw f=!0,n}return function(i,l,y){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),s=l,u=y;(e=s<2?t:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(i="next"),e=a[i]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=t}else if((e=(f=d.n<0)?u:r.call(n,d))!==o)break}catch(e){a=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,i,a),!0),c}var o={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):($t(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,$t(t,i,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,$t(f,"constructor",c),$t(c,"constructor",u),u.displayName="GeneratorFunction",$t(c,i,"GeneratorFunction"),$t(f),$t(f,i,"Generator"),$t(f,n,function(){return this}),$t(f,"toString",function(){return"[object Generator]"}),(Zt=function(){return{w:a,m:d}})()}function $t(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}$t=function(t,e,r,n){function a(e,r){$t(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},$t(t,e,r,n)}function Jt(t,e,r,n,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function te(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var a=t.apply(e,r);function o(t){Jt(a,n,i,o,s,"next",t)}function s(t){Jt(a,n,i,o,s,"throw",t)}o(void 0)})}}function ee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,re(n.key),n)}}function re(t){var e=function(t){if("object"!=Kt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Kt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kt(e)?e:e+""}var ne=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"send",value:(a=te(Zt().m(function t(e,r){var n,i,a,o,s,u;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=e.url,i=e.payload,a=e.options,o=void 0===a?{}:a,t.p=1,n&&i){t.n=2;break}throw new Error("URL and payload are required");case 2:return s={url:n,payload:i,options:o,callback:r},t.n=3,this.executeRequest(s);case 3:t.n=5;break;case 4:t.p=4,u=t.v,c.error("Failed to send request:",u.message),r({retry:!1,status:0,error:u.message});case 5:return t.a(2)}},t,this,[[1,4]])})),function(t,e){return a.apply(this,arguments)})},{key:"executeRequest",value:(i=te(Zt().m(function t(e){var r,n,i,a,o,s,u,c,l,f,d,h;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=e.url,n=e.payload,i=e.options,e.callback,a=Date.now(),t.p=1,s=zt(JSON.stringify(n.body),null===(o=window.NRVIDEO)||void 0===o||null===(o=o.config)||void 0===o?void 0:o.obfuscate),!i.isFinalHarvest||!navigator.sendBeacon){t.n=3;break}return t.n=2,this.sendWithBeacon(r,s);case 2:return u=t.v,c={success:u,status:u?204:0},this.handleRequestComplete(e,c,a),t.a(2);case 3:return t.n=4,this.fetchWithTimeout(r,{method:"POST",body:s,headers:{"Content-Type":"application/json"},keepalive:i.isFinalHarvest},1e4);case 4:l=t.v,f={success:l.ok,status:l.status,statusText:l.statusText},this.handleRequestComplete(e,f,a),t.n=6;break;case 5:t.p=5,h=t.v,d={success:!1,status:0,error:h.message},this.handleRequestComplete(e,d,a);case 6:return t.a(2)}},t,this,[[1,5]])})),function(t){return i.apply(this,arguments)})},{key:"handleRequestComplete",value:function(t,e){(0,t.callback)({retry:!e.success&&(0===e.status||function(t){switch(t){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return t>=502&&t<=504||t>=512&&t<=530}(e.status)),status:e.status,error:e.error})}},{key:"sendWithBeacon",value:(n=te(Zt().m(function t(e,r){var n;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.a(2,navigator.sendBeacon(e,r));case 1:return t.p=1,n=t.v,c.warn("sendBeacon failed, falling back to fetch:",n.message),t.a(2,!1)}},t,null,[[0,1]])})),function(t,e){return n.apply(this,arguments)})},{key:"fetchWithTimeout",value:(r=te(Zt().m(function t(e,r,n){var i,a,o,s;return Zt().w(function(t){for(;;)switch(t.p=t.n){case 0:return i=new AbortController,a=setTimeout(function(){return i.abort()},n),t.p=1,t.n=2,fetch(e,Yt(Yt({},r),{},{signal:i.signal}));case 2:return o=t.v,clearTimeout(a),t.a(2,o);case 3:if(t.p=3,s=t.v,clearTimeout(a),"AbortError"!==s.name){t.n=4;break}throw new Error("Request timeout after ".concat(n,"ms"));case 4:throw s;case 5:return t.a(2)}},t,null,[[1,3]])})),function(t,e,n){return r.apply(this,arguments)})}],e&&ee(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i,a}();function ie(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ae(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ae(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function ae(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function oe(t,e){var r=t[e.viewId];if(!r)return!1;var n,i=ie(v.QOE_KPI_KEYS);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(e[a]!==r[a])return!1}}catch(t){i.e(t)}finally{i.f()}return!0}function se(t,e){var r,n={},i=ie(v.QOE_KPI_KEYS);try{for(i.s();!(r=i.n()).done;){var a=r.value;n[a]=e[a]}}catch(t){i.e(t)}finally{i.f()}t[e.viewId]=n}function ue(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return ce(c,"_invoke",function(r,n,i){var a,s,u,c=0,l=i||[],f=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return a=e,s=0,u=t,d.n=r,o}};function h(r,n){for(s=r,u=n,e=0;!f&&c&&!i&&e<l.length;e++){var i,a=l[e],h=d.p,y=a[2];r>3?(i=y===n)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((i=r<2&&h<a[1])?(s=0,d.v=n,d.n=a[1]):h<y&&(i=r<3||a[0]>n||n>y)&&(a[4]=r,a[5]=n,d.n=y,s=0))}if(i||r>1)return o;throw f=!0,n}return function(i,l,y){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),s=l,u=y;(e=s<2?t:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(i="next"),e=a[i]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=t}else if((e=(f=d.n<0)?u:r.call(n,d))!==o)break}catch(e){a=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,i,a),!0),c}var o={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(ce(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,ce(t,i,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,ce(f,"constructor",c),ce(c,"constructor",u),u.displayName="GeneratorFunction",ce(c,i,"GeneratorFunction"),ce(f),ce(f,i,"Generator"),ce(f,n,function(){return this}),ce(f,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:a,m:d}})()}function ce(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}ce=function(t,e,r,n){function a(e,r){ce(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},ce(t,e,r,n)}function le(t,e,r,n,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function fe(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var a=t.apply(e,r);function o(t){le(a,n,i,o,s,"next",t)}function s(t){le(a,n,i,o,s,"throw",t)}o(void 0)})}}function de(t){return de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},de(t)}function he(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ye(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?he(Object(r),!0).forEach(function(e){ve(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):he(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function ve(t,e,r){return(e=Ae(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pe(t){return function(t){if(Array.isArray(t))return me(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return me(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?me(t,e):void 0}}(t)||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.")}()}function me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ge(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return be(c,"_invoke",function(r,n,i){var a,s,u,c=0,l=i||[],f=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return a=e,s=0,u=t,d.n=r,o}};function h(r,n){for(s=r,u=n,e=0;!f&&c&&!i&&e<l.length;e++){var i,a=l[e],h=d.p,y=a[2];r>3?(i=y===n)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((i=r<2&&h<a[1])?(s=0,d.v=n,d.n=a[1]):h<y&&(i=r<3||a[0]>n||n>y)&&(a[4]=r,a[5]=n,d.n=y,s=0))}if(i||r>1)return o;throw f=!0,n}return function(i,l,y){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),s=l,u=y;(e=s<2?t:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(i="next"),e=a[i]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=t}else if((e=(f=d.n<0)?u:r.call(n,d))!==o)break}catch(e){a=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,i,a),!0),c}var o={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(be(e={},n,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,be(t,i,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,be(f,"constructor",c),be(c,"constructor",u),u.displayName="GeneratorFunction",be(c,i,"GeneratorFunction"),be(f),be(f,i,"Generator"),be(f,n,function(){return this}),be(f,"toString",function(){return"[object Generator]"}),(ge=function(){return{w:a,m:d}})()}function be(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}be=function(t,e,r,n){function a(e,r){be(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},be(t,e,r,n)}function Se(t,e,r,n,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ee(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var a=t.apply(e,r);function o(t){Se(a,n,i,o,s,"next",t)}function s(t){Se(a,n,i,o,s,"throw",t)}o(void 0)})}}function Te(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ae(n.key),n)}}function Ae(t){var e=function(t){if("object"!=de(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=de(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==de(e)?e:e+""}var we=function(){return t=function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.eventBuffer=e,this.retryQueueHandler=new Mt,this.httpClient=new ne,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof It&&this.eventBuffer.setSmartHarvestCallback(function(t,e){return r.triggerSmartHarvest(t,e)}),this.harvestCycle=v.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.timer=function(t){var e=t.onTick,r=t.errorLabel,n=!1,i=null,a=t.interval;function o(){n&&(i=setTimeout(fe(ue().m(function t(){var a;return ue().w(function(t){for(;;)switch(t.p=t.n){case 0:return i=null,t.p=1,t.n=2,e();case 2:t.n=4;break;case 3:t.p=3,a=t.v,c.error("".concat(r,": scheduled tick failed:"),a.message);case 4:return t.p=4,n&&o(),t.f(4);case 5:return t.a(2)}},t,null,[[1,3,4,5]])})),a))}return{start:function(){n||(n=!0,o())},stop:function(){n=!1,i&&(clearTimeout(i),i=null)},cancelAndReschedule:function(){i&&(clearTimeout(i),i=null),n&&o()},updateInterval:function(t){"number"!=typeof t||t<=0||(a=t,n&&i&&(clearTimeout(i),i=null,o()))},isRunning:function(){return n}}}({interval:this.harvestCycle,onTick:function(){return r.onHarvestInterval()},errorLabel:"HarvestScheduler"}),this.setupPageLifecycleHandlers()},e=[{key:"isStarted",get:function(){return this.timer.isRunning()}},{key:"startScheduler",value:function(){this.timer.isRunning()?c.warn("Harvest scheduler is already started"):(c.notice("Starting harvest scheduler",{harvestCycle:this.harvestCycle,eventBufferSize:this.eventBuffer?this.eventBuffer.size():0}),this.timer.start())}},{key:"stopScheduler",value:function(){this.timer.isRunning()&&(this.timer.stop(),c.notice("Harvest scheduler stopped"))}},{key:"triggerSmartHarvest",value:(a=Ee(ge().m(function t(e,r){var n;return ge().w(function(t){for(;;)switch(t.p=t.n){case 0:if(c.notice("".concat(e," harvest triggered at ").concat(r,"% threshold"),{type:e,threshold:r}),this.eventBuffer&&!this.eventBuffer.isEmpty()){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,this.triggerHarvest({});case 2:t.n=4;break;case 3:t.p=3,n=t.v,c.error("".concat(e," harvest failed:"),n.message);case 4:return t.p=4,this.timer.cancelAndReschedule(),t.f(4);case 5:return t.a(2)}},t,this,[[1,3,4,5]])})),function(t,e){return a.apply(this,arguments)})},{key:"onHarvestInterval",value:(i=Ee(ge().m(function t(){var e,r;return ge().w(function(t){for(;;)switch(t.n){case 0:if(e=this.eventBuffer&&!this.eventBuffer.isEmpty(),r=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0,e||r){t.n=1;break}return t.a(2);case 1:return t.n=2,this.triggerHarvest({});case 2:return t.a(2)}},t,this)})),function(){return i.apply(this,arguments)})},{key:"triggerHarvest",value:(n=Ee(ge().m(function t(){var e,r,n,i,a,o=arguments;return ge().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=o.length>0&&void 0!==o[0]?o[0]:{},!this.isHarvesting){t.n=1;break}return t.a(2,{success:!1,reason:"harvest_in_progress"});case 1:return this.isHarvesting=!0,t.p=2,r=this.drainEvents(e),e.isFinalHarvest&&(n=v.MAX_BEACON_SIZE,L(r)>n&&(r=this.trimEventsToFit(r,n))),t.n=3,this.sendChunk(r,e,!0);case 3:return i=t.v,t.a(2,{success:i.success,totalChunks:1,results:[i]});case 4:return t.p=4,a=t.v,c.error("Harvest cycle failed:",a.message),this.handleHarvestFailure(a),t.a(2,{success:!1,error:a.message});case 5:return t.p=5,this.isHarvesting=!1,t.f(5);case 6:return t.a(2)}},t,this,[[2,4,5,6]])})),function(){return n.apply(this,arguments)})},{key:"trimEventsToFit",value:function(t,e){if(0===t.length)return t;for(var r=[],n=0,i=t.length-1;i>=0;i--){var a=t[i],o=L({ins:[a].concat(r)});o>e||(r.unshift(a),n=o)}var s=t.length-r.length;if(s>0){var u=t.slice(0,s);c.warn("Discarded ".concat(s," events to fit beacon size limit"),{originalCount:t.length,trimmedCount:r.length,finalSize:n,maxSize:e}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(u)}return r}},{key:"drainEvents",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(t=null===(e=window.NRVIDEO)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.qoeIntervalFactor)&&void 0!==t?t:1,i=!!r.isFinalHarvest||this.forceNextQoeCycle,a=(this.qoeCycleCount-1)%n==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(t){c.error("Before drain callback failed:",t.message)}var o=function(t,e,r){if(e)return t;var n,i=[],a=ie(t);try{for(a.s();!(n=a.n()).done;){var o=n.value;o.actionName===N.Events.QOE_AGGREGATE?r.add(o):i.push(o)}}catch(t){a.e(t)}finally{a.f()}return i}(this.eventBuffer.drain(),a,this.eventBuffer);this.qoeCycleCount++,function(t,e,r){for(var n=t.length-1;n>=0;n--){var i=t[n];i.actionName===N.Events.QOE_AGGREGATE&&(!r&&oe(e,i)?t.splice(n,1):se(e,i))}}(o,this._lastSentQoeKpis,i);var s=pe(o),u=L(o);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){var l=v.MAX_PAYLOAD_SIZE-u,f=v.MAX_EVENTS_PER_BATCH-s.length;if(l>0&&f>0){var d=this.retryQueueHandler.getRetryEventsToFit(l,f);d.length>0&&(s=[].concat(pe(d),pe(s)))}}return s}},{key:"sendChunk",value:(r=Ee(ge().m(function t(e,r,n){var i,a,o=this;return ge().w(function(t){for(;;)if(0===t.n)return i=I(this.fallBackUrl),a={url:i,payload:{body:{ins:e}},options:ye(ye({},r),{},{isLastChunk:n})},t.a(2,new Promise(function(t){o.httpClient.send(a,function(r){r.retry?o.handleRequestFailure(e):(o.retryCount=0,o.fallBackUrl=""),t({success:!r.retry,status:r.status,error:r.error,chunk:e,eventCount:e.length})})}))},t,this)})),function(t,e,n){return r.apply(this,arguments)})},{key:"handleRequestFailure",value:function(t){var e;this.retryQueueHandler.addFailedEvents(t),"US"===(null===(e=window.NRVIDEO)||void 0===e||null===(e=e.info)||void 0===e?void 0:e.region)&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=v.COLLECTOR.US[1]))}},{key:"handleHarvestFailure",value:function(t){c.warn("Harvest failure handled",{error:t.message})}},{key:"updateHarvestInterval",value:function(t){"number"!=typeof t||isNaN(t)?c.warn("Invalid newInterval provided to updateHarvestInterval"):t<1e3||t>3e5?c.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==t&&(this.harvestCycle=t,c.notice("Updated harvestCycle:",this.harvestCycle),this.timer.updateInterval(t))}},{key:"setupPageLifecycleHandlers",value:function(){var t=this,e=!1,r=function(){e||(e=!0,t.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",function(){document.hidden&&r()}),window.addEventListener("pagehide",function(){r()}),window.addEventListener("beforeunload",function(){r()})}}],e&&Te(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i,a}();const ke={Constants:v,Chrono:k,Log:c,Emitter:S,Tracker:N,VideoTracker:Rt,VideoTrackerState:mt,Core:ct,version:p,NrVideoEventAggregator:It,RetryQueueHandler:Mt,OptimizedHttpClient:ne,HarvestScheduler:we,recordEvent:U};return e=e.default,e})());
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.nrvideo=e():t.nrvideo=e()}(self,()=>(()=>{"use strict";const t={d:(e,i)=>{if(Array.isArray(i))for(var r=0;r<i.length;){var n=i[r++],a=i[r++];t.o(e,n)?0===a&&r++:0===a?Object.defineProperty(e,n,{enumerable:!0,value:i[r++]}):Object.defineProperty(e,n,{enumerable:!0,get:a})}else for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};let e={};function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function r(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,a(r.key),r)}}function n(t,e,i){return(e=a(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function a(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}t.d(e,{default:()=>De});var o=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return e=t,i=[{key:"error",value:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];s(i,t.Levels.ERROR,"darkred")}},{key:"warn",value:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];s(i,t.Levels.WARNING,"darkorange")}},{key:"notice",value:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];s([].slice.call(arguments),t.Levels.NOTICE,"darkcyan")}},{key:"debug",value:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];s(i,t.Levels.DEBUG,"indigo")}},{key:"debugCommonVideoEvents",value:function(e,i,r){try{if(t.level<=t.Levels.DEBUG){r=r||function(e){t.debug("Event: "+e.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];i&&(null===i[0]?(i.shift(),n=i):n=n.concat(i));for(var a=0;a<n.length;a++)"function"==typeof e?e.call(window,n[a],r):e.on?e.on(n[a],r):e.addEventListener?e.addEventListener(n[a],r):e.addEventHandler?e.addEventHandler(n[a],r):t.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){t.warn(e)}}}],null&&r(e.prototype,null),i&&r(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i}();function s(t,e,i){e=e||o.Levels.NOTICE,i=i||"darkcyan";var r,n,a=o.prefix;o.includeTime&&(a+="["+("0"+(r=new Date).getDate()).slice(-2)+":"+("0"+r.getMinutes()).slice(-2)+":"+("0"+r.getSeconds()).slice(-2)+"."+("00"+r.getMilliseconds()).slice(-3)+"] "),a+=function(t){return c[t]}(e)+":",o.level<=e&&e!==o.Levels.SILENT&&(!o.colorful||"undefined"!=typeof document&&document.documentMode?u(t,a):(n=e===o.Levels.ERROR&&console.error?console.error:e===o.Levels.WARNING&&console.warn?console.warn:e===o.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,a="%c"+a,t.splice(0,0,a,"color: "+i),n.apply(console,t)))}function u(t,e){if(t instanceof Array)for(var i in t)u(t[i],e);else"string"==typeof t?console.log(e+" "+t):(console.log(e+"↵"),console.log(t))}n(o,"Levels",void 0),n(o,"level",void 0),n(o,"colorful",void 0),n(o,"includeTime",void 0),n(o,"prefix",void 0),o.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},o.level=o.Levels.ERROR,o.colorful=!0,o.includeTime=!0,o.prefix="[nrvideo]";var c={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var t=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==t&&("true"===t[1]?o.level=o.Levels.ALL:o.level=t[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(o.colorful=!1)}}();const l=o;function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function d(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}function h(t,e,i){return e&&d(t.prototype,e),i&&d(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t,e,i){return(e=y(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function y(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=f(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}var m=h(function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)});v(m,"AdPositions",{PRE:"pre",MID:"mid",POST:"post"}),v(m,"COLLECTOR",{US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",JP:"bam.jp.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"}),v(m,"VALID_EVENT_TYPES",["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"]),v(m,"MAX_PAYLOAD_SIZE",1048576),v(m,"MAX_BEACON_SIZE",61440),v(m,"MAX_EVENTS_PER_BATCH",1e3),v(m,"INTERVAL",1e4),v(m,"DEFAULT_QOE_INTERVAL_FACTOR",2),v(m,"QOE_KPI_KEYS",["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"]),v(m,"QOE_AGGREGATE_KEYS",["coreVersion","instrumentation.name","instrumentation.provider","instrumentation.version","isBackgroundEvent","playerName","playerVersion","src","viewId","viewSession","contentIsAutoplayed","contentIsMuted","contentRenditionHeight","contentRenditionWidth","contentSrc","numberOfVideos","pageUrl","trackerName","trackerVersion","contentDuration","contentPlayrate","contentPlayhead","contentPreload","elapsedTime","contentTitle","contentId","contentIsLive","deviceType","deviceGroup","deviceManufacturer","deviceModel","deviceName","deviceSize","deviceUuid","contentRenditionName","contentIsFullscreen","contentCdn","contentFps","asnOrganization","asnLongitude","asnLatitude","asn","timeSinceRequested","timeSinceStarted"]);const p=m,g="5.1.0";function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function S(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,T(r.key),r)}}function T(t){var e=function(t){if("object"!=b(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=b(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==b(e)?e:e+""}const E=function(){return t=function t(){var e,i,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,r=void 0,(i=T(i="_listeners"))in e?Object.defineProperty(e,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[i]=r},(e=[{key:"on",value:function(t,e){if(this._listeners=this._listeners||{},"function"==typeof e)return this._listeners[t]=this._listeners[t]||[],this._listeners[t].push(e),this}},{key:"off",value:function(t,e){if(this._listeners=this._listeners||{},this._listeners[t]){var i=this._listeners[t].indexOf(e);-1!==i&&this._listeners[t].splice(i,1)}return this}},{key:"emit",value:function(t,e,i){var r=this;return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[e])&&this._listeners[e].forEach(function(n){n.call(r,{eventType:t,type:e,data:i,target:r})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(function(n){n.call(r,{eventType:t,type:e,data:i,target:r})}),this}}])&&S(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}function w(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,O(r.key),r)}}function k(t,e,i){return(e=O(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function O(t){var e=function(t){if("object"!=A(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=A(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==A(e)?e:e+""}var _=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),k(this,"startTime",0),k(this,"stopTime",0),k(this,"accumulator",0),k(this,"offset",0),this.reset()}return e=t,i=[{key:"reset",value:function(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}},{key:"getDeltaTime",value:function(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}},{key:"start",value:function(){this.startTime=(new Date).getTime(),this.stopTime=0}},{key:"stop",value:function(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}},{key:"getDuration",value:function(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(null!==(t=this.getDeltaTime())&&void 0!==t?t:0);var t}},{key:"clone",value:function(){var e=new t;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e.accumulator=this.accumulator,e}}],i&&w(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i}();const P=_;function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function B(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,I(r.key),r)}}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(D=function(){return!!t})()}function j(t){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},j(t)}function C(t,e){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},C(t,e)}function N(t,e,i){return(e=I(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function I(t){var e=function(t){if("object"!=R(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=R(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(e)?e:e+""}var L=function(t){function e(t){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),N(i=function(t,e,i){return e=j(e),function(t,e){if(e&&("object"==R(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,i||[],j(t).constructor):e.apply(t,i))}(this,e),"customData",void 0),N(i,"heartbeat",void 0),N(i,"parentTracker",void 0),N(i,"state",void 0),N(i,"_trackerReadyChrono",void 0),N(i,"_actionTable",void 0),N(i,"_actionAdTable",void 0),N(i,"_heartbeatInterval",void 0),i.customData={},i.heartbeat=null,i.parentTracker=null,i._trackerReadyChrono=new P,i._trackerReadyChrono.start(),i._actionTable=p.ACTION_TABLE,i._actionAdTable=p.ACTION_AD_TABLE,t=t||{},i.setOptions(t),i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&C(t,e)}(e,t),i=e,(r=[{key:"setOptions",value:function(t){t&&(t.parentTracker&&(this.parentTracker=t.parentTracker),t.customData&&(this.customData=t.customData),t.heartbeat&&(this.heartbeat=t.heartbeat))}},{key:"dispose",value:function(){this.unregisterListeners()}},{key:"registerListeners",value:function(){}},{key:"unregisterListeners",value:function(){}},{key:"getHeartbeat",value:function(){var t;return null!==(t=this.state)&&void 0!==t&&t._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}},{key:"startHeartbeat",value:function(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}},{key:"stopHeartbeat",value:function(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}},{key:"sendHeartbeat",value:function(t){this.sendVideoAction(e.Events.HEARTBEAT,t)}},{key:"getAttributes",value:function(t,e){for(var i in(t=t||{}).trackerName=this.getTrackerName(),t.trackerVersion=this.getTrackerVersion(),t.coreVersion=g,t.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime(),this.customData)t[i]=this.customData[i];return null!=document.hidden&&(t.isBackgroundEvent=document.hidden),t}},{key:"getTrackerVersion",value:function(){return g}},{key:"getTrackerName",value:function(){return"base-tracker"}},{key:"sendVideoAction",value:function(t,e){this.emit("VideoAction",t,this.getAttributes(e))}},{key:"sendVideoAdAction",value:function(t,e){this.emit("VideoAdAction",t,this.getAttributes(e))}},{key:"sendVideoErrorAction",value:function(t,e){var i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",t,this.getAttributes(e,i))}},{key:"sendVideoCustomAction",value:function(t,e){this.emit("VideoCustomAction",t,this.getAttributes(e,"customAction"))}},{key:"setHarvestInterval",value:function(t){var e,i=null===(e=this.getHarvester)||void 0===e?void 0:e.call(this);if(i)try{i.setHarvestInterval(t)}catch(t){return void l.error("Failed to set harvest interval:",t.message)}else l.error("Tracker has no harvester; setHarvestInterval ignored")}},{key:"getHarvester",value:function(){return null}}])&&B(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(E);N(L,"Events",void 0),L.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const V=L;function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}function x(t){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");var e=window.NRVIDEO.info,i=e.beacon,r=e.licenseKey,n=e.applicationID;if(!i||!r)throw new Error("Options object provided by New Relic is not correctly initialized");return n?"https://".concat(t||i,"/ins/1/").concat(r,"?a=").concat(n,"&v=").concat(g,"&ref=").concat(window.location.href,"&ca=VA"):"https://".concat(t||i,"/ins/1/").concat(r,"?&v=").concat(g,"&ref=").concat(window.location.href,"&ca=VA")}catch(t){return console.error(t.message),null}}function F(t){if("string"==typeof t&&t.length)return t.length;if("object"===H(t)){if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&t.byteLength)return t.byteLength;if("undefined"!=typeof Blob&&t instanceof Blob&&t.size)return t.size;if(!("undefined"!=typeof FormData&&t instanceof FormData))try{return function(t){try{var e;return null!==(e=JSON.stringify(t,(i=new WeakSet,function(t,e){if("object"===H(e)&&null!==e){if(i.has(e))return;i.add(e)}return e})))&&void 0!==e?e:""}catch(t){return l.error("Error stringifying value:",t.message),""}var i}(t).length}catch(t){return}}}function Q(t){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Q(t)}var q=["qoe"];function U(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function G(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?U(Object(i),!0).forEach(function(e){M(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):U(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function M(t,e,i){return(e=function(t){var e=function(t){if("object"!=Q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Q(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var z=Object.create(null);function K(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{var i,r,n,a;if(!p.VALID_EVENT_TYPES.includes(t))return l.warn("Invalid event type provided to recordEvent",{eventType:t}),!1;var o="Vega"===e.src,s=o?"Vega":"Browser",u="undefined"!=typeof window?window:void 0,c=o?null===(i=globalThis.__NRVIDEO_CD__)||void 0===i?void 0:i.info:null==u||null===(r=u.NRVIDEO)||void 0===r?void 0:r.info;if(!c)return;var f=z[s];return f?function(t,e,i,r,n){var a=(arguments.length>5&&void 0!==arguments[5]?arguments[5]:{}).addTimeSinceLoad;if(!r)return!1;var o=function(t,e,i){var r,n,a=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).addTimeSinceLoad,o=void 0!==a&&a,s=i.appName,u=i.applicationID,c=e.qoe,l=function(t,e){if(null==t)return{};var i,r,n=function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)i=a[r],-1===e.indexOf(i)&&{}.propertyIsEnumerable.call(t,i)&&(n[i]=t[i])}return n}(e,q),f=c?G({},c):{},d=G(G({},u?{}:{appName:s}),{},{timestamp:Date.now()},o?{timeSinceLoad:"undefined"!=typeof window&&window.performance?window.performance.now()/1e3:null}:{}),h=G(G({},l),{},{eventType:t},d),v=null;if("VideoAction"===t){var y=(r=p.QOE_AGGREGATE_KEYS,n=e,r&&Array.isArray(r)&&0!==r.length?n&&"object"===H(n)?r.reduce(function(t,e){return e in n&&(t[e]=n[e]),t},{}):{}:n);v=G(G(G({eventType:"VideoAction",actionName:V.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0"},f),y),d)}return{eventObject:h,qoeEventObject:v}}(t,e,i,{addTimeSinceLoad:void 0!==a&&a}),s=o.eventObject,u=o.qoeEventObject,c=r.addEvent(s);return u&&n?c&&r.addEvent(u):c}(t,e,c,f,!!(o?null===(n=globalThis.__NRVIDEO_CD__)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.qoeAggregate:null==u||null===(a=u.NRVIDEO)||void 0===a||null===(a=a.config)||void 0===a?void 0:a.qoeAggregate),{addTimeSinceLoad:!o}):(l.warn("No harvester registered for routing key",{routingKey:s}),!1)}catch(t){return l.error("Failed to record event:",t.message),!1}}var W={us:"https://mobile-collector.newrelic.com/mobile",eu:"https://mobile-collector.eu01.nr-data.net/mobile",staging:"https://staging-mobile-collector.newrelic.com/mobile",gov:"https://gov-mobile-collector.newrelic.com/mobile",jp:"https://mobile-collector.jp.nr-data.net/mobile"};function Y(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function X(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Y(Object(i),!0).forEach(function(e){Z(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Y(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function Z(t,e,i){return(e=tt(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function $(t){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(t)}function J(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,tt(r.key),r)}}function tt(t){var e=function(t){if("object"!=$(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=$(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$(e)?e:e+""}var et=p.COLLECTOR,it=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"setConfiguration",value:function(t,e,i){return!!("Vega"===i?this.validateVegaFields(t):this.validateRequiredFields(t))&&!!this.validateConfigFields(e)&&(this.initializeGlobalConfig(t,e,i),l.notice("Video analytics configuration initialized successfully"),!0)}},{key:"validateVegaFields",value:function(t){var e;return t&&"object"===$(t)?t.applicationToken?(null===(e=t.endpoint)||void 0===e?void 0:e.toLowerCase())in W||(l.error("Invalid endpoint (must be us, eu, staging, gov, or jp)"),!1):(l.error("applicationToken is required"),!1):(l.error("Configuration must be an object"),!1)}},{key:"validateRequiredFields",value:function(t){if(!t||"object"!==$(t))return l.error("Configuration must be an object"),!1;var e=t.licenseKey,i=t.appName,r=t.region,n=t.applicationID,a=t.beacon;if(!e)return l.error("licenseKey is required"),!1;if(n){if(!a)return l.error("beacon is required when applicationID is provided"),!1;if(!Object.values(et).flatMap(function(t){return t}).includes(a))return l.error("Invalid beacon: ".concat(a)),!1}else{if(!i||!r)return l.error("appName and region are required when applicationID is not provided"),!1;if(!et[r])return l.error("Invalid region: ".concat(r,". Valid regions are: ").concat(Object.keys(et).join(", "))),!1}return!0}},{key:"validateConfigFields",value:function(t){if(null==t)return!0;if("object"!==$(t)||Array.isArray(t))return l.error("config must be an object"),!1;var e=t.qoeAggregate,i=t.obfuscate;return void 0!==e&&"boolean"!=typeof e?(l.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(l.error("obfuscate must be an array"),1))}},{key:"filterObfuscateRules",value:function(t){return t?t.filter(function(t){var e=void 0!==t.regex&&("string"==typeof t.regex||t.regex instanceof RegExp),i=void 0!==t.replacement&&"string"==typeof t.replacement;return!(!e||!i)||(l.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",t),!1)}):[]}},{key:"sanitizeQoeIntervalFactor",value:function(t){return null==t?p.DEFAULT_QOE_INTERVAL_FACTOR:"number"==typeof t&&Number.isInteger(t)&&t>=1?t:(l.warn('Invalid qoeIntervalFactor "'.concat(t,'" — must be a positive integer. Defaulting to ').concat(p.DEFAULT_QOE_INTERVAL_FACTOR,".")),p.DEFAULT_QOE_INTERVAL_FACTOR)}},{key:"initializeGlobalConfig",value:function(t,e,i){var r;if("Vega"!==i){var n=t.licenseKey,a=t.appName,o=t.region,s=t.beacon,u=t.applicationID;s="US"===o?p.COLLECTOR.US[0]:s||et[o],window.NRVIDEO={info:X(X({},o?{region:o}:{}),{},{beacon:s,licenseKey:n,applicationID:u},u?{}:{appName:a}),config:{qoeAggregate:null===(r=null==e?void 0:e.qoeAggregate)||void 0===r||r,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(null==e?void 0:e.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(null==e?void 0:e.obfuscate)}}}else{var c,l;globalThis.__NRVIDEO_CD__={info:X(X(X({accountId:t.accountId,applicationToken:t.applicationToken,endpoint:null===(c=t.endpoint)||void 0===c?void 0:c.toLowerCase()},t.appName?{appName:t.appName}:{}),t.applicationID?{applicationID:t.applicationID}:{}),t.deviceInfo?{deviceInfo:t.deviceInfo}:{}),config:{qoeAggregate:null===(l=null==e?void 0:e.qoeAggregate)||void 0===l||l,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(null==e?void 0:e.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(null==e?void 0:e.obfuscate)}}}}}],e&&J(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),rt=new it;function nt(t){return nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nt(t)}function at(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function ot(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?at(Object(i),!0).forEach(function(e){st(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):at(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function st(t,e,i){return(e=ct(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ut(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ct(r.key),r)}}function ct(t){var e=function(t){if("object"!=nt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=nt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nt(e)?e:e+""}var lt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"addTracker",value:function(t,e){null!=e&&e.info&&function(t,e,i){rt.setConfiguration(t,e,i)}(e.info,null==e?void 0:e.config,null==e?void 0:e.src),t.on&&t.emit?(ft.push(t),t.on("*",dt),"function"==typeof t.trackerInit&&t.trackerInit()):l.error("Tried to load a non-tracker.",t)}},{key:"removeTracker",value:function(t){t.off("*",dt),t.dispose();var e=ft.indexOf(t);-1!==e&&ft.splice(e,1)}},{key:"getTrackers",value:function(){return ft}},{key:"send",value:function(t,e,i){return K(t,ot({actionName:e},i))}},{key:"sendError",value:function(t){return K("VideoErrorAction",ot({actionName:"ERROR"},t))}}],null&&ut(t.prototype,null),e&&ut(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),ft=[];function dt(t){try{var e=function(t){var e={};for(var i in t)null!==t[i]&&void 0!==t[i]&&(e[i]=t[i]);return e}(t.data);l.level<=l.Levels.DEBUG?l.notice("Sent",t.type,e):l.notice("Sent",t.type),lt.send(t.eventType,t.type,e)}catch(t){l.error("Error in event handler:",t.message)}}const ht=lt;function vt(t){return vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vt(t)}function yt(t){return function(t){if(Array.isArray(t))return gt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||pt(t)||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.")}()}function mt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,n,a,o,s=[],u=!0,c=!1;try{if(a=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;u=!1}else for(;!(u=(r=a.call(i)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,n=t}finally{try{if(!u&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw n}}return s}}(t,e)||pt(t,e)||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.")}()}function pt(t,e){if(t){if("string"==typeof t)return gt(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?gt(t,e):void 0}}function gt(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function bt(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Tt(r.key),r)}}function St(t,e,i){return(e=Tt(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Tt(t){var e=function(t){if("object"!=vt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=vt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vt(e)?e:e+""}const Et=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),St(this,"_viewSession",null),St(this,"_viewCount",0),St(this,"_isAd",!1),St(this,"numberOfErrors",0),St(this,"numberOfAds",0),St(this,"numberOfVideos",0),St(this,"totalPlaytime",0),St(this,"weightedAverageBitrate",0),St(this,"totalAdPlaytime",0),St(this,"isAdBreak",!1),St(this,"initialBufferingHappened",!1),St(this,"startupTime",null),St(this,"peakBitrate",0),St(this,"partialAverageBitrate",0),St(this,"_totalBitrateDuration",0),St(this,"weightedBitrate",0),St(this,"_lastBitrate",null),St(this,"_lastBitrateChangeTimestamp",null),St(this,"_downloadBitrates",[]),St(this,"_lastDownloadBitrate",null),St(this,"totalSwitchUps",0),St(this,"totalSwitchDowns",0),St(this,"totalPauseTime",0),St(this,"_playedRenditions",new Set),St(this,"hadStartupError",!1),St(this,"hadPlaybackError",!1),St(this,"totalRebufferingTime",0),St(this,"isPlayerReady",!1),St(this,"isRequested",!1),St(this,"isStarted",!1),St(this,"isPaused",!1),St(this,"isSeeking",!1),St(this,"isBuffering",!1),St(this,"isPlaying",!1),St(this,"timeSinceRequested",void 0),St(this,"timeSinceStarted",void 0),St(this,"timeSincePaused",void 0),St(this,"timeSinceSeekBegin",void 0),St(this,"timeSinceBufferBegin",void 0),St(this,"timeSinceAdBreakStart",void 0),St(this,"timeSinceLastDownload",void 0),St(this,"timeSinceLastHeartbeat",void 0),St(this,"timeSinceLastRenditionChange",void 0),St(this,"timeSinceLastAdQuartile",void 0),St(this,"timeSinceLastAd",void 0),St(this,"timeSinceLastError",void 0),St(this,"timeSinceLastAdError",void 0),St(this,"timeSinceResumed",void 0),St(this,"timeSinceSeekEnd",void 0),St(this,"playtimeSinceLastEvent",void 0),St(this,"customTimeSinceAttributes",{}),St(this,"elapsedTime",void 0),St(this,"bufferElapsedTime",void 0),St(this,"_totalAdPlaytime",void 0),St(this,"_createdAt",void 0),St(this,"_hb",void 0),St(this,"_acc",void 0),St(this,"_bufferAcc",void 0),St(this,"isError",void 0),this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0},(e=[{key:"reset",value:function(){this._viewSession=null,this._viewCount=0,this._isAd=!1,this.numberOfErrors=0,this.numberOfAds=0,this.numberOfVideos=0,this.totalPlaytime=0,this.weightedAverageBitrate=0,this.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,this.startupTime=null,this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.weightedBitrate=0,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this._downloadBitrates=[],this._lastDownloadBitrate=null,this.totalSwitchUps=0,this.totalSwitchDowns=0,this.totalPauseTime=0,this._playedRenditions=new Set,this.hadStartupError=!1,this.hadPlaybackError=!1,this.totalRebufferingTime=0,this.resetFlags(),this.resetChronos()}},{key:"resetFlags",value:function(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}},{key:"resetChronos",value:function(){this.timeSinceRequested=new P,this.timeSinceStarted=new P,this.timeSincePaused=new P,this.timeSinceSeekBegin=new P,this.timeSinceBufferBegin=new P,this.timeSinceAdBreakStart=new P,this.timeSinceLastDownload=new P,this.timeSinceLastHeartbeat=new P,this.timeSinceLastRenditionChange=new P,this.timeSinceLastAdQuartile=new P,this.timeSinceLastAd=new P,this.timeSinceLastError=new P,this.timeSinceLastAdError=new P,this.timeSinceResumed=new P,this.timeSinceSeekEnd=new P,this.playtimeSinceLastEvent=new P,this.customTimeSinceAttributes={},this.elapsedTime=new P,this.bufferElapsedTime=new P,this._totalAdPlaytime=new P}},{key:"isAd",value:function(){return this._isAd}},{key:"setIsAd",value:function(t){this._isAd=t}},{key:"setTimeSinceAttribute",value:function(t){this.customTimeSinceAttributes[t]=new P,this.customTimeSinceAttributes[t].start()}},{key:"removeTimeSinceAttribute",value:function(t){delete this.customTimeSinceAttributes[t]}},{key:"getViewSession",value:function(){if(!this._viewSession){var t=(new Date).getTime(),e=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=t+"-"+e}return this._viewSession}},{key:"getViewId",value:function(){return this.getViewSession()+"-"+this._viewCount}},{key:"getStateAttributes",value:function(t){t=t||{},this.isAd()?(this.isRequested&&(t.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),t.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(t.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(t.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(t.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(t.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(t.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),this.numberOfErrors>0&&this.timeSinceLastAdError.startTime>0&&(t.timeSinceLastAdError=this.timeSinceLastAdError.getDeltaTime()),t.numberOfAds=this.numberOfAds):(this.isRequested&&(t.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),t.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(t.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(t.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(t.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(t.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),t.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),this.numberOfErrors>0&&this.timeSinceLastError.startTime>0&&(t.timeSinceLastError=this.timeSinceLastError.getDeltaTime()),t.numberOfVideos=this.numberOfVideos),t.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?t.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():t.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=t.playtimeSinceLastEvent,t.totalPlaytime=this.totalPlaytime);for(var e=0,i=Object.entries(this.customTimeSinceAttributes);e<i.length;e++){var r=mt(i[e],2),n=r[0],a=r[1];t[n]=a.getDeltaTime()}return t}},{key:"getQoeAttributes",value:function(t){t=t||{};var e={};try{if(null!==this.startupTime&&(e.startupTime=this.startupTime),this.peakBitrate>0&&(e.peakBitrate=this.peakBitrate),e.hadStartupError=this.hadStartupError,e.hadPlaybackError=this.hadPlaybackError,e.totalRebufferingTime=this.totalRebufferingTime,e.rebufferingRatio=this.totalPlaytime>0?this.totalRebufferingTime/this.totalPlaytime*100:0,e.totalPlaytime=this.totalPlaytime,e.averageBitrate=this.weightedBitrate,e.numberOfErrors=this.numberOfErrors,this._downloadBitrates.length>0){var i=this._downloadBitrates.reduce(function(t,e){return t+e},0);e.avgDownloadRate=Math.round(i/this._downloadBitrates.length),e.minDownloadRate=Math.min.apply(Math,yt(this._downloadBitrates)),e.maxDownloadRate=Math.max.apply(Math,yt(this._downloadBitrates))}e.totalSwitchUps=this.totalSwitchUps,e.totalSwitchDowns=this.totalSwitchDowns,e.totalPauseTime=this.timeSincePaused.getDuration(),e.totalViewSessionTime=this.totalPlaytime,e.totalRenditions=this._playedRenditions.size,e.qoeAggregateVersion="1.1.0"}catch(t){l.error("Failed to add attributes for QOE KPIs",t.message)}return t.qoe=e,t}},{key:"calculateBufferType",value:function(t){var e;return e=t?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",l.debug("Buffer Type = "+e),e}},{key:"goViewCountUp",value:function(){this._viewCount++}},{key:"goPlayerReady",value:function(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}},{key:"goRequest",value:function(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}},{key:"goStart",value:function(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}},{key:"goEnd",value:function(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}},{key:"goPause",value:function(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}},{key:"goResume",value:function(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}},{key:"goBufferStart",value:function(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}},{key:"goBufferEnd",value:function(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),!this.isAd()&&this.initialBufferingHappened&&(this.totalRebufferingTime+=this.timeSinceBufferBegin.stopTime-this.timeSinceBufferBegin.startTime),0))}},{key:"goSeekStart",value:function(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}},{key:"goSeekEnd",value:function(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}},{key:"goAdBreakStart",value:function(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}},{key:"goAdBreakEnd",value:function(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}},{key:"goDownload",value:function(){this.timeSinceLastDownload.start()}},{key:"goHeartbeat",value:function(){this.timeSinceLastHeartbeat.start()}},{key:"goRenditionChange",value:function(){this.timeSinceLastRenditionChange.start()}},{key:"goAdQuartile",value:function(){this.timeSinceLastAdQuartile.start()}},{key:"goError",value:function(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}},{key:"goLastAd",value:function(){this.timeSinceLastAd.start()}},{key:"trackContentBitrateState",value:function(t){if(t&&"number"==typeof t){this.peakBitrate=Math.max(this.peakBitrate,t);var e=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){var i=e-this._lastBitrateChangeTimestamp;i>0&&(this.partialAverageBitrate+=this._lastBitrate*i,this._totalBitrateDuration+=i),this._lastBitrateChangeTimestamp=null}return void(this._lastBitrate=t)}if(null===this._lastBitrateChangeTimestamp&&null!==this._lastBitrate&&(this._lastBitrateChangeTimestamp=e),null!==this._lastBitrate&&this._lastBitrate!==t&&null!==this._lastBitrateChangeTimestamp){var r=e-this._lastBitrateChangeTimestamp;r>0&&(this.partialAverageBitrate+=this._lastBitrate*r,this._totalBitrateDuration+=r),this._lastBitrateChangeTimestamp=e}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=e),this._lastBitrate=t;var n=this.partialAverageBitrate,a=this._totalBitrateDuration,o=e-this._lastBitrateChangeTimestamp;o>0&&(n+=t*o,a+=o),this.weightedBitrate=a>0?Math.round(n/a):t}}},{key:"trackDownloadRate",value:function(t){!t||"number"!=typeof t||t<=0||t!==this._lastDownloadBitrate&&(this._downloadBitrates.push(t),this._lastDownloadBitrate=t)}},{key:"addPlayedRendition",value:function(t,e){t&&e&&this._playedRenditions.add("".concat(t,"x").concat(e))}},{key:"resetViewIdTrackedState",value:function(){this.peakBitrate=0,this.startupTime=null,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.weightedBitrate=0,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this._downloadBitrates=[],this._lastDownloadBitrate=null,this.totalSwitchUps=0,this.totalSwitchDowns=0,this.timeSincePaused.reset(),this._playedRenditions=new Set}},{key:"clearTotalAdsTime",value:function(){l.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}},{key:"totalAdTime",value:function(){return this._totalAdPlaytime.getDuration()}},{key:"startAdsTime",value:function(){return l.debug("startAdsTime"),this._totalAdPlaytime.start()}},{key:"stopAdsTime",value:function(){return l.debug("stopAdsTime"),this._totalAdPlaytime.stop()}},{key:"setStartupTime",value:function(t){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-t,0))}}])&&bt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function At(t){return At="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},At(t)}function wt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function kt(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?wt(Object(i),!0).forEach(function(e){Bt(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):wt(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function Ot(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Dt(r.key),r)}}function _t(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_t=function(){return!!t})()}function Pt(t){return Pt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Pt(t)}function Rt(t,e){return Rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rt(t,e)}function Bt(t,e,i){return(e=Dt(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Dt(t){var e=function(t){if("object"!=At(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=At(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}var jt=function(t){function e(t,i){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Bt(r=function(t,e,i){return e=Pt(e),function(t,e){if(e&&("object"==At(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_t()?Reflect.construct(e,i||[],Pt(t).constructor):e.apply(t,i))}(this,e),"state",void 0),Bt(r,"adsTracker",void 0),Bt(r,"_lastBufferType",void 0),Bt(r,"_userId",void 0),Bt(r,"_src",void 0),Bt(r,"player",void 0),Bt(r,"tag",void 0),Bt(r,"_lastWebkitBitrate",void 0),Bt(r,"_lastAdRendition",void 0),Bt(r,"_lastRendition",void 0),r.state=new Et,r.adsTracker=null,r._lastBufferType=null,r._userId=null,r._src=null,i=i||{},r.setOptions(i),t&&r.setPlayer(t,i.tag),l.notice("Tracker "+r.getTrackerName()+" v"+r.getTrackerVersion()+" is ready."),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Rt(t,e)}(e,t),i=e,r=[{key:"setUserId",value:function(t){this._userId=t}},{key:"setOptions",value:function(t){t&&(t.adsTracker&&this.setAdsTracker(t.adsTracker),"boolean"==typeof t.isAd&&this.setIsAd(t.isAd),void 0!==t.src&&(null!==this._src&&this._src!==t.src?l.warn("setOptions: src is locked to '".concat(this._src,"'. Ignoring override '").concat(t.src,"'.")):(this._src=t.src,this.adsTracker&&null==this.adsTracker._src&&(this.adsTracker._src=this._src))),V.prototype.setOptions.apply(this,arguments))}},{key:"setPlayer",value:function(t,e){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof t&&(t=document.getElementById(t)),"string"==typeof e&&(e=document.getElementById(e))),e=e||t,this.player=t,this.tag=e,this.registerListeners()}},{key:"isAd",value:function(){return this.state.isAd()}},{key:"setIsAd",value:function(t){this.state.setIsAd(t)}},{key:"setAdsTracker",value:function(t){this.disposeAdsTracker(),t&&(this.adsTracker=t,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,null!=this._src&&null==t._src&&(t._src=this._src),this.adsTracker.on("*",Ct.bind(this)))}},{key:"disposeAdsTracker",value:function(){this.adsTracker&&(this.adsTracker.off("*",Ct),this.adsTracker.dispose())}},{key:"dispose",value:function(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}},{key:"registerListeners",value:function(){}},{key:"unregisterListeners",value:function(){}},{key:"getViewId",value:function(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}},{key:"getViewSession",value:function(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}},{key:"getVideoId",value:function(){return null}},{key:"getTitle",value:function(){return null}},{key:"isLive",value:function(){return null}},{key:"getBitrate",value:function(){return null}},{key:"getManifestBitrate",value:function(){return null}},{key:"getSegmentDownloadBitrate",value:function(){return null}},{key:"getNetworkDownloadBitrate",value:function(){return null}},{key:"getWebkitBitrate",value:function(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){var t;if(this._lastWebkitBitrate){var e=(t=this.tag.webkitVideoDecodedByteCount)-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;t=Math.round(e/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,t||null}}},{key:"getRenditionName",value:function(){return null}},{key:"getRenditionBitrate",value:function(){return null}},{key:"getRenditionShift",value:function(t){var e,i=this.getManifestBitrate();return this.isAd()?(e=this._lastAdRendition,t&&(this._lastAdRendition=i)):(e=this._lastRendition,t&&(this._lastRendition=i)),i&&e?i>e?"up":i<e?"down":null:null}},{key:"getRenditionHeight",value:function(){return this.tag?this.tag.videoHeight:null}},{key:"getRenditionWidth",value:function(){return this.tag?this.tag.videoWidth:null}},{key:"getDuration",value:function(){return this.tag?this.tag.duration:null}},{key:"getPlayhead",value:function(){return this.tag?this.tag.currentTime:null}},{key:"getLanguage",value:function(){return null}},{key:"getSrc",value:function(){return this.tag?this.tag.currentSrc:null}},{key:"getPlayrate",value:function(){return this.tag?this.tag.playbackRate:null}},{key:"isMuted",value:function(){return this.tag?this.tag.muted:null}},{key:"isFullscreen",value:function(){return null}},{key:"getCdn",value:function(){return null}},{key:"getPlayerName",value:function(){return this.getTrackerName()}},{key:"getPlayerVersion",value:function(){return g}},{key:"getFps",value:function(){return null}},{key:"isAutoplayed",value:function(){return this.tag?this.tag.autoplay:null}},{key:"getPreload",value:function(){return this.tag?this.tag.preload:null}},{key:"getAdQuartile",value:function(){return null}},{key:"getAdPosition",value:function(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}},{key:"getAdPartner",value:function(){return null}},{key:"getAdCreativeId",value:function(){return null}},{key:"getInstrumentationProvider",value:function(){return null}},{key:"getInstrumentationName",value:function(){return null}},{key:"getInstrumentationVersion",value:function(){return null}},{key:"getAttributes",value:function(t,e){if(void 0===(t=V.prototype.getAttributes.apply(this,arguments)).isAd&&(t.isAd=this.isAd()),t.viewSession=this.getViewSession(),t.viewId=this.getViewId(),t.playerName=this.getPlayerName(),t.playerVersion=this.getPlayerVersion(),t["instrumentation.provider"]=this.getInstrumentationProvider(),t["instrumentation.name"]=this.getInstrumentationName(),t["instrumentation.version"]=this.getInstrumentationVersion(),t["enduser.id"]=this._userId,t.src=this._src||"Browser","customAction"===e)return t;try{t.pageUrl=window.location.href}catch(t){}for(var i in this.isAd()?(t.adId=this.getVideoId(),t.adTitle=this.getTitle(),t.adSrc=this.getSrc(),t.adCdn=this.getCdn(),this.state.isStarted&&(t.adBitrate=this.getBitrate()||0),t.adRenditionName=this.getRenditionName(),t.adRenditionHeight=this.getRenditionHeight(),t.adRenditionWidth=this.getRenditionWidth(),t.adDuration=this.getDuration(),t.adPlayhead=this.getPlayhead(),t.adLanguage=this.getLanguage(),t.adIsMuted=this.isMuted(),t.adFps=this.getFps(),t.adPosition=this.getAdPosition(),t.adCreativeId=this.getAdCreativeId(),t.adPartner=this.getAdPartner()):(t.contentId=this.getVideoId(),t.contentTitle=this.getTitle(),t.contentSrc=this.getSrc(),t.contentCdn=this.getCdn(),t.contentPlayhead=this.getPlayhead(),t.contentIsLive=this.isLive(),this.state.isStarted&&(t.contentBitrate=this.getBitrate()||0,t.contentManifestBitrate=this.getManifestBitrate()||0,t.contentSegmentDownloadBitrate=this.getSegmentDownloadBitrate()||0,t.contentNetworkDownloadBitrate=this.getNetworkDownloadBitrate()||0),t.contentRenditionName=this.getRenditionName(),t.contentRenditionHeight=this.getRenditionHeight(),t.contentRenditionWidth=this.getRenditionWidth(),t.contentDuration=this.getDuration(),t.contentLanguage=this.getLanguage(),t.contentPlayrate=this.getPlayrate(),t.contentIsFullscreen=this.isFullscreen(),t.contentIsMuted=this.isMuted(),t.contentIsAutoplayed=this.isAutoplayed(),t.contentPreload=this.getPreload(),t.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(t.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(t),this.state.isStarted&&!this.isAd()&&(this.state.trackContentBitrateState(t.contentBitrate),this.state.trackDownloadRate(t.contentNetworkDownloadBitrate),this.state.addPlayedRendition(t.contentRenditionHeight,t.contentRenditionWidth)),this.customData)t[i]=this.customData[i];if(!this.isAd()){this.state.getQoeAttributes(t);var r=t.qoe;for(var n in this.customData)r[n]=this.customData[n]}return t}},{key:"sendCustom",value:function(t,e,i){i=i||{},this.sendVideoCustomAction(t,i),this.state.setTimeSinceAttribute(e)}},{key:"sendPlayerReady",value:function(t){this.state.goPlayerReady()&&(t=t||{},this.sendVideoAction(e.Events.PLAYER_READY,t))}},{key:"sendRequest",value:function(t){var i;this.state.goRequest()&&(this.isAd()?(i=e.Events.AD_REQUEST,this.sendVideoAdAction(i,t)):(i=e.Events.CONTENT_REQUEST,this.sendVideoAction(i,t)))}},{key:"sendStart",value:function(t){var i=this;if(this.state.goStart()){var r;if(this.isAd())r=e.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(r,t),this.state.startAdsTime();else{var n;r=e.Events.CONTENT_START;var a,o=0;this.adsTracker&&((this.adsTracker.state.isPlaying||this.adsTracker.state.isBuffering)&&(this.adsTracker.state.stopAdsTime(),this.adsTracker.state.isPlaying=!1,this.adsTracker.state.isBuffering=!1),o=null!==(a=this.adsTracker.state.totalAdTime())&&void 0!==a?a:0),this.state.setStartupTime(o),this.sendVideoAction(r,t);var s=null===(n=this.getHarvester)||void 0===n?void 0:n.call(this);null==s||s.setBeforeDrainCallback(function(){if(i.state){var t=i.state.getQoeAttributes({}).qoe;s.refreshQoeKpis(t,i.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}},{key:"sendEnd",value:function(t){var i;if(this.state.goEnd()&&(t=t||{},this.isAd()?(i=e.Events.AD_END,t.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0,this.parentTracker.state.timeSincePaused.reset()),this.state.stopAdsTime()):(i=e.Events.CONTENT_END,t.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0,!this.isAd())){var r,n,a=null===(r=this.getHarvester)||void 0===r?void 0:r.call(this);null==a||null===(n=a.forceNextQoeCycle)||void 0===n||n.call(a),null==a||a.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState()}}},{key:"sendPause",value:function(t){if(this.state.goPause()){var i=this.isAd()?e.Events.AD_PAUSE:e.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t)}}},{key:"sendResume",value:function(t){var i;this.state.goResume()&&(t=t||{},this.isAd()?(i=e.Events.AD_RESUME,t.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(i=e.Events.CONTENT_RESUME,t.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t))}},{key:"sendBufferStart",value:function(t){var i;this.state.goBufferStart()&&(t=t||{},i=this.isAd()?e.Events.AD_BUFFER_START:e.Events.CONTENT_BUFFER_START,t=this.buildBufferAttributes(t),this._lastBufferType=t.bufferType,this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t))}},{key:"sendBufferEnd",value:function(t){var i;this.state.goBufferEnd()&&(t=t||{},this.isAd()?(i=e.Events.AD_BUFFER_END,t.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(i=e.Events.CONTENT_BUFFER_END,t.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),t=this.buildBufferAttributes(t),null!=this._lastBufferType&&(t.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t),this.state.initialBufferingHappened=!0)}},{key:"buildBufferAttributes",value:function(t){return null==t.timeSinceStarted||t.timeSinceStarted<100?t.isInitialBuffering=!this.state.initialBufferingHappened:t.isInitialBuffering=!1,t.bufferType=this.state.calculateBufferType(t.isInitialBuffering),t.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),t.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),t}},{key:"sendSeekStart",value:function(t){var i;this.state.goSeekStart()&&(i=this.isAd()?e.Events.AD_SEEK_START:e.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t))}},{key:"sendSeekEnd",value:function(t){var i;this.state.goSeekEnd()&&(t=t||{},this.isAd()?(i=e.Events.AD_SEEK_END,t.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(i=e.Events.CONTENT_SEEK_END,t.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t))}},{key:"sendDownload",value:function(t){(t=t||{}).state||l.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(e.Events.DOWNLOAD,t),this.state.goDownload()}},{key:"sendError",value:function(t){(t=t||{}).isAd=this.isAd(),this.state.goError();var i=this.isAd()?e.Events.AD_ERROR:e.Events.CONTENT_ERROR;this.sendVideoErrorAction(i,t)}},{key:"sendRenditionChanged",value:function(t){(t=t||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime();var i,r=t,n=r.oldBitrate,a=r.newBitrate;this.isAd()||void 0===n||void 0===a||(a>n?(t.shift="up",this.state.totalSwitchUps+=1):a<n?(t.shift="down",this.state.totalSwitchDowns+=1):t.shift=null),delete t.oldBitrate,delete t.newBitrate,i=this.isAd()?e.Events.AD_RENDITION_CHANGE:e.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(i,t):this.sendVideoAction(i,t),this.state.goRenditionChange()}},{key:"sendHeartbeat",value:function(t){if(this.state.isRequested){var i,r=this.getHeartbeat();this.state._hb=!0,r=this.adjustElapsedTimeForPause(r),this.isAd()?(i=e.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(i,t):this.sendVideoAdAction(i,kt({elapsedTime:r},t))):(i=e.Events.CONTENT_HEARTBEAT,this.sendVideoAction(i,kt({elapsedTime:r},t))),this.state.goHeartbeat()}}},{key:"adjustElapsedTimeForPause",value:function(t){return this.state._acc&&(t-=this.state._acc,this.state._acc=0),this.state.isPaused&&((t-=this.state.elapsedTime.getDeltaTime())<10&&(t=0),this.state.elapsedTime.start()),this.state._bufferAcc?(t-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((t-=this.state.bufferElapsedTime.getDeltaTime())<5&&(t=0),this.state.bufferElapsedTime.start()),Math.max(0,t)}},{key:"sendAdBreakStart",value:function(t){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(e.Events.AD_BREAK_START,t))}},{key:"sendAdBreakEnd",value:function(t){this.isAd()&&this.state.goAdBreakEnd()&&((t=t||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(e.Events.AD_BREAK_END,t),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}},{key:"sendAdQuartile",value:function(t){this.isAd()&&((t=t||{}).quartile||l.warn("Called sendAdQuartile without { quartile: xxxxx }."),t.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(e.Events.AD_QUARTILE,t),this.state.goAdQuartile())}},{key:"sendAdClick",value:function(t){this.isAd()&&((t=t||{}).url||l.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(e.Events.AD_CLICK,t))}}],r&&Ot(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(V);function Ct(t){t.type!==jt.Events.AD_ERROR?this.sendVideoAdAction(t.type,t.data):this.sendVideoErrorAction(t.type,t.data)}Bt(jt,"Events",void 0),jt.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"};const Nt=jt;function It(t){return It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(t)}function Lt(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ht(r.key),r)}}function Vt(t,e,i){return(e=Ht(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ht(t){var e=function(t){if("object"!=It(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=It(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==It(e)?e:e+""}var xt=p.MAX_PAYLOAD_SIZE,Ft=p.MAX_EVENTS_PER_BATCH,Qt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Vt(this,"buffer",void 0),Vt(this,"maxPayloadSize",void 0),Vt(this,"maxEventsPerBatch",void 0),Vt(this,"currentPayloadSize",void 0),Vt(this,"totalEvents",void 0),Vt(this,"smartHarvestPayloadThreshold",void 0),Vt(this,"overflowPayloadThreshold",void 0),Vt(this,"smartHarvestEventThreshold",void 0),Vt(this,"overflowEventThreshold",void 0),Vt(this,"onSmartHarvestTrigger",void 0),this.buffer=[],this.maxPayloadSize=xt,this.maxEventsPerBatch=Ft,this.currentPayloadSize=0,this.totalEvents=0,this.smartHarvestPayloadThreshold=Math.floor(.6*this.maxPayloadSize),this.overflowPayloadThreshold=Math.floor(.9*this.maxPayloadSize),this.smartHarvestEventThreshold=Math.floor(.6*this.maxEventsPerBatch),this.overflowEventThreshold=Math.floor(.9*this.maxEventsPerBatch),this.onSmartHarvestTrigger=null},e=[{key:"addOrReplaceByActionName",value:function(t,e){var i=this.buffer.findIndex(function(e){return e.actionName===t});try{return-1===i?this.add(e):this.add(e,i),!0}catch(t){return l.error("Failed to set or replace the event to buffer:",t.message),!1}}},{key:"addOrReplaceByActionNameAndViewId",value:function(t,e,i){var r=this.buffer.findIndex(function(i){return i.actionName===t&&i.viewId===e});try{return-1===r?this.add(i):this.add(i,r),!0}catch(t){return l.error("Failed to set or replace the event to buffer:",t.message),!1}}},{key:"findByActionNameAndViewId",value:function(t,e){return this.buffer.find(function(i){return i.actionName===t&&i.viewId===e})||null}},{key:"findByActionName",value:function(t){return this.buffer.find(function(e){return e.actionName===t})||null}},{key:"add",value:function(t,e){try{var i,r=null!==(i=F(t))&&void 0!==i?i:0,n=this.currentPayloadSize+r>=this.maxPayloadSize,a=this.totalEvents+1>=this.maxEventsPerBatch;if((n||a)&&this.makeRoom(r),null!=e&&e>-1){var o,s=null!==(o=F(this.buffer[e]))&&void 0!==o?o:0;this.buffer[e]=t,this.currentPayloadSize+=r-s}else this.buffer.push(t),this.totalEvents++,this.currentPayloadSize+=r;return this.checkSmartHarvestTrigger(),!0}catch(t){return l.error("Failed to add event to buffer:",t.message),!1}}},{key:"checkSmartHarvestTrigger",value:function(){var t=this.currentPayloadSize/this.maxPayloadSize,e=this.totalEvents/this.maxEventsPerBatch,i=this.currentPayloadSize>=this.overflowPayloadThreshold,r=this.totalEvents>=this.overflowEventThreshold;if(i||r){var n=i?"payload ".concat(this.currentPayloadSize,"/").concat(this.maxPayloadSize," bytes (").concat(Math.round(100*t),"%)"):"events ".concat(this.totalEvents,"/").concat(this.maxEventsPerBatch," (").concat(Math.round(100*e),"%)");l.warn("OVERFLOW PREVENTION: ".concat(n," - Emergency harvest triggered")),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{var a=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,o=this.totalEvents>=this.smartHarvestEventThreshold;(a||o)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}},{key:"setSmartHarvestCallback",value:function(t){this.onSmartHarvestTrigger=t}},{key:"drain",value:function(){try{var t=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,t}catch(t){return l.error("Failed to drain events from buffer:",t.message),[]}}},{key:"isEmpty",value:function(){return 0===this.totalEvents}},{key:"size",value:function(){return this.totalEvents}},{key:"clear",value:function(){this.buffer=[],this.totalEvents=0}},{key:"makeRoom",value:function(t){if(t>this.maxPayloadSize)l.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+t>=this.maxPayloadSize)&&this.buffer.length>0;){var e,i=null!==(e=F(this.buffer.shift()))&&void 0!==e?e:0;this.totalEvents--,this.currentPayloadSize-=i,l.warn("Event buffer full, oldest event removed.")}}}],e&&Lt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function qt(t){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qt(t)}function Ut(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function Gt(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ut(Object(i),!0).forEach(function(e){Kt(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Ut(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function zt(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Wt(r.key),r)}}function Kt(t,e,i){return(e=Wt(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Wt(t){var e=function(t){if("object"!=qt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=qt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}var Yt=p.MAX_PAYLOAD_SIZE,Xt=p.MAX_EVENTS_PER_BATCH,Zt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Kt(this,"retryQueue",void 0),Kt(this,"maxQueueSize",void 0),Kt(this,"maxQueueSizeBytes",void 0),this.retryQueue=[],this.maxQueueSize=Xt,this.maxQueueSizeBytes=Yt},(e=[{key:"addFailedEvents",value:function(t){try{var e=Array.isArray(t)?t:[t];l.notice("Adding ".concat(e.length," failed events to retry queue"),{queueSizeBefore:this.retryQueue.length});var i,r=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Mt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}(e);try{for(r.s();!(i=r.n()).done;){var n,a=i.value;this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();for(var o=null!==(n=F(a))&&void 0!==n?n:0;(null!==(s=F(this.retryQueue))&&void 0!==s?s:0)+o>this.maxQueueSizeBytes;){var s;this.evictOldestEvent()}this.retryQueue.push(Gt({},a))}}catch(t){r.e(t)}finally{r.f()}}catch(t){l.error("Failed to add events to retry queue:",t.message)}}},{key:"discardEvent",value:function(t,e){l.warn("Discarded event",{reason:e,eventType:t.eventType})}},{key:"evictOldestEvent",value:function(){if(this.retryQueue.length>0){var t=this.retryQueue.shift();this.discardEvent(t,"Queue full - evicted oldest")}}},{key:"getRetryEventsToFit",value:function(t,e){for(var i=[],r=0,n=0,a=this.retryQueue.length-1;a>=0;a--){var o,s=this.retryQueue[a];if(n>=e)break;var u=null!==(o=F(s))&&void 0!==o?o:0;if(r+u>t)break;i.unshift(s),r+=u,n++,this.retryQueue.splice(a,1)}return i}},{key:"getQueueSize",value:function(){return this.retryQueue.length}},{key:"clear",value:function(){this.retryQueue=[]}}])&&zt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function $t(t,e){return e&&0!==e.length?e.reduce(function(t,e){var i;try{if(e.regex instanceof RegExp){var r=e.regex.flags.includes("g")?e.regex.flags:e.regex.flags+"g";i=new RegExp(e.regex.source,r)}else i=new RegExp(e.regex,"g")}catch(i){return l.warn("applyObfuscationRules: invalid regex, skipping rule:",e.regex,i.message),t}return t.replace(i,e.replacement)},t):t}function Jt(t){return Jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jt(t)}function te(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function ee(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?te(Object(i),!0).forEach(function(e){ie(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):te(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function ie(t,e,i){return(e=ue(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function re(){var t,e,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",n=i.toStringTag||"@@toStringTag";function a(i,r,n,a){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ne(c,"_invoke",function(i,r,n){var a,s,u,c=0,l=n||[],f=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,i){return a=e,s=0,u=t,d.n=i,o}};function h(i,r){for(s=i,u=r,e=0;!f&&c&&!n&&e<l.length;e++){var n,a=l[e],h=d.p,v=a[2];i>3?(n=v===r)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((n=i<2&&h<a[1])?(s=0,d.v=r,d.n=a[1]):h<v&&(n=i<3||a[0]>r||r>v)&&(a[4]=i,a[5]=r,d.n=v,s=0))}if(n||i>1)return o;throw f=!0,r}return function(n,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,v),s=l,u=v;(e=s<2?t:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(n="next"),e=a[n]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+n+"' method"),s=1);a=t}else if((e=(f=d.n<0)?u:i.call(r,d))!==o)break}catch(e){a=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(i,n,a),!0),c}var o={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(ne(e={},r,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,ne(t,n,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,ne(f,"constructor",c),ne(c,"constructor",u),u.displayName="GeneratorFunction",ne(c,n,"GeneratorFunction"),ne(f),ne(f,n,"Generator"),ne(f,r,function(){return this}),ne(f,"toString",function(){return"[object Generator]"}),(re=function(){return{w:a,m:d}})()}function ne(t,e,i,r){var n=Object.defineProperty;try{n({},"",{})}catch(t){n=0}ne=function(t,e,i,r){function a(e,i){ne(t,e,function(t){return this._invoke(e,i,t)})}e?n?n(t,e,{value:i,enumerable:!r,configurable:!r,writable:!r}):t[e]=i:(a("next",0),a("throw",1),a("return",2))},ne(t,e,i,r)}function ae(t,e,i,r,n,a,o){try{var s=t[a](o),u=s.value}catch(t){return void i(t)}s.done?e(u):Promise.resolve(u).then(r,n)}function oe(t){return function(){var e=this,i=arguments;return new Promise(function(r,n){var a=t.apply(e,i);function o(t){ae(a,r,n,o,s,"next",t)}function s(t){ae(a,r,n,o,s,"throw",t)}o(void 0)})}}function se(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ue(r.key),r)}}function ue(t){var e=function(t){if("object"!=Jt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Jt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Jt(e)?e:e+""}var ce=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"send",value:(a=oe(re().m(function t(e,i){var r,n,a,o,s,u;return re().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=e.url,n=e.payload,a=e.options,o=void 0===a?{}:a,t.p=1,r&&n){t.n=2;break}throw new Error("URL and payload are required");case 2:return s={url:r,payload:n,options:o,callback:i},t.n=3,this.executeRequest(s);case 3:t.n=5;break;case 4:t.p=4,u=t.v,l.error("Failed to send request:",u.message),i({retry:!1,status:0,error:u.message});case 5:return t.a(2)}},t,this,[[1,4]])})),function(t,e){return a.apply(this,arguments)})},{key:"executeRequest",value:(n=oe(re().m(function t(e){var i,r,n,a,o,s,u,c,l,f,d,h;return re().w(function(t){for(;;)switch(t.p=t.n){case 0:if(i=e.url,r=e.payload,n=e.options,e.callback,a=Date.now(),t.p=1,s=$t(JSON.stringify(r.body),null===(o=window.NRVIDEO)||void 0===o||null===(o=o.config)||void 0===o?void 0:o.obfuscate),!n.isFinalHarvest||!navigator.sendBeacon){t.n=3;break}return t.n=2,this.sendWithBeacon(i,s);case 2:return u=t.v,c={success:u,status:u?204:0},this.handleRequestComplete(e,c,a),t.a(2);case 3:return t.n=4,this.fetchWithTimeout(i,{method:"POST",body:s,headers:{"Content-Type":"application/json"},keepalive:n.isFinalHarvest},1e4);case 4:l=t.v,f={success:l.ok,status:l.status,statusText:l.statusText},this.handleRequestComplete(e,f,a),t.n=6;break;case 5:t.p=5,h=t.v,d={success:!1,status:0,error:h.message},this.handleRequestComplete(e,d,a);case 6:return t.a(2)}},t,this,[[1,5]])})),function(t){return n.apply(this,arguments)})},{key:"handleRequestComplete",value:function(t,e,i){(0,t.callback)({retry:!e.success&&(0===e.status||function(t){switch(t){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return t>=502&&t<=504||t>=512&&t<=530}(e.status)),status:e.status,error:e.error})}},{key:"sendWithBeacon",value:(r=oe(re().m(function t(e,i){var r;return re().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.a(2,navigator.sendBeacon(e,i));case 1:return t.p=1,r=t.v,l.warn("sendBeacon failed, falling back to fetch:",r.message),t.a(2,!1)}},t,null,[[0,1]])})),function(t,e){return r.apply(this,arguments)})},{key:"fetchWithTimeout",value:(i=oe(re().m(function t(e,i,r){var n,a,o,s;return re().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=new AbortController,a=setTimeout(function(){return n.abort()},r),t.p=1,t.n=2,fetch(e,ee(ee({},i),{},{signal:n.signal}));case 2:return o=t.v,clearTimeout(a),t.a(2,o);case 3:if(t.p=3,s=t.v,clearTimeout(a),"AbortError"!==s.name){t.n=4;break}throw new Error("Request timeout after ".concat(r,"ms"));case 4:throw s;case 5:return t.a(2)}},t,null,[[1,3]])})),function(t,e,r){return i.apply(this,arguments)})}],e&&se(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i,r,n,a}();function le(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return fe(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?fe(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function fe(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function de(t,e){var i=t[e.viewId];if(!i)return!1;var r,n=le(p.QOE_KPI_KEYS);try{for(n.s();!(r=n.n()).done;){var a=r.value;if(e[a]!==i[a])return!1}}catch(t){n.e(t)}finally{n.f()}return!0}function he(t,e){var i,r={},n=le(p.QOE_KPI_KEYS);try{for(n.s();!(i=n.n()).done;){var a=i.value;r[a]=e[a]}}catch(t){n.e(t)}finally{n.f()}t[e.viewId]=r}function ve(){var t,e,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",n=i.toStringTag||"@@toStringTag";function a(i,r,n,a){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ye(c,"_invoke",function(i,r,n){var a,s,u,c=0,l=n||[],f=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,i){return a=e,s=0,u=t,d.n=i,o}};function h(i,r){for(s=i,u=r,e=0;!f&&c&&!n&&e<l.length;e++){var n,a=l[e],h=d.p,v=a[2];i>3?(n=v===r)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((n=i<2&&h<a[1])?(s=0,d.v=r,d.n=a[1]):h<v&&(n=i<3||a[0]>r||r>v)&&(a[4]=i,a[5]=r,d.n=v,s=0))}if(n||i>1)return o;throw f=!0,r}return function(n,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,v),s=l,u=v;(e=s<2?t:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(n="next"),e=a[n]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+n+"' method"),s=1);a=t}else if((e=(f=d.n<0)?u:i.call(r,d))!==o)break}catch(e){a=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(i,n,a),!0),c}var o={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(ye(e={},r,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,ye(t,n,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,ye(f,"constructor",c),ye(c,"constructor",u),u.displayName="GeneratorFunction",ye(c,n,"GeneratorFunction"),ye(f),ye(f,n,"Generator"),ye(f,r,function(){return this}),ye(f,"toString",function(){return"[object Generator]"}),(ve=function(){return{w:a,m:d}})()}function ye(t,e,i,r){var n=Object.defineProperty;try{n({},"",{})}catch(t){n=0}ye=function(t,e,i,r){function a(e,i){ye(t,e,function(t){return this._invoke(e,i,t)})}e?n?n(t,e,{value:i,enumerable:!r,configurable:!r,writable:!r}):t[e]=i:(a("next",0),a("throw",1),a("return",2))},ye(t,e,i,r)}function me(t,e,i,r,n,a,o){try{var s=t[a](o),u=s.value}catch(t){return void i(t)}s.done?e(u):Promise.resolve(u).then(r,n)}function pe(t){return function(){var e=this,i=arguments;return new Promise(function(r,n){var a=t.apply(e,i);function o(t){me(a,r,n,o,s,"next",t)}function s(t){me(a,r,n,o,s,"throw",t)}o(void 0)})}}function ge(t){return ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ge(t)}function be(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function Se(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?be(Object(i),!0).forEach(function(e){Pe(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):be(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function Te(t){return function(t){if(Array.isArray(t))return Ee(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ee(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Ee(t,e):void 0}}(t)||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.")}()}function Ee(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function Ae(){var t,e,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",n=i.toStringTag||"@@toStringTag";function a(i,r,n,a){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return we(c,"_invoke",function(i,r,n){var a,s,u,c=0,l=n||[],f=!1,d={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,i){return a=e,s=0,u=t,d.n=i,o}};function h(i,r){for(s=i,u=r,e=0;!f&&c&&!n&&e<l.length;e++){var n,a=l[e],h=d.p,v=a[2];i>3?(n=v===r)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((n=i<2&&h<a[1])?(s=0,d.v=r,d.n=a[1]):h<v&&(n=i<3||a[0]>r||r>v)&&(a[4]=i,a[5]=r,d.n=v,s=0))}if(n||i>1)return o;throw f=!0,r}return function(n,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,v),s=l,u=v;(e=s<2?t:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(n="next"),e=a[n]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+n+"' method"),s=1);a=t}else if((e=(f=d.n<0)?u:i.call(r,d))!==o)break}catch(e){a=t,s=1,u=e}finally{c=1}}return{value:e,done:f}}}(i,n,a),!0),c}var o={};function s(){}function u(){}function c(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(we(e={},r,function(){return this}),e),f=c.prototype=s.prototype=Object.create(l);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,we(t,n,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=c,we(f,"constructor",c),we(c,"constructor",u),u.displayName="GeneratorFunction",we(c,n,"GeneratorFunction"),we(f),we(f,n,"Generator"),we(f,r,function(){return this}),we(f,"toString",function(){return"[object Generator]"}),(Ae=function(){return{w:a,m:d}})()}function we(t,e,i,r){var n=Object.defineProperty;try{n({},"",{})}catch(t){n=0}we=function(t,e,i,r){function a(e,i){we(t,e,function(t){return this._invoke(e,i,t)})}e?n?n(t,e,{value:i,enumerable:!r,configurable:!r,writable:!r}):t[e]=i:(a("next",0),a("throw",1),a("return",2))},we(t,e,i,r)}function ke(t,e,i,r,n,a,o){try{var s=t[a](o),u=s.value}catch(t){return void i(t)}s.done?e(u):Promise.resolve(u).then(r,n)}function Oe(t){return function(){var e=this,i=arguments;return new Promise(function(r,n){var a=t.apply(e,i);function o(t){ke(a,r,n,o,s,"next",t)}function s(t){ke(a,r,n,o,s,"throw",t)}o(void 0)})}}function _e(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Re(r.key),r)}}function Pe(t,e,i){return(e=Re(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Re(t){var e=function(t){if("object"!=ge(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=ge(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ge(e)?e:e+""}var Be=function(){return t=function t(e){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Pe(this,"eventBuffer",void 0),Pe(this,"retryQueueHandler",void 0),Pe(this,"httpClient",void 0),Pe(this,"fallBackUrl",void 0),Pe(this,"retryCount",void 0),Pe(this,"harvestCycle",void 0),Pe(this,"isHarvesting",void 0),Pe(this,"qoeCycleCount",void 0),Pe(this,"forceNextQoeCycle",void 0),Pe(this,"beforeDrainCallback",void 0),Pe(this,"_lastSentQoeKpis",void 0),Pe(this,"timer",void 0),this.eventBuffer=e,this.retryQueueHandler=new Zt,this.httpClient=new ce,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof Qt&&this.eventBuffer.setSmartHarvestCallback(function(t,e){return i.triggerSmartHarvest(t,e)}),this.harvestCycle=p.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.timer=function(t){var e=t.onTick,i=t.errorLabel,r=!1,n=null,a=t.interval;function o(){r&&(n=setTimeout(pe(ve().m(function t(){var a;return ve().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=null,t.p=1,t.n=2,e();case 2:t.n=4;break;case 3:t.p=3,a=t.v,l.error("".concat(i,": scheduled tick failed:"),a.message);case 4:return t.p=4,r&&o(),t.f(4);case 5:return t.a(2)}},t,null,[[1,3,4,5]])})),a))}return{start:function(){r||(r=!0,o())},stop:function(){r=!1,n&&(clearTimeout(n),n=null)},cancelAndReschedule:function(){n&&(clearTimeout(n),n=null),r&&o()},updateInterval:function(t){"number"!=typeof t||t<=0||(a=t,r&&n&&(clearTimeout(n),n=null,o()))},isRunning:function(){return r}}}({interval:this.harvestCycle,onTick:function(){return i.onHarvestInterval()},errorLabel:"HarvestScheduler"}),this.setupPageLifecycleHandlers()},e=[{key:"isStarted",get:function(){return this.timer.isRunning()}},{key:"startScheduler",value:function(){this.timer.isRunning()?l.warn("Harvest scheduler is already started"):(l.notice("Starting harvest scheduler",{harvestCycle:this.harvestCycle,eventBufferSize:this.eventBuffer?this.eventBuffer.size():0}),this.timer.start())}},{key:"stopScheduler",value:function(){this.timer.isRunning()&&(this.timer.stop(),l.notice("Harvest scheduler stopped"))}},{key:"triggerSmartHarvest",value:(a=Oe(Ae().m(function t(e,i){var r;return Ae().w(function(t){for(;;)switch(t.p=t.n){case 0:if(l.notice("".concat(e," harvest triggered at ").concat(i,"% threshold"),{type:e,threshold:i}),this.eventBuffer&&!this.eventBuffer.isEmpty()){t.n=1;break}return t.a(2);case 1:return t.p=1,t.n=2,this.triggerHarvest({});case 2:t.n=4;break;case 3:t.p=3,r=t.v,l.error("".concat(e," harvest failed:"),r.message);case 4:return t.p=4,this.timer.cancelAndReschedule(),t.f(4);case 5:return t.a(2)}},t,this,[[1,3,4,5]])})),function(t,e){return a.apply(this,arguments)})},{key:"onHarvestInterval",value:(n=Oe(Ae().m(function t(){var e,i;return Ae().w(function(t){for(;;)switch(t.n){case 0:if(e=this.eventBuffer&&!this.eventBuffer.isEmpty(),i=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0,e||i){t.n=1;break}return t.a(2);case 1:return t.n=2,this.triggerHarvest({});case 2:return t.a(2)}},t,this)})),function(){return n.apply(this,arguments)})},{key:"triggerHarvest",value:(r=Oe(Ae().m(function t(){var e,i,r,n,a,o,s=arguments;return Ae().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=s.length>0&&void 0!==s[0]?s[0]:{},!this.isHarvesting){t.n=1;break}return t.a(2,{success:!1,reason:"harvest_in_progress"});case 1:return this.isHarvesting=!0,t.p=2,i=this.drainEvents(e),e.isFinalHarvest&&(n=p.MAX_BEACON_SIZE,(null!==(r=F(i))&&void 0!==r?r:0)>n&&(i=this.trimEventsToFit(i,n))),t.n=3,this.sendChunk(i,e,!0);case 3:return a=t.v,t.a(2,{success:a.success,totalChunks:1,results:[a]});case 4:return t.p=4,o=t.v,l.error("Harvest cycle failed:",o.message),this.handleHarvestFailure(o),t.a(2,{success:!1,error:o.message});case 5:return t.p=5,this.isHarvesting=!1,t.f(5);case 6:return t.a(2)}},t,this,[[2,4,5,6]])})),function(){return r.apply(this,arguments)})},{key:"trimEventsToFit",value:function(t,e){if(0===t.length)return t;for(var i=[],r=0,n=t.length-1;n>=0;n--){var a,o=t[n],s=null!==(a=F({ins:[o].concat(i)}))&&void 0!==a?a:0;s>e||(i.unshift(o),r=s)}var u=t.length-i.length;if(u>0){var c=t.slice(0,u);l.warn("Discarded ".concat(u," events to fit beacon size limit"),{originalCount:t.length,trimmedCount:i.length,finalSize:r,maxSize:e}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(c)}return i}},{key:"drainEvents",value:function(){var t,e,i,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(t=null===(e=window.NRVIDEO)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.qoeIntervalFactor)&&void 0!==t?t:1,a=!!r.isFinalHarvest||this.forceNextQoeCycle,o=(this.qoeCycleCount-1)%n==0||a;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(t){l.error("Before drain callback failed:",t.message)}var s=function(t,e,i){if(e)return t;var r,n=[],a=le(t);try{for(a.s();!(r=a.n()).done;){var o=r.value;o.actionName===V.Events.QOE_AGGREGATE?i.add(o):n.push(o)}}catch(t){a.e(t)}finally{a.f()}return n}(this.eventBuffer.drain(),o,this.eventBuffer);this.qoeCycleCount++,function(t,e,i){for(var r=t.length-1;r>=0;r--){var n=t[r];n.actionName===V.Events.QOE_AGGREGATE&&(!i&&de(e,n)?t.splice(r,1):he(e,n))}}(s,this._lastSentQoeKpis,a);var u=Te(s),c=null!==(i=F(s))&&void 0!==i?i:0;if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){var f=p.MAX_PAYLOAD_SIZE-c,d=p.MAX_EVENTS_PER_BATCH-u.length;if(f>0&&d>0){var h=this.retryQueueHandler.getRetryEventsToFit(f,d);h.length>0&&(u=[].concat(Te(h),Te(u)))}}return u}},{key:"sendChunk",value:(i=Oe(Ae().m(function t(e,i,r){var n,a,o=this;return Ae().w(function(t){for(;;)if(0===t.n)return n=x(this.fallBackUrl),a={url:n,payload:{body:{ins:e}},options:Se(Se({},i),{},{isLastChunk:r})},t.a(2,new Promise(function(t){o.httpClient.send(a,function(i){i.retry?o.handleRequestFailure(e):(o.retryCount=0,o.fallBackUrl=""),t({success:!i.retry,status:i.status,error:i.error,chunk:e,eventCount:e.length})})}))},t,this)})),function(t,e,r){return i.apply(this,arguments)})},{key:"handleRequestFailure",value:function(t){var e;this.retryQueueHandler.addFailedEvents(t),"US"===(null===(e=window.NRVIDEO)||void 0===e||null===(e=e.info)||void 0===e?void 0:e.region)&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=p.COLLECTOR.US[1]))}},{key:"handleHarvestFailure",value:function(t){l.warn("Harvest failure handled",{error:t.message})}},{key:"updateHarvestInterval",value:function(t){"number"!=typeof t||isNaN(t)?l.warn("Invalid newInterval provided to updateHarvestInterval"):t<1e3||t>3e5?l.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==t&&(this.harvestCycle=t,l.notice("Updated harvestCycle:",this.harvestCycle),this.timer.updateInterval(t))}},{key:"setupPageLifecycleHandlers",value:function(){var t=this,e=!1,i=function(){e||(e=!0,t.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",function(){document.hidden&&i()}),window.addEventListener("pagehide",function(){i()}),window.addEventListener("beforeunload",function(){i()})}}],e&&_e(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i,r,n,a}();const De={Constants:p,Chrono:P,Log:l,Emitter:E,Tracker:V,VideoTracker:Nt,VideoTrackerState:Et,Core:ht,version:g,NrVideoEventAggregator:Qt,RetryQueueHandler:Zt,OptimizedHttpClient:ce,HarvestScheduler:Be,recordEvent:K};return e=e.default,e})());
|
|
3
3
|
//# sourceMappingURL=nrvideo.min.js.map
|