@newrelic/video-videojs 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- (()=>{"use strict";var e={38:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,r=(s=i(472))&&s.__esModule?s:{default:s};class a extends r.default{static isUsing(e){return!!e.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}getTrackerName(){return"freewheel-ads"}getPlayerName(){return"freewheel-ads"}getPlayerVersion(){return this.player.FreeWheelPlugin.VERSION}getPlayhead(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}getDuration(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}getVideoId(){return this.player.ads.ad.id}getAdPartner(){return"freewheel"}getAdCreativeId(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(e){}}getSrc(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(e){}}getTitle(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(e){}}getAdPosition(){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}}}t.default=a},64:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(i(555)),r=a(i(472));function a(e){return e&&e.__esModule?e:{default:e}}class n extends r.default{static isUsing(e){return!!e.ima3}getTrackerName(){return"brightcove-ima-ads"}getPlayerName(){return"brightcove-ima-ads"}getPlayhead(){return this.player?.ima3?.adPlayer?.currentTime()}registerListeners(){s.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))}unregisterListeners(){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)}onStarted(e){this.sendRequest(),this.sendStart()}onPaused(e){this.sendPause()}onResume(e){this.sendResume()}onComplete(e){this.sendEnd()}onSkipped(e){this.sendEnd({skipped:!0})}onError(e){this.sendError()}onClick(e){this.sendClick()}}t.default=n},257:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.vhs_}getResource(e){return this.tech.url}getRenditionName(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.name)return t.name}catch(e){}return null}getRenditionBitrate(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return t.bitrate}catch(e){}return null}getRenditionWidth(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.width)return t.width}catch(e){}return null}getRenditionHeight(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.height)return t.height}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.vhs_}},298:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(i(555)),r=a(i(472));function a(e){return e&&e.__esModule?e:{default:e}}class n extends r.default{static isUsing(e){return e.ima&&"undefined"!=typeof google}getTrackerName(){return"ima-ads"}getPlayerName(){return"ima"}getPlayerVersion(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}getCuePoints(){return this.player.ima.getAdsManager().getCuePoints()}getAdPosition(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){const e=this.lastAdData.podInfo.podIndex;return 0===e?"pre":-1===e?"post":"mid"}return null}getDuration(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}getVideoId(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}getAdCreativeId(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}getSrc(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}getTitle(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}getPlayhead(){let e=this.player.ima.getAdsManager();if(e)return 1e3*(this.getDuration()-e.getRemainingTime())}getPlayrate(){return this.player.playbackRate()}getAdPartner(){return"ima"}getWebkitBitrate(){const e=this.getAdVideoElement();if(e&&e.webkitVideoDecodedByteCount){let t;if(this._lastAdWebkitBitrate>0){const i=e.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,s=this.getHeartbeat()/1e3;t=Math.round(i/s*8)}return this._lastAdWebkitBitrate=e.webkitVideoDecodedByteCount,t??null}return null}getRenditionBitrate(){if(this.lastAdData)return this.lastAdData.renditionBitrate}registerListeners(){let e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,s.default.Log.debugCommonVideoEvents(this.player.ima.addEventListener,[null,e.ALL_ADS_COMPLETED,e.LINEAR_CHANGED,e.COMPLETE,e.USER_CLOSE,e.IMPRESSION,e.CONTENT_PAUSE_REQUESTED,e.CONTENT_RESUME_REQUESTED,e.SKIPPED,e.SKIPPABLE_STATE_CHANGED,e.LOADED,e.PAUSED,e.RESUMED,e.STARTED,e.AD_CAN_PLAY,e.AD_METADATA,e.EXPANDED_CHANGED,e.AD_BREAK_READY,e.LOG,e.CLICK,e.FIRST_QUARTILE,e.MIDPOINT,e.THIRD_QUARTILE,t]),this.player.ima.addEventListener(e.LOADED,this.onLoaded.bind(this)),this.player.ima.addEventListener(e.STARTED,this.onStart.bind(this)),this.player.ima.addEventListener(e.PAUSED,this.onPaused.bind(this)),this.player.ima.addEventListener(e.RESUMED,this.onResumed.bind(this)),this.player.ima.addEventListener(e.COMPLETE,this.onComplete.bind(this)),this.player.ima.addEventListener(e.SKIPPED,this.onSkipped.bind(this)),this.player.ima.addEventListener(e.CLICK,this.onClick.bind(this)),this.player.ima.addEventListener(e.FIRST_QUARTILE,this.onFirstQuartile.bind(this)),this.player.ima.addEventListener(e.MIDPOINT,this.onMidpoint.bind(this)),this.player.ima.addEventListener(e.THIRD_QUARTILE,this.onThirdQuartile.bind(this)),this.player.ima.addEventListener(t,this.onError.bind(this))}unregisterListeners(){let e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.player.ima.removeEventListener(e.LOADED,this.onLoaded),this.player.ima.removeEventListener(e.STARTED,this.onLoaded.bind(this)),this.player.ima.removeEventListener(e.IMPRESSION,this.onImpression),this.player.ima.removeEventListener(e.PAUSED,this.onPaused),this.player.ima.removeEventListener(e.RESUMED,this.onResumed),this.player.ima.removeEventListener(e.COMPLETE,this.onComplete),this.player.ima.removeEventListener(e.SKIPPED,this.onSkipped),this.player.ima.removeEventListener(e.CLICK,this.onClick),this.player.ima.removeEventListener(e.FIRST_QUARTILE,this.onFirstQuartile),this.player.ima.removeEventListener(e.MIDPOINT,this.onMidpoint),this.player.ima.removeEventListener(e.THIRD_QUARTILE,this.onThirdQuartile),this.player.ima.removeEventListener(t,this.onError),this.lastAdData=null}onLoaded(e){this.lastAdData=this.getAdData(),this.sendRequest()}onStart(e){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}onComplete(e){this.sendEnd(),this.lastAdData=null}onSkipped(e){this.sendEnd({skipped:!0}),this.lastAdData=null}onError(e){const t=e.getError(),i=t.getErrorCode(),s=t.getMessage();this.sendError({adError:t,errorCode:i,errorMessage:s})}onClick(e){this.sendAdClick()}onFirstQuartile(){this.sendAdQuartile({adQuartile:1})}onMidpoint(){this.sendAdQuartile({adQuartile:2})}onThirdQuartile(){this.sendAdQuartile({adQuartile:3})}onPaused(){this.sendPause()}onResumed(){this.sendResume()}getAdData(){try{const e=this.player.ima.getAdsManager();if(e){const t=e.getCurrentAd();if(t)return{adId:t.getAdId(),creativeId:t.getCreativeId(),duration:t.getDuration(),mediaUrl:t.getMediaUrl(),title:t.getTitle(),podInfo:t.getAdPodInfo()?.data,renditionBitrate:t.getVastMediaBitrate()}}return null}catch(e){return null}}getAdVideoElement(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){const e=this.player.ima.controller.adUi.adContainerDiv;if(e){const t=e.querySelector("video");if(t)return t}}}}t.default=n},302:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(t,"ContribHlsTech",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"FreewheelAdsTracker",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"HlsJsTech",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"ImaAdsTracker",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"ShakaTech",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(t,"VideojsAdsTracker",{enumerable:!0,get:function(){return o.default}}),t.default=void 0;var s=f(i(555)),r=f(i(330)),a=f(i(409)),n=f(i(257)),d=f(i(338)),o=f(i(472)),l=f(i(298)),h=f(i(64)),u=f(i(38)),c=f(i(717));function f(e){return e&&e.__esModule?e:{default:e}}class g extends s.default.VideoTracker{constructor(e,t){super(e,t),this.isContentEnd=!1,this.imaAdCuePoints="",this.daiInitialized=!1,s.default.Core.addTracker(this,t)}getTech(){let e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(a.default.isUsing(e))return new a.default(e);if(n.default.isUsing(e))return new n.default(e);if(d.default.isUsing(e))return new d.default(e)}}getTrackerName(){return"videojs"}getInstrumentationProvider(){return"New Relic"}getInstrumentationName(){return this.getPlayerName()}getInstrumentationVersion(){return this.getPlayerVersion()}getTrackerVersion(){return r.default.version}getPlayhead(){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()}getDuration(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}getTitle(){return this.player?.mediainfo?.name}getId(){return this.player?.mediainfo?.id}getLanguage(){return this.player?.language()}getSrc(){let e=this.getTech();return e&&e.getSrc?e.getSrc():this.player.currentSrc()}getPlayerName(){return this.player?.name()||"videojs"}getPlayerVersion(){return this.player?.version||videojs.VERSION}isMuted(){return this.player.muted()}getBitrate(){let e=0,t=0,i=0;if(this.player){const s=this.player.tech({IWillNotUseThisInPlugins:!0});if(s){let r,a;if(s.vhs&&s.vhs.playlists&&s.vhs.playlists.media?(r=s.vhs.playlists,a=s.vhs.playlists.media()):s.hls&&s.hls.playlists&&s.hls.playlists.media&&(r=s.hls.playlists,a=s.hls.playlists.media()),a&&a.attributes){a.attributes.BANDWIDTH&&(e=a.attributes.BANDWIDTH);const s=this.player.audioTracks();let n;if(s&&s.length>0)for(let e=0;e<s.length;e++)if(s[e].enabled){n=s[e];break}if(n&&a.attributes.AUDIO){let e;if(r&&(e=r.master||r.main),e&&e.mediaGroups&&e.mediaGroups.AUDIO){const i=e.mediaGroups.AUDIO[a.attributes.AUDIO],s=i&&i[n.id];if(s&&s.playlists&&s.playlists[0]){const e=s.playlists[0].attributes;e&&e.BANDWIDTH&&(t=e.BANDWIDTH)}}}return i=e+t,i}const n=s.shakaPlayer_||s.shaka_||s.shakaPlayer;if(n&&"function"==typeof n.getStats){const e=n.getStats();if(e&&e.streamBandwidth)return e.streamBandwidth}const d=s.hls_;if(d&&d.levels&&d.currentLevel>=0){const e=d.levels[d.currentLevel];if(e&&e.bitrate)return e.bitrate}}let r;if(this.player.mediaPlayer?r=this.player.mediaPlayer:this.player.dash&&this.player.dash.mediaPlayer&&(r=this.player.dash.mediaPlayer),r&&"function"==typeof r.getQualityFor&&"function"==typeof r.getBitrateInfoListFor){const s=r.getQualityFor("audio"),a=r.getBitrateInfoListFor("audio");void 0!==s&&a&&a[s]&&a[s].bitrate&&(t=a[s].bitrate);const n=r.getQualityFor("video"),d=r.getBitrateInfoListFor("video");return e=void 0!==n&&d&&d[n]&&d[n].bitrate?d[n].bitrate:e||0,i=t+e,i}}const s=this.getTech();if(s){if(s.getBitrate&&"function"==typeof s.getBitrate)return s.getBitrate();if(s.tech&&s.tech.stats&&s.tech.stats.bandwidth)return s.tech.stats.bandwidth}return null}getRenditionName(){let e=this.getTech();if(e&&e.getRenditionName)return e.getRenditionName()}getRenditionBitrate(){let e=this.getTech();if(e&&e.getRenditionBitrate)return e.getRenditionBitrate()}getRenditionHeight(){let e=this.getTech();return e&&e.getRenditionHeight?e.getRenditionHeight():this.player.videoHeight()}getRenditionWidth(){let e=this.getTech();return e&&e.getRenditionWidth?e.getRenditionWidth():this.player.videoWidth()}getPlayrate(){return this.player.playbackRate()}isAutoplayed(){return this.player.autoplay()}isFullscreen(){return this.player.isFullscreen()}getPreload(){return this.player.preload()}registerListeners(){s.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)}unregisterListeners(){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)}onDownload(e){this.sendDownload({state:e.type})}onStreamManager(e){if(!this.adsTracker&&e.StreamManager){const t=new c.default(this.player);t.setStreamManager(e.StreamManager),this.setAdsTracker(t)}}onAdsready(){this.adsTracker||(h.default.isUsing(this.player)?this.setAdsTracker(new h.default(this.player)):l.default.isUsing(this.player)?this.setAdsTracker(new l.default(this.player)):u.default.isUsing(this.player)?this.setAdsTracker(new u.default(this.player)):this.setAdsTracker(new o.default(this.player)))}onAdStart(){this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=this.player?.ima?.getAdsManager().getCuePoints())}onAdEnd(){this.isContentEnd&&this.sendEnd()}OnAdsAllpodsCompleted(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}onPlay(){this.sendRequest()}onPause(){this.sendPause()}onPlaying(){this.sendResume(),this.sendBufferEnd()}onAbort(){this.sendEnd()}onEnded(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}onDispose(){this.sendEnd()}onSeeking(){this.sendSeekStart()}onSeeked(){this.sendSeekEnd()}onError(){const e=this.player.error(),t=e.code,i=e.message;this.player.error&&this.player.error()&&this.sendError({errorCode:t,errorMessage:i})}onWaiting(e){this.sendBufferStart()}onTimeupdate(e){this.getPlayhead()>.1&&this.sendStart()}}t.default=g},330:e=>{e.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.0.2","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","aws-sdk":"^2.920.0","@newrelic/newrelic-oss-cli":"^0.1.2","babel-loader":"^9.1.3","videojs-ima":"2.1.0","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"dependencies":{"@newrelic/video-core":"^4.0.0"},"files":["THIRD_PARTY_NOTICES.md","dist","CHANGELOG.md","README.md","src","!test"],"publishConfig":{"access":"public"}}')},338:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.shakaPlayer}getSrc(e){try{return this.tech.getManifestUri()}catch(e){}return null}getRenditionBitrate(e){try{return this.tech.getStats().streamBandwidth}catch(e){}return null}getRenditionWidth(e){try{var t=this.tech.getVariantTracks();for(var i in t){var s=t[i];if(s.active&&"video"===s.type)return s.width}}catch(e){}return null}getRenditionHeight(e){try{var t=this.tech.getVariantTracks();for(var i in t){var s=t[i];if(s.active&&"video"===s.type)return s.height}}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.shakaPlayer}},409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.vhs}getRenditionName(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return e.attributes.NAME}catch(e){}return null}getRenditionBitrate(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return e.attributes.BANDWIDTH}catch(e){}return null}getRenditionWidth(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.width}catch(e){}return null}getRenditionHeight(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.height}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.vhs}},472:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(555)),r=o(i(330)),a=o(i(409)),n=o(i(257)),d=o(i(338));function o(e){return e&&e.__esModule?e:{default:e}}class l extends s.default.VideoTracker{getTech(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(a.default.isUsing(e))return new a.default(e);if(n.default.isUsing(e))return new n.default(e);if(d.default.isUsing(e))return new d.default(e)}}getTrackerName(){return"videojs-ads"}getTrackerVersion(){return r.default.version}isMuted(){return this.player.muted()}getRenditionHeight(){return null}getRenditionWidth(){return null}getPlayerName(){return"videojs-ads"}getPlayerVersion(){return this.player.ads.VERSION}registerListeners(){s.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))}unregisterListeners(){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)}onAdrequest(e){this.sendRequest(),this.sendDownload({state:"ads-request"})}onAdload(e){this.sendDownload({state:"ads-load"})}onAdstart(e){this.sendRequest(),this.sendStart()}onAdend(e){this.sendEnd()}onAdskip(e){this.sendEnd({skipped:!0})}onAdserror(e){this.sendError()}onAdsClick(e){this.sendAdClick({url:"unknown"})}onPodStart(e){this.sendAdBreakStart()}onPodEnd(e){this.sendAdBreakEnd()}onFirstQuartile(){this.sendAdQuartile({quartile:1})}onMidpoint(){this.sendAdQuartile({quartile:2})}onThirdQuartile(){this.sendAdQuartile({quartile:3})}onAdspause(){this.sendPause()}onAdsplay(){this.sendResume()}}t.default=l},555:(e,t,i)=>{i.r(t),i.d(t,{__esModule:()=>d,default:()=>o});var s={28:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.OptimizedHttpClient=void 0;var s,r=i(347),a=(s=i(144))&&s.__esModule?s:{default:s};class n{async send(e,t){const{url:i,payload:s,options:r={}}=e;try{if(!i||!s)throw new Error("URL and payload are required");const e={url:i,payload:s,options:r,callback:t};await this.executeRequest(e)}catch(e){a.default.error("Failed to send request:",e.message),t({retry:!1,status:0,error:e.message})}}async executeRequest(e){const{url:t,payload:i,options:s,callback:r}=e,a=Date.now();try{const r=JSON.stringify(i.body);if(s.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(t,r),s={success:i,status:i?204:0};return void this.handleRequestComplete(e,s,a)}const n=await this.fetchWithTimeout(t,{method:"POST",body:r,headers:{"Content-Type":"application/json"},keepalive:s.isFinalHarvest},1e4),d={success:n.ok,status:n.status,statusText:n.statusText};this.handleRequestComplete(e,d,a)}catch(t){const i={success:!1,status:0,error:t.message};this.handleRequestComplete(e,i,a)}}handleRequestComplete(e,t){const{callback:i}=e;i({retry:!t.success&&(0===t.status||(0,r.shouldRetry)(t.status)),status:t.status,error:t.error})}async sendWithBeacon(e,t){try{return navigator.sendBeacon(e,t)}catch(e){return a.default.warn("sendBeacon failed, falling back to fetch:",e.message),!1}}async fetchWithTimeout(e,t,i){const s=new AbortController,r=setTimeout((()=>s.abort()),i);try{const i=await fetch(e,{...t,signal:s.signal});return clearTimeout(r),i}catch(e){if(clearTimeout(r),"AbortError"===e.name)throw new Error(`Request timeout after ${i}ms`);throw e}}}t.OptimizedHttpClient=n,t.default=n},51:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{}i.AdPositions={PRE:"pre",MID:"mid",POST:"post"},i.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"},i.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],i.MAX_PAYLOAD_SIZE=1048576,i.MAX_BEACON_SIZE=61440,i.MAX_EVENTS_PER_BATCH=1e3,i.INTERVAL=1e4,t.default=i},144:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{static error(...e){s(e,i.Levels.ERROR,"darkred")}static warn(...e){s(e,i.Levels.WARNING,"darkorange")}static notice(...e){s([].slice.call(arguments),i.Levels.NOTICE,"darkcyan")}static debug(...e){s(e,i.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(e,t,s){try{if(i.level<=i.Levels.DEBUG){s=s||function(e){i.debug("Event: "+e.type)};var r=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];t&&(null===t[0]?(t.shift(),r=t):r=r.concat(t));for(var a=0;a<r.length;a++)"function"==typeof e?e.call(window,r[a],s):e.on?e.on(r[a],s):e.addEventListener?e.addEventListener(r[a],s):e.addEventHandler?e.addEventHandler(r[a],s):i.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){i.warn(e)}}}function s(e,t,s){t=t||i.Levels.NOTICE,s=s||"darkcyan";var n,d,o=i.prefix;i.includeTime&&(o+="["+("0"+(n=new Date).getDate()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+"] "),o+=function(e){return a[e]}(t)+":",i.level<=t&&t!==i.Levels.SILENT&&(!i.colorful||"undefined"!=typeof document&&document.documentMode?r(e,o):(d=t===i.Levels.ERROR&&console.error?console.error:t===i.Levels.WARNING&&console.warn?console.warn:t===i.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,o="%c"+o,e.splice(0,0,o,"color: "+s),d.apply(console,e)))}function r(e,t){if(e instanceof Array)for(var i in e)r(e[i],t);else"string"==typeof e?console.log(t+" "+e):(console.log(t+"↵"),console.log(e))}i.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},i.level=i.Levels.ERROR,i.colorful=!0,i.includeTime=!0,i.prefix="[nrvideo]";const a={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var e=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==e&&("true"===e[1]?i.level=i.Levels.ALL:i.level=e[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(i.colorful=!1)}}(),t.default=i},302:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=l(i(330)),r=l(i(568)),a=l(i(455)),n=l(i(51)),d=i(487),o=l(i(144));function l(e){return e&&e.__esModule?e:{default:e}}class h extends r.default{constructor(e){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new a.default,this._trackerReadyChrono.start(),this._actionTable=n.default.ACTION_TABLE,this._actionAdTable=n.default.ACTION_AD_TABLE,e=e||{},this.setOptions(e)}setOptions(e){e&&(e.parentTracker&&(this.parentTracker=e.parentTracker),e.customData&&(this.customData=e.customData),e.heartbeat&&(this.heartbeat=e.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(e){this.sendVideoAction(h.Events.HEARTBEAT,e)}getAttributes(e,t){(e=e||{}).trackerName=this.getTrackerName(),e.trackerVersion=this.getTrackerVersion(),e.coreVersion=s.default.version,e.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let t in this.customData)e[t]=this.customData[t];return null!=document.hidden&&(e.isBackgroundEvent=document.hidden),e}getTrackerVersion(){return s.default.version}getTrackerName(){return"base-tracker"}sendVideoAction(e,t){this.emit("VideoAction",e,this.getAttributes(t))}sendVideoAdAction(e,t){this.emit("VideoAdAction",e,this.getAttributes(t))}sendVideoErrorAction(e,t){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",e,this.getAttributes(t,i))}sendVideoCustomAction(e,t){this.emit("VideoCustomAction",e,this.getAttributes(t,"customAction"))}setHarvestInterval(e){if(d.videoAnalyticsHarvester)try{d.videoAnalyticsHarvester.setHarvestInterval(e)}catch(e){return void o.default.error("Failed to set harvest interval:",e.message)}else o.default.error("VideoAnalyticsHarvester is not available")}}h.Events={HEARTBEAT:"HEARTBEAT"},t.default=h},328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(i(455)),r=a(i(144));function a(e){return e&&e.__esModule?e:{default:e}}t.default=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.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,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 s.default,this.timeSinceStarted=new s.default,this.timeSincePaused=new s.default,this.timeSinceSeekBegin=new s.default,this.timeSinceBufferBegin=new s.default,this.timeSinceAdBreakStart=new s.default,this.timeSinceLastDownload=new s.default,this.timeSinceLastHeartbeat=new s.default,this.timeSinceLastRenditionChange=new s.default,this.timeSinceLastAdQuartile=new s.default,this.timeSinceLastAd=new s.default,this.timeSinceLastError=new s.default,this.timeSinceLastAdError=new s.default,this.timeSinceResumed=new s.default,this.timeSinceSeekEnd=new s.default,this.playtimeSinceLastEvent=new s.default,this.customTimeSinceAttributes={},this.elapsedTime=new s.default,this.bufferElapsedTime=new s.default}isAd(){return this._isAd}setIsAd(e){this._isAd=e}setTimeSinceAttribute(e){this.customTimeSinceAttributes[e]=new s.default,this.customTimeSinceAttributes[e].start()}removeTimeSinceAttribute(e){delete this.customTimeSinceAttributes[e]}getViewSession(){if(!this._viewSession){let e=(new Date).getTime(),t=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=e+"-"+t}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(e){e=e||{},this.isAd()?(this.isRequested&&(e.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(e.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),this.numberOfErrors>0&&this.timeSinceLastAdError.startTime>0&&(e.timeSinceLastAdError=this.timeSinceLastAdError.getDeltaTime()),e.numberOfAds=this.numberOfAds):(this.isRequested&&(e.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),e.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),this.numberOfErrors>0&&this.timeSinceLastError.startTime>0&&(e.timeSinceLastError=this.timeSinceLastError.getDeltaTime()),e.numberOfVideos=this.numberOfVideos),e.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?e.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():e.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=e.playtimeSinceLastEvent,e.totalPlaytime=this.totalPlaytime);for(const[t,i]of Object.entries(this.customTimeSinceAttributes))e[t]=i.getDeltaTime();return e}calculateBufferType(e){let t="";return t=e?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",r.default.debug("Buffer Type = "+t),t}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(),!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(),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()}goLastAd(){this.timeSinceLastAd.start()}}},330:e=>{e.exports=JSON.parse('{"name":"@newrelic/video-core","version":"4.0.1","description":"New Relic video tracking core library","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","clean":"rm -rf dist coverage doc","test":"nyc --reporter=html --reporter=text mocha --require @babel/register","doc":"jsdoc -c jsdoc.json -d documentation","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-core-js"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop","Malay Chandan","Bharat Sarsawat"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@newrelic/newrelic-oss-cli":"^0.1.2","@babel/preset-env":"^7.24.5","@babel/register":"^7.24.6","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","chai":"^4.3.4","diff":"^5.0.0","jsdom":"^25.0.1","mocha":"^10.4.0","nyc":"^15.1.0","sinon":"^2.4.1","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","src","CHANGELOG.md","LICENSE","README.md","src","!test"],"publishConfig":{"access":"public"}}')},347:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildUrl=function(e){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:t,licenseKey:i,applicationID:r}=window.NRVIDEO.info;if(!t||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return r?`https://${e||t}/ins/1/${i}?a=${r}&v=${s.default.version}&ref=${window.location.href}&ca=VA`:`https://${e||t}/ins/1/${i}?&v=${s.default.version}&ref=${window.location.href}&ca=VA`}catch(e){return console.error(e.message),null}},t.compressPayload=function(e){const t=JSON.stringify(e),i=new Blob([t]).stream(),s=new CompressionStream("gzip"),r=i.pipeThrough(s);return new Response(r).blob()},t.dataSize=function(e){if("string"==typeof e&&e.length)return e.length;if("object"==typeof e){if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer&&e.byteLength)return e.byteLength;if("undefined"!=typeof Blob&&e instanceof Blob&&e.size)return e.size;if(!("undefined"!=typeof FormData&&e instanceof FormData))try{return function(e){try{return JSON.stringify(e,n())??""}catch(e){return r.default.error("Error stringifying value:",e.message),""}}(e).length}catch(e){return}}},t.decompressPayload=async function(e){try{let t;if(e instanceof Blob)t=e.stream();else if(e instanceof ArrayBuffer)t=new Blob([e]).stream();else{if(!(e instanceof Uint8Array))throw new Error("Unsupported compressed data type");t=new Blob([e]).stream()}const i=new DecompressionStream("gzip"),s=t.pipeThrough(i),r=new Response(s),a=await r.text();return JSON.parse(a)}catch(e){throw new Error(`Failed to decompress payload: ${e.message}`)}},t.shouldRetry=function(e){switch(e){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return e>=502&&e<=504||e>=512&&e<=530};var s=a(i(330)),r=a(i(144));function a(e){return e&&e.__esModule?e:{default:e}}const n=()=>{const e=new WeakSet;return(t,i)=>{if("object"==typeof i&&null!==i){if(e.has(i))return;e.add(i)}return i}}},374:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HarvestScheduler=void 0;var s=i(431),r=i(413),a=i(28),n=i(347),d=l(i(51)),o=l(i(144));function l(e){return e&&e.__esModule?e:{default:e}}t.HarvestScheduler=class{constructor(e){this.eventBuffer=e,this.retryQueueHandler=new r.RetryQueueHandler,this.httpClient=new a.OptimizedHttpClient,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof s.NrVideoEventAggregator&&this.eventBuffer.setSmartHarvestCallback(((e,t)=>this.triggerSmartHarvest(e,t))),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=d.default.INTERVAL,this.isHarvesting=!1,this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?o.default.warn("Harvest scheduler is already started"):(this.isStarted=!0,o.default.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),o.default.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(e,t){if(o.default.notice(`${e} harvest triggered at ${t}% threshold`,{type:e,threshold:t}),this.eventBuffer&&!this.eventBuffer.isEmpty()){this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null);try{await this.triggerHarvest({})}catch(t){o.default.error(`${e} harvest failed:`,t.message)}finally{this.isStarted&&this.scheduleNextHarvest()}}}scheduleNextHarvest(){if(!this.isStarted)return;const e=this.harvestCycle;this.currentTimerId=setTimeout((()=>this.onHarvestInterval()),e)}async onHarvestInterval(){try{const e=this.eventBuffer&&!this.eventBuffer.isEmpty(),t=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0;if(!e&&!t)return;await this.triggerHarvest({})}catch(e){o.default.error("Error during scheduled harvest:",e.message)}finally{this.scheduleNextHarvest()}}async triggerHarvest(e={}){if(this.isHarvesting)return{success:!1,reason:"harvest_in_progress"};this.isHarvesting=!0;try{let t=this.drainEvents(e);if(e.isFinalHarvest){const e=d.default.MAX_BEACON_SIZE;(0,n.dataSize)(t)>e&&(t=this.trimEventsToFit(t,e))}const i=await this.sendChunk(t,e,!0);return{success:i.success,totalChunks:1,results:[i]}}catch(e){return o.default.error("Harvest cycle failed:",e.message),this.handleHarvestFailure(e),{success:!1,error:e.message,consecutiveFailures:this.consecutiveFailures}}finally{this.isHarvesting=!1}}trimEventsToFit(e,t){if(0===e.length)return e;const i=[];let s=0;for(let r=e.length-1;r>=0;r--){const a=e[r],d=(0,n.dataSize)({ins:[a,...i]});d>t||(i.unshift(a),s=d)}const r=e.length-i.length;if(r>0){const a=e.slice(0,r);o.default.warn(`Discarded ${r} events to fit beacon size limit`,{originalCount:e.length,trimmedCount:i.length,finalSize:s,maxSize:t}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(a)}return i}drainEvents(){const e=this.eventBuffer.drain();let t=[...e],i=(0,n.dataSize)(e);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const e=d.default.MAX_PAYLOAD_SIZE-i,s=d.default.MAX_EVENTS_PER_BATCH-t.length;if(e>0&&s>0){const i=this.retryQueueHandler.getRetryEventsToFit(e,s);i.length>0&&(t=[...i,...t])}}return t}async sendChunk(e,t,i){const s={url:(0,n.buildUrl)(this.fallBackUrl),payload:{body:{ins:e}},options:{...t,isLastChunk:i}};return new Promise((t=>{this.httpClient.send(s,(i=>{i.retry?this.handleRequestFailure(e):(this.retryCount=0,this.fallBackUrl=""),t({success:!i.retry,status:i.status,error:i.error,chunk:e,eventCount:e.length})}))}))}handleRequestFailure(e){this.retryQueueHandler.addFailedEvents(e),"US"===window.NRVIDEO?.info?.region&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=d.default.COLLECTOR.US[1]))}handleHarvestFailure(e){this.consecutiveFailures++,o.default.warn("Harvest failure handled",{error:e.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(e){"number"!=typeof e&&isNaN(e)?o.default.warn("Invalid newInterval provided to updateHarvestInterval"):e<1e3||e>3e5?o.default.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==e&&(this.harvestCycle=e,o.default.notice("Updated harvestCycle:",this.harvestCycle),this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),this.isStarted&&this.scheduleNextHarvest())}setupPageLifecycleHandlers(){let e=!1;const t=()=>{e||(e=!0,this.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",(()=>{document.hidden&&t()})),window.addEventListener("pagehide",(()=>{t()})),window.addEventListener("beforeunload",(()=>{t()}))}}},399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,r=(s=i(144))&&s.__esModule?s:{default:s},a=i(449),n=i(659);class d{static addTracker(e,t){t?.info&&(0,n.setVideoConfig)(t.info),e.on&&e.emit?(o.push(e),e.on("*",l),"function"==typeof e.trackerInit&&e.trackerInit()):r.default.error("Tried to load a non-tracker.",e)}static removeTracker(e){e.off("*",l),e.dispose();let t=o.indexOf(e);-1!==t&&o.splice(t,1)}static getTrackers(){return o}static send(e,t,i){const s={actionName:t,...i};return(0,a.recordEvent)(e,s)}static sendError(e){return(0,a.recordEvent)("VideoErrorAction",{actionName:"ERROR",...e})}static async forceHarvest(){try{const{videoAnalyticsHarvester:e}=i(487);return await e.forceHarvest()}catch(e){return r.default.error("Failed to force harvest:",e.message),{success:!1,error:e.message}}}}let o=[];function l(e){try{let t=function(e){let t={};for(let i in e)null!==e[i]&&void 0!==e[i]&&(t[i]=e[i]);return t}(e.data);r.default.level<=r.default.Levels.DEBUG?r.default.notice("Sent",e.type,t):r.default.notice("Sent",e.type),d.send(e.eventType,e.type,t)}catch(e){r.default.error("Error in event handler:",e.message)}}t.default=d},413:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.RetryQueueHandler=void 0;var s=n(i(144)),r=i(347),a=n(i(51));function n(e){return e&&e.__esModule?e:{default:e}}const{MAX_PAYLOAD_SIZE:d,MAX_EVENTS_PER_BATCH:o}=a.default;class l{constructor(){this.retryQueue=[],this.maxQueueSize=o,this.maxQueueSizeBytes=d}addFailedEvents(e){try{const t=Array.isArray(e)?e:[e];s.default.notice(`Adding ${t.length} failed events to retry queue`,{queueSizeBefore:this.retryQueue.length});for(const e of t){this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();const t=(0,r.dataSize)(e);for(;(0,r.dataSize)(this.retryQueue)+t>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...e})}}catch(e){s.default.error("Failed to add events to retry queue:",e.message)}}discardEvent(e,t){s.default.warn("Discarded event",{reason:t,eventType:e.eventType})}evictOldestEvent(){if(this.retryQueue.length>0){const e=this.retryQueue.shift();this.discardEvent(e,"Queue full - evicted oldest")}}getRetryEventsToFit(e,t){const i=[];let s=0,a=0;for(let n=this.retryQueue.length-1;n>=0;n--){const d=this.retryQueue[n];if(a>=t)break;const o=(0,r.dataSize)(d);if(s+o>e)break;i.unshift(d),s+=o,a++,this.retryQueue.splice(n,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}t.RetryQueueHandler=l,t.default=l},431:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.NrVideoEventAggregator=void 0;var s=n(i(144)),r=n(i(51)),a=i(347);function n(e){return e&&e.__esModule?e:{default:e}}const{MAX_PAYLOAD_SIZE:d,MAX_EVENTS_PER_BATCH:o}=r.default;class l{constructor(){this.buffer=[],this.maxPayloadSize=d,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}add(e){try{const t=(0,a.dataSize)(e),i=this.currentPayloadSize+t>=this.maxPayloadSize,s=this.totalEvents+1>=this.maxEventsPerBatch;return(i||s)&&this.makeRoom(t),this.buffer.push(e),this.totalEvents++,this.currentPayloadSize+=t,this.checkSmartHarvestTrigger(),!0}catch(e){return s.default.error("Failed to add event to buffer:",e.message),!1}}checkSmartHarvestTrigger(){const e=this.currentPayloadSize/this.maxPayloadSize,t=this.totalEvents/this.maxEventsPerBatch,i=this.currentPayloadSize>=this.overflowPayloadThreshold,r=this.totalEvents>=this.overflowEventThreshold;if(i||r){const r=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*e)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*t)}%)`;s.default.warn(`OVERFLOW PREVENTION: ${r} - Emergency harvest triggered`),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{const e=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,t=this.totalEvents>=this.smartHarvestEventThreshold;(e||t)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}setSmartHarvestCallback(e){this.onSmartHarvestTrigger=e}drain(){try{const e=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,e}catch(e){return s.default.error("Failed to drain events from buffer:",e.message),[]}}isEmpty(){return 0===this.totalEvents}size(){return this.totalEvents}clear(){this.buffer=[],this.totalEvents=0}makeRoom(e){if(e>this.maxPayloadSize)s.default.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+e>=this.maxPayloadSize)&&this.buffer.length>0;){const e=this.buffer.shift(),t=(0,a.dataSize)(e);this.totalEvents--,this.currentPayloadSize-=t,s.default.warn("Event buffer full, oldest event removed.")}}}t.NrVideoEventAggregator=l,t.default=l},449:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recordEvent=function(e,t={}){try{if(!r.default.VALID_EVENT_TYPES.includes(e))return a.default.warn("Invalid event type provided to recordEvent",{eventType:e}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:n}=window.NRVIDEO.info,d={...t,eventType:e,...n?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null};return s.videoAnalyticsHarvester.addEvent(d)}catch(e){return a.default.error("Failed to record event:",e.message),!1}};var s=i(487),r=n(i(51)),a=n(i(144));function n(e){return e&&e.__esModule?e:{default:e}}},455:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=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.getDeltaTime()}clone(){var e=new i;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e}}t.default=i},487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.videoAnalyticsHarvester=void 0;var s,r=i(374),a=i(431),n=(s=i(144))&&s.__esModule?s:{default:s};const d=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)n.default.warn("Video analytics agent already initialized");else try{this.eventBuffer=new a.NrVideoEventAggregator,this.harvestScheduler=new r.HarvestScheduler(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,n.default.notice("Video analytics agent initialized successfully")}catch(e){n.default.error("Failed to initialize video analytics agent:",e.message)}}addEvent(e){this.isInitialized||(n.default.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return this.eventBuffer.add(e)}catch(e){return n.default.error("Failed to add event to harvesting system:",e.message),!1}}setHarvestInterval(e){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(e)}};t.videoAnalyticsHarvester=d},568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=class{on(e,t){if(this._listeners=this._listeners||{},"function"==typeof t)return this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t),this}off(e,t){if(this._listeners=this._listeners||{},this._listeners[e]){var i=this._listeners[e].indexOf(t);-1!==i&&this._listeners[e].splice(i,1)}return this}emit(e,t,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[t])&&this._listeners[t].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),this}}},659:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.setVideoConfig=function(e){return o.setConfiguration(e)},t.videoConfiguration=void 0;var s=a(i(144)),r=a(i(51));function a(e){return e&&e.__esModule?e:{default:e}}const{COLLECTOR:n}=r.default;class d{setConfiguration(e){return this.initializeGlobalConfig(e),s.default.notice("Video analytics configuration initialized successfully"),!0}validateRequiredFields(e){if(!e||"object"!=typeof e)return s.default.error("Configuration must be an object"),!1;const{licenseKey:t,appName:i,region:r,applicationID:a,beacon:d}=e;if(!t)return s.default.error("licenseKey is required"),!1;if(a){if(!d)return s.default.error("beacon is required when applicationID is provided"),!1;if(!Object.values(n).flatMap((e=>e)).includes(d))return s.default.error(`Invalid beacon: ${d}`),!1}else{if(!i||!r)return s.default.error("appName and region are required when applicationID is not provided"),!1;if(!n[r])return s.default.error(`Invalid region: ${r}. Valid regions are: ${Object.keys(n).join(", ")}`),!1}return!0}initializeGlobalConfig(e){if(!this.validateRequiredFields(e))return;let{licenseKey:t,appName:i,region:s,beacon:a,applicationID:d}=e;a="US"===s?r.default.COLLECTOR.US[0]:a||n[s],window.NRVIDEO={info:{...s?{region:s}:{},beacon:a,licenseKey:t,applicationID:d,...d?{}:{appName:i}}}}}const o=t.videoConfiguration=new d;t.default=d},793:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=d(i(144)),r=d(i(302)),a=d(i(328)),n=d(i(330));function d(e){return e&&e.__esModule?e:{default:e}}class o extends r.default{constructor(e,t){super(),this.state=new a.default,this.adsTracker=null,this._lastBufferType=null,this._userId=null,t=t||{},this.setOptions(t),e&&this.setPlayer(e,t.tag),s.default.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(e){this._userId=e}setOptions(e){e&&(e.adsTracker&&this.setAdsTracker(e.adsTracker),"boolean"==typeof e.isAd&&this.setIsAd(e.isAd),r.default.prototype.setOptions.apply(this,arguments))}setPlayer(e,t){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof e&&(e=document.getElementById(e)),"string"==typeof t&&(t=document.getElementById(t))),t=t||e,this.player=e,this.tag=t,this.registerListeners()}isAd(){return this.state.isAd()}setIsAd(e){this.state.setIsAd(e)}setAdsTracker(e){this.disposeAdsTracker(),e&&(this.adsTracker=e,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",l.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",l),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}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let e;if(this._lastWebkitBitrate){e=this.tag.webkitVideoDecodedByteCount;let t=e-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;e=Math.round(t/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,e||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(e){let t,i=this.getRenditionBitrate();return this.isAd()?(t=this._lastAdRendition,e&&(this._lastAdRendition=i)):(t=this._lastRendition,e&&(this._lastRendition=i)),i&&t?i>t?"up":i<t?"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 n.default.version}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(e,t){if(void 0===(e=r.default.prototype.getAttributes.apply(this,arguments)).isAd&&(e.isAd=this.isAd()),e.viewSession=this.getViewSession(),e.viewId=this.getViewId(),e.playerName=this.getPlayerName(),e.playerVersion=this.getPlayerVersion(),e["instrumentation.provider"]=this.getInstrumentationProvider(),e["instrumentation.name"]=this.getInstrumentationName(),e["instrumentation.version"]=this.getInstrumentationVersion(),e["enduser.id"]=this._userId,e.src="Browser","customAction"===t)return e;try{e.pageUrl=window.location.href}catch(e){}this.isAd()?(e.adId=this.getVideoId(),e.adTitle=this.getTitle(),e.adSrc=this.getSrc(),e.adCdn=this.getCdn(),e.adBitrate=this.getBitrate()||this.getWebkitBitrate()||this.getRenditionBitrate(),e.adRenditionName=this.getRenditionName(),e.adRenditionBitrate=this.getRenditionBitrate(),e.adRenditionHeight=this.getRenditionHeight(),e.adRenditionWidth=this.getRenditionWidth(),e.adDuration=this.getDuration(),e.adPlayhead=this.getPlayhead(),e.adLanguage=this.getLanguage(),e.adIsMuted=this.isMuted(),e.adFps=this.getFps(),e.adPosition=this.getAdPosition(),e.adCreativeId=this.getAdCreativeId(),e.adPartner=this.getAdPartner()):(e.contentId=this.getVideoId(),e.contentTitle=this.getTitle(),e.contentSrc=this.getSrc(),e.contentCdn=this.getCdn(),e.contentPlayhead=this.getPlayhead(),e.contentIsLive=this.isLive(),e.contentBitrate=this.getBitrate()||this.getWebkitBitrate()||this.getRenditionBitrate(),e.contentRenditionName=this.getRenditionName(),e.contentRenditionBitrate=this.getRenditionBitrate(),e.contentRenditionHeight=this.getRenditionHeight(),e.contentRenditionWidth=this.getRenditionWidth(),e.contentDuration=this.getDuration(),e.contentLanguage=this.getLanguage(),e.contentPlayrate=this.getPlayrate(),e.contentIsFullscreen=this.isFullscreen(),e.contentIsMuted=this.isMuted(),e.contentIsAutoplayed=this.isAutoplayed(),e.contentPreload=this.getPreload(),e.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(e.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(e);for(let t in this.customData)e[t]=this.customData[t];return e}sendCustom(e,t,i){i=i||{},this.sendVideoCustomAction(e,i),this.state.setTimeSinceAttribute(t)}sendPlayerReady(e){this.state.goPlayerReady()&&(e=e||{},this.sendVideoAction(o.Events.PLAYER_READY,e))}sendRequest(e){if(this.state.goRequest()){let t;this.isAd()?(t=o.Events.AD_REQUEST,this.sendVideoAdAction(t,e)):(t=o.Events.CONTENT_REQUEST,this.sendVideoAction(t,e))}}sendStart(e){if(this.state.goStart()){let t;this.isAd()?(t=o.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(t,e)):(t=o.Events.CONTENT_START,this.sendVideoAction(t,e)),this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(e){if(this.state.goEnd()){let t;e=e||{},this.isAd()?(t=o.Events.AD_END,e.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0)):(t=o.Events.CONTENT_END,e.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0}}sendPause(e){if(this.state.goPause()){let t=this.isAd()?o.Events.AD_PAUSE:o.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendResume(e){if(this.state.goResume()){let t;e=e||{},this.isAd()?(t=o.Events.AD_RESUME,e.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(t=o.Events.CONTENT_RESUME,e.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferStart(e){if(this.state.goBufferStart()){let t;e=e||{},t=this.isAd()?o.Events.AD_BUFFER_START:o.Events.CONTENT_BUFFER_START,e=this.buildBufferAttributes(e),this._lastBufferType=e.bufferType,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferEnd(e){if(this.state.goBufferEnd()){let t;e=e||{},this.isAd()?(t=o.Events.AD_BUFFER_END,e.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(t=o.Events.CONTENT_BUFFER_END,e.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),e=this.buildBufferAttributes(e),null!=this._lastBufferType&&(e.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.initialBufferingHappened=!0}}buildBufferAttributes(e){return null==e.timeSinceStarted||e.timeSinceStarted<100?e.isInitialBuffering=!this.state.initialBufferingHappened:e.isInitialBuffering=!1,e.bufferType=this.state.calculateBufferType(e.isInitialBuffering),e.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),e.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),e}sendSeekStart(e){if(this.state.goSeekStart()){let t;t=this.isAd()?o.Events.AD_SEEK_START:o.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendSeekEnd(e){if(this.state.goSeekEnd()){let t;e=e||{},this.isAd()?(t=o.Events.AD_SEEK_END,e.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(t=o.Events.CONTENT_SEEK_END,e.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendDownload(e){(e=e||{}).state||s.default.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(o.Events.DOWNLOAD,e),this.state.goDownload()}sendError(e){(e=e||{}).isAd=this.isAd(),this.state.goError();let t=this.isAd()?o.Events.AD_ERROR:o.Events.CONTENT_ERROR;this.sendVideoErrorAction(t,e)}sendRenditionChanged(e){let t;(e=e||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),e.shift=this.getRenditionShift(!0),t=this.isAd()?o.Events.AD_RENDITION_CHANGE:o.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.goRenditionChange()}sendHeartbeat(e){if(this.state.isRequested){let t,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(t=o.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(t,e):this.sendVideoAdAction(t,{elapsedTime:i,...e})):(t=o.Events.CONTENT_HEARTBEAT,this.sendVideoAction(t,{elapsedTime:i,...e})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(e){return this.state._acc&&(e-=this.state._acc,this.state._acc=0),this.state.isPaused&&((e-=this.state.elapsedTime.getDeltaTime())<10&&(e=0),this.state.elapsedTime.start()),this.state._bufferAcc?(e-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((e-=this.state.bufferElapsedTime.getDeltaTime())<5&&(e=0),this.state.bufferElapsedTime.start()),Math.max(0,e)}sendAdBreakStart(e){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(o.Events.AD_BREAK_START,e))}sendAdBreakEnd(e){this.isAd()&&this.state.goAdBreakEnd()&&((e=e||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(o.Events.AD_BREAK_END,e),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(e){this.isAd()&&((e=e||{}).quartile||s.default.warn("Called sendAdQuartile without { quartile: xxxxx }."),e.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(o.Events.AD_QUARTILE,e),this.state.goAdQuartile())}sendAdClick(e){this.isAd()&&((e=e||{}).url||s.default.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(o.Events.AD_CLICK,e))}}function l(e){e.type!==o.Events.AD_ERROR?this.sendVideoAdAction(e.type,e.data):this.sendVideoErrorAction(e.type,e.data)}o.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"},t.default=o}},r={};function a(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return s[e](i,i.exports,a),i.exports}var n={};(()=>{var e=n;Object.defineProperty(e,"B",{value:!0}),e.A=void 0;var t=A(a(399)),i=A(a(51)),s=A(a(455)),r=A(a(144)),d=A(a(568)),o=A(a(302)),l=A(a(793)),h=A(a(328)),u=a(431),c=a(413),f=a(28),g=a(374),m=a(449),p=a(330);function A(e){return e&&e.__esModule?e:{default:e}}const y={Constants:i.default,Chrono:s.default,Log:r.default,Emitter:d.default,Tracker:o.default,VideoTracker:l.default,VideoTrackerState:h.default,Core:t.default,version:p.version,NrVideoEventAggregator:u.NrVideoEventAggregator,RetryQueueHandler:c.RetryQueueHandler,OptimizedHttpClient:f.OptimizedHttpClient,HarvestScheduler:g.HarvestScheduler,recordEvent:m.recordEvent};e.A=y})();const d=n.B,o=n.A},717:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(i(555)),r=a(i(472));function a(e){return e&&e.__esModule?e:{default:e}}const n={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"};class d extends r.default{static isUsing(e){return e.imaDai&&"function"==typeof e.imaDai||e.dai&&void 0!==e.dai.VERSION||e.ima&&e.ima.dai||e.streamManager}constructor(e){super(e),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}setStreamManager(e){this.streamManager=e,this.setupStreamManagerListeners(),this.initialized=!0,s.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}setupStreamManagerListeners(){if(!this.streamManager||!google?.ima?.dai?.api?.StreamEvent)return void s.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available");const e=google.ima.dai.api.StreamEvent.Type;this.eventHandlers={[e.LOADED]:this.onStreamLoaded.bind(this),[e.STREAM_INITIALIZED]:this.onStreamInitialized.bind(this),[e.ERROR]:this.onStreamError.bind(this),[e.AD_BREAK_STARTED]:this.onAdBreakStarted.bind(this),[e.AD_BREAK_ENDED]:this.onAdBreakEnded.bind(this),[e.AD_PERIOD_STARTED]:this.onAdPeriodStarted.bind(this),[e.AD_PERIOD_ENDED]:this.onAdPeriodEnded.bind(this),[e.STARTED]:this.onAdStarted.bind(this),[e.FIRST_QUARTILE]:this.onAdFirstQuartile.bind(this),[e.MIDPOINT]:this.onAdMidpoint.bind(this),[e.THIRD_QUARTILE]:this.onAdThirdQuartile.bind(this),[e.COMPLETE]:this.onAdComplete.bind(this),[e.SKIPPED]:this.onAdSkipped.bind(this),[e.PAUSED]:this.onAdPaused.bind(this),[e.RESUMED]:this.onAdResumed.bind(this),[e.CLICK]:this.onAdClicked.bind(this),[e.VIDEO_CLICKED]:this.onAdClicked.bind(this),[e.CUEPOINTS_CHANGED]:this.onCuePointsChanged.bind(this),[e.TIMED_METADATA]:this.onTimedMetadata.bind(this)},Object.entries(this.eventHandlers).forEach((([e,t])=>{this.streamManager.addEventListener(e,t)})),s.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}registerListeners(){super.registerListeners(),s.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(n)])}unregisterListeners(){super.unregisterListeners(),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach((([e,t])=>{this.streamManager.removeEventListener(e,t)})),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}onStreamLoaded(e){this.streamData=this.extractStreamData(e),s.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}onStreamInitialized(e){s.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}onStreamError(e){const t=this.extractErrorData(e);s.default.Log.error("DaiAdsTracker: Stream error",t),this.sendError(t)}onAdBreakStarted(e){this.adBreakData=this.extractAdBreakData(e),s.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}onAdBreakEnded(e){s.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}onAdPeriodStarted(e){s.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(e)}onAdPeriodEnded(e){s.default.Log.debug("DaiAdsTracker: Ad period ended")}onAdStarted(e){this.currentAdData=this.extractAdData(e),s.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}onAdFirstQuartile(e){s.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}onAdMidpoint(e){s.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}onAdThirdQuartile(e){s.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}onAdComplete(e){s.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}onAdSkipped(e){s.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}onAdPaused(e){s.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}onAdResumed(e){s.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}onAdClicked(e){s.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}onCuePointsChanged(e){this.cuePoints=this.extractCuePoints(e),s.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}onTimedMetadata(e){const t=this.extractTimedMetadata(e);s.default.Log.debug("DaiAdsTracker: Timed metadata",t)}extractStreamData(e){try{const t=e.getStreamData();return{streamId:t?.streamId,url:t?.url,adTagParameters:t?.adTagParameters,streamType:this.getStreamType()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract stream data",e),{}}}extractAdBreakData(e){try{const t=e.getAdBreak();return{adBreakId:t?.id,adBreakTitle:t?.title,adCount:t?.ads?.length||0,position:this.getAdPosition()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",e),{}}}extractAdData(e){try{const t=e.getAd();return{adId:t?.getAdId(),creativeId:t?.getCreativeId(),duration:t?.getDuration(),title:t?.getTitle(),description:t?.getDescription(),advertiserName:t?.getAdvertiserName(),clickThroughUrl:t?.getClickThroughUrl(),dealId:t?.getDealId(),wrapperAdIds:t?.getWrapperAdIds(),position:this.getAdPosition()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad data",e),{}}}extractErrorData(e){try{const t=e.getError();return{errorCode:t?.getErrorCode(),errorMessage:t?.getMessage(),innerError:t?.getInnerError()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract error data",e),{errorMessage:"Unknown DAI error"}}}extractCuePoints(e){try{return e.getCuepoints()||[]}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract cue points",e),[]}}extractTimedMetadata(e){try{return{type:e.getType(),data:e.getData()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",e),{}}}getTrackerName(){return"dai-ads"}getPlayerName(){return"videojs-dai"}getPlayerVersion(){return this.player.dai?.VERSION?this.player.dai.VERSION:this.player.ima?.VERSION?`ima-dai: ${this.player.ima.VERSION}`:"unknown"}getAdCuePoints(){return this.cuePoints}getAdPosition(){if(!this.currentAdData&&!this.adBreakData)return null;const e=this.player.currentTime(),t=this.player.duration();return e<5?"pre":t&&e>t-10?"post":"mid"}getDuration(){return void 0!==this.currentAdData?.duration?1e3*this.currentAdData.duration:null}getVideoId(){return this.currentAdData?.adId||null}getAdCreativeId(){return this.currentAdData?.creativeId||null}getTitle(){return this.currentAdData?.title||null}getSrc(){return this.streamData?.url||null}getPlayhead(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(e){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}getAdPartner(){return"google-dai"}getClickThroughUrl(){return this.currentAdData?.clickThroughUrl||null}getStreamType(){if(this.streamData?.streamType)return this.streamData.streamType;return this.player.duration()===1/0?"live":"vod"}isLiveStream(){return"live"===this.getStreamType()}getCurrentAdBreak(){return this.adBreakData}getCurrentAd(){return this.currentAdData}getStreamData(){return this.streamData}getBitrate(){const e=this.getTech();if(e&&e.tech&&e.tech.stats)return e.tech.stats.bandwidth}getRenditionBitrate(){const e=this.getTech();if(e&&e.getRenditionBitrate)return e.getRenditionBitrate()}}t.default=d}},t={};function i(s){var r=t[s];if(void 0!==r)return r.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t,r=(t=i(302))&&t.__esModule?t:{default:t};e.default=r.default})(),module.exports.VideojsTracker=s})();
2
+ (()=>{"use strict";var t={555(t,e,i){i.r(e),i.d(e,{default:()=>P});var s={487(t,e,i){i.r(e),i.d(e,{videoAnalyticsHarvester:()=>o});var s=i(374),r=i(431),a=i(51),n=i(144),d=i(302);const o=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)n.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new r.t,this.harvestScheduler=new s.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,n.A.notice("Video analytics agent initialized successfully")}catch(t){n.A.error("Failed to initialize video analytics agent:",t.message)}}addEvent(t){this.isInitialized||(n.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return t.actionName&&t.actionName===d.A.Events.QOE_AGGREGATE?t.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,t.viewId,t):this.eventBuffer.addOrReplaceByActionName(d.A.Events.QOE_AGGREGATE,t):this.eventBuffer.add(t)}catch(t){return n.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(d.A.Events.QOE_AGGREGATE,e):this.eventBuffer.findByActionName(d.A.Events.QOE_AGGREGATE);if(i){const s={...i};for(const e of a.A.QOE_KPI_KEYS)e in t&&(s[e]=t[e]);e?this.eventBuffer.addOrReplaceByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,e,s):this.eventBuffer.addOrReplaceByActionName(d.A.Events.QOE_AGGREGATE,s)}}}},455(t,e,i){i.d(e,{A:()=>r});class s{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 s;return t.startTime=this.startTime,t.stopTime=this.stopTime,t.offset=this.offset,t.accumulator=this.accumulator,t}}const r=s},51(t,e,i){i.d(e,{A:()=>r});class s{}s.AdPositions={PRE:"pre",MID:"mid",POST:"post"},s.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"},s.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],s.MAX_PAYLOAD_SIZE=1048576,s.MAX_BEACON_SIZE=61440,s.MAX_EVENTS_PER_BATCH=1e3,s.INTERVAL=1e4,s.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],s.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 r=s},568(t,e,i){i.d(e,{A:()=>s});const s=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(s=>{s.call(this,{eventType:t,type:e,data:i,target:this})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(s=>{s.call(this,{eventType:t,type:e,data:i,target:this})}),this}}},431(t,e,i){i.d(e,{t:()=>o});var s=i(144),r=i(51),a=i(347);const{MAX_PAYLOAD_SIZE:n,MAX_EVENTS_PER_BATCH:d}=r.A;class o{constructor(){this.buffer=[],this.maxPayloadSize=n,this.maxEventsPerBatch=d,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 s.A.error("Failed to set or replace the event to buffer:",t.message),!1}}addOrReplaceByActionNameAndViewId(t,e,i){const r=this.buffer.findIndex(i=>i.actionName===t&&i.viewId===e);try{return-1===r?this.add(i):this.add(i,r),!0}catch(t){return s.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),s=this.currentPayloadSize+i>=this.maxPayloadSize,r=this.totalEvents+1>=this.maxEventsPerBatch;if((s||r)&&this.makeRoom(i),null!=e&&e>-1){const s=(0,a.Q3)(this.buffer[e]);this.buffer[e]=t,this.currentPayloadSize+=i-s}else this.buffer.push(t),this.totalEvents++,this.currentPayloadSize+=i;return this.checkSmartHarvestTrigger(),!0}catch(t){return s.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,r=this.totalEvents>=this.overflowEventThreshold;if(i||r){const r=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*t)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*e)}%)`;s.A.warn(`OVERFLOW PREVENTION: ${r} - 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 s.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)s.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,s.A.warn("Event buffer full, oldest event removed.")}}}},374(t,e,i){i.d(e,{n:()=>l});var s=i(431),r=i(413),a=i(481),n=i(347),d=i(51),o=i(302),h=i(144);class l{constructor(t){this.eventBuffer=t,this.retryQueueHandler=new r.u,this.httpClient=new a.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof s.t&&this.eventBuffer.setSmartHarvestCallback((t,e)=>this.triggerSmartHarvest(t,e)),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=d.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?h.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,h.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),h.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(t,e){if(h.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){h.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){h.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=d.A.MAX_BEACON_SIZE;(0,n.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 h.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 s=0;for(let r=t.length-1;r>=0;r--){const a=t[r],d=(0,n.Q3)({ins:[a,...i]});d>e||(i.unshift(a),s=d)}const r=t.length-i.length;if(r>0){const a=t.slice(0,r);h.A.warn(`Discarded ${r} events to fit beacon size limit`,{originalCount:t.length,trimmedCount:i.length,finalSize:s,maxSize:e}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(a)}return i}drainEvents(t={}){const e=window.NRVIDEO?.config?.qoeIntervalFactor??1,i=!!t.isFinalHarvest||this.forceNextQoeCycle,s=(this.qoeCycleCount-1)%e==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(t){h.A.error("Before drain callback failed:",t.message)}const r=this.eventBuffer.drain();let a;if(s)a=r;else{a=[];for(const t of r)t.actionName===o.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===o.A.Events.QOE_AGGREGATE&&(!i&&this._qoeKpisUnchanged(e)?a.splice(t,1):this._saveQoeKpis(e))}let l=[...a],u=(0,n.Q3)(a);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const t=d.A.MAX_PAYLOAD_SIZE-u,e=d.A.MAX_EVENTS_PER_BATCH-l.length;if(t>0&&e>0){const i=this.retryQueueHandler.getRetryEventsToFit(t,e);i.length>0&&(l=[...i,...l])}}return l}async sendChunk(t,e,i){const s={url:(0,n.c$)(this.fallBackUrl),payload:{body:{ins:t}},options:{...e,isLastChunk:i}};return new Promise(e=>{this.httpClient.send(s,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=d.A.COLLECTOR.US[1]))}handleHarvestFailure(t){this.consecutiveFailures++,h.A.warn("Harvest failure handled",{error:t.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(t){"number"!=typeof t&&isNaN(t)?h.A.warn("Invalid newInterval provided to updateHarvestInterval"):t<1e3||t>3e5?h.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==t&&(this.harvestCycle=t,h.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 d.A.QOE_KPI_KEYS)if(t[i]!==e[i])return!1;return!0}_saveQoeKpis(t){const e={};for(const i of d.A.QOE_KPI_KEYS)e[i]=t[i];this._lastSentQoeKpis[t.viewId]=e}}},144(t,e,i){i.d(e,{A:()=>d});class s{static error(...t){r(t,s.Levels.ERROR,"darkred")}static warn(...t){r(t,s.Levels.WARNING,"darkorange")}static notice(...t){r([].slice.call(arguments),s.Levels.NOTICE,"darkcyan")}static debug(...t){r(t,s.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(t,e,i){try{if(s.level<=s.Levels.DEBUG){i=i||function(t){s.debug("Event: "+t.type)};var r=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];e&&(null===e[0]?(e.shift(),r=e):r=r.concat(e));for(var a=0;a<r.length;a++)"function"==typeof t?t.call(window,r[a],i):t.on?t.on(r[a],i):t.addEventListener?t.addEventListener(r[a],i):t.addEventHandler?t.addEventHandler(r[a],i):s.warn("debugCommonVideoEvents: No common listener function found for ",t)}}catch(t){s.warn(t)}}}function r(t,e,i){e=e||s.Levels.NOTICE,i=i||"darkcyan";var r,d,o=s.prefix;s.includeTime&&(o+="["+("0"+(r=new Date).getDate()).slice(-2)+":"+("0"+r.getMinutes()).slice(-2)+":"+("0"+r.getSeconds()).slice(-2)+"."+("00"+r.getMilliseconds()).slice(-3)+"] "),o+=function(t){return n[t]}(e)+":",s.level<=e&&e!==s.Levels.SILENT&&(!s.colorful||"undefined"!=typeof document&&document.documentMode?a(t,o):(d=e===s.Levels.ERROR&&console.error?console.error:e===s.Levels.WARNING&&console.warn?console.warn:e===s.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,o="%c"+o,t.splice(0,0,o,"color: "+i),d.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))}s.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},s.level=s.Levels.ERROR,s.colorful=!0,s.includeTime=!0,s.prefix="[nrvideo]";const n={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]?s.level=s.Levels.ALL:s.level=t[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(s.colorful=!1)}}();const d=s},481(t,e,i){i.d(e,{X:()=>a});var s=i(347),r=i(144);class a{async send(t,e){const{url:i,payload:s,options:a={}}=t;try{if(!i||!s)throw new Error("URL and payload are required");const t={url:i,payload:s,options:a,callback:e};await this.executeRequest(t)}catch(t){r.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:s,callback:a}=t,n=Date.now();try{const a=(d=JSON.stringify(i.body),o=window.NRVIDEO?.config?.obfuscate,o&&0!==o.length?o.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 r.A.warn("applyObfuscationRules: invalid regex, skipping rule:",e.regex,i.message),t}return t.replace(i,e.replacement)},d):d);if(s.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(e,a),s={success:i,status:i?204:0};return void this.handleRequestComplete(t,s,n)}const h=await this.fetchWithTimeout(e,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:s.isFinalHarvest},1e4),l={success:h.ok,status:h.status,statusText:h.statusText};this.handleRequestComplete(t,l,n)}catch(e){const i={success:!1,status:0,error:e.message};this.handleRequestComplete(t,i,n)}var d,o}handleRequestComplete(t,e){const{callback:i}=t;i({retry:!e.success&&(0===e.status||(0,s.Sc)(e.status)),status:e.status,error:e.error})}async sendWithBeacon(t,e){try{return navigator.sendBeacon(t,e)}catch(t){return r.A.warn("sendBeacon failed, falling back to fetch:",t.message),!1}}async fetchWithTimeout(t,e,i){const s=new AbortController,r=setTimeout(()=>s.abort(),i);try{const i=await fetch(t,{...e,signal:s.signal});return clearTimeout(r),i}catch(t){if(clearTimeout(r),"AbortError"===t.name)throw new Error(`Request timeout after ${i}ms`);throw t}}}},413(t,e,i){i.d(e,{u:()=>o});var s=i(144),r=i(347),a=i(51);const{MAX_PAYLOAD_SIZE:n,MAX_EVENTS_PER_BATCH:d}=a.A;class o{constructor(){this.retryQueue=[],this.maxQueueSize=d,this.maxQueueSizeBytes=n}addFailedEvents(t){try{const e=Array.isArray(t)?t:[t];s.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,r.Q3)(t);for(;(0,r.Q3)(this.retryQueue)+e>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...t})}}catch(t){s.A.error("Failed to add events to retry queue:",t.message)}}discardEvent(t,e){s.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 s=0,a=0;for(let n=this.retryQueue.length-1;n>=0;n--){const d=this.retryQueue[n];if(a>=e)break;const o=(0,r.Q3)(d);if(s+o>t)break;i.unshift(d),s+=o,a++,this.retryQueue.splice(n,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(t,e,i){i.d(e,{A:()=>l});var s=i(330),r=i(568),a=i(455),n=i(51),d=i(487),o=i(144);class h extends r.A{constructor(t){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new a.A,this._trackerReadyChrono.start(),this._actionTable=n.A.ACTION_TABLE,this._actionAdTable=n.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(h.Events.HEARTBEAT,t)}getAttributes(t,e){(t=t||{}).trackerName=this.getTrackerName(),t.trackerVersion=this.getTrackerVersion(),t.coreVersion=s.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 s.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(d.videoAnalyticsHarvester)try{d.videoAnalyticsHarvester.setHarvestInterval(t)}catch(t){return void o.A.error("Failed to set harvest interval:",t.message)}else o.A.error("VideoAnalyticsHarvester is not available")}}h.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const l=h},347(t,e,i){i.d(e,{Q3:()=>n,Sc:()=>d,c$:()=>a,z8:()=>o});var s=i(330),r=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:r}=window.NRVIDEO.info;if(!e||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return r?`https://${t||e}/ins/1/${i}?a=${r}&v=${s.rE}&ref=${window.location.href}&ca=VA`:`https://${t||e}/ins/1/${i}?&v=${s.rE}&ref=${window.location.href}&ca=VA`}catch(t){return console.error(t.message),null}}function n(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 r.A.error("Error stringifying value:",t.message),""}}(t).length}catch(t){return}}}function d(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 o(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"}}},r={};function a(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return s[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 n=a(144),d=a(487),o=a(51),h=a(302),l=a(347);function u(t,e={}){try{if(!o.A.VALID_EVENT_TYPES.includes(t))return n.A.warn("Invalid event type provided to recordEvent",{eventType:t}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:s}=window.NRVIDEO.info,{qoe:r,...a}=e,u=r?{...r}:{},c={...s?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},g={...a,eventType:t,...c},A=(0,l.z8)(o.A.QOE_AGGREGATE_KEYS,e);let m=null;"VideoAction"===t&&(m={eventType:"VideoAction",actionName:h.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...u,...A,...c});const f=d.videoAnalyticsHarvester.addEvent(g);if(m&&window?.NRVIDEO?.config?.qoeAggregate){const t=d.videoAnalyticsHarvester.addEvent(m);return f&&t}return f}catch(t){return n.A.error("Failed to record event:",t.message),!1}}const{COLLECTOR:c}=o.A,g=new class{setConfiguration(t,e){return!!this.validateRequiredFields(t)&&!!this.validateConfigFields(e)&&(this.initializeGlobalConfig(t,e),n.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(t){if(!t||"object"!=typeof t)return n.A.error("Configuration must be an object"),!1;const{licenseKey:e,appName:i,region:s,applicationID:r,beacon:a}=t;if(!e)return n.A.error("licenseKey is required"),!1;if(r){if(!a)return n.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(c).flatMap(t=>t).includes(a))return n.A.error(`Invalid beacon: ${a}`),!1}else{if(!i||!s)return n.A.error("appName and region are required when applicationID is not provided"),!1;if(!c[s])return n.A.error(`Invalid region: ${s}. Valid regions are: ${Object.keys(c).join(", ")}`),!1}return!0}validateConfigFields(t){if(null==t)return!0;if("object"!=typeof t||Array.isArray(t))return n.A.error("config must be an object"),!1;const{qoeAggregate:e,obfuscate:i}=t;return void 0!==e&&"boolean"!=typeof e?(n.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(n.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)||(n.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:s,region:r,beacon:a,applicationID:n}=t;a="US"===r?o.A.COLLECTOR.US[0]:a||c[r],window.NRVIDEO={info:{...r?{region:r}:{},beacon:a,licenseKey:i,applicationID:n,...n?{}:{appName:s}},config:{qoeAggregate:e?.qoeAggregate??!1,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(e?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(e?.obfuscate)}}}};class A{static addTracker(t,e){var i,s;e?.info&&(i=e.info,s=e?.config,g.setConfiguration(i,s)),t.on&&t.emit?(m.push(t),t.on("*",f),"function"==typeof t.trackerInit&&t.trackerInit()):n.A.error("Tried to load a non-tracker.",t)}static removeTracker(t){t.off("*",f),t.dispose();let e=m.indexOf(t);-1!==e&&m.splice(e,1)}static getTrackers(){return m}static send(t,e,i){return u(t,{actionName:e,...i})}static sendError(t){return u("VideoErrorAction",{actionName:"ERROR",...t})}static async forceHarvest(){try{const{videoAnalyticsHarvester:t}=a(487);return await t.forceHarvest()}catch(t){return n.A.error("Failed to force harvest:",t.message),{success:!1,error:t.message}}}}let m=[];function f(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);n.A.level<=n.A.Levels.DEBUG?n.A.notice("Sent",t.type,e):n.A.notice("Sent",t.type),A.send(t.eventType,t.type,e)}catch(t){n.A.error("Error in event handler:",t.message)}}const p=A;var E=a(455),y=a(568);const T=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 E.A,this.timeSinceStarted=new E.A,this.timeSincePaused=new E.A,this.timeSinceSeekBegin=new E.A,this.timeSinceBufferBegin=new E.A,this.timeSinceAdBreakStart=new E.A,this.timeSinceLastDownload=new E.A,this.timeSinceLastHeartbeat=new E.A,this.timeSinceLastRenditionChange=new E.A,this.timeSinceLastAdQuartile=new E.A,this.timeSinceLastAd=new E.A,this.timeSinceLastError=new E.A,this.timeSinceLastAdError=new E.A,this.timeSinceResumed=new E.A,this.timeSinceSeekEnd=new E.A,this.playtimeSinceLastEvent=new E.A,this.customTimeSinceAttributes={},this.elapsedTime=new E.A,this.bufferElapsedTime=new E.A,this._totalAdPlaytime=new E.A}isAd(){return this._isAd}setIsAd(t){this._isAd=t}setTimeSinceAttribute(t){this.customTimeSinceAttributes[t]=new E.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){n.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",n.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,s=this._totalBitrateDuration;const r=e-this._lastBitrateChangeTimestamp;r>0&&(i+=t*r,s+=r),this.weightedBitrate=s>0?Math.round(i/s):t}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){n.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return n.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return n.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(t){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-t,0))}};var v=a(330);class S extends h.A{constructor(t,e){super(),this.state=new T,this.adsTracker=null,this._lastBufferType=null,this._userId=null,e=e||{},this.setOptions(e),t&&this.setPlayer(t,e.tag),n.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),h.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("*",D.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",D),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 v.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=h.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(S.Events.PLAYER_READY,t))}sendRequest(t){if(this.state.goRequest()){let e;this.isAd()?(e=S.Events.AD_REQUEST,this.sendVideoAdAction(e,t)):(e=S.Events.CONTENT_REQUEST,this.sendVideoAction(e,t))}}sendStart(t){if(this.state.goStart()){let e;if(this.isAd())e=S.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(e,t),this.state.startAdsTime();else{e=S.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),d.videoAnalyticsHarvester.setBeforeDrainCallback(()=>{if(this.state){const t=this.state.getQoeAttributes({}).qoe;d.videoAnalyticsHarvester.refreshQoeKpis(t,this.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(t){if(this.state.goEnd()){let e;t=t||{},this.isAd()?(e=S.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=S.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()||(d.videoAnalyticsHarvester.forceNextQoeCycle(),d.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(t){if(this.state.goPause()){let e=this.isAd()?S.Events.AD_PAUSE:S.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=S.Events.AD_RESUME,t.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(e=S.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()?S.Events.AD_BUFFER_START:S.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=S.Events.AD_BUFFER_END,t.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(e=S.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()?S.Events.AD_SEEK_START:S.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=S.Events.AD_SEEK_END,t.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(e=S.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||n.A.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(S.Events.DOWNLOAD,t),this.state.goDownload()}sendError(t){(t=t||{}).isAd=this.isAd(),this.state.goError();let e=this.isAd()?S.Events.AD_ERROR:S.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()?S.Events.AD_RENDITION_CHANGE:S.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=S.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(e,t):this.sendVideoAdAction(e,{elapsedTime:i,...t})):(e=S.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(S.Events.AD_BREAK_START,t))}sendAdBreakEnd(t){this.isAd()&&this.state.goAdBreakEnd()&&((t=t||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(S.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||n.A.warn("Called sendAdQuartile without { quartile: xxxxx }."),t.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(S.Events.AD_QUARTILE,t),this.state.goAdQuartile())}sendAdClick(t){this.isAd()&&((t=t||{}).url||n.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(S.Events.AD_CLICK,t))}}function D(t){t.type!==S.Events.AD_ERROR?this.sendVideoAdAction(t.type,t.data):this.sendVideoErrorAction(t.type,t.data)}S.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 b=S;var R=a(431),_=a(413),k=a(481),B=a(374);const P={Constants:o.A,Chrono:E.A,Log:n.A,Emitter:y.A,Tracker:h.A,VideoTracker:b,VideoTrackerState:T,Core:p,version:v.rE,NrVideoEventAggregator:R.t,RetryQueueHandler:_.u,OptimizedHttpClient:k.X,HarvestScheduler:B.n,recordEvent:u}},64(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=a(i(555)),r=a(i(472));function a(t){return t&&t.__esModule?t:{default:t}}class n extends r.default{static isUsing(t){return!!t.ima3}getTrackerName(){return"brightcove-ima-ads"}getPlayerName(){return"brightcove-ima-ads"}getPlayhead(){return this.player?.ima3?.adPlayer?.currentTime()}registerListeners(){s.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))}unregisterListeners(){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)}onStarted(t){this.sendRequest(),this.sendStart()}onPaused(t){this.sendPause()}onResume(t){this.sendResume()}onComplete(t){this.sendEnd()}onSkipped(t){this.sendEnd({skipped:!0})}onError(t){this.sendError()}onClick(t){this.sendClick()}}e.default=n},717(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=a(i(555)),r=a(i(472));function a(t){return t&&t.__esModule?t:{default:t}}const n={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"};class d extends r.default{static isUsing(t){return t.imaDai&&"function"==typeof t.imaDai||t.dai&&void 0!==t.dai.VERSION||t.ima&&t.ima.dai||t.streamManager}constructor(t){super(t),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}setStreamManager(t){this.streamManager=t,this.setupStreamManagerListeners(),this.initialized=!0,s.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}setupStreamManagerListeners(){if(!this.streamManager||!google?.ima?.dai?.api?.StreamEvent)return void s.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available");const t=google.ima.dai.api.StreamEvent.Type;this.eventHandlers={[t.LOADED]:this.onStreamLoaded.bind(this),[t.STREAM_INITIALIZED]:this.onStreamInitialized.bind(this),[t.ERROR]:this.onStreamError.bind(this),[t.AD_BREAK_STARTED]:this.onAdBreakStarted.bind(this),[t.AD_BREAK_ENDED]:this.onAdBreakEnded.bind(this),[t.AD_PERIOD_STARTED]:this.onAdPeriodStarted.bind(this),[t.AD_PERIOD_ENDED]:this.onAdPeriodEnded.bind(this),[t.STARTED]:this.onAdStarted.bind(this),[t.FIRST_QUARTILE]:this.onAdFirstQuartile.bind(this),[t.MIDPOINT]:this.onAdMidpoint.bind(this),[t.THIRD_QUARTILE]:this.onAdThirdQuartile.bind(this),[t.COMPLETE]:this.onAdComplete.bind(this),[t.SKIPPED]:this.onAdSkipped.bind(this),[t.PAUSED]:this.onAdPaused.bind(this),[t.RESUMED]:this.onAdResumed.bind(this),[t.CLICK]:this.onAdClicked.bind(this),[t.VIDEO_CLICKED]:this.onAdClicked.bind(this),[t.CUEPOINTS_CHANGED]:this.onCuePointsChanged.bind(this),[t.TIMED_METADATA]:this.onTimedMetadata.bind(this)},Object.entries(this.eventHandlers).forEach(([t,e])=>{this.streamManager.addEventListener(t,e)}),s.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}registerListeners(){super.registerListeners(),s.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(n)])}unregisterListeners(){super.unregisterListeners(),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach(([t,e])=>{this.streamManager.removeEventListener(t,e)}),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}onStreamLoaded(t){this.streamData=this.extractStreamData(t),s.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}onStreamInitialized(t){s.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}onStreamError(t){const e=this.extractErrorData(t);s.default.Log.error("DaiAdsTracker: Stream error",e),this.sendError(e)}onAdBreakStarted(t){this.adBreakData=this.extractAdBreakData(t),s.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}onAdBreakEnded(t){s.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}onAdPeriodStarted(t){s.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(t)}onAdPeriodEnded(t){s.default.Log.debug("DaiAdsTracker: Ad period ended")}onAdStarted(t){this.currentAdData=this.extractAdData(t),s.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}onAdFirstQuartile(t){s.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}onAdMidpoint(t){s.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}onAdThirdQuartile(t){s.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}onAdComplete(t){s.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}onAdSkipped(t){s.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}onAdPaused(t){s.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}onAdResumed(t){s.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}onAdClicked(t){s.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}onCuePointsChanged(t){this.cuePoints=this.extractCuePoints(t),s.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}onTimedMetadata(t){const e=this.extractTimedMetadata(t);s.default.Log.debug("DaiAdsTracker: Timed metadata",e)}extractStreamData(t){try{const e=t.getStreamData();return{streamId:e?.streamId,url:e?.url,adTagParameters:e?.adTagParameters,streamType:this.getStreamType()}}catch(t){return s.default.Log.warn("DaiAdsTracker: Failed to extract stream data",t),{}}}extractAdBreakData(t){try{const e=t.getAdBreak();return{adBreakId:e?.id,adBreakTitle:e?.title,adCount:e?.ads?.length||0,position:this.getAdPosition()}}catch(t){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",t),{}}}extractAdData(t){try{const e=t.getAd();return{adId:e?.getAdId(),creativeId:e?.getCreativeId(),duration:e?.getDuration(),title:e?.getTitle(),description:e?.getDescription(),advertiserName:e?.getAdvertiserName(),clickThroughUrl:e?.getClickThroughUrl(),dealId:e?.getDealId(),wrapperAdIds:e?.getWrapperAdIds(),position:this.getAdPosition()}}catch(t){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad data",t),{}}}extractErrorData(t){try{const e=t.getError();return{errorCode:e?.getErrorCode(),errorMessage:e?.getMessage(),innerError:e?.getInnerError()}}catch(t){return s.default.Log.warn("DaiAdsTracker: Failed to extract error data",t),{errorMessage:"Unknown DAI error"}}}extractCuePoints(t){try{return t.getCuepoints()||[]}catch(t){return s.default.Log.warn("DaiAdsTracker: Failed to extract cue points",t),[]}}extractTimedMetadata(t){try{return{type:t.getType(),data:t.getData()}}catch(t){return s.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",t),{}}}getTrackerName(){return"dai-ads"}getPlayerName(){return"videojs-dai"}getPlayerVersion(){return this.player.dai?.VERSION?this.player.dai.VERSION:this.player.ima?.VERSION?`ima-dai: ${this.player.ima.VERSION}`:"unknown"}getAdCuePoints(){return this.cuePoints}getAdPosition(){if(!this.currentAdData&&!this.adBreakData)return null;const t=this.player.currentTime(),e=this.player.duration();return t<5?"pre":e&&t>e-10?"post":"mid"}getDuration(){return void 0!==this.currentAdData?.duration?1e3*this.currentAdData.duration:null}getVideoId(){return this.currentAdData?.adId||null}getAdCreativeId(){return this.currentAdData?.creativeId||null}getTitle(){return this.currentAdData?.title||null}getSrc(){return this.streamData?.url||null}getPlayhead(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(t){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}getAdPartner(){return"google-dai"}getClickThroughUrl(){return this.currentAdData?.clickThroughUrl||null}getStreamType(){if(this.streamData?.streamType)return this.streamData.streamType;return this.player.duration()===1/0?"live":"vod"}isLiveStream(){return"live"===this.getStreamType()}getCurrentAdBreak(){return this.adBreakData}getCurrentAd(){return this.currentAdData}getStreamData(){return this.streamData}getBitrate(){const t=this.getTech();if(t&&t.tech&&t.tech.stats)return t.tech.stats.bandwidth}getRenditionBitrate(){const t=this.getTech();if(t&&t.getRenditionBitrate)return t.getRenditionBitrate()}}e.default=d},38(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s,r=(s=i(472))&&s.__esModule?s:{default:s};class a extends r.default{static isUsing(t){return!!t.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}getTrackerName(){return"freewheel-ads"}getPlayerName(){return"freewheel-ads"}getPlayerVersion(){return this.player.FreeWheelPlugin.VERSION}getPlayhead(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}getDuration(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}getVideoId(){return this.player.ads.ad.id}getAdPartner(){return"freewheel"}getAdCreativeId(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(t){}}getSrc(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(t){}}getTitle(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(t){}}getAdPosition(){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}}}e.default=a},298(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=a(i(555)),r=a(i(472));function a(t){return t&&t.__esModule?t:{default:t}}class n extends r.default{static isUsing(t){return t.ima&&"undefined"!=typeof google}getTrackerName(){return"ima-ads"}getPlayerName(){return"ima"}getPlayerVersion(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}getCuePoints(){return this.player.ima.getAdsManager().getCuePoints()}getAdPosition(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){const t=this.lastAdData.podInfo.podIndex;return 0===t?"pre":-1===t?"post":"mid"}return null}getDuration(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}getVideoId(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}getAdCreativeId(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}getSrc(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}getTitle(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}getPlayhead(){let t=this.player.ima.getAdsManager();if(t)return 1e3*(this.getDuration()-t.getRemainingTime())}getPlayrate(){return this.player.playbackRate()}getAdPartner(){return"ima"}getWebkitBitrate(){const t=this.getAdVideoElement();if(t&&t.webkitVideoDecodedByteCount){let e;if(this._lastAdWebkitBitrate>0){const i=t.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,s=this.getHeartbeat()/1e3;e=Math.round(i/s*8)}return this._lastAdWebkitBitrate=t.webkitVideoDecodedByteCount,e??null}return null}getRenditionBitrate(){if(this.lastAdData)return this.lastAdData.renditionBitrate}registerListeners(){let t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,s.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))}unregisterListeners(){let 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}onLoaded(t){this.lastAdData=this.getAdData(),this.sendRequest()}onStart(t){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}onComplete(t){this.sendEnd(),this.lastAdData=null}onSkipped(t){this.sendEnd({skipped:!0}),this.lastAdData=null}onError(t){const e=t.getError(),i=e.getErrorCode(),s=e.getMessage();this.sendError({adError:e,errorCode:i,errorMessage:s})}onClick(t){this.sendAdClick()}onFirstQuartile(){this.sendAdQuartile({adQuartile:1})}onMidpoint(){this.sendAdQuartile({adQuartile:2})}onThirdQuartile(){this.sendAdQuartile({adQuartile:3})}onPaused(){this.sendPause()}onResumed(){this.sendResume()}getAdData(){try{const t=this.player.ima.getAdsManager();if(t){const e=t.getCurrentAd();if(e)return{adId:e.getAdId(),creativeId:e.getCreativeId(),duration:e.getDuration(),mediaUrl:e.getMediaUrl(),title:e.getTitle(),podInfo:e.getAdPodInfo()?.data,renditionBitrate:e.getVastMediaBitrate()}}return null}catch(t){return null}}getAdVideoElement(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){const t=this.player.ima.controller.adUi.adContainerDiv;if(t){const e=t.querySelector("video");if(e)return e}}}}e.default=n},472(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=o(i(555)),r=o(i(330)),a=o(i(409)),n=o(i(257)),d=o(i(338));function o(t){return t&&t.__esModule?t:{default:t}}class h extends s.default.VideoTracker{getTech(){const t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(a.default.isUsing(t))return new a.default(t);if(n.default.isUsing(t))return new n.default(t);if(d.default.isUsing(t))return new d.default(t)}}getTrackerName(){return"videojs-ads"}getTrackerVersion(){return r.default.version}isMuted(){return this.player.muted()}getRenditionHeight(){return null}getRenditionWidth(){return null}getPlayerName(){return"videojs-ads"}getPlayerVersion(){return this.player.ads.VERSION}registerListeners(){s.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))}unregisterListeners(){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)}onAdrequest(t){this.sendRequest(),this.sendDownload({state:"ads-request"})}onAdload(t){this.sendDownload({state:"ads-load"})}onAdstart(t){this.sendRequest(),this.sendStart()}onAdend(t){this.sendEnd()}onAdskip(t){this.sendEnd({skipped:!0})}onAdserror(t){this.sendError()}onAdsClick(t){this.sendAdClick({url:"unknown"})}onPodStart(t){this.sendAdBreakStart()}onPodEnd(t){this.sendAdBreakEnd()}onFirstQuartile(){this.sendAdQuartile({quartile:1})}onMidpoint(){this.sendAdQuartile({quartile:2})}onThirdQuartile(){this.sendAdQuartile({quartile:3})}onAdspause(){this.sendPause()}onAdsplay(){this.sendResume()}}e.default=h},409(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class i{constructor(t){this.tech=t.vhs,this.player=t.el().player}getRenditionName(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.NAME}catch(t){}return null}getRenditionBitrate(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.BANDWIDTH}catch(t){}return null}getRenditionWidth(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.width}catch(t){}return null}getRenditionHeight(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.height}catch(t){}return null}getBitrate(){return this.getContentBitratePlayback()}getManifestBitrate(){try{const t=this.tech.playlists.master.playlists;if(t&&t.length>0)return Math.max(...t.map(t=>t.attributes.BANDWIDTH))}catch(t){}return null}getSegmentDownloadBitrate(){return void 0!==this.tech.stats?.bandwidth&&this.tech.stats.bandwidth>0?this.tech.stats.bandwidth:null}getNetworkDownloadBitrate(){return void 0!==this.tech.throughput&&this.tech.throughput>0?this.tech.throughput:null}getContentBitratePlayback(){try{const t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH||null}catch(t){}return null}}e.default=i,i.isUsing=function(t){return!!t.vhs}},257(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class i{constructor(t){this.tech=t.vhs_,this.player=t.el().player}getResource(t){return this.tech.url}getRenditionName(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.name)return e.name}catch(t){}return null}getRenditionBitrate(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return e.bitrate}catch(t){}return null}getRenditionWidth(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.width)return e.width}catch(t){}return null}getRenditionHeight(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.height)return e.height}catch(t){}return null}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{const t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return t.bitrate}catch(t){}return null}getManifestBitrate(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.max(...this.tech.levels.map(t=>t.bitrate))}catch(t){}return null}getSegmentDownloadBitrate(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return this.tech.stats.bandwidth}catch(t){}return null}getNetworkDownloadBitrate(){return this.tech.throughput&&this.tech.throughput>0?this.tech.throughput:null}}e.default=i,i.isUsing=function(t){return!!t.vhs_}},338(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class i{constructor(t){this.tech=t.shakaPlayer,this.player=t.el().player}getSrc(t){try{return this.tech.getManifestUri()}catch(t){}return null}getRenditionBitrate(t){try{return this.tech.getStats().streamBandwidth}catch(t){}return null}getManifestBitrate(){try{const t=this.tech.getVariantTracks();if(t&&t.length>0)return Math.max(...t.map(t=>t.videoBandwidth+(t.audioBandwidth||0)))}catch(t){}return null}getRenditionWidth(t){try{var e=this.tech.getVariantTracks();for(var i in e){var s=e[i];if(s.active&&"video"===s.type)return s.width}}catch(t){}return null}getRenditionHeight(t){try{var e=this.tech.getVariantTracks();for(var i in e){var s=e[i];if(s.active&&"video"===s.type)return s.height}}catch(t){}return null}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{var t=this.tech.getStats();if(t&&t.streamBandwidth&&t.streamBandwidth>0)return t.streamBandwidth}catch(t){}return null}getSegmentDownloadBitrate(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return t.estimatedBandwidth}catch(t){}return null}getNetworkDownloadBitrate(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return t.estimatedBandwidth}catch(t){}return null}}e.default=i,i.isUsing=function(t){return!!t.shakaPlayer}},302(t,e,i){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,"ContribHlsTech",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,"FreewheelAdsTracker",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"HlsJsTech",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"ImaAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,"ShakaTech",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(e,"VideojsAdsTracker",{enumerable:!0,get:function(){return o.default}}),e.default=void 0;var s=g(i(555)),r=g(i(330)),a=g(i(409)),n=g(i(257)),d=g(i(338)),o=g(i(472)),h=g(i(298)),l=g(i(64)),u=g(i(38)),c=g(i(717));function g(t){return t&&t.__esModule?t:{default:t}}class A extends s.default.VideoTracker{constructor(t,e){super(t,e),this.isContentEnd=!1,this.imaAdCuePoints="",this.daiInitialized=!1,s.default.Core.addTracker(this,e)}getTech(){let t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(a.default.isUsing(t))return new a.default(t);if(n.default.isUsing(t))return new n.default(t);if(d.default.isUsing(t))return new d.default(t)}}getTrackerName(){return"videojs"}getInstrumentationProvider(){return"New Relic"}getInstrumentationName(){return this.getPlayerName()}getInstrumentationVersion(){return this.getPlayerVersion()}getTrackerVersion(){return r.default.version}getPlayhead(){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()}getDuration(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}getTitle(){return this.player?.mediainfo?.name}getId(){return this.player?.mediainfo?.id}getLanguage(){return this.player?.language()}getSrc(){let t=this.getTech();return t&&t.getSrc?t.getSrc():this.player.currentSrc()}getPlayerName(){return this.player?.name()||"videojs"}getPlayerVersion(){return this.player?.version||videojs.VERSION}isMuted(){return this.player.muted()}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{const t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t?.vhs?.playlists?.media()){const e=t.vhs.playlists.media();return e.attributes["AVERAGE-BANDWIDTH"]||e.attributes.BANDWIDTH||null}const e=this.getTech();if(e?.getBitrate)return e.getBitrate()}catch(t){}return null}getRenditionName(){let t=this.getTech();if(t&&t.getRenditionName)return t.getRenditionName()}getManifestBitrate(){try{const t=this.player.tech({IWillNotUseThisInPlugins:!0}),e=t?.vhs?.playlists?.master?.playlists;if(e&&e.length>0){const t=Math.max(...e.map(t=>t.attributes.BANDWIDTH||0));return t>0?t:null}const i=this.getTech();if(i?.getManifestBitrate)return i.getManifestBitrate()}catch(t){}return null}getSegmentDownloadBitrate(){try{const t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t?.vhs?.stats?.bandwidth&&t.vhs.stats.bandwidth>0)return t.vhs.stats.bandwidth;const e=this.getTech();if(e?.getSegmentDownloadBitrate)return e.getSegmentDownloadBitrate()}catch(t){}return null}getNetworkDownloadBitrate(){const t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t?.vhs?.throughput&&t.vhs.throughput>0)return t.vhs.throughput;const e=this.getTech();return e?.getNetworkDownloadBitrate?e.getNetworkDownloadBitrate():null}getRenditionHeight(){let t=this.getTech();return t&&t.getRenditionHeight?t.getRenditionHeight():this.player.videoHeight()}getRenditionWidth(){let t=this.getTech();return t&&t.getRenditionWidth?t.getRenditionWidth():this.player.videoWidth()}getPlayrate(){return this.player.playbackRate()}isAutoplayed(){return this.player.autoplay()}isFullscreen(){return this.player.isFullscreen()}getPreload(){return this.player.preload()}registerListeners(){s.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)}unregisterListeners(){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)}onDownload(t){this.sendDownload({state:t.type})}onStreamManager(t){if(!this.adsTracker&&t.StreamManager){const e=new c.default(this.player);e.setStreamManager(t.StreamManager),this.setAdsTracker(e)}}onAdsready(){this.adsTracker||(l.default.isUsing(this.player)?this.setAdsTracker(new l.default(this.player)):h.default.isUsing(this.player)?this.setAdsTracker(new h.default(this.player)):u.default.isUsing(this.player)?this.setAdsTracker(new u.default(this.player)):this.setAdsTracker(new o.default(this.player)))}onAdStart(){this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=this.player?.ima?.getAdsManager().getCuePoints())}onAdEnd(){this.isContentEnd&&this.sendEnd()}OnAdsAllpodsCompleted(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}onPlay(){this.sendRequest()}onPause(){this.sendPause()}onPlaying(){this.sendResume(),this.sendBufferEnd()}onAbort(){this.sendEnd()}onEnded(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}onDispose(){this.sendEnd()}onSeeking(){this.sendSeekStart()}onSeeked(){this.sendSeekEnd()}onError(){const t=this.player.error(),e=t.code,i=t.message;this.player.error&&this.player.error()&&this.sendError({errorCode:e,errorMessage:i})}onWaiting(t){this.sendBufferStart()}onTimeupdate(t){this.getPlayhead()>.1&&this.sendStart()}}e.default=A},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(s){var r=e[s];if(void 0!==r)return r.exports;var a=e[s]={exports:{}};return t[s](a,a.exports,i),a.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},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 s={};(()=>{var t=s;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e,r=(e=i(302))&&e.__esModule?e:{default:e};t.default=r.default})(),module.exports.VideojsTracker=s})();
3
3
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @license Apache-2.0
3
- * @newrelic/video-videojs 4.0.2
3
+ * @newrelic/video-videojs 4.1.0
4
4
  * Copyright New Relic <http://newrelic.com/>
5
5
  * @author Jordi Aguilar
6
6
  */