@newrelic/video-videojs 4.1.0 → 4.1.1
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 +11 -0
- package/README.md +187 -23
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.LICENSE.txt +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.LICENSE.txt +1 -1
- package/dist/umd/newrelic-video-videojs.min.js +1 -1
- package/dist/umd/newrelic-video-videojs.min.js.LICENSE.txt +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see newrelic-video-videojs.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.VideojsTracker=e():t.VideojsTracker=e()}(self,()=>(()=>{"use strict";var t={555(t,e,i){i.r(e),i.d(e,{default:()=>P});var r={487(t,e,i){i.r(e),i.d(e,{videoAnalyticsHarvester:()=>u});var r=i(374),n=i(431),a=i(51),s=i(144),o=i(302);const u=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)s.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new n.t,this.harvestScheduler=new r.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,s.A.notice("Video analytics agent initialized successfully")}catch(t){s.A.error("Failed to initialize video analytics agent:",t.message)}}addEvent(t){this.isInitialized||(s.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return t.actionName&&t.actionName===o.A.Events.QOE_AGGREGATE?t.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,t.viewId,t):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,t):this.eventBuffer.add(t)}catch(t){return s.A.error("Failed to add event to harvesting system:",t.message),!1}}setHarvestInterval(t){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(t)}forceNextQoeCycle(){this.harvestScheduler&&(this.harvestScheduler.forceNextQoeCycle=!0)}setBeforeDrainCallback(t){this.harvestScheduler&&(this.harvestScheduler.beforeDrainCallback=t)}refreshQoeKpis(t,e){if(!this.eventBuffer||!t)return;const i=e?this.eventBuffer.findByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e):this.eventBuffer.findByActionName(o.A.Events.QOE_AGGREGATE);if(i){const r={...i};for(const e of a.A.QOE_KPI_KEYS)e in t&&(r[e]=t[e]);e?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e,r):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,r)}}}},455(t,e,i){i.d(e,{A:()=>n});class r{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}getDuration(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(this.getDeltaTime()??0)}clone(){var t=new r;return t.startTime=this.startTime,t.stopTime=this.stopTime,t.offset=this.offset,t.accumulator=this.accumulator,t}}const n=r},51(t,e,i){i.d(e,{A:()=>n});class r{}r.AdPositions={PRE:"pre",MID:"mid",POST:"post"},r.COLLECTOR={US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},r.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],r.MAX_PAYLOAD_SIZE=1048576,r.MAX_BEACON_SIZE=61440,r.MAX_EVENTS_PER_BATCH=1e3,r.INTERVAL=1e4,r.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],r.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 n=r},568(t,e,i){i.d(e,{A:()=>r});const r=class{on(t,e){if(this._listeners=this._listeners||{},"function"==typeof e)return this._listeners[t]=this._listeners[t]||[],this._listeners[t].push(e),this}off(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}emit(t,e,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[e])&&this._listeners[e].forEach(r=>{r.call(this,{eventType:t,type:e,data:i,target:this})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(r=>{r.call(this,{eventType:t,type:e,data:i,target:this})}),this}}},431(t,e,i){i.d(e,{t:()=>u});var r=i(144),n=i(51),a=i(347);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=n.A;class u{constructor(){this.buffer=[],this.maxPayloadSize=s,this.maxEventsPerBatch=o,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}addOrReplaceByActionName(t,e){const i=this.buffer.findIndex(e=>e.actionName===t);try{return-1===i?this.add(e):this.add(e,i),!0}catch(t){return r.A.error("Failed to set or replace the event to buffer:",t.message),!1}}addOrReplaceByActionNameAndViewId(t,e,i){const n=this.buffer.findIndex(i=>i.actionName===t&&i.viewId===e);try{return-1===n?this.add(i):this.add(i,n),!0}catch(t){return r.A.error("Failed to set or replace the event to buffer:",t.message),!1}}findByActionNameAndViewId(t,e){return this.buffer.find(i=>i.actionName===t&&i.viewId===e)||null}findByActionName(t){return this.buffer.find(e=>e.actionName===t)||null}add(t,e){try{const i=(0,a.Q3)(t),r=this.currentPayloadSize+i>=this.maxPayloadSize,n=this.totalEvents+1>=this.maxEventsPerBatch;if((r||n)&&this.makeRoom(i),null!=e&&e>-1){const r=(0,a.Q3)(this.buffer[e]);this.buffer[e]=t,this.currentPayloadSize+=i-r}else this.buffer.push(t),this.totalEvents++,this.currentPayloadSize+=i;return this.checkSmartHarvestTrigger(),!0}catch(t){return r.A.error("Failed to add event to buffer:",t.message),!1}}checkSmartHarvestTrigger(){const t=this.currentPayloadSize/this.maxPayloadSize,e=this.totalEvents/this.maxEventsPerBatch,i=this.currentPayloadSize>=this.overflowPayloadThreshold,n=this.totalEvents>=this.overflowEventThreshold;if(i||n){const n=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*t)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*e)}%)`;r.A.warn(`OVERFLOW PREVENTION: ${n} - Emergency harvest triggered`),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{const t=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,e=this.totalEvents>=this.smartHarvestEventThreshold;(t||e)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}setSmartHarvestCallback(t){this.onSmartHarvestTrigger=t}drain(){try{const t=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,t}catch(t){return r.A.error("Failed to drain events from buffer:",t.message),[]}}isEmpty(){return 0===this.totalEvents}size(){return this.totalEvents}clear(){this.buffer=[],this.totalEvents=0}makeRoom(t){if(t>this.maxPayloadSize)r.A.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+t>=this.maxPayloadSize)&&this.buffer.length>0;){const t=this.buffer.shift(),e=(0,a.Q3)(t);this.totalEvents--,this.currentPayloadSize-=e,r.A.warn("Event buffer full, oldest event removed.")}}}},374(t,e,i){i.d(e,{n:()=>d});var r=i(431),n=i(413),a=i(481),s=i(347),o=i(51),u=i(302),l=i(144);class d{constructor(t){this.eventBuffer=t,this.retryQueueHandler=new n.u,this.httpClient=new a.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof r.t&&this.eventBuffer.setSmartHarvestCallback((t,e)=>this.triggerSmartHarvest(t,e)),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=o.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?l.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,l.A.notice("Starting harvest scheduler",{harvestCycle:this.harvestCycle,eventBufferSize:this.eventBuffer?this.eventBuffer.size():0}),this.scheduleNextHarvest())}stopScheduler(){this.isStarted&&(this.isStarted=!1,this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),l.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(t,e){if(l.A.notice(`${t} harvest triggered at ${e}% threshold`,{type:t,threshold:e}),this.eventBuffer&&!this.eventBuffer.isEmpty()){this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null);try{await this.triggerHarvest({})}catch(e){l.A.error(`${t} harvest failed:`,e.message)}finally{this.isStarted&&this.scheduleNextHarvest()}}}scheduleNextHarvest(){if(!this.isStarted)return;const t=this.harvestCycle;this.currentTimerId=setTimeout(()=>this.onHarvestInterval(),t)}async onHarvestInterval(){try{const t=this.eventBuffer&&!this.eventBuffer.isEmpty(),e=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0;if(!t&&!e)return;await this.triggerHarvest({})}catch(t){l.A.error("Error during scheduled harvest:",t.message)}finally{this.scheduleNextHarvest()}}async triggerHarvest(t={}){if(this.isHarvesting)return{success:!1,reason:"harvest_in_progress"};this.isHarvesting=!0;try{let e=this.drainEvents(t);if(t.isFinalHarvest){const t=o.A.MAX_BEACON_SIZE;(0,s.Q3)(e)>t&&(e=this.trimEventsToFit(e,t))}const i=await this.sendChunk(e,t,!0);return{success:i.success,totalChunks:1,results:[i]}}catch(t){return l.A.error("Harvest cycle failed:",t.message),this.handleHarvestFailure(t),{success:!1,error:t.message,consecutiveFailures:this.consecutiveFailures}}finally{this.isHarvesting=!1}}trimEventsToFit(t,e){if(0===t.length)return t;const i=[];let r=0;for(let n=t.length-1;n>=0;n--){const a=t[n],o=(0,s.Q3)({ins:[a,...i]});o>e||(i.unshift(a),r=o)}const n=t.length-i.length;if(n>0){const a=t.slice(0,n);l.A.warn(`Discarded ${n} events to fit beacon size limit`,{originalCount:t.length,trimmedCount:i.length,finalSize:r,maxSize:e}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(a)}return i}drainEvents(t={}){const e=window.NRVIDEO?.config?.qoeIntervalFactor??1,i=!!t.isFinalHarvest||this.forceNextQoeCycle,r=(this.qoeCycleCount-1)%e==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(t){l.A.error("Before drain callback failed:",t.message)}const n=this.eventBuffer.drain();let a;if(r)a=n;else{a=[];for(const t of n)t.actionName===u.A.Events.QOE_AGGREGATE?this.eventBuffer.add(t):a.push(t)}this.qoeCycleCount++;for(let t=a.length-1;t>=0;t--){const e=a[t];e.actionName===u.A.Events.QOE_AGGREGATE&&(!i&&this._qoeKpisUnchanged(e)?a.splice(t,1):this._saveQoeKpis(e))}let d=[...a],c=(0,s.Q3)(a);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const t=o.A.MAX_PAYLOAD_SIZE-c,e=o.A.MAX_EVENTS_PER_BATCH-d.length;if(t>0&&e>0){const i=this.retryQueueHandler.getRetryEventsToFit(t,e);i.length>0&&(d=[...i,...d])}}return d}async sendChunk(t,e,i){const r={url:(0,s.c$)(this.fallBackUrl),payload:{body:{ins:t}},options:{...e,isLastChunk:i}};return new Promise(e=>{this.httpClient.send(r,i=>{i.retry?this.handleRequestFailure(t):(this.retryCount=0,this.fallBackUrl=""),e({success:!i.retry,status:i.status,error:i.error,chunk:t,eventCount:t.length})})})}handleRequestFailure(t){this.retryQueueHandler.addFailedEvents(t),"US"===window.NRVIDEO?.info?.region&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=o.A.COLLECTOR.US[1]))}handleHarvestFailure(t){this.consecutiveFailures++,l.A.warn("Harvest failure handled",{error:t.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(t){"number"!=typeof t&&isNaN(t)?l.A.warn("Invalid newInterval provided to updateHarvestInterval"):t<1e3||t>3e5?l.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==t&&(this.harvestCycle=t,l.A.notice("Updated harvestCycle:",this.harvestCycle),this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),this.isStarted&&this.scheduleNextHarvest())}setupPageLifecycleHandlers(){let t=!1;const e=()=>{t||(t=!0,this.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",()=>{document.hidden&&e()}),window.addEventListener("pagehide",()=>{e()}),window.addEventListener("beforeunload",()=>{e()})}_qoeKpisUnchanged(t){const e=this._lastSentQoeKpis[t.viewId];if(!e)return!1;for(const i of o.A.QOE_KPI_KEYS)if(t[i]!==e[i])return!1;return!0}_saveQoeKpis(t){const e={};for(const i of o.A.QOE_KPI_KEYS)e[i]=t[i];this._lastSentQoeKpis[t.viewId]=e}}},144(t,e,i){i.d(e,{A:()=>o});class r{static error(...t){n(t,r.Levels.ERROR,"darkred")}static warn(...t){n(t,r.Levels.WARNING,"darkorange")}static notice(...t){n([].slice.call(arguments),r.Levels.NOTICE,"darkcyan")}static debug(...t){n(t,r.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(t,e,i){try{if(r.level<=r.Levels.DEBUG){i=i||function(t){r.debug("Event: "+t.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];e&&(null===e[0]?(e.shift(),n=e):n=n.concat(e));for(var a=0;a<n.length;a++)"function"==typeof t?t.call(window,n[a],i):t.on?t.on(n[a],i):t.addEventListener?t.addEventListener(n[a],i):t.addEventHandler?t.addEventHandler(n[a],i):r.warn("debugCommonVideoEvents: No common listener function found for ",t)}}catch(t){r.warn(t)}}}function n(t,e,i){e=e||r.Levels.NOTICE,i=i||"darkcyan";var n,o,u=r.prefix;r.includeTime&&(u+="["+("0"+(n=new Date).getDate()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+"] "),u+=function(t){return s[t]}(e)+":",r.level<=e&&e!==r.Levels.SILENT&&(!r.colorful||"undefined"!=typeof document&&document.documentMode?a(t,u):(o=e===r.Levels.ERROR&&console.error?console.error:e===r.Levels.WARNING&&console.warn?console.warn:e===r.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,u="%c"+u,t.splice(0,0,u,"color: "+i),o.apply(console,t)))}function a(t,e){if(t instanceof Array)for(var i in t)a(t[i],e);else"string"==typeof t?console.log(e+" "+t):(console.log(e+"↵"),console.log(t))}r.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},r.level=r.Levels.ERROR,r.colorful=!0,r.includeTime=!0,r.prefix="[nrvideo]";const s={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]?r.level=r.Levels.ALL:r.level=t[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(r.colorful=!1)}}();const o=r},481(t,e,i){i.d(e,{X:()=>a});var r=i(347),n=i(144);class a{async send(t,e){const{url:i,payload:r,options:a={}}=t;try{if(!i||!r)throw new Error("URL and payload are required");const t={url:i,payload:r,options:a,callback:e};await this.executeRequest(t)}catch(t){n.A.error("Failed to send request:",t.message),e({retry:!1,status:0,error:t.message})}}async executeRequest(t){const{url:e,payload:i,options:r,callback:a}=t,s=Date.now();try{const a=(o=JSON.stringify(i.body),u=window.NRVIDEO?.config?.obfuscate,u&&0!==u.length?u.reduce((t,e)=>{let i;try{if(e.regex instanceof RegExp){const t=e.regex.flags.includes("g")?e.regex.flags:e.regex.flags+"g";i=new RegExp(e.regex.source,t)}else i=new RegExp(e.regex,"g")}catch(i){return n.A.warn("applyObfuscationRules: invalid regex, skipping rule:",e.regex,i.message),t}return t.replace(i,e.replacement)},o):o);if(r.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(e,a),r={success:i,status:i?204:0};return void this.handleRequestComplete(t,r,s)}const l=await this.fetchWithTimeout(e,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:r.isFinalHarvest},1e4),d={success:l.ok,status:l.status,statusText:l.statusText};this.handleRequestComplete(t,d,s)}catch(e){const i={success:!1,status:0,error:e.message};this.handleRequestComplete(t,i,s)}var o,u}handleRequestComplete(t,e){const{callback:i}=t;i({retry:!e.success&&(0===e.status||(0,r.Sc)(e.status)),status:e.status,error:e.error})}async sendWithBeacon(t,e){try{return navigator.sendBeacon(t,e)}catch(t){return n.A.warn("sendBeacon failed, falling back to fetch:",t.message),!1}}async fetchWithTimeout(t,e,i){const r=new AbortController,n=setTimeout(()=>r.abort(),i);try{const i=await fetch(t,{...e,signal:r.signal});return clearTimeout(n),i}catch(t){if(clearTimeout(n),"AbortError"===t.name)throw new Error(`Request timeout after ${i}ms`);throw t}}}},413(t,e,i){i.d(e,{u:()=>u});var r=i(144),n=i(347),a=i(51);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=a.A;class u{constructor(){this.retryQueue=[],this.maxQueueSize=o,this.maxQueueSizeBytes=s}addFailedEvents(t){try{const e=Array.isArray(t)?t:[t];r.A.notice(`Adding ${e.length} failed events to retry queue`,{queueSizeBefore:this.retryQueue.length});for(const t of e){this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();const e=(0,n.Q3)(t);for(;(0,n.Q3)(this.retryQueue)+e>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...t})}}catch(t){r.A.error("Failed to add events to retry queue:",t.message)}}discardEvent(t,e){r.A.warn("Discarded event",{reason:e,eventType:t.eventType})}evictOldestEvent(){if(this.retryQueue.length>0){const t=this.retryQueue.shift();this.discardEvent(t,"Queue full - evicted oldest")}}getRetryEventsToFit(t,e){const i=[];let r=0,a=0;for(let s=this.retryQueue.length-1;s>=0;s--){const o=this.retryQueue[s];if(a>=e)break;const u=(0,n.Q3)(o);if(r+u>t)break;i.unshift(o),r+=u,a++,this.retryQueue.splice(s,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(t,e,i){i.d(e,{A:()=>d});var r=i(330),n=i(568),a=i(455),s=i(51),o=i(487),u=i(144);class l extends n.A{constructor(t){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new a.A,this._trackerReadyChrono.start(),this._actionTable=s.A.ACTION_TABLE,this._actionAdTable=s.A.ACTION_AD_TABLE,t=t||{},this.setOptions(t)}setOptions(t){t&&(t.parentTracker&&(this.parentTracker=t.parentTracker),t.customData&&(this.customData=t.customData),t.heartbeat&&(this.heartbeat=t.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(t){this.sendVideoAction(l.Events.HEARTBEAT,t)}getAttributes(t,e){(t=t||{}).trackerName=this.getTrackerName(),t.trackerVersion=this.getTrackerVersion(),t.coreVersion=r.rE,t.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let e in this.customData)t[e]=this.customData[e];return null!=document.hidden&&(t.isBackgroundEvent=document.hidden),t}getTrackerVersion(){return r.rE}getTrackerName(){return"base-tracker"}sendVideoAction(t,e){this.emit("VideoAction",t,this.getAttributes(e))}sendVideoAdAction(t,e){this.emit("VideoAdAction",t,this.getAttributes(e))}sendVideoErrorAction(t,e){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",t,this.getAttributes(e,i))}sendVideoCustomAction(t,e){this.emit("VideoCustomAction",t,this.getAttributes(e,"customAction"))}setHarvestInterval(t){if(o.videoAnalyticsHarvester)try{o.videoAnalyticsHarvester.setHarvestInterval(t)}catch(t){return void u.A.error("Failed to set harvest interval:",t.message)}else u.A.error("VideoAnalyticsHarvester is not available")}}l.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const d=l},347(t,e,i){i.d(e,{Q3:()=>s,Sc:()=>o,c$:()=>a,z8:()=>u});var r=i(330),n=i(144);function a(t){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:e,licenseKey:i,applicationID:n}=window.NRVIDEO.info;if(!e||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return n?`https://${t||e}/ins/1/${i}?a=${n}&v=${r.rE}&ref=${window.location.href}&ca=VA`:`https://${t||e}/ins/1/${i}?&v=${r.rE}&ref=${window.location.href}&ca=VA`}catch(t){return console.error(t.message),null}}function s(t){if("string"==typeof t&&t.length)return t.length;if("object"==typeof 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{return JSON.stringify(t,(()=>{const t=new WeakSet;return(e,i)=>{if("object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})())??""}catch(t){return n.A.error("Error stringifying value:",t.message),""}}(t).length}catch(t){return}}}function o(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}function u(t,e){return t&&Array.isArray(t)&&0!==t.length?e&&"object"==typeof e?t.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{}):{}:e}},330(t){t.exports={rE:"4.1.5"}}},n={};function a(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,a),i.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s=a(144),o=a(487),u=a(51),l=a(302),d=a(347);function c(t,e={}){try{if(!u.A.VALID_EVENT_TYPES.includes(t))return s.A.warn("Invalid event type provided to recordEvent",{eventType:t}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:r}=window.NRVIDEO.info,{qoe:n,...a}=e,c=n?{...n}:{},h={...r?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},f={...a,eventType:t,...h},y=(0,d.z8)(u.A.QOE_AGGREGATE_KEYS,e);let p=null;"VideoAction"===t&&(p={eventType:"VideoAction",actionName:l.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...c,...y,...h});const m=o.videoAnalyticsHarvester.addEvent(f);if(p&&window?.NRVIDEO?.config?.qoeAggregate){const t=o.videoAnalyticsHarvester.addEvent(p);return m&&t}return m}catch(t){return s.A.error("Failed to record event:",t.message),!1}}const{COLLECTOR:h}=u.A,f=new class{setConfiguration(t,e){return!!this.validateRequiredFields(t)&&!!this.validateConfigFields(e)&&(this.initializeGlobalConfig(t,e),s.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(t){if(!t||"object"!=typeof t)return s.A.error("Configuration must be an object"),!1;const{licenseKey:e,appName:i,region:r,applicationID:n,beacon:a}=t;if(!e)return s.A.error("licenseKey is required"),!1;if(n){if(!a)return s.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(h).flatMap(t=>t).includes(a))return s.A.error(`Invalid beacon: ${a}`),!1}else{if(!i||!r)return s.A.error("appName and region are required when applicationID is not provided"),!1;if(!h[r])return s.A.error(`Invalid region: ${r}. Valid regions are: ${Object.keys(h).join(", ")}`),!1}return!0}validateConfigFields(t){if(null==t)return!0;if("object"!=typeof t||Array.isArray(t))return s.A.error("config must be an object"),!1;const{qoeAggregate:e,obfuscate:i}=t;return void 0!==e&&"boolean"!=typeof e?(s.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(s.A.error("obfuscate must be an array"),1))}filterObfuscateRules(t){return t?t.filter(t=>{const 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)||(s.A.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",t),!1)}):[]}sanitizeQoeIntervalFactor(t){return null==t?1:"number"==typeof t&&Number.isInteger(t)&&t>=1?t:(console.warn(`[nrvideo] Invalid qoeIntervalFactor "${t}" — must be a positive integer. Defaulting to 1.`),1)}initializeGlobalConfig(t,e){let{licenseKey:i,appName:r,region:n,beacon:a,applicationID:s}=t;a="US"===n?u.A.COLLECTOR.US[0]:a||h[n],window.NRVIDEO={info:{...n?{region:n}:{},beacon:a,licenseKey:i,applicationID:s,...s?{}:{appName:r}},config:{qoeAggregate:e?.qoeAggregate??!1,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(e?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(e?.obfuscate)}}}};class y{static addTracker(t,e){var i,r;e?.info&&(i=e.info,r=e?.config,f.setConfiguration(i,r)),t.on&&t.emit?(p.push(t),t.on("*",m),"function"==typeof t.trackerInit&&t.trackerInit()):s.A.error("Tried to load a non-tracker.",t)}static removeTracker(t){t.off("*",m),t.dispose();let e=p.indexOf(t);-1!==e&&p.splice(e,1)}static getTrackers(){return p}static send(t,e,i){return c(t,{actionName:e,...i})}static sendError(t){return c("VideoErrorAction",{actionName:"ERROR",...t})}static async forceHarvest(){try{const{videoAnalyticsHarvester:t}=a(487);return await t.forceHarvest()}catch(t){return s.A.error("Failed to force harvest:",t.message),{success:!1,error:t.message}}}}let p=[];function m(t){try{let e=function(t){let e={};for(let i in t)null!==t[i]&&void 0!==t[i]&&(e[i]=t[i]);return e}(t.data);s.A.level<=s.A.Levels.DEBUG?s.A.notice("Sent",t.type,e):s.A.notice("Sent",t.type),y.send(t.eventType,t.type,e)}catch(t){s.A.error("Error in event handler:",t.message)}}const v=y;var g=a(455),A=a(568);const E=class{constructor(){this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0}reset(){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._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.hadStartupError=!1,this.hadPlaybackError=!1,this.totalRebufferingTime=0,this.resetFlags(),this.resetChronos()}resetFlags(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}resetChronos(){this.timeSinceRequested=new g.A,this.timeSinceStarted=new g.A,this.timeSincePaused=new g.A,this.timeSinceSeekBegin=new g.A,this.timeSinceBufferBegin=new g.A,this.timeSinceAdBreakStart=new g.A,this.timeSinceLastDownload=new g.A,this.timeSinceLastHeartbeat=new g.A,this.timeSinceLastRenditionChange=new g.A,this.timeSinceLastAdQuartile=new g.A,this.timeSinceLastAd=new g.A,this.timeSinceLastError=new g.A,this.timeSinceLastAdError=new g.A,this.timeSinceResumed=new g.A,this.timeSinceSeekEnd=new g.A,this.playtimeSinceLastEvent=new g.A,this.customTimeSinceAttributes={},this.elapsedTime=new g.A,this.bufferElapsedTime=new g.A,this._totalAdPlaytime=new g.A}isAd(){return this._isAd}setIsAd(t){this._isAd=t}setTimeSinceAttribute(t){this.customTimeSinceAttributes[t]=new g.A,this.customTimeSinceAttributes[t].start()}removeTimeSinceAttribute(t){delete this.customTimeSinceAttributes[t]}getViewSession(){if(!this._viewSession){let t=(new Date).getTime(),e=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=t+"-"+e}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(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(const[e,i]of Object.entries(this.customTimeSinceAttributes))t[e]=i.getDeltaTime();return t}getQoeAttributes(t){t=t||{};const e={};try{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}catch(t){s.A.error("Failed to add attributes for QOE KPIs",t.message)}return t.qoe=e,t}calculateBufferType(t){let e="";return e=t?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",s.A.debug("Buffer Type = "+e),e}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}goPause(){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))}goResume(){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))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){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))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}goLastAd(){this.timeSinceLastAd.start()}trackContentBitrateState(t){if(t&&"number"==typeof t){this.peakBitrate=Math.max(this.peakBitrate,t);const e=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){const t=e-this._lastBitrateChangeTimestamp;t>0&&(this.partialAverageBitrate+=this._lastBitrate*t,this._totalBitrateDuration+=t),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){const t=e-this._lastBitrateChangeTimestamp;t>0&&(this.partialAverageBitrate+=this._lastBitrate*t,this._totalBitrateDuration+=t),this._lastBitrateChangeTimestamp=e}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=e),this._lastBitrate=t;let i=this.partialAverageBitrate,r=this._totalBitrateDuration;const n=e-this._lastBitrateChangeTimestamp;n>0&&(i+=t*n,r+=n),this.weightedBitrate=r>0?Math.round(i/r):t}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){s.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return s.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return s.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(t){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-t,0))}};var b=a(330);class T extends l.A{constructor(t,e){super(),this.state=new E,this.adsTracker=null,this._lastBufferType=null,this._userId=null,e=e||{},this.setOptions(e),t&&this.setPlayer(t,e.tag),s.A.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(t){this._userId=t}setOptions(t){t&&(t.adsTracker&&this.setAdsTracker(t.adsTracker),"boolean"==typeof t.isAd&&this.setIsAd(t.isAd),l.A.prototype.setOptions.apply(this,arguments))}setPlayer(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()}isAd(){return this.state.isAd()}setIsAd(t){this.state.setIsAd(t)}setAdsTracker(t){this.disposeAdsTracker(),t&&(this.adsTracker=t,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",S.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",S),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getManifestBitrate(){return null}getSegmentDownloadBitrate(){return null}getNetworkDownloadBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let t;if(this._lastWebkitBitrate){t=this.tag.webkitVideoDecodedByteCount;let e=t-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;t=Math.round(e/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,t||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(t){let e,i=this.getRenditionBitrate();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}getRenditionHeight(){return this.tag?this.tag.videoHeight:null}getRenditionWidth(){return this.tag?this.tag.videoWidth:null}getDuration(){return this.tag?this.tag.duration:null}getPlayhead(){return this.tag?this.tag.currentTime:null}getLanguage(){return null}getSrc(){return this.tag?this.tag.currentSrc:null}getPlayrate(){return this.tag?this.tag.playbackRate:null}isMuted(){return this.tag?this.tag.muted:null}isFullscreen(){return null}getCdn(){return null}getPlayerName(){return this.getTrackerName()}getPlayerVersion(){return b.rE}getFps(){return null}isAutoplayed(){return this.tag?this.tag.autoplay:null}getPreload(){return this.tag?this.tag.preload:null}getAdQuartile(){return null}getAdPosition(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}getAdPartner(){return null}getAdCreativeId(){return null}getInstrumentationProvider(){return null}getInstrumentationName(){return null}getInstrumentationVersion(){return null}getAttributes(t,e){if(void 0===(t=l.A.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="Browser","customAction"===e)return t;try{t.pageUrl=window.location.href}catch(t){}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);for(let e in this.customData)t[e]=this.customData[e];return this.addQoeAttributes(t),t}addQoeAttributes(t){const e=(t=this.state.getQoeAttributes(t)).qoe;for(let t in this.customData)e[t]=this.customData[t]}sendCustom(t,e,i){i=i||{},this.sendVideoCustomAction(t,i),this.state.setTimeSinceAttribute(e)}sendPlayerReady(t){this.state.goPlayerReady()&&(t=t||{},this.sendVideoAction(T.Events.PLAYER_READY,t))}sendRequest(t){if(this.state.goRequest()){let e;this.isAd()?(e=T.Events.AD_REQUEST,this.sendVideoAdAction(e,t)):(e=T.Events.CONTENT_REQUEST,this.sendVideoAction(e,t))}}sendStart(t){if(this.state.goStart()){let e;if(this.isAd())e=T.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(e,t),this.state.startAdsTime();else{e=T.Events.CONTENT_START;let i=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),i=this.adsTracker.state.totalAdTime()??0),this.state.setStartupTime(i),this.sendVideoAction(e,t),o.videoAnalyticsHarvester.setBeforeDrainCallback(()=>{if(this.state){const t=this.state.getQoeAttributes({}).qoe;o.videoAnalyticsHarvester.refreshQoeKpis(t,this.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(t){if(this.state.goEnd()){let e;t=t||{},this.isAd()?(e=T.Events.AD_END,t.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.state.stopAdsTime()):(e=T.Events.CONTENT_END,t.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0,this.isAd()||(o.videoAnalyticsHarvester.forceNextQoeCycle(),o.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(t){if(this.state.goPause()){let e=this.isAd()?T.Events.AD_PAUSE:T.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendResume(t){if(this.state.goResume()){let e;t=t||{},this.isAd()?(e=T.Events.AD_RESUME,t.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(e=T.Events.CONTENT_RESUME,t.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendBufferStart(t){if(this.state.goBufferStart()){let e;t=t||{},e=this.isAd()?T.Events.AD_BUFFER_START:T.Events.CONTENT_BUFFER_START,t=this.buildBufferAttributes(t),this._lastBufferType=t.bufferType,this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendBufferEnd(t){if(this.state.goBufferEnd()){let e;t=t||{},this.isAd()?(e=T.Events.AD_BUFFER_END,t.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(e=T.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(e,t):this.sendVideoAction(e,t),this.state.initialBufferingHappened=!0}}buildBufferAttributes(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}sendSeekStart(t){if(this.state.goSeekStart()){let e;e=this.isAd()?T.Events.AD_SEEK_START:T.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendSeekEnd(t){if(this.state.goSeekEnd()){let e;t=t||{},this.isAd()?(e=T.Events.AD_SEEK_END,t.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(e=T.Events.CONTENT_SEEK_END,t.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendDownload(t){(t=t||{}).state||s.A.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(T.Events.DOWNLOAD,t),this.state.goDownload()}sendError(t){(t=t||{}).isAd=this.isAd(),this.state.goError();let e=this.isAd()?T.Events.AD_ERROR:T.Events.CONTENT_ERROR;this.sendVideoErrorAction(e,t)}sendRenditionChanged(t){let e;(t=t||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),t.shift=this.getRenditionShift(!0),e=this.isAd()?T.Events.AD_RENDITION_CHANGE:T.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t),this.state.goRenditionChange()}sendHeartbeat(t){if(this.state.isRequested){let e,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(e=T.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(e,t):this.sendVideoAdAction(e,{elapsedTime:i,...t})):(e=T.Events.CONTENT_HEARTBEAT,this.sendVideoAction(e,{elapsedTime:i,...t})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(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)}sendAdBreakStart(t){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(T.Events.AD_BREAK_START,t))}sendAdBreakEnd(t){this.isAd()&&this.state.goAdBreakEnd()&&((t=t||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(T.Events.AD_BREAK_END,t),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(t){this.isAd()&&((t=t||{}).quartile||s.A.warn("Called sendAdQuartile without { quartile: xxxxx }."),t.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(T.Events.AD_QUARTILE,t),this.state.goAdQuartile())}sendAdClick(t){this.isAd()&&((t=t||{}).url||s.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(T.Events.AD_CLICK,t))}}function S(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 k=T;var D=a(431),_=a(413),R=a(481),w=a(374);const P={Constants:u.A,Chrono:g.A,Log:s.A,Emitter:A.A,Tracker:l.A,VideoTracker:k,VideoTrackerState:E,Core:v,version:b.rE,NrVideoEventAggregator:D.t,RetryQueueHandler:_.u,OptimizedHttpClient:R.X,HarvestScheduler:w.n,recordEvent:c}},64(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(i(555)),a=s(i(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(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,u(r.key),r)}}function u(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+""}function l(t,e,i){return e=c(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||[],c(t).constructor):e.apply(t,i))}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(d=function(){return!!t})()}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,e,arguments)}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&&h(t,e)}(e,t),i=e,a=[{key:"isUsing",value:function(t){return!!t.ima3}}],(r=[{key:"getTrackerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayhead",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.ima3)||void 0===t||null===(t=t.adPlayer)||void 0===t?void 0:t.currentTime()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ima3-ready","ima3error","ima3-ad-error","ima3-started","ima3-complete","ima3-paused","ima3-resumed","ads-request","ads-load","ads-ad-started","ads-ad-ended","ads-pause","ads-play","ads-click","ads-pod-started","ads-pod-ended","ads-allpods-completed"]),this.player.on("ima3-started",this.onStarted.bind(this)),this.player.on("ima3-paused",this.onPaused.bind(this)),this.player.on("ima3-resumed",this.onResume.bind(this)),this.player.on("ima3-complete",this.onComplete.bind(this)),this.player.on("ima3-skipped",this.onSkipped.bind(this)),this.player.on("adserror",this.onError.bind(this)),this.player.on("ads-click",this.onClick.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ima3-started",this.onStarted),this.player.off("ima3-paused",this.onPaused),this.player.off("ima3-resumed",this.onResume),this.player.off("ima3-complete",this.onComplete),this.player.off("ima3-skipped",this.onSkipped),this.player.off("adserror",this.onError),this.player.off("ads-click",this.onClick)}},{key:"onStarted",value:function(t){this.sendRequest(),this.sendStart()}},{key:"onPaused",value:function(t){this.sendPause()}},{key:"onResume",value:function(t){this.sendResume()}},{key:"onComplete",value:function(t){this.sendEnd()}},{key:"onSkipped",value:function(t){this.sendEnd({skipped:!0})}},{key:"onError",value:function(t){this.sendError()}},{key:"onClick",value:function(t){this.sendClick()}}])&&o(i.prototype,r),a&&o(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},717(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(i(555)),a=s(i(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(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,s,o=[],u=!0,l=!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)&&(o.push(r.value),o.length!==e);u=!0);}catch(t){l=!0,n=t}finally{try{if(!u&&null!=i.return&&(s=i.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return u(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)?u(t,e):void 0}}(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 u(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 l(t,e,i){return(e=c(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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,c(r.key),r)}}function c(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+""}function h(t,e,i){return e=m(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,f()?Reflect.construct(e,i||[],m(t).constructor):e.apply(t,i))}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function y(t,e,i,r){var n=p(m(1&r?t.prototype:t),e,i);return 2&r&&"function"==typeof n?function(t){return n.apply(i,t)}:n}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=m(t)););return t}(t,e);if(r){var n=Object.getOwnPropertyDescriptor(r,e);return n.get?n.get.call(arguments.length<3?t:i):n.value}},p.apply(null,arguments)}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},m(t)}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}var g={DAI_STREAM_INITIALIZED:"dai-stream-initialized",DAI_STREAM_LOADED:"dai-stream-loaded",DAI_STREAM_ERROR:"dai-stream-error",DAI_AD_BREAK_STARTED:"dai-ad-break-started",DAI_AD_BREAK_ENDED:"dai-ad-break-ended",DAI_AD_PERIOD_STARTED:"dai-ad-period-started",DAI_AD_PERIOD_ENDED:"dai-ad-period-ended",DAI_AD_STARTED:"dai-ad-started",DAI_AD_FIRST_QUARTILE:"dai-ad-first-quartile",DAI_AD_MIDPOINT:"dai-ad-midpoint",DAI_AD_THIRD_QUARTILE:"dai-ad-third-quartile",DAI_AD_COMPLETE:"dai-ad-complete",DAI_AD_SKIPPED:"dai-ad-skipped",DAI_AD_PAUSED:"dai-ad-paused",DAI_AD_RESUMED:"dai-ad-resumed",DAI_AD_CLICKED:"dai-ad-clicked",DAI_AD_ERROR:"dai-ad-error",DAI_CUEPOINTS_CHANGED:"dai-cuepoints-changed",DAI_TIMED_METADATA:"dai-timed-metadata"};e.default=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),(i=h(this,e,[t])).streamManager=null,i.currentAdData=null,i.adBreakData=null,i.streamData=null,i.cuePoints=[],i.initialized=!1,i.eventHandlers=null,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&&v(t,e)}(e,t),i=e,a=[{key:"isUsing",value:function(t){return t.imaDai&&"function"==typeof t.imaDai||t.dai&&void 0!==t.dai.VERSION||t.ima&&t.ima.dai||t.streamManager}}],(r=[{key:"setStreamManager",value:function(t){this.streamManager=t,this.setupStreamManagerListeners(),this.initialized=!0,n.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}},{key:"setupStreamManagerListeners",value:function(){var t,e,i=this;if(this.streamManager&&null!==(t=google)&&void 0!==t&&null!==(t=t.ima)&&void 0!==t&&null!==(t=t.dai)&&void 0!==t&&null!==(t=t.api)&&void 0!==t&&t.StreamEvent){var r=google.ima.dai.api.StreamEvent.Type;this.eventHandlers=(l(l(l(l(l(l(l(l(l(l(e={},r.LOADED,this.onStreamLoaded.bind(this)),r.STREAM_INITIALIZED,this.onStreamInitialized.bind(this)),r.ERROR,this.onStreamError.bind(this)),r.AD_BREAK_STARTED,this.onAdBreakStarted.bind(this)),r.AD_BREAK_ENDED,this.onAdBreakEnded.bind(this)),r.AD_PERIOD_STARTED,this.onAdPeriodStarted.bind(this)),r.AD_PERIOD_ENDED,this.onAdPeriodEnded.bind(this)),r.STARTED,this.onAdStarted.bind(this)),r.FIRST_QUARTILE,this.onAdFirstQuartile.bind(this)),r.MIDPOINT,this.onAdMidpoint.bind(this)),l(l(l(l(l(l(l(l(l(e,r.THIRD_QUARTILE,this.onAdThirdQuartile.bind(this)),r.COMPLETE,this.onAdComplete.bind(this)),r.SKIPPED,this.onAdSkipped.bind(this)),r.PAUSED,this.onAdPaused.bind(this)),r.RESUMED,this.onAdResumed.bind(this)),r.CLICK,this.onAdClicked.bind(this)),r.VIDEO_CLICKED,this.onAdClicked.bind(this)),r.CUEPOINTS_CHANGED,this.onCuePointsChanged.bind(this)),r.TIMED_METADATA,this.onTimedMetadata.bind(this))),Object.entries(this.eventHandlers).forEach(function(t){var e=o(t,2),r=e[0],n=e[1];i.streamManager.addEventListener(r,n)}),n.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}else n.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available")}},{key:"registerListeners",value:function(){y(e,"registerListeners",this,3)([]),n.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(g)])}},{key:"unregisterListeners",value:function(){var t=this;y(e,"unregisterListeners",this,3)([]),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach(function(e){var i=o(e,2),r=i[0],n=i[1];t.streamManager.removeEventListener(r,n)}),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}},{key:"onStreamLoaded",value:function(t){this.streamData=this.extractStreamData(t),n.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}},{key:"onStreamInitialized",value:function(t){n.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}},{key:"onStreamError",value:function(t){var e=this.extractErrorData(t);n.default.Log.error("DaiAdsTracker: Stream error",e),this.sendError(e)}},{key:"onAdBreakStarted",value:function(t){this.adBreakData=this.extractAdBreakData(t),n.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}},{key:"onAdBreakEnded",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}},{key:"onAdPeriodStarted",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(t)}},{key:"onAdPeriodEnded",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad period ended")}},{key:"onAdStarted",value:function(t){this.currentAdData=this.extractAdData(t),n.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}},{key:"onAdFirstQuartile",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}},{key:"onAdMidpoint",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}},{key:"onAdThirdQuartile",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}},{key:"onAdComplete",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}},{key:"onAdSkipped",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}},{key:"onAdPaused",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}},{key:"onAdResumed",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}},{key:"onAdClicked",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}},{key:"onCuePointsChanged",value:function(t){this.cuePoints=this.extractCuePoints(t),n.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}},{key:"onTimedMetadata",value:function(t){var e=this.extractTimedMetadata(t);n.default.Log.debug("DaiAdsTracker: Timed metadata",e)}},{key:"extractStreamData",value:function(t){try{var e=t.getStreamData();return{streamId:null==e?void 0:e.streamId,url:null==e?void 0:e.url,adTagParameters:null==e?void 0:e.adTagParameters,streamType:this.getStreamType()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract stream data",t),{}}}},{key:"extractAdBreakData",value:function(t){try{var e,i=t.getAdBreak();return{adBreakId:null==i?void 0:i.id,adBreakTitle:null==i?void 0:i.title,adCount:(null==i||null===(e=i.ads)||void 0===e?void 0:e.length)||0,position:this.getAdPosition()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",t),{}}}},{key:"extractAdData",value:function(t){try{var e=t.getAd();return{adId:null==e?void 0:e.getAdId(),creativeId:null==e?void 0:e.getCreativeId(),duration:null==e?void 0:e.getDuration(),title:null==e?void 0:e.getTitle(),description:null==e?void 0:e.getDescription(),advertiserName:null==e?void 0:e.getAdvertiserName(),clickThroughUrl:null==e?void 0:e.getClickThroughUrl(),dealId:null==e?void 0:e.getDealId(),wrapperAdIds:null==e?void 0:e.getWrapperAdIds(),position:this.getAdPosition()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad data",t),{}}}},{key:"extractErrorData",value:function(t){try{var e=t.getError();return{errorCode:null==e?void 0:e.getErrorCode(),errorMessage:null==e?void 0:e.getMessage(),innerError:null==e?void 0:e.getInnerError()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract error data",e),{errorMessage:"Unknown DAI error"}}}},{key:"extractCuePoints",value:function(t){try{return t.getCuepoints()||[]}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract cue points",t),[]}}},{key:"extractTimedMetadata",value:function(t){try{return{type:t.getType(),data:t.getData()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",t),{}}}},{key:"getTrackerName",value:function(){return"dai-ads"}},{key:"getPlayerName",value:function(){return"videojs-dai"}},{key:"getPlayerVersion",value:function(){var t,e;return null!==(t=this.player.dai)&&void 0!==t&&t.VERSION?this.player.dai.VERSION:null!==(e=this.player.ima)&&void 0!==e&&e.VERSION?"ima-dai: ".concat(this.player.ima.VERSION):"unknown"}},{key:"getAdCuePoints",value:function(){return this.cuePoints}},{key:"getAdPosition",value:function(){if(!this.currentAdData&&!this.adBreakData)return null;var t=this.player.currentTime(),e=this.player.duration();return t<5?"pre":e&&t>e-10?"post":"mid"}},{key:"getDuration",value:function(){var t;return void 0!==(null===(t=this.currentAdData)||void 0===t?void 0:t.duration)?1e3*this.currentAdData.duration:null}},{key:"getVideoId",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.adId)||null}},{key:"getAdCreativeId",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.creativeId)||null}},{key:"getTitle",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.title)||null}},{key:"getSrc",value:function(){var t;return(null===(t=this.streamData)||void 0===t?void 0:t.url)||null}},{key:"getPlayhead",value:function(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(t){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}},{key:"getAdPartner",value:function(){return"google-dai"}},{key:"getClickThroughUrl",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.clickThroughUrl)||null}},{key:"getStreamType",value:function(){var t;return null!==(t=this.streamData)&&void 0!==t&&t.streamType?this.streamData.streamType:this.player.duration()===1/0?"live":"vod"}},{key:"isLiveStream",value:function(){return"live"===this.getStreamType()}},{key:"getCurrentAdBreak",value:function(){return this.adBreakData}},{key:"getCurrentAd",value:function(){return this.currentAdData}},{key:"getStreamData",value:function(){return this.streamData}},{key:"getBitrate",value:function(){var t=this.getTech();if(t&&t.tech&&t.tech.stats)return t.tech.stats.bandwidth}},{key:"getRenditionBitrate",value:function(){var t=this.getTech();if(t&&t.getRenditionBitrate)return t.getRenditionBitrate()}}])&&d(i.prototype,r),a&&d(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},38(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n,a=(n=i(472))&&n.__esModule?n:{default:n};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,o(r.key),r)}}function o(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+""}function u(t,e,i){return e=d(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,l()?Reflect.construct(e,i||[],d(t).constructor):e.apply(t,i))}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,e,arguments)}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),function(t,e,i){return e&&s(t.prototype,e),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(e,[{key:"getTrackerName",value:function(){return"freewheel-ads"}},{key:"getPlayerName",value:function(){return"freewheel-ads"}},{key:"getPlayerVersion",value:function(){return this.player.FreeWheelPlugin.VERSION}},{key:"getPlayhead",value:function(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}},{key:"getDuration",value:function(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}},{key:"getVideoId",value:function(){return this.player.ads.ad.id}},{key:"getAdPartner",value:function(){return"freewheel"}},{key:"getAdCreativeId",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(t){}}},{key:"getSrc",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(t){}}},{key:"getTitle",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(t){}}},{key:"getAdPosition",value:function(){switch(this.player.ads.ad.type){case"PREROLL":return nrvideo.Constants.AdPositions.PRE;case"MIDROLL":return nrvideo.Constants.AdPositions.MID;case"POSTROLL":return nrvideo.Constants.AdPositions.POST}}}],[{key:"isUsing",value:function(t){return!!t.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}}])}(a.default)},298(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(i(555)),a=s(i(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(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,u(r.key),r)}}function u(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+""}function l(t,e,i){return e=c(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||[],c(t).constructor):e.apply(t,i))}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(d=function(){return!!t})()}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,e,arguments)}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&&h(t,e)}(e,t),i=e,r=[{key:"getTrackerName",value:function(){return"ima-ads"}},{key:"getPlayerName",value:function(){return"ima"}},{key:"getPlayerVersion",value:function(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}},{key:"getCuePoints",value:function(){return this.player.ima.getAdsManager().getCuePoints()}},{key:"getAdPosition",value:function(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){var t=this.lastAdData.podInfo.podIndex;return 0===t?"pre":-1===t?"post":"mid"}return null}},{key:"getDuration",value:function(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}},{key:"getVideoId",value:function(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}},{key:"getAdCreativeId",value:function(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}},{key:"getSrc",value:function(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}},{key:"getTitle",value:function(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}},{key:"getPlayhead",value:function(){var t=this.player.ima.getAdsManager();if(t)return 1e3*(this.getDuration()-t.getRemainingTime())}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"getAdPartner",value:function(){return"ima"}},{key:"getWebkitBitrate",value:function(){var t=this.getAdVideoElement();if(t&&t.webkitVideoDecodedByteCount){var e;if(this._lastAdWebkitBitrate>0){var i=t.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,r=this.getHeartbeat()/1e3;e=Math.round(i/r*8)}return this._lastAdWebkitBitrate=t.webkitVideoDecodedByteCount,null!=e?e:null}return null}},{key:"getRenditionBitrate",value:function(){if(this.lastAdData)return this.lastAdData.renditionBitrate}},{key:"registerListeners",value:function(){var t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,n.default.Log.debugCommonVideoEvents(this.player.ima.addEventListener,[null,t.ALL_ADS_COMPLETED,t.LINEAR_CHANGED,t.COMPLETE,t.USER_CLOSE,t.IMPRESSION,t.CONTENT_PAUSE_REQUESTED,t.CONTENT_RESUME_REQUESTED,t.SKIPPED,t.SKIPPABLE_STATE_CHANGED,t.LOADED,t.PAUSED,t.RESUMED,t.STARTED,t.AD_CAN_PLAY,t.AD_METADATA,t.EXPANDED_CHANGED,t.AD_BREAK_READY,t.LOG,t.CLICK,t.FIRST_QUARTILE,t.MIDPOINT,t.THIRD_QUARTILE,e]),this.player.ima.addEventListener(t.LOADED,this.onLoaded.bind(this)),this.player.ima.addEventListener(t.STARTED,this.onStart.bind(this)),this.player.ima.addEventListener(t.PAUSED,this.onPaused.bind(this)),this.player.ima.addEventListener(t.RESUMED,this.onResumed.bind(this)),this.player.ima.addEventListener(t.COMPLETE,this.onComplete.bind(this)),this.player.ima.addEventListener(t.SKIPPED,this.onSkipped.bind(this)),this.player.ima.addEventListener(t.CLICK,this.onClick.bind(this)),this.player.ima.addEventListener(t.FIRST_QUARTILE,this.onFirstQuartile.bind(this)),this.player.ima.addEventListener(t.MIDPOINT,this.onMidpoint.bind(this)),this.player.ima.addEventListener(t.THIRD_QUARTILE,this.onThirdQuartile.bind(this)),this.player.ima.addEventListener(e,this.onError.bind(this))}},{key:"unregisterListeners",value:function(){var t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.player.ima.removeEventListener(t.LOADED,this.onLoaded),this.player.ima.removeEventListener(t.STARTED,this.onLoaded.bind(this)),this.player.ima.removeEventListener(t.IMPRESSION,this.onImpression),this.player.ima.removeEventListener(t.PAUSED,this.onPaused),this.player.ima.removeEventListener(t.RESUMED,this.onResumed),this.player.ima.removeEventListener(t.COMPLETE,this.onComplete),this.player.ima.removeEventListener(t.SKIPPED,this.onSkipped),this.player.ima.removeEventListener(t.CLICK,this.onClick),this.player.ima.removeEventListener(t.FIRST_QUARTILE,this.onFirstQuartile),this.player.ima.removeEventListener(t.MIDPOINT,this.onMidpoint),this.player.ima.removeEventListener(t.THIRD_QUARTILE,this.onThirdQuartile),this.player.ima.removeEventListener(e,this.onError),this.lastAdData=null}},{key:"onLoaded",value:function(t){this.lastAdData=this.getAdData(),this.sendRequest()}},{key:"onStart",value:function(t){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}},{key:"onComplete",value:function(t){this.sendEnd(),this.lastAdData=null}},{key:"onSkipped",value:function(t){this.sendEnd({skipped:!0}),this.lastAdData=null}},{key:"onError",value:function(t){var e=t.getError(),i=e.getErrorCode(),r=e.getMessage();this.sendError({adError:e,errorCode:i,errorMessage:r})}},{key:"onClick",value:function(t){this.sendAdClick()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({adQuartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({adQuartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({adQuartile:3})}},{key:"onPaused",value:function(){this.sendPause()}},{key:"onResumed",value:function(){this.sendResume()}},{key:"getAdData",value:function(){try{var t=this.player.ima.getAdsManager();if(t){var e,i=t.getCurrentAd();if(i)return{adId:i.getAdId(),creativeId:i.getCreativeId(),duration:i.getDuration(),mediaUrl:i.getMediaUrl(),title:i.getTitle(),podInfo:null===(e=i.getAdPodInfo())||void 0===e?void 0:e.data,renditionBitrate:i.getVastMediaBitrate()}}return null}catch(t){return null}}},{key:"getAdVideoElement",value:function(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){var t=this.player.ima.controller.adUi.adContainerDiv;if(t){var e=t.querySelector("video");if(e)return e}}}}],a=[{key:"isUsing",value:function(t){return t.ima&&"undefined"!=typeof google}}],r&&o(i.prototype,r),a&&o(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},472(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=l(i(555)),a=l(i(330)),s=l(i(409)),o=l(i(257)),u=l(i(338));function l(t){return t&&t.__esModule?t:{default: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,c(r.key),r)}}function c(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+""}function h(t,e,i){return e=y(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,f()?Reflect.construct(e,i||[],y(t).constructor):e.apply(t,i))}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),h(this,e,arguments)}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&&p(t,e)}(e,t),i=e,(r=[{key:"getTech",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(s.default.isUsing(t))return new s.default(t);if(o.default.isUsing(t))return new o.default(t);if(u.default.isUsing(t))return new u.default(t)}}},{key:"getTrackerName",value:function(){return"videojs-ads"}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getRenditionHeight",value:function(){return null}},{key:"getRenditionWidth",value:function(){return null}},{key:"getPlayerName",value:function(){return"videojs-ads"}},{key:"getPlayerVersion",value:function(){return this.player.ads.VERSION}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ads-request","ads-load","adstart","adend","adskip","adserror","ads-click","ads-pod-started","ads-pod-ended","ads-first-quartile","ads-midpoint","ads-third-quartile","ads-pause","ads-play","adtimeout"]),this.player.on("ads-request",this.onAdrequest.bind(this)),this.player.on("ads-load",this.onAdload.bind(this)),this.player.on("adstart",this.onAdstart.bind(this)),this.player.on("adend",this.onAdend.bind(this)),this.player.on("adskip",this.onAdskip.bind(this)),this.player.on("adserror",this.onAdserror.bind(this)),this.player.on("ads-click",this.onAdsClick.bind(this)),this.player.on("ads-pod-started",this.onPodStart.bind(this)),this.player.on("ads-pod-ended",this.onPodEnd.bind(this)),this.player.on("ads-first-quartile",this.onFirstQuartile.bind(this)),this.player.on("ads-midpoint",this.onMidpoint.bind(this)),this.player.on("ads-third-quartile",this.onThirdQuartile.bind(this)),this.player.on("ads-pause",this.onAdspause.bind(this)),this.player.on("ads-play",this.onAdsplay.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ads-request",this.onAdrequest),this.player.off("ads-load",this.onAdload),this.player.off("adstart",this.onAdstart),this.player.off("adend",this.onAdend),this.player.off("adskip",this.onAdskip),this.player.off("adserror",this.onAdserror),this.player.off("ads-click",this.onAdsClick),this.player.off("ads-pod-started",this.onPodStart),this.player.off("ads-pod-ended",this.onPodEnd),this.player.off("ads-first-quartile",this.onFirstQuartile),this.player.off("ads-midpoint",this.onMidpoint),this.player.off("ads-third-quartile",this.onThirdQuartile),this.player.off("ads-pause",this.onAdspause),this.player.off("ads-play",this.onAdsplay)}},{key:"onAdrequest",value:function(t){this.sendRequest(),this.sendDownload({state:"ads-request"})}},{key:"onAdload",value:function(t){this.sendDownload({state:"ads-load"})}},{key:"onAdstart",value:function(t){this.sendRequest(),this.sendStart()}},{key:"onAdend",value:function(t){this.sendEnd()}},{key:"onAdskip",value:function(t){this.sendEnd({skipped:!0})}},{key:"onAdserror",value:function(t){this.sendError()}},{key:"onAdsClick",value:function(t){this.sendAdClick({url:"unknown"})}},{key:"onPodStart",value:function(t){this.sendAdBreakStart()}},{key:"onPodEnd",value:function(t){this.sendAdBreakEnd()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({quartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({quartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({quartile:3})}},{key:"onAdspause",value:function(){this.sendPause()}},{key:"onAdsplay",value:function(){this.sendResume()}}])&&d(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(n.default.VideoTracker)},409(t,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){(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 n(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 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+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.vhs,this.player=e.el().player},(e=[{key:"getRenditionName",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.NAME}catch(t){}return null}},{key:"getRenditionBitrate",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.BANDWIDTH}catch(t){}return null}},{key:"getRenditionWidth",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.width}catch(t){}return null}},{key:"getRenditionHeight",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.height}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getManifestBitrate",value:function(){try{var t=this.tech.playlists.master.playlists;if(t&&t.length>0)return Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return r(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 r(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)?r(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.")}()}(t.map(function(t){return t.attributes.BANDWIDTH})))}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){var t;return void 0!==(null===(t=this.tech.stats)||void 0===t?void 0:t.bandwidth)&&this.tech.stats.bandwidth>0?this.tech.stats.bandwidth:null}},{key:"getNetworkDownloadBitrate",value:function(){return void 0!==this.tech.throughput&&this.tech.throughput>0?this.tech.throughput:null}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH||null}catch(t){}return null}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.vhs}},257(t,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){(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 n(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 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+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.vhs_,this.player=e.el().player},(e=[{key:"getResource",value:function(t){return this.tech.url}},{key:"getRenditionName",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.name)return e.name}catch(t){}return null}},{key:"getRenditionBitrate",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return e.bitrate}catch(t){}return null}},{key:"getRenditionWidth",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.width)return e.width}catch(t){}return null}},{key:"getRenditionHeight",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.height)return e.height}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return t.bitrate}catch(t){}return null}},{key:"getManifestBitrate",value:function(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return r(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 r(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)?r(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.")}()}(this.tech.levels.map(function(t){return t.bitrate})))}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return this.tech.stats.bandwidth}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){return this.tech.throughput&&this.tech.throughput>0?this.tech.throughput:null}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.vhs_}},338(t,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){(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 n(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 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+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.shakaPlayer,this.player=e.el().player},e=[{key:"getSrc",value:function(t){try{return this.tech.getManifestUri()}catch(t){}return null}},{key:"getRenditionBitrate",value:function(t){try{return this.tech.getStats().streamBandwidth}catch(t){}return null}},{key:"getManifestBitrate",value:function(){try{var t=this.tech.getVariantTracks();if(t&&t.length>0)return Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return r(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 r(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)?r(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.")}()}(t.map(function(t){return t.videoBandwidth+(t.audioBandwidth||0)})))}catch(t){}return null}},{key:"getRenditionWidth",value:function(t){try{var e=this.tech.getVariantTracks();for(var i in e){var r=e[i];if(r.active&&"video"===r.type)return r.width}}catch(t){}return null}},{key:"getRenditionHeight",value:function(t){try{var e=this.tech.getVariantTracks();for(var i in e){var r=e[i];if(r.active&&"video"===r.type)return r.height}}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.getStats();if(t&&t.streamBandwidth&&t.streamBandwidth>0)return t.streamBandwidth}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return t.estimatedBandwidth}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return t.estimatedBandwidth}catch(t){}return null}}],e&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.shakaPlayer}},302(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"ContribHlsTech",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"FreewheelAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,"HlsJsTech",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"ImaAdsTracker",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(e,"ShakaTech",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"VideojsAdsTracker",{enumerable:!0,get:function(){return l.default}}),e.default=void 0;var n=y(i(555)),a=y(i(330)),s=y(i(409)),o=y(i(257)),u=y(i(338)),l=y(i(472)),d=y(i(298)),c=y(i(64)),h=y(i(38)),f=y(i(717));function y(t){return t&&t.__esModule?t:{default:t}}function p(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 m(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,v(r.key),r)}}function v(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+""}function g(t,e,i){return e=E(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,A()?Reflect.construct(e,i||[],E(t).constructor):e.apply(t,i))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(A=function(){return!!t})()}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}e.default=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),(r=g(this,e,[t,i])).isContentEnd=!1,r.imaAdCuePoints="",r.daiInitialized=!1,n.default.Core.addTracker(r,i),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&&b(t,e)}(e,t),i=e,r=[{key:"getTech",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(s.default.isUsing(t))return new s.default(t);if(o.default.isUsing(t))return new o.default(t);if(u.default.isUsing(t))return new u.default(t)}}},{key:"getTrackerName",value:function(){return"videojs"}},{key:"getInstrumentationProvider",value:function(){return"New Relic"}},{key:"getInstrumentationName",value:function(){return this.getPlayerName()}},{key:"getInstrumentationVersion",value:function(){return this.getPlayerVersion()}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"getPlayhead",value:function(){return this.player.ads&&"ads-playback"===this.player.ads.state&&this.player.ads.snapshot&&this.player.ads.snapshot.currentTime?1e3*this.player.ads.snapshot.currentTime:this.player.absoluteTime?1e3*this.player.absoluteTime():1e3*this.player.currentTime()}},{key:"getDuration",value:function(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}},{key:"getTitle",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.mediainfo)||void 0===t?void 0:t.name}},{key:"getId",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.mediainfo)||void 0===t?void 0:t.id}},{key:"getLanguage",value:function(){var t;return null===(t=this.player)||void 0===t?void 0:t.language()}},{key:"getSrc",value:function(){var t=this.getTech();return t&&t.getSrc?t.getSrc():this.player.currentSrc()}},{key:"getPlayerName",value:function(){var t;return(null===(t=this.player)||void 0===t?void 0:t.name())||"videojs"}},{key:"getPlayerVersion",value:function(){var t;return(null===(t=this.player)||void 0===t?void 0:t.version)||videojs.VERSION}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&null!==(t=t.playlists)&&void 0!==t&&t.media()){var i=e.vhs.playlists.media();return i.attributes["AVERAGE-BANDWIDTH"]||i.attributes.BANDWIDTH||null}var r=this.getTech();if(null!=r&&r.getBitrate)return r.getBitrate()}catch(t){}return null}},{key:"getRenditionName",value:function(){var t=this.getTech();if(t&&t.getRenditionName)return t.getRenditionName()}},{key:"getManifestBitrate",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0}),i=null==e||null===(t=e.vhs)||void 0===t||null===(t=t.playlists)||void 0===t||null===(t=t.master)||void 0===t?void 0:t.playlists;if(i&&i.length>0){var r=Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return p(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 p(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)?p(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.")}()}(i.map(function(t){return t.attributes.BANDWIDTH||0})));return r>0?r:null}var n=this.getTech();if(null!=n&&n.getManifestBitrate)return n.getManifestBitrate()}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&null!==(t=t.stats)&&void 0!==t&&t.bandwidth&&e.vhs.stats.bandwidth>0)return e.vhs.stats.bandwidth;var i=this.getTech();if(null!=i&&i.getSegmentDownloadBitrate)return i.getSegmentDownloadBitrate()}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&t.throughput&&e.vhs.throughput>0)return e.vhs.throughput;var i=this.getTech();return null!=i&&i.getNetworkDownloadBitrate?i.getNetworkDownloadBitrate():null}},{key:"getRenditionHeight",value:function(){var t=this.getTech();return t&&t.getRenditionHeight?t.getRenditionHeight():this.player.videoHeight()}},{key:"getRenditionWidth",value:function(){var t=this.getTech();return t&&t.getRenditionWidth?t.getRenditionWidth():this.player.videoWidth()}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"isAutoplayed",value:function(){return this.player.autoplay()}},{key:"isFullscreen",value:function(){return this.player.isFullscreen()}},{key:"getPreload",value:function(){return this.player.preload()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,["adstart","adend","adskip","adsready","adserror","dispose"]),this.onDownload=this.onDownload.bind(this),this.onAdsready=this.onAdsready.bind(this),this.onAdStart=this.onAdStart.bind(this),this.onAdEnd=this.onAdEnd.bind(this),this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onAbort=this.onAbort.bind(this),this.onEnded=this.onEnded.bind(this),this.onDispose=this.onDispose.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onError=this.onError.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onTimeupdate=this.onTimeupdate.bind(this),this.OnAdsAllpodsCompleted=this.OnAdsAllpodsCompleted.bind(this),this.onStreamManager=this.onStreamManager.bind(this),this.player.on("loadstart",this.onDownload),this.player.on("loadeddata",this.onDownload),this.player.on("loadedmetadata",this.onDownload),this.player.on("adsready",this.onAdsready),this.player.on("adstart",this.onAdStart),this.player.on("adend",this.onAdEnd),this.player.on("play",this.onPlay),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("abort",this.onAbort),this.player.on("ended",this.onEnded),this.player.on("dispose",this.onDispose),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("error",this.onError),this.player.on("waiting",this.onWaiting),this.player.on("timeupdate",this.onTimeupdate),this.player.on("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.on("stream-manager",this.onStreamManager)}},{key:"unregisterListeners",value:function(){this.player.off("loadstart",this.onDownload),this.player.off("loadeddata",this.onDownload),this.player.off("loadedmetadata",this.onDownload),this.player.off("adsready",this.onAdsready),this.player.off("adstart",this.onAdStart),this.player.off("adend",this.onAdEnd),this.player.off("play",this.onPlay),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("abort",this.onAbort),this.player.off("ended",this.onEnded),this.player.off("dispose",this.onDispose),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("error",this.onError),this.player.off("waiting",this.onWaiting),this.player.off("timeupdate",this.onTimeupdate),this.player.off("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.off("stream-manager",this.onStreamManager)}},{key:"onDownload",value:function(t){this.sendDownload({state:t.type})}},{key:"onStreamManager",value:function(t){if(!this.adsTracker&&t.StreamManager){var e=new f.default(this.player);e.setStreamManager(t.StreamManager),this.setAdsTracker(e)}}},{key:"onAdsready",value:function(){this.adsTracker||(c.default.isUsing(this.player)?this.setAdsTracker(new c.default(this.player)):d.default.isUsing(this.player)?this.setAdsTracker(new d.default(this.player)):h.default.isUsing(this.player)?this.setAdsTracker(new h.default(this.player)):this.setAdsTracker(new l.default(this.player)))}},{key:"onAdStart",value:function(){var t;this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=null===(t=this.player)||void 0===t||null===(t=t.ima)||void 0===t?void 0:t.getAdsManager().getCuePoints())}},{key:"onAdEnd",value:function(){this.isContentEnd&&this.sendEnd()}},{key:"OnAdsAllpodsCompleted",value:function(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}},{key:"onPlay",value:function(){this.sendRequest()}},{key:"onPause",value:function(){this.sendPause()}},{key:"onPlaying",value:function(){this.sendResume(),this.sendBufferEnd()}},{key:"onAbort",value:function(){this.sendEnd()}},{key:"onEnded",value:function(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}},{key:"onDispose",value:function(){this.sendEnd()}},{key:"onSeeking",value:function(){this.sendSeekStart()}},{key:"onSeeked",value:function(){this.sendSeekEnd()}},{key:"onError",value:function(){var t=this.player.error(),e=t.code,i=t.message;this.player.error&&this.player.error()&&this.sendError({errorCode:e,errorMessage:i})}},{key:"onWaiting",value:function(t){this.sendBufferStart()}},{key:"onTimeupdate",value:function(t){this.getPlayhead()>.1&&this.sendStart()}}],r&&m(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(n.default.VideoTracker)},330(t){t.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.1.0","description":"New relic tracker for Videojs","main":"dist/cjs/index.js","module":"dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch --mode development","prezip":"npm run build","zip":"zip -P newrelic -x \'*.DS_Store\' -x \'samples/agent.js\' -r videojs.zip dist samples README.md CHANGELOG.md EULA.md","clean":"rm -rf dist *.zip","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-videojs-js.git"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop","Bharat Saraswat","Malay Chandan"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@newrelic/newrelic-oss-cli":"^0.1.2","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","videojs-ima":"2.1.0","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","CHANGELOG.md","README.md","src","!test"],"publishConfig":{"access":"public"},"dependencies":{"@newrelic/video-core":"^4.0.0"}}')}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,i),a.exports}i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{var t=r;t.default=void 0;var e,n=(e=i(302))&&e.__esModule?e:{default:e};t.default=n.default})(),r.default})());
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VideojsTracker=e():t.VideojsTracker=e()}(self,()=>(()=>{"use strict";var t={555(t,e,i){i.r(e),i.d(e,{default:()=>P});var r={487(t,e,i){i.r(e),i.d(e,{videoAnalyticsHarvester:()=>u});var r=i(374),n=i(431),a=i(51),s=i(144),o=i(302);const u=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)s.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new n.t,this.harvestScheduler=new r.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,s.A.notice("Video analytics agent initialized successfully")}catch(t){s.A.error("Failed to initialize video analytics agent:",t.message)}}addEvent(t){this.isInitialized||(s.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return t.actionName&&t.actionName===o.A.Events.QOE_AGGREGATE?t.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,t.viewId,t):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,t):this.eventBuffer.add(t)}catch(t){return s.A.error("Failed to add event to harvesting system:",t.message),!1}}setHarvestInterval(t){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(t)}forceNextQoeCycle(){this.harvestScheduler&&(this.harvestScheduler.forceNextQoeCycle=!0)}setBeforeDrainCallback(t){this.harvestScheduler&&(this.harvestScheduler.beforeDrainCallback=t)}refreshQoeKpis(t,e){if(!this.eventBuffer||!t)return;const i=e?this.eventBuffer.findByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e):this.eventBuffer.findByActionName(o.A.Events.QOE_AGGREGATE);if(i){const r={...i};for(const e of a.A.QOE_KPI_KEYS)e in t&&(r[e]=t[e]);e?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e,r):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,r)}}}},455(t,e,i){i.d(e,{A:()=>n});class r{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}getDuration(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(this.getDeltaTime()??0)}clone(){var t=new r;return t.startTime=this.startTime,t.stopTime=this.stopTime,t.offset=this.offset,t.accumulator=this.accumulator,t}}const n=r},51(t,e,i){i.d(e,{A:()=>n});class r{}r.AdPositions={PRE:"pre",MID:"mid",POST:"post"},r.COLLECTOR={US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},r.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],r.MAX_PAYLOAD_SIZE=1048576,r.MAX_BEACON_SIZE=61440,r.MAX_EVENTS_PER_BATCH=1e3,r.INTERVAL=1e4,r.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],r.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 n=r},568(t,e,i){i.d(e,{A:()=>r});const r=class{on(t,e){if(this._listeners=this._listeners||{},"function"==typeof e)return this._listeners[t]=this._listeners[t]||[],this._listeners[t].push(e),this}off(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}emit(t,e,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[e])&&this._listeners[e].forEach(r=>{r.call(this,{eventType:t,type:e,data:i,target:this})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(r=>{r.call(this,{eventType:t,type:e,data:i,target:this})}),this}}},431(t,e,i){i.d(e,{t:()=>u});var r=i(144),n=i(51),a=i(347);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=n.A;class u{constructor(){this.buffer=[],this.maxPayloadSize=s,this.maxEventsPerBatch=o,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}addOrReplaceByActionName(t,e){const i=this.buffer.findIndex(e=>e.actionName===t);try{return-1===i?this.add(e):this.add(e,i),!0}catch(t){return r.A.error("Failed to set or replace the event to buffer:",t.message),!1}}addOrReplaceByActionNameAndViewId(t,e,i){const n=this.buffer.findIndex(i=>i.actionName===t&&i.viewId===e);try{return-1===n?this.add(i):this.add(i,n),!0}catch(t){return r.A.error("Failed to set or replace the event to buffer:",t.message),!1}}findByActionNameAndViewId(t,e){return this.buffer.find(i=>i.actionName===t&&i.viewId===e)||null}findByActionName(t){return this.buffer.find(e=>e.actionName===t)||null}add(t,e){try{const i=(0,a.Q3)(t),r=this.currentPayloadSize+i>=this.maxPayloadSize,n=this.totalEvents+1>=this.maxEventsPerBatch;if((r||n)&&this.makeRoom(i),null!=e&&e>-1){const r=(0,a.Q3)(this.buffer[e]);this.buffer[e]=t,this.currentPayloadSize+=i-r}else this.buffer.push(t),this.totalEvents++,this.currentPayloadSize+=i;return this.checkSmartHarvestTrigger(),!0}catch(t){return r.A.error("Failed to add event to buffer:",t.message),!1}}checkSmartHarvestTrigger(){const t=this.currentPayloadSize/this.maxPayloadSize,e=this.totalEvents/this.maxEventsPerBatch,i=this.currentPayloadSize>=this.overflowPayloadThreshold,n=this.totalEvents>=this.overflowEventThreshold;if(i||n){const n=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*t)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*e)}%)`;r.A.warn(`OVERFLOW PREVENTION: ${n} - Emergency harvest triggered`),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{const t=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,e=this.totalEvents>=this.smartHarvestEventThreshold;(t||e)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}setSmartHarvestCallback(t){this.onSmartHarvestTrigger=t}drain(){try{const t=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,t}catch(t){return r.A.error("Failed to drain events from buffer:",t.message),[]}}isEmpty(){return 0===this.totalEvents}size(){return this.totalEvents}clear(){this.buffer=[],this.totalEvents=0}makeRoom(t){if(t>this.maxPayloadSize)r.A.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+t>=this.maxPayloadSize)&&this.buffer.length>0;){const t=this.buffer.shift(),e=(0,a.Q3)(t);this.totalEvents--,this.currentPayloadSize-=e,r.A.warn("Event buffer full, oldest event removed.")}}}},374(t,e,i){i.d(e,{n:()=>d});var r=i(431),n=i(413),a=i(481),s=i(347),o=i(51),u=i(302),l=i(144);class d{constructor(t){this.eventBuffer=t,this.retryQueueHandler=new n.u,this.httpClient=new a.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof r.t&&this.eventBuffer.setSmartHarvestCallback((t,e)=>this.triggerSmartHarvest(t,e)),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=o.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?l.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,l.A.notice("Starting harvest scheduler",{harvestCycle:this.harvestCycle,eventBufferSize:this.eventBuffer?this.eventBuffer.size():0}),this.scheduleNextHarvest())}stopScheduler(){this.isStarted&&(this.isStarted=!1,this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),l.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(t,e){if(l.A.notice(`${t} harvest triggered at ${e}% threshold`,{type:t,threshold:e}),this.eventBuffer&&!this.eventBuffer.isEmpty()){this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null);try{await this.triggerHarvest({})}catch(e){l.A.error(`${t} harvest failed:`,e.message)}finally{this.isStarted&&this.scheduleNextHarvest()}}}scheduleNextHarvest(){if(!this.isStarted)return;const t=this.harvestCycle;this.currentTimerId=setTimeout(()=>this.onHarvestInterval(),t)}async onHarvestInterval(){try{const t=this.eventBuffer&&!this.eventBuffer.isEmpty(),e=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0;if(!t&&!e)return;await this.triggerHarvest({})}catch(t){l.A.error("Error during scheduled harvest:",t.message)}finally{this.scheduleNextHarvest()}}async triggerHarvest(t={}){if(this.isHarvesting)return{success:!1,reason:"harvest_in_progress"};this.isHarvesting=!0;try{let e=this.drainEvents(t);if(t.isFinalHarvest){const t=o.A.MAX_BEACON_SIZE;(0,s.Q3)(e)>t&&(e=this.trimEventsToFit(e,t))}const i=await this.sendChunk(e,t,!0);return{success:i.success,totalChunks:1,results:[i]}}catch(t){return l.A.error("Harvest cycle failed:",t.message),this.handleHarvestFailure(t),{success:!1,error:t.message,consecutiveFailures:this.consecutiveFailures}}finally{this.isHarvesting=!1}}trimEventsToFit(t,e){if(0===t.length)return t;const i=[];let r=0;for(let n=t.length-1;n>=0;n--){const a=t[n],o=(0,s.Q3)({ins:[a,...i]});o>e||(i.unshift(a),r=o)}const n=t.length-i.length;if(n>0){const a=t.slice(0,n);l.A.warn(`Discarded ${n} events to fit beacon size limit`,{originalCount:t.length,trimmedCount:i.length,finalSize:r,maxSize:e}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(a)}return i}drainEvents(t={}){const e=window.NRVIDEO?.config?.qoeIntervalFactor??1,i=!!t.isFinalHarvest||this.forceNextQoeCycle,r=(this.qoeCycleCount-1)%e==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(t){l.A.error("Before drain callback failed:",t.message)}const n=this.eventBuffer.drain();let a;if(r)a=n;else{a=[];for(const t of n)t.actionName===u.A.Events.QOE_AGGREGATE?this.eventBuffer.add(t):a.push(t)}this.qoeCycleCount++;for(let t=a.length-1;t>=0;t--){const e=a[t];e.actionName===u.A.Events.QOE_AGGREGATE&&(!i&&this._qoeKpisUnchanged(e)?a.splice(t,1):this._saveQoeKpis(e))}let d=[...a],c=(0,s.Q3)(a);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const t=o.A.MAX_PAYLOAD_SIZE-c,e=o.A.MAX_EVENTS_PER_BATCH-d.length;if(t>0&&e>0){const i=this.retryQueueHandler.getRetryEventsToFit(t,e);i.length>0&&(d=[...i,...d])}}return d}async sendChunk(t,e,i){const r={url:(0,s.c$)(this.fallBackUrl),payload:{body:{ins:t}},options:{...e,isLastChunk:i}};return new Promise(e=>{this.httpClient.send(r,i=>{i.retry?this.handleRequestFailure(t):(this.retryCount=0,this.fallBackUrl=""),e({success:!i.retry,status:i.status,error:i.error,chunk:t,eventCount:t.length})})})}handleRequestFailure(t){this.retryQueueHandler.addFailedEvents(t),"US"===window.NRVIDEO?.info?.region&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=o.A.COLLECTOR.US[1]))}handleHarvestFailure(t){this.consecutiveFailures++,l.A.warn("Harvest failure handled",{error:t.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(t){"number"!=typeof t&&isNaN(t)?l.A.warn("Invalid newInterval provided to updateHarvestInterval"):t<1e3||t>3e5?l.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==t&&(this.harvestCycle=t,l.A.notice("Updated harvestCycle:",this.harvestCycle),this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),this.isStarted&&this.scheduleNextHarvest())}setupPageLifecycleHandlers(){let t=!1;const e=()=>{t||(t=!0,this.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",()=>{document.hidden&&e()}),window.addEventListener("pagehide",()=>{e()}),window.addEventListener("beforeunload",()=>{e()})}_qoeKpisUnchanged(t){const e=this._lastSentQoeKpis[t.viewId];if(!e)return!1;for(const i of o.A.QOE_KPI_KEYS)if(t[i]!==e[i])return!1;return!0}_saveQoeKpis(t){const e={};for(const i of o.A.QOE_KPI_KEYS)e[i]=t[i];this._lastSentQoeKpis[t.viewId]=e}}},144(t,e,i){i.d(e,{A:()=>o});class r{static error(...t){n(t,r.Levels.ERROR,"darkred")}static warn(...t){n(t,r.Levels.WARNING,"darkorange")}static notice(...t){n([].slice.call(arguments),r.Levels.NOTICE,"darkcyan")}static debug(...t){n(t,r.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(t,e,i){try{if(r.level<=r.Levels.DEBUG){i=i||function(t){r.debug("Event: "+t.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];e&&(null===e[0]?(e.shift(),n=e):n=n.concat(e));for(var a=0;a<n.length;a++)"function"==typeof t?t.call(window,n[a],i):t.on?t.on(n[a],i):t.addEventListener?t.addEventListener(n[a],i):t.addEventHandler?t.addEventHandler(n[a],i):r.warn("debugCommonVideoEvents: No common listener function found for ",t)}}catch(t){r.warn(t)}}}function n(t,e,i){e=e||r.Levels.NOTICE,i=i||"darkcyan";var n,o,u=r.prefix;r.includeTime&&(u+="["+("0"+(n=new Date).getDate()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+"] "),u+=function(t){return s[t]}(e)+":",r.level<=e&&e!==r.Levels.SILENT&&(!r.colorful||"undefined"!=typeof document&&document.documentMode?a(t,u):(o=e===r.Levels.ERROR&&console.error?console.error:e===r.Levels.WARNING&&console.warn?console.warn:e===r.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,u="%c"+u,t.splice(0,0,u,"color: "+i),o.apply(console,t)))}function a(t,e){if(t instanceof Array)for(var i in t)a(t[i],e);else"string"==typeof t?console.log(e+" "+t):(console.log(e+"↵"),console.log(t))}r.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},r.level=r.Levels.ERROR,r.colorful=!0,r.includeTime=!0,r.prefix="[nrvideo]";const s={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]?r.level=r.Levels.ALL:r.level=t[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(r.colorful=!1)}}();const o=r},481(t,e,i){i.d(e,{X:()=>a});var r=i(347),n=i(144);class a{async send(t,e){const{url:i,payload:r,options:a={}}=t;try{if(!i||!r)throw new Error("URL and payload are required");const t={url:i,payload:r,options:a,callback:e};await this.executeRequest(t)}catch(t){n.A.error("Failed to send request:",t.message),e({retry:!1,status:0,error:t.message})}}async executeRequest(t){const{url:e,payload:i,options:r,callback:a}=t,s=Date.now();try{const a=(o=JSON.stringify(i.body),u=window.NRVIDEO?.config?.obfuscate,u&&0!==u.length?u.reduce((t,e)=>{let i;try{if(e.regex instanceof RegExp){const t=e.regex.flags.includes("g")?e.regex.flags:e.regex.flags+"g";i=new RegExp(e.regex.source,t)}else i=new RegExp(e.regex,"g")}catch(i){return n.A.warn("applyObfuscationRules: invalid regex, skipping rule:",e.regex,i.message),t}return t.replace(i,e.replacement)},o):o);if(r.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(e,a),r={success:i,status:i?204:0};return void this.handleRequestComplete(t,r,s)}const l=await this.fetchWithTimeout(e,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:r.isFinalHarvest},1e4),d={success:l.ok,status:l.status,statusText:l.statusText};this.handleRequestComplete(t,d,s)}catch(e){const i={success:!1,status:0,error:e.message};this.handleRequestComplete(t,i,s)}var o,u}handleRequestComplete(t,e){const{callback:i}=t;i({retry:!e.success&&(0===e.status||(0,r.Sc)(e.status)),status:e.status,error:e.error})}async sendWithBeacon(t,e){try{return navigator.sendBeacon(t,e)}catch(t){return n.A.warn("sendBeacon failed, falling back to fetch:",t.message),!1}}async fetchWithTimeout(t,e,i){const r=new AbortController,n=setTimeout(()=>r.abort(),i);try{const i=await fetch(t,{...e,signal:r.signal});return clearTimeout(n),i}catch(t){if(clearTimeout(n),"AbortError"===t.name)throw new Error(`Request timeout after ${i}ms`);throw t}}}},413(t,e,i){i.d(e,{u:()=>u});var r=i(144),n=i(347),a=i(51);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=a.A;class u{constructor(){this.retryQueue=[],this.maxQueueSize=o,this.maxQueueSizeBytes=s}addFailedEvents(t){try{const e=Array.isArray(t)?t:[t];r.A.notice(`Adding ${e.length} failed events to retry queue`,{queueSizeBefore:this.retryQueue.length});for(const t of e){this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();const e=(0,n.Q3)(t);for(;(0,n.Q3)(this.retryQueue)+e>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...t})}}catch(t){r.A.error("Failed to add events to retry queue:",t.message)}}discardEvent(t,e){r.A.warn("Discarded event",{reason:e,eventType:t.eventType})}evictOldestEvent(){if(this.retryQueue.length>0){const t=this.retryQueue.shift();this.discardEvent(t,"Queue full - evicted oldest")}}getRetryEventsToFit(t,e){const i=[];let r=0,a=0;for(let s=this.retryQueue.length-1;s>=0;s--){const o=this.retryQueue[s];if(a>=e)break;const u=(0,n.Q3)(o);if(r+u>t)break;i.unshift(o),r+=u,a++,this.retryQueue.splice(s,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(t,e,i){i.d(e,{A:()=>d});var r=i(330),n=i(568),a=i(455),s=i(51),o=i(487),u=i(144);class l extends n.A{constructor(t){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new a.A,this._trackerReadyChrono.start(),this._actionTable=s.A.ACTION_TABLE,this._actionAdTable=s.A.ACTION_AD_TABLE,t=t||{},this.setOptions(t)}setOptions(t){t&&(t.parentTracker&&(this.parentTracker=t.parentTracker),t.customData&&(this.customData=t.customData),t.heartbeat&&(this.heartbeat=t.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(t){this.sendVideoAction(l.Events.HEARTBEAT,t)}getAttributes(t,e){(t=t||{}).trackerName=this.getTrackerName(),t.trackerVersion=this.getTrackerVersion(),t.coreVersion=r.rE,t.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let e in this.customData)t[e]=this.customData[e];return null!=document.hidden&&(t.isBackgroundEvent=document.hidden),t}getTrackerVersion(){return r.rE}getTrackerName(){return"base-tracker"}sendVideoAction(t,e){this.emit("VideoAction",t,this.getAttributes(e))}sendVideoAdAction(t,e){this.emit("VideoAdAction",t,this.getAttributes(e))}sendVideoErrorAction(t,e){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",t,this.getAttributes(e,i))}sendVideoCustomAction(t,e){this.emit("VideoCustomAction",t,this.getAttributes(e,"customAction"))}setHarvestInterval(t){if(o.videoAnalyticsHarvester)try{o.videoAnalyticsHarvester.setHarvestInterval(t)}catch(t){return void u.A.error("Failed to set harvest interval:",t.message)}else u.A.error("VideoAnalyticsHarvester is not available")}}l.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const d=l},347(t,e,i){i.d(e,{Q3:()=>s,Sc:()=>o,c$:()=>a,z8:()=>u});var r=i(330),n=i(144);function a(t){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:e,licenseKey:i,applicationID:n}=window.NRVIDEO.info;if(!e||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return n?`https://${t||e}/ins/1/${i}?a=${n}&v=${r.rE}&ref=${window.location.href}&ca=VA`:`https://${t||e}/ins/1/${i}?&v=${r.rE}&ref=${window.location.href}&ca=VA`}catch(t){return console.error(t.message),null}}function s(t){if("string"==typeof t&&t.length)return t.length;if("object"==typeof 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{return JSON.stringify(t,(()=>{const t=new WeakSet;return(e,i)=>{if("object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})())??""}catch(t){return n.A.error("Error stringifying value:",t.message),""}}(t).length}catch(t){return}}}function o(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}function u(t,e){return t&&Array.isArray(t)&&0!==t.length?e&&"object"==typeof e?t.reduce((t,i)=>(i in e&&(t[i]=e[i]),t),{}):{}:e}},330(t){t.exports={rE:"4.1.5"}}},n={};function a(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,a),i.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s=a(144),o=a(487),u=a(51),l=a(302),d=a(347);function c(t,e={}){try{if(!u.A.VALID_EVENT_TYPES.includes(t))return s.A.warn("Invalid event type provided to recordEvent",{eventType:t}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:r}=window.NRVIDEO.info,{qoe:n,...a}=e,c=n?{...n}:{},h={...r?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},f={...a,eventType:t,...h},y=(0,d.z8)(u.A.QOE_AGGREGATE_KEYS,e);let p=null;"VideoAction"===t&&(p={eventType:"VideoAction",actionName:l.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...c,...y,...h});const m=o.videoAnalyticsHarvester.addEvent(f);if(p&&window?.NRVIDEO?.config?.qoeAggregate){const t=o.videoAnalyticsHarvester.addEvent(p);return m&&t}return m}catch(t){return s.A.error("Failed to record event:",t.message),!1}}const{COLLECTOR:h}=u.A,f=new class{setConfiguration(t,e){return!!this.validateRequiredFields(t)&&!!this.validateConfigFields(e)&&(this.initializeGlobalConfig(t,e),s.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(t){if(!t||"object"!=typeof t)return s.A.error("Configuration must be an object"),!1;const{licenseKey:e,appName:i,region:r,applicationID:n,beacon:a}=t;if(!e)return s.A.error("licenseKey is required"),!1;if(n){if(!a)return s.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(h).flatMap(t=>t).includes(a))return s.A.error(`Invalid beacon: ${a}`),!1}else{if(!i||!r)return s.A.error("appName and region are required when applicationID is not provided"),!1;if(!h[r])return s.A.error(`Invalid region: ${r}. Valid regions are: ${Object.keys(h).join(", ")}`),!1}return!0}validateConfigFields(t){if(null==t)return!0;if("object"!=typeof t||Array.isArray(t))return s.A.error("config must be an object"),!1;const{qoeAggregate:e,obfuscate:i}=t;return void 0!==e&&"boolean"!=typeof e?(s.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(s.A.error("obfuscate must be an array"),1))}filterObfuscateRules(t){return t?t.filter(t=>{const 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)||(s.A.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",t),!1)}):[]}sanitizeQoeIntervalFactor(t){return null==t?1:"number"==typeof t&&Number.isInteger(t)&&t>=1?t:(console.warn(`[nrvideo] Invalid qoeIntervalFactor "${t}" — must be a positive integer. Defaulting to 1.`),1)}initializeGlobalConfig(t,e){let{licenseKey:i,appName:r,region:n,beacon:a,applicationID:s}=t;a="US"===n?u.A.COLLECTOR.US[0]:a||h[n],window.NRVIDEO={info:{...n?{region:n}:{},beacon:a,licenseKey:i,applicationID:s,...s?{}:{appName:r}},config:{qoeAggregate:e?.qoeAggregate??!1,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(e?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(e?.obfuscate)}}}};class y{static addTracker(t,e){var i,r;e?.info&&(i=e.info,r=e?.config,f.setConfiguration(i,r)),t.on&&t.emit?(p.push(t),t.on("*",m),"function"==typeof t.trackerInit&&t.trackerInit()):s.A.error("Tried to load a non-tracker.",t)}static removeTracker(t){t.off("*",m),t.dispose();let e=p.indexOf(t);-1!==e&&p.splice(e,1)}static getTrackers(){return p}static send(t,e,i){return c(t,{actionName:e,...i})}static sendError(t){return c("VideoErrorAction",{actionName:"ERROR",...t})}static async forceHarvest(){try{const{videoAnalyticsHarvester:t}=a(487);return await t.forceHarvest()}catch(t){return s.A.error("Failed to force harvest:",t.message),{success:!1,error:t.message}}}}let p=[];function m(t){try{let e=function(t){let e={};for(let i in t)null!==t[i]&&void 0!==t[i]&&(e[i]=t[i]);return e}(t.data);s.A.level<=s.A.Levels.DEBUG?s.A.notice("Sent",t.type,e):s.A.notice("Sent",t.type),y.send(t.eventType,t.type,e)}catch(t){s.A.error("Error in event handler:",t.message)}}const v=y;var g=a(455),A=a(568);const E=class{constructor(){this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0}reset(){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._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.hadStartupError=!1,this.hadPlaybackError=!1,this.totalRebufferingTime=0,this.resetFlags(),this.resetChronos()}resetFlags(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}resetChronos(){this.timeSinceRequested=new g.A,this.timeSinceStarted=new g.A,this.timeSincePaused=new g.A,this.timeSinceSeekBegin=new g.A,this.timeSinceBufferBegin=new g.A,this.timeSinceAdBreakStart=new g.A,this.timeSinceLastDownload=new g.A,this.timeSinceLastHeartbeat=new g.A,this.timeSinceLastRenditionChange=new g.A,this.timeSinceLastAdQuartile=new g.A,this.timeSinceLastAd=new g.A,this.timeSinceLastError=new g.A,this.timeSinceLastAdError=new g.A,this.timeSinceResumed=new g.A,this.timeSinceSeekEnd=new g.A,this.playtimeSinceLastEvent=new g.A,this.customTimeSinceAttributes={},this.elapsedTime=new g.A,this.bufferElapsedTime=new g.A,this._totalAdPlaytime=new g.A}isAd(){return this._isAd}setIsAd(t){this._isAd=t}setTimeSinceAttribute(t){this.customTimeSinceAttributes[t]=new g.A,this.customTimeSinceAttributes[t].start()}removeTimeSinceAttribute(t){delete this.customTimeSinceAttributes[t]}getViewSession(){if(!this._viewSession){let t=(new Date).getTime(),e=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=t+"-"+e}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(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(const[e,i]of Object.entries(this.customTimeSinceAttributes))t[e]=i.getDeltaTime();return t}getQoeAttributes(t){t=t||{};const e={};try{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}catch(t){s.A.error("Failed to add attributes for QOE KPIs",t.message)}return t.qoe=e,t}calculateBufferType(t){let e="";return e=t?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",s.A.debug("Buffer Type = "+e),e}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}goPause(){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))}goResume(){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))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){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))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}goLastAd(){this.timeSinceLastAd.start()}trackContentBitrateState(t){if(t&&"number"==typeof t){this.peakBitrate=Math.max(this.peakBitrate,t);const e=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){const t=e-this._lastBitrateChangeTimestamp;t>0&&(this.partialAverageBitrate+=this._lastBitrate*t,this._totalBitrateDuration+=t),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){const t=e-this._lastBitrateChangeTimestamp;t>0&&(this.partialAverageBitrate+=this._lastBitrate*t,this._totalBitrateDuration+=t),this._lastBitrateChangeTimestamp=e}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=e),this._lastBitrate=t;let i=this.partialAverageBitrate,r=this._totalBitrateDuration;const n=e-this._lastBitrateChangeTimestamp;n>0&&(i+=t*n,r+=n),this.weightedBitrate=r>0?Math.round(i/r):t}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){s.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return s.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return s.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(t){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-t,0))}};var b=a(330);class T extends l.A{constructor(t,e){super(),this.state=new E,this.adsTracker=null,this._lastBufferType=null,this._userId=null,e=e||{},this.setOptions(e),t&&this.setPlayer(t,e.tag),s.A.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(t){this._userId=t}setOptions(t){t&&(t.adsTracker&&this.setAdsTracker(t.adsTracker),"boolean"==typeof t.isAd&&this.setIsAd(t.isAd),l.A.prototype.setOptions.apply(this,arguments))}setPlayer(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()}isAd(){return this.state.isAd()}setIsAd(t){this.state.setIsAd(t)}setAdsTracker(t){this.disposeAdsTracker(),t&&(this.adsTracker=t,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",S.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",S),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getManifestBitrate(){return null}getSegmentDownloadBitrate(){return null}getNetworkDownloadBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let t;if(this._lastWebkitBitrate){t=this.tag.webkitVideoDecodedByteCount;let e=t-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;t=Math.round(e/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,t||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(t){let e,i=this.getRenditionBitrate();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}getRenditionHeight(){return this.tag?this.tag.videoHeight:null}getRenditionWidth(){return this.tag?this.tag.videoWidth:null}getDuration(){return this.tag?this.tag.duration:null}getPlayhead(){return this.tag?this.tag.currentTime:null}getLanguage(){return null}getSrc(){return this.tag?this.tag.currentSrc:null}getPlayrate(){return this.tag?this.tag.playbackRate:null}isMuted(){return this.tag?this.tag.muted:null}isFullscreen(){return null}getCdn(){return null}getPlayerName(){return this.getTrackerName()}getPlayerVersion(){return b.rE}getFps(){return null}isAutoplayed(){return this.tag?this.tag.autoplay:null}getPreload(){return this.tag?this.tag.preload:null}getAdQuartile(){return null}getAdPosition(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}getAdPartner(){return null}getAdCreativeId(){return null}getInstrumentationProvider(){return null}getInstrumentationName(){return null}getInstrumentationVersion(){return null}getAttributes(t,e){if(void 0===(t=l.A.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="Browser","customAction"===e)return t;try{t.pageUrl=window.location.href}catch(t){}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);for(let e in this.customData)t[e]=this.customData[e];return this.addQoeAttributes(t),t}addQoeAttributes(t){const e=(t=this.state.getQoeAttributes(t)).qoe;for(let t in this.customData)e[t]=this.customData[t]}sendCustom(t,e,i){i=i||{},this.sendVideoCustomAction(t,i),this.state.setTimeSinceAttribute(e)}sendPlayerReady(t){this.state.goPlayerReady()&&(t=t||{},this.sendVideoAction(T.Events.PLAYER_READY,t))}sendRequest(t){if(this.state.goRequest()){let e;this.isAd()?(e=T.Events.AD_REQUEST,this.sendVideoAdAction(e,t)):(e=T.Events.CONTENT_REQUEST,this.sendVideoAction(e,t))}}sendStart(t){if(this.state.goStart()){let e;if(this.isAd())e=T.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(e,t),this.state.startAdsTime();else{e=T.Events.CONTENT_START;let i=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),i=this.adsTracker.state.totalAdTime()??0),this.state.setStartupTime(i),this.sendVideoAction(e,t),o.videoAnalyticsHarvester.setBeforeDrainCallback(()=>{if(this.state){const t=this.state.getQoeAttributes({}).qoe;o.videoAnalyticsHarvester.refreshQoeKpis(t,this.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(t){if(this.state.goEnd()){let e;t=t||{},this.isAd()?(e=T.Events.AD_END,t.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.state.stopAdsTime()):(e=T.Events.CONTENT_END,t.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),t.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0,this.isAd()||(o.videoAnalyticsHarvester.forceNextQoeCycle(),o.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(t){if(this.state.goPause()){let e=this.isAd()?T.Events.AD_PAUSE:T.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendResume(t){if(this.state.goResume()){let e;t=t||{},this.isAd()?(e=T.Events.AD_RESUME,t.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(e=T.Events.CONTENT_RESUME,t.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendBufferStart(t){if(this.state.goBufferStart()){let e;t=t||{},e=this.isAd()?T.Events.AD_BUFFER_START:T.Events.CONTENT_BUFFER_START,t=this.buildBufferAttributes(t),this._lastBufferType=t.bufferType,this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendBufferEnd(t){if(this.state.goBufferEnd()){let e;t=t||{},this.isAd()?(e=T.Events.AD_BUFFER_END,t.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(e=T.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(e,t):this.sendVideoAction(e,t),this.state.initialBufferingHappened=!0}}buildBufferAttributes(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}sendSeekStart(t){if(this.state.goSeekStart()){let e;e=this.isAd()?T.Events.AD_SEEK_START:T.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendSeekEnd(t){if(this.state.goSeekEnd()){let e;t=t||{},this.isAd()?(e=T.Events.AD_SEEK_END,t.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(e=T.Events.CONTENT_SEEK_END,t.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t)}}sendDownload(t){(t=t||{}).state||s.A.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(T.Events.DOWNLOAD,t),this.state.goDownload()}sendError(t){(t=t||{}).isAd=this.isAd(),this.state.goError();let e=this.isAd()?T.Events.AD_ERROR:T.Events.CONTENT_ERROR;this.sendVideoErrorAction(e,t)}sendRenditionChanged(t){let e;(t=t||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),t.shift=this.getRenditionShift(!0),e=this.isAd()?T.Events.AD_RENDITION_CHANGE:T.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(e,t):this.sendVideoAction(e,t),this.state.goRenditionChange()}sendHeartbeat(t){if(this.state.isRequested){let e,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(e=T.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(e,t):this.sendVideoAdAction(e,{elapsedTime:i,...t})):(e=T.Events.CONTENT_HEARTBEAT,this.sendVideoAction(e,{elapsedTime:i,...t})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(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)}sendAdBreakStart(t){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(T.Events.AD_BREAK_START,t))}sendAdBreakEnd(t){this.isAd()&&this.state.goAdBreakEnd()&&((t=t||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(T.Events.AD_BREAK_END,t),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(t){this.isAd()&&((t=t||{}).quartile||s.A.warn("Called sendAdQuartile without { quartile: xxxxx }."),t.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(T.Events.AD_QUARTILE,t),this.state.goAdQuartile())}sendAdClick(t){this.isAd()&&((t=t||{}).url||s.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(T.Events.AD_CLICK,t))}}function S(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 k=T;var D=a(431),_=a(413),R=a(481),w=a(374);const P={Constants:u.A,Chrono:g.A,Log:s.A,Emitter:A.A,Tracker:l.A,VideoTracker:k,VideoTrackerState:E,Core:v,version:b.rE,NrVideoEventAggregator:D.t,RetryQueueHandler:_.u,OptimizedHttpClient:R.X,HarvestScheduler:w.n,recordEvent:c}},64(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(i(555)),a=s(i(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(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,u(r.key),r)}}function u(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+""}function l(t,e,i){return e=c(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||[],c(t).constructor):e.apply(t,i))}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(d=function(){return!!t})()}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,e,arguments)}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&&h(t,e)}(e,t),i=e,a=[{key:"isUsing",value:function(t){return!!t.ima3}}],(r=[{key:"getTrackerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayhead",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.ima3)||void 0===t||null===(t=t.adPlayer)||void 0===t?void 0:t.currentTime()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ima3-ready","ima3error","ima3-ad-error","ima3-started","ima3-complete","ima3-paused","ima3-resumed","ads-request","ads-load","ads-ad-started","ads-ad-ended","ads-pause","ads-play","ads-click","ads-pod-started","ads-pod-ended","ads-allpods-completed"]),this.player.on("ima3-started",this.onStarted.bind(this)),this.player.on("ima3-paused",this.onPaused.bind(this)),this.player.on("ima3-resumed",this.onResume.bind(this)),this.player.on("ima3-complete",this.onComplete.bind(this)),this.player.on("ima3-skipped",this.onSkipped.bind(this)),this.player.on("adserror",this.onError.bind(this)),this.player.on("ads-click",this.onClick.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ima3-started",this.onStarted),this.player.off("ima3-paused",this.onPaused),this.player.off("ima3-resumed",this.onResume),this.player.off("ima3-complete",this.onComplete),this.player.off("ima3-skipped",this.onSkipped),this.player.off("adserror",this.onError),this.player.off("ads-click",this.onClick)}},{key:"onStarted",value:function(t){this.sendRequest(),this.sendStart()}},{key:"onPaused",value:function(t){this.sendPause()}},{key:"onResume",value:function(t){this.sendResume()}},{key:"onComplete",value:function(t){this.sendEnd()}},{key:"onSkipped",value:function(t){this.sendEnd({skipped:!0})}},{key:"onError",value:function(t){this.sendError()}},{key:"onClick",value:function(t){this.sendClick()}}])&&o(i.prototype,r),a&&o(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},717(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(i(555)),a=s(i(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(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,s,o=[],u=!0,l=!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)&&(o.push(r.value),o.length!==e);u=!0);}catch(t){l=!0,n=t}finally{try{if(!u&&null!=i.return&&(s=i.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return u(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)?u(t,e):void 0}}(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 u(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 l(t,e,i){return(e=c(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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,c(r.key),r)}}function c(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+""}function h(t,e,i){return e=m(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,f()?Reflect.construct(e,i||[],m(t).constructor):e.apply(t,i))}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function y(t,e,i,r){var n=p(m(1&r?t.prototype:t),e,i);return 2&r&&"function"==typeof n?function(t){return n.apply(i,t)}:n}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=m(t)););return t}(t,e);if(r){var n=Object.getOwnPropertyDescriptor(r,e);return n.get?n.get.call(arguments.length<3?t:i):n.value}},p.apply(null,arguments)}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},m(t)}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}var g={DAI_STREAM_INITIALIZED:"dai-stream-initialized",DAI_STREAM_LOADED:"dai-stream-loaded",DAI_STREAM_ERROR:"dai-stream-error",DAI_AD_BREAK_STARTED:"dai-ad-break-started",DAI_AD_BREAK_ENDED:"dai-ad-break-ended",DAI_AD_PERIOD_STARTED:"dai-ad-period-started",DAI_AD_PERIOD_ENDED:"dai-ad-period-ended",DAI_AD_STARTED:"dai-ad-started",DAI_AD_FIRST_QUARTILE:"dai-ad-first-quartile",DAI_AD_MIDPOINT:"dai-ad-midpoint",DAI_AD_THIRD_QUARTILE:"dai-ad-third-quartile",DAI_AD_COMPLETE:"dai-ad-complete",DAI_AD_SKIPPED:"dai-ad-skipped",DAI_AD_PAUSED:"dai-ad-paused",DAI_AD_RESUMED:"dai-ad-resumed",DAI_AD_CLICKED:"dai-ad-clicked",DAI_AD_ERROR:"dai-ad-error",DAI_CUEPOINTS_CHANGED:"dai-cuepoints-changed",DAI_TIMED_METADATA:"dai-timed-metadata"};e.default=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),(i=h(this,e,[t])).streamManager=null,i.currentAdData=null,i.adBreakData=null,i.streamData=null,i.cuePoints=[],i.initialized=!1,i.eventHandlers=null,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&&v(t,e)}(e,t),i=e,a=[{key:"isUsing",value:function(t){return t.imaDai&&"function"==typeof t.imaDai||t.dai&&void 0!==t.dai.VERSION||t.ima&&t.ima.dai||t.streamManager}}],(r=[{key:"setStreamManager",value:function(t){this.streamManager=t,this.setupStreamManagerListeners(),this.initialized=!0,n.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}},{key:"setupStreamManagerListeners",value:function(){var t,e,i=this;if(this.streamManager&&null!==(t=google)&&void 0!==t&&null!==(t=t.ima)&&void 0!==t&&null!==(t=t.dai)&&void 0!==t&&null!==(t=t.api)&&void 0!==t&&t.StreamEvent){var r=google.ima.dai.api.StreamEvent.Type;this.eventHandlers=(l(l(l(l(l(l(l(l(l(l(e={},r.LOADED,this.onStreamLoaded.bind(this)),r.STREAM_INITIALIZED,this.onStreamInitialized.bind(this)),r.ERROR,this.onStreamError.bind(this)),r.AD_BREAK_STARTED,this.onAdBreakStarted.bind(this)),r.AD_BREAK_ENDED,this.onAdBreakEnded.bind(this)),r.AD_PERIOD_STARTED,this.onAdPeriodStarted.bind(this)),r.AD_PERIOD_ENDED,this.onAdPeriodEnded.bind(this)),r.STARTED,this.onAdStarted.bind(this)),r.FIRST_QUARTILE,this.onAdFirstQuartile.bind(this)),r.MIDPOINT,this.onAdMidpoint.bind(this)),l(l(l(l(l(l(l(l(l(e,r.THIRD_QUARTILE,this.onAdThirdQuartile.bind(this)),r.COMPLETE,this.onAdComplete.bind(this)),r.SKIPPED,this.onAdSkipped.bind(this)),r.PAUSED,this.onAdPaused.bind(this)),r.RESUMED,this.onAdResumed.bind(this)),r.CLICK,this.onAdClicked.bind(this)),r.VIDEO_CLICKED,this.onAdClicked.bind(this)),r.CUEPOINTS_CHANGED,this.onCuePointsChanged.bind(this)),r.TIMED_METADATA,this.onTimedMetadata.bind(this))),Object.entries(this.eventHandlers).forEach(function(t){var e=o(t,2),r=e[0],n=e[1];i.streamManager.addEventListener(r,n)}),n.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}else n.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available")}},{key:"registerListeners",value:function(){y(e,"registerListeners",this,3)([]),n.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(g)])}},{key:"unregisterListeners",value:function(){var t=this;y(e,"unregisterListeners",this,3)([]),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach(function(e){var i=o(e,2),r=i[0],n=i[1];t.streamManager.removeEventListener(r,n)}),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}},{key:"onStreamLoaded",value:function(t){this.streamData=this.extractStreamData(t),n.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}},{key:"onStreamInitialized",value:function(t){n.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}},{key:"onStreamError",value:function(t){var e=this.extractErrorData(t);n.default.Log.error("DaiAdsTracker: Stream error",e),this.sendError(e)}},{key:"onAdBreakStarted",value:function(t){this.adBreakData=this.extractAdBreakData(t),n.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}},{key:"onAdBreakEnded",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}},{key:"onAdPeriodStarted",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(t)}},{key:"onAdPeriodEnded",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad period ended")}},{key:"onAdStarted",value:function(t){this.currentAdData=this.extractAdData(t),n.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}},{key:"onAdFirstQuartile",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}},{key:"onAdMidpoint",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}},{key:"onAdThirdQuartile",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}},{key:"onAdComplete",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}},{key:"onAdSkipped",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}},{key:"onAdPaused",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}},{key:"onAdResumed",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}},{key:"onAdClicked",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}},{key:"onCuePointsChanged",value:function(t){this.cuePoints=this.extractCuePoints(t),n.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}},{key:"onTimedMetadata",value:function(t){var e=this.extractTimedMetadata(t);n.default.Log.debug("DaiAdsTracker: Timed metadata",e)}},{key:"extractStreamData",value:function(t){try{var e=t.getStreamData();return{streamId:null==e?void 0:e.streamId,url:null==e?void 0:e.url,adTagParameters:null==e?void 0:e.adTagParameters,streamType:this.getStreamType()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract stream data",t),{}}}},{key:"extractAdBreakData",value:function(t){try{var e,i=t.getAdBreak();return{adBreakId:null==i?void 0:i.id,adBreakTitle:null==i?void 0:i.title,adCount:(null==i||null===(e=i.ads)||void 0===e?void 0:e.length)||0,position:this.getAdPosition()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",t),{}}}},{key:"extractAdData",value:function(t){try{var e=t.getAd();return{adId:null==e?void 0:e.getAdId(),creativeId:null==e?void 0:e.getCreativeId(),duration:null==e?void 0:e.getDuration(),title:null==e?void 0:e.getTitle(),description:null==e?void 0:e.getDescription(),advertiserName:null==e?void 0:e.getAdvertiserName(),clickThroughUrl:null==e?void 0:e.getClickThroughUrl(),dealId:null==e?void 0:e.getDealId(),wrapperAdIds:null==e?void 0:e.getWrapperAdIds(),position:this.getAdPosition()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad data",t),{}}}},{key:"extractErrorData",value:function(t){try{var e=t.getError();return{errorCode:null==e?void 0:e.getErrorCode(),errorMessage:null==e?void 0:e.getMessage(),innerError:null==e?void 0:e.getInnerError()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract error data",e),{errorMessage:"Unknown DAI error"}}}},{key:"extractCuePoints",value:function(t){try{return t.getCuepoints()||[]}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract cue points",t),[]}}},{key:"extractTimedMetadata",value:function(t){try{return{type:t.getType(),data:t.getData()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",t),{}}}},{key:"getTrackerName",value:function(){return"dai-ads"}},{key:"getPlayerName",value:function(){return"videojs-dai"}},{key:"getPlayerVersion",value:function(){var t,e;return null!==(t=this.player.dai)&&void 0!==t&&t.VERSION?this.player.dai.VERSION:null!==(e=this.player.ima)&&void 0!==e&&e.VERSION?"ima-dai: ".concat(this.player.ima.VERSION):"unknown"}},{key:"getAdCuePoints",value:function(){return this.cuePoints}},{key:"getAdPosition",value:function(){if(!this.currentAdData&&!this.adBreakData)return null;var t=this.player.currentTime(),e=this.player.duration();return t<5?"pre":e&&t>e-10?"post":"mid"}},{key:"getDuration",value:function(){var t;return void 0!==(null===(t=this.currentAdData)||void 0===t?void 0:t.duration)?1e3*this.currentAdData.duration:null}},{key:"getVideoId",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.adId)||null}},{key:"getAdCreativeId",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.creativeId)||null}},{key:"getTitle",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.title)||null}},{key:"getSrc",value:function(){var t;return(null===(t=this.streamData)||void 0===t?void 0:t.url)||null}},{key:"getPlayhead",value:function(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(t){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}},{key:"getAdPartner",value:function(){return"google-dai"}},{key:"getClickThroughUrl",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.clickThroughUrl)||null}},{key:"getStreamType",value:function(){var t;return null!==(t=this.streamData)&&void 0!==t&&t.streamType?this.streamData.streamType:this.player.duration()===1/0?"live":"vod"}},{key:"isLiveStream",value:function(){return"live"===this.getStreamType()}},{key:"getCurrentAdBreak",value:function(){return this.adBreakData}},{key:"getCurrentAd",value:function(){return this.currentAdData}},{key:"getStreamData",value:function(){return this.streamData}},{key:"getBitrate",value:function(){var t=this.getTech();if(t&&t.tech&&t.tech.stats)return t.tech.stats.bandwidth}},{key:"getRenditionBitrate",value:function(){var t=this.getTech();if(t&&t.getRenditionBitrate)return t.getRenditionBitrate()}}])&&d(i.prototype,r),a&&d(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},38(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n,a=(n=i(472))&&n.__esModule?n:{default:n};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,o(r.key),r)}}function o(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+""}function u(t,e,i){return e=d(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,l()?Reflect.construct(e,i||[],d(t).constructor):e.apply(t,i))}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,e,arguments)}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),function(t,e,i){return e&&s(t.prototype,e),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(e,[{key:"getTrackerName",value:function(){return"freewheel-ads"}},{key:"getPlayerName",value:function(){return"freewheel-ads"}},{key:"getPlayerVersion",value:function(){return this.player.FreeWheelPlugin.VERSION}},{key:"getPlayhead",value:function(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}},{key:"getDuration",value:function(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}},{key:"getVideoId",value:function(){return this.player.ads.ad.id}},{key:"getAdPartner",value:function(){return"freewheel"}},{key:"getAdCreativeId",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(t){}}},{key:"getSrc",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(t){}}},{key:"getTitle",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(t){}}},{key:"getAdPosition",value:function(){switch(this.player.ads.ad.type){case"PREROLL":return nrvideo.Constants.AdPositions.PRE;case"MIDROLL":return nrvideo.Constants.AdPositions.MID;case"POSTROLL":return nrvideo.Constants.AdPositions.POST}}}],[{key:"isUsing",value:function(t){return!!t.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}}])}(a.default)},298(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(i(555)),a=s(i(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(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,u(r.key),r)}}function u(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+""}function l(t,e,i){return e=c(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||[],c(t).constructor):e.apply(t,i))}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(d=function(){return!!t})()}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,e,arguments)}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&&h(t,e)}(e,t),i=e,r=[{key:"getTrackerName",value:function(){return"ima-ads"}},{key:"getPlayerName",value:function(){return"ima"}},{key:"getPlayerVersion",value:function(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}},{key:"getCuePoints",value:function(){return this.player.ima.getAdsManager().getCuePoints()}},{key:"getAdPosition",value:function(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){var t=this.lastAdData.podInfo.podIndex;return 0===t?"pre":-1===t?"post":"mid"}return null}},{key:"getDuration",value:function(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}},{key:"getVideoId",value:function(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}},{key:"getAdCreativeId",value:function(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}},{key:"getSrc",value:function(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}},{key:"getTitle",value:function(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}},{key:"getPlayhead",value:function(){var t=this.player.ima.getAdsManager();if(t)return 1e3*(this.getDuration()-t.getRemainingTime())}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"getAdPartner",value:function(){return"ima"}},{key:"getWebkitBitrate",value:function(){var t=this.getAdVideoElement();if(t&&t.webkitVideoDecodedByteCount){var e;if(this._lastAdWebkitBitrate>0){var i=t.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,r=this.getHeartbeat()/1e3;e=Math.round(i/r*8)}return this._lastAdWebkitBitrate=t.webkitVideoDecodedByteCount,null!=e?e:null}return null}},{key:"getRenditionBitrate",value:function(){if(this.lastAdData)return this.lastAdData.renditionBitrate}},{key:"registerListeners",value:function(){var t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,n.default.Log.debugCommonVideoEvents(this.player.ima.addEventListener,[null,t.ALL_ADS_COMPLETED,t.LINEAR_CHANGED,t.COMPLETE,t.USER_CLOSE,t.IMPRESSION,t.CONTENT_PAUSE_REQUESTED,t.CONTENT_RESUME_REQUESTED,t.SKIPPED,t.SKIPPABLE_STATE_CHANGED,t.LOADED,t.PAUSED,t.RESUMED,t.STARTED,t.AD_CAN_PLAY,t.AD_METADATA,t.EXPANDED_CHANGED,t.AD_BREAK_READY,t.LOG,t.CLICK,t.FIRST_QUARTILE,t.MIDPOINT,t.THIRD_QUARTILE,e]),this.player.ima.addEventListener(t.LOADED,this.onLoaded.bind(this)),this.player.ima.addEventListener(t.STARTED,this.onStart.bind(this)),this.player.ima.addEventListener(t.PAUSED,this.onPaused.bind(this)),this.player.ima.addEventListener(t.RESUMED,this.onResumed.bind(this)),this.player.ima.addEventListener(t.COMPLETE,this.onComplete.bind(this)),this.player.ima.addEventListener(t.SKIPPED,this.onSkipped.bind(this)),this.player.ima.addEventListener(t.CLICK,this.onClick.bind(this)),this.player.ima.addEventListener(t.FIRST_QUARTILE,this.onFirstQuartile.bind(this)),this.player.ima.addEventListener(t.MIDPOINT,this.onMidpoint.bind(this)),this.player.ima.addEventListener(t.THIRD_QUARTILE,this.onThirdQuartile.bind(this)),this.player.ima.addEventListener(e,this.onError.bind(this))}},{key:"unregisterListeners",value:function(){var t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.player.ima.removeEventListener(t.LOADED,this.onLoaded),this.player.ima.removeEventListener(t.STARTED,this.onLoaded.bind(this)),this.player.ima.removeEventListener(t.IMPRESSION,this.onImpression),this.player.ima.removeEventListener(t.PAUSED,this.onPaused),this.player.ima.removeEventListener(t.RESUMED,this.onResumed),this.player.ima.removeEventListener(t.COMPLETE,this.onComplete),this.player.ima.removeEventListener(t.SKIPPED,this.onSkipped),this.player.ima.removeEventListener(t.CLICK,this.onClick),this.player.ima.removeEventListener(t.FIRST_QUARTILE,this.onFirstQuartile),this.player.ima.removeEventListener(t.MIDPOINT,this.onMidpoint),this.player.ima.removeEventListener(t.THIRD_QUARTILE,this.onThirdQuartile),this.player.ima.removeEventListener(e,this.onError),this.lastAdData=null}},{key:"onLoaded",value:function(t){this.lastAdData=this.getAdData(),this.sendRequest()}},{key:"onStart",value:function(t){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}},{key:"onComplete",value:function(t){this.sendEnd(),this.lastAdData=null}},{key:"onSkipped",value:function(t){this.sendEnd({skipped:!0}),this.lastAdData=null}},{key:"onError",value:function(t){var e=t.getError(),i=e.getErrorCode(),r=e.getMessage();this.sendError({adError:e,errorCode:i,errorMessage:r})}},{key:"onClick",value:function(t){this.sendAdClick()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({adQuartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({adQuartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({adQuartile:3})}},{key:"onPaused",value:function(){this.sendPause()}},{key:"onResumed",value:function(){this.sendResume()}},{key:"getAdData",value:function(){try{var t=this.player.ima.getAdsManager();if(t){var e,i=t.getCurrentAd();if(i)return{adId:i.getAdId(),creativeId:i.getCreativeId(),duration:i.getDuration(),mediaUrl:i.getMediaUrl(),title:i.getTitle(),podInfo:null===(e=i.getAdPodInfo())||void 0===e?void 0:e.data,renditionBitrate:i.getVastMediaBitrate()}}return null}catch(t){return null}}},{key:"getAdVideoElement",value:function(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){var t=this.player.ima.controller.adUi.adContainerDiv;if(t){var e=t.querySelector("video");if(e)return e}}}}],a=[{key:"isUsing",value:function(t){return t.ima&&"undefined"!=typeof google}}],r&&o(i.prototype,r),a&&o(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},472(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=l(i(555)),a=l(i(330)),s=l(i(409)),o=l(i(257)),u=l(i(338));function l(t){return t&&t.__esModule?t:{default: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,c(r.key),r)}}function c(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+""}function h(t,e,i){return e=y(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,f()?Reflect.construct(e,i||[],y(t).constructor):e.apply(t,i))}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),h(this,e,arguments)}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&&p(t,e)}(e,t),i=e,(r=[{key:"getTech",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(s.default.isUsing(t))return new s.default(t);if(o.default.isUsing(t))return new o.default(t);if(u.default.isUsing(t))return new u.default(t)}}},{key:"getTrackerName",value:function(){return"videojs-ads"}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getRenditionHeight",value:function(){return null}},{key:"getRenditionWidth",value:function(){return null}},{key:"getPlayerName",value:function(){return"videojs-ads"}},{key:"getPlayerVersion",value:function(){return this.player.ads.VERSION}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ads-request","ads-load","adstart","adend","adskip","adserror","ads-click","ads-pod-started","ads-pod-ended","ads-first-quartile","ads-midpoint","ads-third-quartile","ads-pause","ads-play","adtimeout"]),this.player.on("ads-request",this.onAdrequest.bind(this)),this.player.on("ads-load",this.onAdload.bind(this)),this.player.on("adstart",this.onAdstart.bind(this)),this.player.on("adend",this.onAdend.bind(this)),this.player.on("adskip",this.onAdskip.bind(this)),this.player.on("adserror",this.onAdserror.bind(this)),this.player.on("ads-click",this.onAdsClick.bind(this)),this.player.on("ads-pod-started",this.onPodStart.bind(this)),this.player.on("ads-pod-ended",this.onPodEnd.bind(this)),this.player.on("ads-first-quartile",this.onFirstQuartile.bind(this)),this.player.on("ads-midpoint",this.onMidpoint.bind(this)),this.player.on("ads-third-quartile",this.onThirdQuartile.bind(this)),this.player.on("ads-pause",this.onAdspause.bind(this)),this.player.on("ads-play",this.onAdsplay.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ads-request",this.onAdrequest),this.player.off("ads-load",this.onAdload),this.player.off("adstart",this.onAdstart),this.player.off("adend",this.onAdend),this.player.off("adskip",this.onAdskip),this.player.off("adserror",this.onAdserror),this.player.off("ads-click",this.onAdsClick),this.player.off("ads-pod-started",this.onPodStart),this.player.off("ads-pod-ended",this.onPodEnd),this.player.off("ads-first-quartile",this.onFirstQuartile),this.player.off("ads-midpoint",this.onMidpoint),this.player.off("ads-third-quartile",this.onThirdQuartile),this.player.off("ads-pause",this.onAdspause),this.player.off("ads-play",this.onAdsplay)}},{key:"onAdrequest",value:function(t){this.sendRequest(),this.sendDownload({state:"ads-request"})}},{key:"onAdload",value:function(t){this.sendDownload({state:"ads-load"})}},{key:"onAdstart",value:function(t){this.sendRequest(),this.sendStart()}},{key:"onAdend",value:function(t){this.sendEnd()}},{key:"onAdskip",value:function(t){this.sendEnd({skipped:!0})}},{key:"onAdserror",value:function(t){this.sendError()}},{key:"onAdsClick",value:function(t){this.sendAdClick({url:"unknown"})}},{key:"onPodStart",value:function(t){this.sendAdBreakStart()}},{key:"onPodEnd",value:function(t){this.sendAdBreakEnd()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({quartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({quartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({quartile:3})}},{key:"onAdspause",value:function(){this.sendPause()}},{key:"onAdsplay",value:function(){this.sendResume()}}])&&d(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(n.default.VideoTracker)},409(t,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){(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 n(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 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+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.vhs,this.player=e.el().player},(e=[{key:"getRenditionName",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.NAME}catch(t){}return null}},{key:"getRenditionBitrate",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.BANDWIDTH}catch(t){}return null}},{key:"getRenditionWidth",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.width}catch(t){}return null}},{key:"getRenditionHeight",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.height}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getManifestBitrate",value:function(){try{var t=this.tech.playlists.master.playlists;if(t&&t.length>0)return Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return r(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 r(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)?r(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.")}()}(t.map(function(t){return t.attributes.BANDWIDTH})))}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){var t;return void 0!==(null===(t=this.tech.stats)||void 0===t?void 0:t.bandwidth)&&this.tech.stats.bandwidth>0?this.tech.stats.bandwidth:null}},{key:"getNetworkDownloadBitrate",value:function(){return void 0!==this.tech.throughput&&this.tech.throughput>0?this.tech.throughput:null}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH||null}catch(t){}return null}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.vhs}},257(t,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){(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 n(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 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+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.vhs_,this.player=e.el().player},(e=[{key:"getResource",value:function(t){return this.tech.url}},{key:"getRenditionName",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.name)return e.name}catch(t){}return null}},{key:"getRenditionBitrate",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return e.bitrate}catch(t){}return null}},{key:"getRenditionWidth",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.width)return e.width}catch(t){}return null}},{key:"getRenditionHeight",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.height)return e.height}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return t.bitrate}catch(t){}return null}},{key:"getManifestBitrate",value:function(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return r(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 r(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)?r(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.")}()}(this.tech.levels.map(function(t){return t.bitrate})))}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return this.tech.stats.bandwidth}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){return this.tech.throughput&&this.tech.throughput>0?this.tech.throughput:null}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.vhs_}},338(t,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){(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 n(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 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+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.shakaPlayer,this.player=e.el().player},e=[{key:"getSrc",value:function(t){try{return this.tech.getManifestUri()}catch(t){}return null}},{key:"getRenditionBitrate",value:function(t){try{return this.tech.getStats().streamBandwidth}catch(t){}return null}},{key:"getManifestBitrate",value:function(){try{var t=this.tech.getVariantTracks();if(t&&t.length>0)return Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return r(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 r(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)?r(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.")}()}(t.map(function(t){return t.videoBandwidth+(t.audioBandwidth||0)})))}catch(t){}return null}},{key:"getRenditionWidth",value:function(t){try{var e=this.tech.getVariantTracks();for(var i in e){var r=e[i];if(r.active&&"video"===r.type)return r.width}}catch(t){}return null}},{key:"getRenditionHeight",value:function(t){try{var e=this.tech.getVariantTracks();for(var i in e){var r=e[i];if(r.active&&"video"===r.type)return r.height}}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.getStats();if(t&&t.streamBandwidth&&t.streamBandwidth>0)return t.streamBandwidth}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return t.estimatedBandwidth}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return t.estimatedBandwidth}catch(t){}return null}}],e&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.shakaPlayer}},302(t,e,i){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)}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"ContribHlsTech",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"FreewheelAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,"HlsJsTech",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"ImaAdsTracker",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(e,"ShakaTech",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"VideojsAdsTracker",{enumerable:!0,get:function(){return l.default}}),e.default=void 0;var n=y(i(555)),a=y(i(330)),s=y(i(409)),o=y(i(257)),u=y(i(338)),l=y(i(472)),d=y(i(298)),c=y(i(64)),h=y(i(38)),f=y(i(717));function y(t){return t&&t.__esModule?t:{default:t}}function p(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 m(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,v(r.key),r)}}function v(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+""}function g(t,e,i){return e=E(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,A()?Reflect.construct(e,i||[],E(t).constructor):e.apply(t,i))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(A=function(){return!!t})()}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}e.default=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),(r=g(this,e,[t,i])).isContentEnd=!1,r.imaAdCuePoints="",r.daiInitialized=!1,n.default.Core.addTracker(r,i),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&&b(t,e)}(e,t),i=e,r=[{key:"getTech",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(s.default.isUsing(t))return new s.default(t);if(o.default.isUsing(t))return new o.default(t);if(u.default.isUsing(t))return new u.default(t)}}},{key:"getTrackerName",value:function(){return"videojs"}},{key:"getInstrumentationProvider",value:function(){return"New Relic"}},{key:"getInstrumentationName",value:function(){return this.getPlayerName()}},{key:"getInstrumentationVersion",value:function(){return this.getPlayerVersion()}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"getPlayhead",value:function(){return this.player.ads&&"ads-playback"===this.player.ads.state&&this.player.ads.snapshot&&this.player.ads.snapshot.currentTime?1e3*this.player.ads.snapshot.currentTime:this.player.absoluteTime?1e3*this.player.absoluteTime():1e3*this.player.currentTime()}},{key:"getDuration",value:function(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}},{key:"getTitle",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.mediainfo)||void 0===t?void 0:t.name}},{key:"getId",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.mediainfo)||void 0===t?void 0:t.id}},{key:"getLanguage",value:function(){var t;return null===(t=this.player)||void 0===t?void 0:t.language()}},{key:"getSrc",value:function(){var t=this.getTech();return t&&t.getSrc?t.getSrc():this.player.currentSrc()}},{key:"getPlayerName",value:function(){var t;return(null===(t=this.player)||void 0===t?void 0:t.name())||"videojs"}},{key:"getPlayerVersion",value:function(){var t;return(null===(t=this.player)||void 0===t?void 0:t.version)||videojs.VERSION}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&null!==(t=t.playlists)&&void 0!==t&&t.media()){var i=e.vhs.playlists.media();return i.attributes["AVERAGE-BANDWIDTH"]||i.attributes.BANDWIDTH||null}var r=this.getTech();if(null!=r&&r.getBitrate)return r.getBitrate()}catch(t){}return null}},{key:"getRenditionName",value:function(){var t=this.getTech();if(t&&t.getRenditionName)return t.getRenditionName()}},{key:"getManifestBitrate",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0}),i=null==e||null===(t=e.vhs)||void 0===t||null===(t=t.playlists)||void 0===t||null===(t=t.master)||void 0===t?void 0:t.playlists;if(i&&i.length>0){var r=Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return p(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 p(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)?p(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.")}()}(i.map(function(t){return t.attributes.BANDWIDTH||0})));return r>0?r:null}var n=this.getTech();if(null!=n&&n.getManifestBitrate)return n.getManifestBitrate()}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&null!==(t=t.stats)&&void 0!==t&&t.bandwidth&&e.vhs.stats.bandwidth>0)return e.vhs.stats.bandwidth;var i=this.getTech();if(null!=i&&i.getSegmentDownloadBitrate)return i.getSegmentDownloadBitrate()}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&t.throughput&&e.vhs.throughput>0)return e.vhs.throughput;var i=this.getTech();return null!=i&&i.getNetworkDownloadBitrate?i.getNetworkDownloadBitrate():null}},{key:"getRenditionHeight",value:function(){var t=this.getTech();return t&&t.getRenditionHeight?t.getRenditionHeight():this.player.videoHeight()}},{key:"getRenditionWidth",value:function(){var t=this.getTech();return t&&t.getRenditionWidth?t.getRenditionWidth():this.player.videoWidth()}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"isAutoplayed",value:function(){return this.player.autoplay()}},{key:"isFullscreen",value:function(){return this.player.isFullscreen()}},{key:"getPreload",value:function(){return this.player.preload()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,["adstart","adend","adskip","adsready","adserror","dispose"]),this.onDownload=this.onDownload.bind(this),this.onAdsready=this.onAdsready.bind(this),this.onAdStart=this.onAdStart.bind(this),this.onAdEnd=this.onAdEnd.bind(this),this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onAbort=this.onAbort.bind(this),this.onEnded=this.onEnded.bind(this),this.onDispose=this.onDispose.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onError=this.onError.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onTimeupdate=this.onTimeupdate.bind(this),this.OnAdsAllpodsCompleted=this.OnAdsAllpodsCompleted.bind(this),this.onStreamManager=this.onStreamManager.bind(this),this.player.on("loadstart",this.onDownload),this.player.on("loadeddata",this.onDownload),this.player.on("loadedmetadata",this.onDownload),this.player.on("adsready",this.onAdsready),this.player.on("adstart",this.onAdStart),this.player.on("adend",this.onAdEnd),this.player.on("play",this.onPlay),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("abort",this.onAbort),this.player.on("ended",this.onEnded),this.player.on("dispose",this.onDispose),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("error",this.onError),this.player.on("waiting",this.onWaiting),this.player.on("timeupdate",this.onTimeupdate),this.player.on("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.on("stream-manager",this.onStreamManager)}},{key:"unregisterListeners",value:function(){this.player.off("loadstart",this.onDownload),this.player.off("loadeddata",this.onDownload),this.player.off("loadedmetadata",this.onDownload),this.player.off("adsready",this.onAdsready),this.player.off("adstart",this.onAdStart),this.player.off("adend",this.onAdEnd),this.player.off("play",this.onPlay),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("abort",this.onAbort),this.player.off("ended",this.onEnded),this.player.off("dispose",this.onDispose),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("error",this.onError),this.player.off("waiting",this.onWaiting),this.player.off("timeupdate",this.onTimeupdate),this.player.off("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.off("stream-manager",this.onStreamManager)}},{key:"onDownload",value:function(t){this.sendDownload({state:t.type})}},{key:"onStreamManager",value:function(t){if(!this.adsTracker&&t.StreamManager){var e=new f.default(this.player);e.setStreamManager(t.StreamManager),this.setAdsTracker(e)}}},{key:"onAdsready",value:function(){this.adsTracker||(c.default.isUsing(this.player)?this.setAdsTracker(new c.default(this.player)):d.default.isUsing(this.player)?this.setAdsTracker(new d.default(this.player)):h.default.isUsing(this.player)?this.setAdsTracker(new h.default(this.player)):this.setAdsTracker(new l.default(this.player)))}},{key:"onAdStart",value:function(){var t;this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=null===(t=this.player)||void 0===t||null===(t=t.ima)||void 0===t?void 0:t.getAdsManager().getCuePoints())}},{key:"onAdEnd",value:function(){this.isContentEnd&&this.sendEnd()}},{key:"OnAdsAllpodsCompleted",value:function(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}},{key:"onPlay",value:function(){this.sendRequest()}},{key:"onPause",value:function(){this.sendPause()}},{key:"onPlaying",value:function(){this.sendResume(),this.sendBufferEnd()}},{key:"onAbort",value:function(){this.sendEnd()}},{key:"onEnded",value:function(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}},{key:"onDispose",value:function(){this.sendEnd()}},{key:"onSeeking",value:function(){this.sendSeekStart()}},{key:"onSeeked",value:function(){this.sendSeekEnd()}},{key:"onError",value:function(){var t=this.player.error(),e=t.code,i=t.message;this.player.error&&this.player.error()&&this.sendError({errorCode:e,errorMessage:i})}},{key:"onWaiting",value:function(t){this.sendBufferStart()}},{key:"onTimeupdate",value:function(t){this.getPlayhead()>.1&&this.sendStart()}}],r&&m(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(n.default.VideoTracker)},330(t){t.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.1.1","description":"New relic tracker for Videojs","main":"dist/cjs/index.js","module":"dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch --mode development","prezip":"npm run build","zip":"zip -P newrelic -x \'*.DS_Store\' -x \'samples/agent.js\' -r videojs.zip dist samples README.md CHANGELOG.md EULA.md","clean":"rm -rf dist *.zip","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-videojs-js.git"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop","Bharat Saraswat","Malay Chandan"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@newrelic/newrelic-oss-cli":"^0.1.2","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","videojs-ima":"2.1.0","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","CHANGELOG.md","README.md","src","!test"],"publishConfig":{"access":"public"},"dependencies":{"@newrelic/video-core":"^4.0.0"}}')}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,i),a.exports}i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{var t=r;t.default=void 0;var e,n=(e=i(302))&&e.__esModule?e:{default:e};t.default=n.default})(),r.default})());
|
|
3
3
|
//# sourceMappingURL=newrelic-video-videojs.min.js.map
|