@newrelic/video-videojs 4.1.2 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see newrelic-video-videojs.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VideojsTracker=e():t.VideojsTracker=e()}(self,(()=>(()=>{"use strict";var t={38:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n,a=(n=r(472))&&n.__esModule?n:{default:n};function s(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,o(i.key),i)}}function o(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(l=function(){return!!t})()}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=u(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,l()?Reflect.construct(e,r||[],u(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(e,t),function(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(e,[{key:"getTrackerName",value:function(){return"freewheel-ads"}},{key:"getPlayerName",value:function(){return"freewheel-ads"}},{key:"getPlayerVersion",value:function(){return this.player.FreeWheelPlugin.VERSION}},{key:"getPlayhead",value:function(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}},{key:"getDuration",value:function(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}},{key:"getVideoId",value:function(){return this.player.ads.ad.id}},{key:"getAdPartner",value:function(){return"freewheel"}},{key:"getAdCreativeId",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(t){}}},{key:"getSrc",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(t){}}},{key:"getTitle",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(t){}}},{key:"getAdPosition",value:function(){switch(this.player.ads.ad.type){case"PREROLL":return nrvideo.Constants.AdPositions.PRE;case"MIDROLL":return nrvideo.Constants.AdPositions.MID;case"POSTROLL":return nrvideo.Constants.AdPositions.POST}}}],[{key:"isUsing",value:function(t){return!!t.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}}])}(a.default)},64:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(r(555)),a=s(r(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,l(i.key),i)}}function l(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(u=function(){return!!t})()}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,u()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),r=e,s=[{key:"isUsing",value:function(t){return!!t.ima3}}],(a=[{key:"getTrackerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayhead",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.ima3)||void 0===t||null===(t=t.adPlayer)||void 0===t?void 0:t.currentTime()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ima3-ready","ima3error","ima3-ad-error","ima3-started","ima3-complete","ima3-paused","ima3-resumed","ads-request","ads-load","ads-ad-started","ads-ad-ended","ads-pause","ads-play","ads-click","ads-pod-started","ads-pod-ended","ads-allpods-completed"]),this.player.on("ima3-started",this.onStarted.bind(this)),this.player.on("ima3-paused",this.onPaused.bind(this)),this.player.on("ima3-resumed",this.onResume.bind(this)),this.player.on("ima3-complete",this.onComplete.bind(this)),this.player.on("ima3-skipped",this.onSkipped.bind(this)),this.player.on("adserror",this.onError.bind(this)),this.player.on("ads-click",this.onClick.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ima3-started",this.onStarted),this.player.off("ima3-paused",this.onPaused),this.player.off("ima3-resumed",this.onResume),this.player.off("ima3-complete",this.onComplete),this.player.off("ima3-skipped",this.onSkipped),this.player.off("adserror",this.onError),this.player.off("ads-click",this.onClick)}},{key:"onStarted",value:function(t){this.sendRequest(),this.sendStart()}},{key:"onPaused",value:function(t){this.sendPause()}},{key:"onResume",value:function(t){this.sendResume()}},{key:"onComplete",value:function(t){this.sendEnd()}},{key:"onSkipped",value:function(t){this.sendEnd({skipped:!0})}},{key:"onError",value:function(t){this.sendError()}},{key:"onClick",value:function(t){this.sendClick()}}])&&o(r.prototype,a),s&&o(r,s),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,a,s}(a.default)},257:(t,e)=>{function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,a(i.key),i)}}function a(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.vhs_,this.player=e.el().player},(e=[{key:"getResource",value:function(t){return this.tech.url}},{key:"getRenditionName",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.name)return e.name}catch(t){}return null}},{key:"getRenditionBitrate",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return Math.round(e.bitrate)}catch(t){}return null}},{key:"getRenditionWidth",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.width)return e.width}catch(t){}return null}},{key:"getRenditionHeight",value:function(t){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.height)return e.height}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return Math.round(t.bitrate)}catch(t){}return null}},{key:"getManifestBitrate",value:function(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.round(Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.tech.levels.map((function(t){return t.bitrate})))))}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return Math.round(this.tech.stats.bandwidth)}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){return this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.vhs_}},298:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(r(555)),a=s(r(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,l(i.key),i)}}function l(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(u=function(){return!!t})()}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,u()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),r=e,a=[{key:"getTrackerName",value:function(){return"ima-ads"}},{key:"getPlayerName",value:function(){return"ima"}},{key:"getPlayerVersion",value:function(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}},{key:"getCuePoints",value:function(){return this.player.ima.getAdsManager().getCuePoints()}},{key:"getAdPosition",value:function(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){var t=this.lastAdData.podInfo.podIndex;return 0===t?"pre":-1===t?"post":"mid"}return null}},{key:"getDuration",value:function(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}},{key:"getVideoId",value:function(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}},{key:"getAdCreativeId",value:function(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}},{key:"getSrc",value:function(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}},{key:"getTitle",value:function(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}},{key:"getPlayhead",value:function(){var t=this.player.ima.getAdsManager();if(t)return 1e3*(this.getDuration()-t.getRemainingTime())}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"getAdPartner",value:function(){return"ima"}},{key:"getWebkitBitrate",value:function(){var t=this.getAdVideoElement();if(t&&t.webkitVideoDecodedByteCount){var e;if(this._lastAdWebkitBitrate>0){var r=t.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,i=this.getHeartbeat()/1e3;e=Math.round(r/i*8)}return this._lastAdWebkitBitrate=t.webkitVideoDecodedByteCount,null!=e?e:null}return null}},{key:"getRenditionBitrate",value:function(){return this.lastAdData&&this.lastAdData.renditionBitrate?Math.round(this.lastAdData.renditionBitrate):null}},{key:"registerListeners",value:function(){var t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,n.default.Log.debugCommonVideoEvents(this.player.ima.addEventListener,[null,t.ALL_ADS_COMPLETED,t.LINEAR_CHANGED,t.COMPLETE,t.USER_CLOSE,t.IMPRESSION,t.CONTENT_PAUSE_REQUESTED,t.CONTENT_RESUME_REQUESTED,t.SKIPPED,t.SKIPPABLE_STATE_CHANGED,t.LOADED,t.PAUSED,t.RESUMED,t.STARTED,t.AD_CAN_PLAY,t.AD_METADATA,t.EXPANDED_CHANGED,t.AD_BREAK_READY,t.LOG,t.CLICK,t.FIRST_QUARTILE,t.MIDPOINT,t.THIRD_QUARTILE,e]),this.player.ima.addEventListener(t.LOADED,this.onLoaded.bind(this)),this.player.ima.addEventListener(t.STARTED,this.onStart.bind(this)),this.player.ima.addEventListener(t.PAUSED,this.onPaused.bind(this)),this.player.ima.addEventListener(t.RESUMED,this.onResumed.bind(this)),this.player.ima.addEventListener(t.COMPLETE,this.onComplete.bind(this)),this.player.ima.addEventListener(t.SKIPPED,this.onSkipped.bind(this)),this.player.ima.addEventListener(t.CLICK,this.onClick.bind(this)),this.player.ima.addEventListener(t.FIRST_QUARTILE,this.onFirstQuartile.bind(this)),this.player.ima.addEventListener(t.MIDPOINT,this.onMidpoint.bind(this)),this.player.ima.addEventListener(t.THIRD_QUARTILE,this.onThirdQuartile.bind(this)),this.player.ima.addEventListener(e,this.onError.bind(this))}},{key:"unregisterListeners",value:function(){var t=google.ima.AdEvent.Type,e=google.ima.AdErrorEvent.Type.AD_ERROR;this.player.ima.removeEventListener(t.LOADED,this.onLoaded),this.player.ima.removeEventListener(t.STARTED,this.onLoaded.bind(this)),this.player.ima.removeEventListener(t.IMPRESSION,this.onImpression),this.player.ima.removeEventListener(t.PAUSED,this.onPaused),this.player.ima.removeEventListener(t.RESUMED,this.onResumed),this.player.ima.removeEventListener(t.COMPLETE,this.onComplete),this.player.ima.removeEventListener(t.SKIPPED,this.onSkipped),this.player.ima.removeEventListener(t.CLICK,this.onClick),this.player.ima.removeEventListener(t.FIRST_QUARTILE,this.onFirstQuartile),this.player.ima.removeEventListener(t.MIDPOINT,this.onMidpoint),this.player.ima.removeEventListener(t.THIRD_QUARTILE,this.onThirdQuartile),this.player.ima.removeEventListener(e,this.onError),this.lastAdData=null}},{key:"onLoaded",value:function(t){this.lastAdData=this.getAdData(),this.sendRequest()}},{key:"onStart",value:function(t){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}},{key:"onComplete",value:function(t){this.sendEnd(),this.lastAdData=null}},{key:"onSkipped",value:function(t){this.sendEnd({skipped:!0}),this.lastAdData=null}},{key:"onError",value:function(t){var e=t.getError(),r=e.getErrorCode(),i=e.getMessage();this.sendError({adError:e,errorCode:r,errorMessage:i})}},{key:"onClick",value:function(t){this.sendAdClick()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({adQuartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({adQuartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({adQuartile:3})}},{key:"onPaused",value:function(){this.sendPause()}},{key:"onResumed",value:function(){this.sendResume()}},{key:"getAdData",value:function(){try{var t=this.player.ima.getAdsManager();if(t){var e,r=t.getCurrentAd();if(r)return{adId:r.getAdId(),creativeId:r.getCreativeId(),duration:r.getDuration(),mediaUrl:r.getMediaUrl(),title:r.getTitle(),podInfo:null===(e=r.getAdPodInfo())||void 0===e?void 0:e.data,renditionBitrate:r.getVastMediaBitrate()}}return null}catch(t){return null}}},{key:"getAdVideoElement",value:function(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){var t=this.player.ima.controller.adUi.adContainerDiv;if(t){var e=t.querySelector("video");if(e)return e}}}}],s=[{key:"isUsing",value:function(t){return t.ima&&"undefined"!=typeof google}}],a&&o(r.prototype,a),s&&o(r,s),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,a,s}(a.default)},302:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"ContribHlsTech",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"FreewheelAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,"HlsJsTech",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"ImaAdsTracker",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(e,"MediaTailorAdsTracker",{enumerable:!0,get:function(){return p.default}}),Object.defineProperty(e,"ShakaTech",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,"VideojsAdsTracker",{enumerable:!0,get:function(){return u.default}}),e.default=void 0;var n=m(r(555)),a=m(r(330)),s=m(r(409)),o=m(r(257)),l=m(r(338)),u=m(r(472)),d=m(r(298)),c=m(r(64)),h=m(r(38)),f=m(r(717)),p=m(r(687));function m(t){return t&&t.__esModule?t:{default:t}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function y(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,v(i.key),i)}}function v(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function T(t){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},T(t)}function E(t,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},E(t,e)}e.default=function(t){function e(t,r){var a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(a=function(t,e,r){return e=T(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(e,r||[],T(t).constructor):e.apply(t,r))}(this,e,[t,r])).options=r,a.isContentEnd=!1,a.imaAdCuePoints="",a.daiInitialized=!1,n.default.Core.addTracker(a,r),a}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e)}(e,t),r=e,m=[{key:"getTech",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(s.default.isUsing(t))return new s.default(t);if(o.default.isUsing(t))return new o.default(t);if(l.default.isUsing(t))return new l.default(t)}}},{key:"getTrackerName",value:function(){return"videojs"}},{key:"getInstrumentationProvider",value:function(){return"New Relic"}},{key:"getInstrumentationName",value:function(){return this.getPlayerName()}},{key:"getInstrumentationVersion",value:function(){return this.getPlayerVersion()}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"getPlayhead",value:function(){return this.player.ads&&"ads-playback"===this.player.ads.state&&this.player.ads.snapshot&&this.player.ads.snapshot.currentTime?1e3*this.player.ads.snapshot.currentTime:this.player.absoluteTime?1e3*this.player.absoluteTime():1e3*this.player.currentTime()}},{key:"getDuration",value:function(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}},{key:"getTitle",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.mediainfo)||void 0===t?void 0:t.name}},{key:"getId",value:function(){var t;return null===(t=this.player)||void 0===t||null===(t=t.mediainfo)||void 0===t?void 0:t.id}},{key:"getLanguage",value:function(){var t;return null===(t=this.player)||void 0===t?void 0:t.language()}},{key:"getSrc",value:function(){var t=this.getTech();return t&&t.getSrc?t.getSrc():this.player.currentSrc()}},{key:"getPlayerName",value:function(){var t;return(null===(t=this.player)||void 0===t?void 0:t.name())||"videojs"}},{key:"getPlayerVersion",value:function(){var t;return(null===(t=this.player)||void 0===t?void 0:t.version)||videojs.VERSION}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&null!==(t=t.playlists)&&void 0!==t&&t.media()){var r=e.vhs.playlists.media(),i=r.attributes["AVERAGE-BANDWIDTH"]||r.attributes.BANDWIDTH||null;return null!==i?Math.round(i):null}var n=this.getTech();if(null!=n&&n.getBitrate){var a=n.getBitrate();return null!==a?Math.round(a):null}}catch(t){}return null}},{key:"getRenditionName",value:function(){var t=this.getTech();if(t&&t.getRenditionName)return t.getRenditionName()}},{key:"getManifestBitrate",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0}),r=null==e||null===(t=e.vhs)||void 0===t||null===(t=t.playlists)||void 0===t||null===(t=t.master)||void 0===t?void 0:t.playlists;if(r&&r.length>0){var i=Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return g(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return g(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(r.map((function(t){return t.attributes.BANDWIDTH||0}))));return i>0?Math.round(i):null}var n=this.getTech();if(null!=n&&n.getManifestBitrate){var a=n.getManifestBitrate();return null!==a?Math.round(a):null}}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&null!==(t=t.stats)&&void 0!==t&&t.bandwidth&&e.vhs.stats.bandwidth>0)return Math.round(e.vhs.stats.bandwidth);var r=this.getTech();if(null!=r&&r.getSegmentDownloadBitrate){var i=r.getSegmentDownloadBitrate();return null!==i?Math.round(i):null}}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){var t,e=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=e&&null!==(t=e.vhs)&&void 0!==t&&t.throughput&&e.vhs.throughput>0)return Math.round(e.vhs.throughput);var r=this.getTech();if(null!=r&&r.getNetworkDownloadBitrate){var i=r.getNetworkDownloadBitrate();return null!==i?Math.round(i):null}return null}},{key:"getRenditionHeight",value:function(){var t=this.getTech();return t&&t.getRenditionHeight?t.getRenditionHeight():this.player.videoHeight()}},{key:"getRenditionWidth",value:function(){var t=this.getTech();return t&&t.getRenditionWidth?t.getRenditionWidth():this.player.videoWidth()}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"isAutoplayed",value:function(){return this.player.autoplay()}},{key:"isFullscreen",value:function(){return this.player.isFullscreen()}},{key:"getPreload",value:function(){return this.player.preload()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,["adstart","adend","adskip","adsready","adserror","dispose"]),this.onDownload=this.onDownload.bind(this),this.onAdsready=this.onAdsready.bind(this),this.onAdStart=this.onAdStart.bind(this),this.onAdEnd=this.onAdEnd.bind(this),this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onAbort=this.onAbort.bind(this),this.onEnded=this.onEnded.bind(this),this.onDispose=this.onDispose.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onError=this.onError.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onTimeupdate=this.onTimeupdate.bind(this),this.OnAdsAllpodsCompleted=this.OnAdsAllpodsCompleted.bind(this),this.onStreamManager=this.onStreamManager.bind(this),this.player.on("loadstart",this.onDownload),this.player.on("loadeddata",this.onDownload),this.player.on("loadedmetadata",this.onDownload),this.player.on("adsready",this.onAdsready),this.player.on("adstart",this.onAdStart),this.player.on("adend",this.onAdEnd),this.player.on("play",this.onPlay),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("abort",this.onAbort),this.player.on("ended",this.onEnded),this.player.on("dispose",this.onDispose),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("error",this.onError),this.player.on("waiting",this.onWaiting),this.player.on("timeupdate",this.onTimeupdate),this.player.on("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.on("stream-manager",this.onStreamManager)}},{key:"unregisterListeners",value:function(){this.player.off("loadstart",this.onDownload),this.player.off("loadeddata",this.onDownload),this.player.off("loadedmetadata",this.onDownload),this.player.off("adsready",this.onAdsready),this.player.off("adstart",this.onAdStart),this.player.off("adend",this.onAdEnd),this.player.off("play",this.onPlay),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("abort",this.onAbort),this.player.off("ended",this.onEnded),this.player.off("dispose",this.onDispose),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("error",this.onError),this.player.off("waiting",this.onWaiting),this.player.off("timeupdate",this.onTimeupdate),this.player.off("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.off("stream-manager",this.onStreamManager)}},{key:"onDownload",value:function(t){this.sendDownload({state:t.type}),!this.adsTracker&&"loadstart"===t.type&&p.default.isUsing(this.player)&&(console.log("VideojsTracker: Creating MediaTailorAdsTracker after source load"),this.setAdsTracker(new p.default(this.player,this.options)),this.adsTracker.setIsAd(!1))}},{key:"onStreamManager",value:function(t){if(!this.adsTracker&&t.StreamManager){var e=new f.default(this.player);e.setStreamManager(t.StreamManager),this.setAdsTracker(e)}}},{key:"onAdsready",value:function(){this.adsTracker||(c.default.isUsing(this.player)?this.setAdsTracker(new c.default(this.player)):d.default.isUsing(this.player)?this.setAdsTracker(new d.default(this.player)):h.default.isUsing(this.player)?this.setAdsTracker(new h.default(this.player)):this.setAdsTracker(new u.default(this.player)))}},{key:"onAdStart",value:function(){var t;this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=null===(t=this.player)||void 0===t||null===(t=t.ima)||void 0===t?void 0:t.getAdsManager().getCuePoints())}},{key:"onAdEnd",value:function(){this.isContentEnd&&this.sendEnd()}},{key:"OnAdsAllpodsCompleted",value:function(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}},{key:"isAdsTrackerActive",value:function(){return this.adsTracker&&this.adsTracker.isAd&&this.adsTracker.isAd()}},{key:"onPlay",value:function(){this.sendRequest()}},{key:"onPause",value:function(){this.isAdsTrackerActive()||this.player.ended()||this.sendPause()}},{key:"onPlaying",value:function(){this.isAdsTrackerActive()||(this.sendResume(),this.sendBufferEnd())}},{key:"onAbort",value:function(){this.sendEnd()}},{key:"onEnded",value:function(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}},{key:"onDispose",value:function(){this.sendEnd()}},{key:"onSeeking",value:function(){this.isAdsTrackerActive()||this.sendSeekStart()}},{key:"onSeeked",value:function(){this.isAdsTrackerActive()||this.sendSeekEnd()}},{key:"onError",value:function(){var t=this.player.error(),e=t.code,r=t.message;this.player.error&&this.player.error()&&this.sendError({errorCode:e,errorMessage:r})}},{key:"onWaiting",value:function(t){this.isAdsTrackerActive()||this.sendBufferStart()}},{key:"onTimeupdate",value:function(t){this.getPlayhead()>.1&&this.sendStart()}}],m&&y(r.prototype,m),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,m}(n.default.VideoTracker)},324:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TRACKING_API_TIMEOUT_MS=e.STREAM_TYPE=e.SCTE35_SCHEME_MARKER=e.REGEX_TRACKING_PATH_SEGMENT=e.REGEX_SESSION_ID=e.REGEX_MAP=e.REGEX_MANIFEST_FILE_SUFFIX=e.REGEX_ISO_8601_DURATION=e.REGEX_HLS_TARGET_DURATION=e.REGEX_DISCONTINUITY=e.REGEX_DASH_MINIMUM_UPDATE_PERIOD=e.REGEX_CUE_OUT=e.QUARTILES=e.POST_AD_PAUSE_THRESHOLD=e.MT_SEGMENT_PATTERN=e.MT_HLS_CUE_OUT_TAG=e.MT_HLS_CUE_IN_TAG=e.MIN_AD_DURATION=e.MEDIATAILOR_HOST_MARKER=e.MANIFEST_TYPE=e.HLS_TAG_PREFIX=e.HLS_SEGMENT_DURATION_TAG=e.HLS_MIME_TYPE=e.HLS_MANIFEST_EXTENSION=e.DEFAULT_LIVE_POLL_INTERVAL_MS=e.DASH_SCTE35_EVENT_STREAM_SELECTOR=e.DASH_MANIFEST_EXTENSION=e.AD_TIMING_TOLERANCE=e.AD_SOURCE=e.AD_POSITION=void 0,e.REGEX_CUE_OUT=/#EXT-X-CUE-OUT:DURATION=([\d.]+)/,e.REGEX_DISCONTINUITY=/#EXT-X-DISCONTINUITY/,e.REGEX_MAP=/#EXT-X-MAP:URI="([^"]+)"/,e.REGEX_SESSION_ID=/sessionId=([^&]+)/,e.REGEX_TRACKING_PATH_SEGMENT=/\/v1\/(master|session|dash)\//,e.REGEX_MANIFEST_FILE_SUFFIX=/\/[^/]*\.(m3u8|mpd).*$/,e.REGEX_HLS_TARGET_DURATION=/#EXT-X-TARGETDURATION:(\d+)/,e.REGEX_DASH_MINIMUM_UPDATE_PERIOD=/minimumUpdatePeriod="([^"]+)"/,e.REGEX_ISO_8601_DURATION=/PT(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?/,e.HLS_MANIFEST_EXTENSION=".m3u8",e.DASH_MANIFEST_EXTENSION=".mpd",e.MEDIATAILOR_HOST_MARKER=".mediatailor.",e.MT_HLS_CUE_OUT_TAG="#EXT-X-CUE-OUT",e.MT_HLS_CUE_IN_TAG="#EXT-X-CUE-IN",e.HLS_SEGMENT_DURATION_TAG="#EXTINF:",e.HLS_TAG_PREFIX="#",e.SCTE35_SCHEME_MARKER="scte35",e.DASH_SCTE35_EVENT_STREAM_SELECTOR='EventStream[schemeIdUri*="scte35"], EventStream[schemeIdUri*="SCTE35"]',e.HLS_MIME_TYPE="application/vnd.apple.mpegurl",e.MT_SEGMENT_PATTERN="segments.mediatailor",e.TRACKING_API_TIMEOUT_MS=5e3,e.DEFAULT_LIVE_POLL_INTERVAL_MS=5e3,e.MIN_AD_DURATION=.5,e.AD_TIMING_TOLERANCE=.5,e.POST_AD_PAUSE_THRESHOLD=500,e.STREAM_TYPE={VOD:"vod",LIVE:"live"},e.MANIFEST_TYPE={HLS:"hls",DASH:"dash"},e.AD_POSITION={PRE_ROLL:"pre",MID_ROLL:"mid",POST_ROLL:"post"},e.AD_SOURCE={MANIFEST_CUE:"manifest-cue",VHS_DISCONTINUITY:"vhs-discontinuity",TRACKING_API:"tracking-api",MANIFEST_AND_TRACKING:"manifest+tracking",DASH_EMSG:"dash-emsg",DASH_EVENT_STREAM:"dash-event-stream"},e.QUARTILES={Q1:.25,Q2:.5,Q3:.75}},330:t=>{t.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.1.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","@newrelic/newrelic-oss-cli":"^0.1.2","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^12.0.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^10.0.3","@semantic-release/npm":"^12.0.0","@semantic-release/release-notes-generator":"^13.0.0","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","semantic-release":"^23.0.8","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.1.5"}}')},338:(t,e)=>{function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,a(i.key),i)}}function a(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.shakaPlayer,this.player=e.el().player},e=[{key:"getSrc",value:function(t){try{return this.tech.getManifestUri()}catch(t){}return null}},{key:"getRenditionBitrate",value:function(t){try{var e=this.tech.getStats().streamBandwidth;return e?Math.round(e):null}catch(t){}return null}},{key:"getManifestBitrate",value:function(){try{var t=this.tech.getVariantTracks();if(t&&t.length>0)return Math.round(Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t.map((function(t){return t.videoBandwidth+(t.audioBandwidth||0)})))))}catch(t){}return null}},{key:"getRenditionWidth",value:function(t){try{var e=this.tech.getVariantTracks();for(var r in e){var i=e[r];if(i.active&&"video"===i.type)return i.width}}catch(t){}return null}},{key:"getRenditionHeight",value:function(t){try{var e=this.tech.getVariantTracks();for(var r in e){var i=e[r];if(i.active&&"video"===i.type)return i.height}}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.getStats();if(t&&t.streamBandwidth&&t.streamBandwidth>0)return Math.round(t.streamBandwidth)}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return Math.round(t.estimatedBandwidth)}catch(t){}return null}},{key:"getNetworkDownloadBitrate",value:function(){try{var t=this.tech.getStats();if(t&&t.estimatedBandwidth>0)return Math.round(t.estimatedBandwidth)}catch(t){}return null}}],e&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.shakaPlayer}},409:(t,e)=>{function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,a(i.key),i)}}function a(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,(e.default=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tech=e.vhs,this.player=e.el().player},(e=[{key:"getRenditionName",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return t.attributes.NAME}catch(t){}return null}},{key:"getRenditionBitrate",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes)return Math.round(t.attributes.BANDWIDTH)}catch(t){}return null}},{key:"getRenditionWidth",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.width}catch(t){}return null}},{key:"getRenditionHeight",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes&&t.attributes.RESOLUTION)return t.attributes.RESOLUTION.height}catch(t){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getManifestBitrate",value:function(){try{var t=this.tech.playlists.master.playlists;if(t&&t.length>0)return Math.round(Math.max.apply(Math,function(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t.map((function(t){return t.attributes.BANDWIDTH})))))}catch(t){}return null}},{key:"getSegmentDownloadBitrate",value:function(){var t;return void 0!==(null===(t=this.tech.stats)||void 0===t?void 0:t.bandwidth)&&this.tech.stats.bandwidth>0?Math.round(this.tech.stats.bandwidth):null}},{key:"getNetworkDownloadBitrate",value:function(){return void 0!==this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}},{key:"getContentBitratePlayback",value:function(){try{var t=this.tech.playlists.media();if(t&&t.attributes){var e=t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH||null;return null!==e?Math.round(e):null}}catch(t){}return null}}])&&n(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()).isUsing=function(t){return!!t.vhs}},472:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=u(r(555)),a=u(r(330)),s=u(r(409)),o=u(r(257)),l=u(r(338));function u(t){return t&&t.__esModule?t:{default:t}}function d(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,c(i.key),i)}}function c(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(h=function(){return!!t})()}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}e.default=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=f(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,h()?Reflect.construct(e,r||[],f(t).constructor):e.apply(t,r))}(this,e,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}(e,t),r=e,(u=[{key:"getTech",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(t){if(s.default.isUsing(t))return new s.default(t);if(o.default.isUsing(t))return new o.default(t);if(l.default.isUsing(t))return new l.default(t)}}},{key:"getTrackerName",value:function(){return"videojs-ads"}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getRenditionHeight",value:function(){return null}},{key:"getRenditionWidth",value:function(){return null}},{key:"getPlayerName",value:function(){return"videojs-ads"}},{key:"getPlayerVersion",value:function(){return this.player.ads.VERSION}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ads-request","ads-load","adstart","adend","adskip","adserror","ads-click","ads-pod-started","ads-pod-ended","ads-first-quartile","ads-midpoint","ads-third-quartile","ads-pause","ads-play","adtimeout"]),this.player.on("ads-request",this.onAdrequest.bind(this)),this.player.on("ads-load",this.onAdload.bind(this)),this.player.on("adstart",this.onAdstart.bind(this)),this.player.on("adend",this.onAdend.bind(this)),this.player.on("adskip",this.onAdskip.bind(this)),this.player.on("adserror",this.onAdserror.bind(this)),this.player.on("ads-click",this.onAdsClick.bind(this)),this.player.on("ads-pod-started",this.onPodStart.bind(this)),this.player.on("ads-pod-ended",this.onPodEnd.bind(this)),this.player.on("ads-first-quartile",this.onFirstQuartile.bind(this)),this.player.on("ads-midpoint",this.onMidpoint.bind(this)),this.player.on("ads-third-quartile",this.onThirdQuartile.bind(this)),this.player.on("ads-pause",this.onAdspause.bind(this)),this.player.on("ads-play",this.onAdsplay.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ads-request",this.onAdrequest),this.player.off("ads-load",this.onAdload),this.player.off("adstart",this.onAdstart),this.player.off("adend",this.onAdend),this.player.off("adskip",this.onAdskip),this.player.off("adserror",this.onAdserror),this.player.off("ads-click",this.onAdsClick),this.player.off("ads-pod-started",this.onPodStart),this.player.off("ads-pod-ended",this.onPodEnd),this.player.off("ads-first-quartile",this.onFirstQuartile),this.player.off("ads-midpoint",this.onMidpoint),this.player.off("ads-third-quartile",this.onThirdQuartile),this.player.off("ads-pause",this.onAdspause),this.player.off("ads-play",this.onAdsplay)}},{key:"onAdrequest",value:function(t){this.sendRequest(),this.sendDownload({state:"ads-request"})}},{key:"onAdload",value:function(t){this.sendDownload({state:"ads-load"})}},{key:"onAdstart",value:function(t){this.sendRequest(),this.sendStart()}},{key:"onAdend",value:function(t){this.sendEnd()}},{key:"onAdskip",value:function(t){this.sendEnd({skipped:!0})}},{key:"onAdserror",value:function(t){this.sendError()}},{key:"onAdsClick",value:function(t){this.sendAdClick({url:"unknown"})}},{key:"onPodStart",value:function(t){this.sendAdBreakStart()}},{key:"onPodEnd",value:function(t){this.sendAdBreakEnd()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({quartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({quartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({quartile:3})}},{key:"onAdspause",value:function(){this.sendPause()}},{key:"onAdsplay",value:function(){this.sendResume()}}])&&d(r.prototype,u),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,u}(n.default.VideoTracker)},555:(t,e,r)=>{r.r(e),r.d(e,{default:()=>R});var i={487(t,e,r){r.r(e),r.d(e,{videoAnalyticsHarvester:()=>l});var i=r(374),n=r(431),a=r(51),s=r(144),o=r(302);const l=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)s.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new n.t,this.harvestScheduler=new i.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,s.A.notice("Video analytics agent initialized successfully")}catch(t){s.A.error("Failed to initialize video analytics agent:",t.message)}}addEvent(t){this.isInitialized||(s.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return t.actionName&&t.actionName===o.A.Events.QOE_AGGREGATE?t.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,t.viewId,t):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,t):this.eventBuffer.add(t)}catch(t){return s.A.error("Failed to add event to harvesting system:",t.message),!1}}setHarvestInterval(t){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(t)}forceNextQoeCycle(){this.harvestScheduler&&(this.harvestScheduler.forceNextQoeCycle=!0)}setBeforeDrainCallback(t){this.harvestScheduler&&(this.harvestScheduler.beforeDrainCallback=t)}refreshQoeKpis(t,e){if(!this.eventBuffer||!t)return;const r=e?this.eventBuffer.findByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e):this.eventBuffer.findByActionName(o.A.Events.QOE_AGGREGATE);if(r){const i={...r};for(const e of a.A.QOE_KPI_KEYS)e in t&&(i[e]=t[e]);e?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e,i):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,i)}}}},455(t,e,r){r.d(e,{A:()=>n});class i{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 i;return t.startTime=this.startTime,t.stopTime=this.stopTime,t.offset=this.offset,t.accumulator=this.accumulator,t}}const n=i},51(t,e,r){r.d(e,{A:()=>n});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,i.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],i.QOE_AGGREGATE_KEYS=["coreVersion","instrumentation.name","instrumentation.provider","instrumentation.version","isBackgroundEvent","playerName","playerVersion","src","viewId","viewSession","contentIsAutoplayed","contentIsMuted","contentRenditionHeight","contentRenditionWidth","contentSrc","numberOfVideos","pageUrl","trackerName","trackerVersion","contentDuration","contentPlayrate","contentPlayhead","contentPreload","elapsedTime","contentTitle","contentId","contentIsLive","deviceType","deviceGroup","deviceManufacturer","deviceModel","deviceName","deviceSize","deviceUuid","contentRenditionName","contentIsFullscreen","contentCdn","contentFps","asnOrganization","asnLongitude","asnLatitude","asn","timeSinceRequested","timeSinceStarted"];const n=i},568(t,e,r){r.d(e,{A:()=>i});const i=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 r=this._listeners[t].indexOf(e);-1!==r&&this._listeners[t].splice(r,1)}return this}emit(t,e,r){return this._listeners=this._listeners||{},r=r||{},Array.isArray(this._listeners[e])&&this._listeners[e].forEach((i=>{i.call(this,{eventType:t,type:e,data:r,target:this})})),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach((i=>{i.call(this,{eventType:t,type:e,data:r,target:this})})),this}}},431(t,e,r){r.d(e,{t:()=>l});var i=r(144),n=r(51),a=r(347);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=n.A;class l{constructor(){this.buffer=[],this.maxPayloadSize=s,this.maxEventsPerBatch=o,this.currentPayloadSize=0,this.totalEvents=0,this.smartHarvestPayloadThreshold=Math.floor(.6*this.maxPayloadSize),this.overflowPayloadThreshold=Math.floor(.9*this.maxPayloadSize),this.smartHarvestEventThreshold=Math.floor(.6*this.maxEventsPerBatch),this.overflowEventThreshold=Math.floor(.9*this.maxEventsPerBatch),this.onSmartHarvestTrigger=null}addOrReplaceByActionName(t,e){const r=this.buffer.findIndex((e=>e.actionName===t));try{return-1===r?this.add(e):this.add(e,r),!0}catch(t){return i.A.error("Failed to set or replace the event to buffer:",t.message),!1}}addOrReplaceByActionNameAndViewId(t,e,r){const n=this.buffer.findIndex((r=>r.actionName===t&&r.viewId===e));try{return-1===n?this.add(r):this.add(r,n),!0}catch(t){return i.A.error("Failed to set or replace the event to buffer:",t.message),!1}}findByActionNameAndViewId(t,e){return this.buffer.find((r=>r.actionName===t&&r.viewId===e))||null}findByActionName(t){return this.buffer.find((e=>e.actionName===t))||null}add(t,e){try{const r=(0,a.Q3)(t),i=this.currentPayloadSize+r>=this.maxPayloadSize,n=this.totalEvents+1>=this.maxEventsPerBatch;if((i||n)&&this.makeRoom(r),null!=e&&e>-1){const i=(0,a.Q3)(this.buffer[e]);this.buffer[e]=t,this.currentPayloadSize+=r-i}else this.buffer.push(t),this.totalEvents++,this.currentPayloadSize+=r;return this.checkSmartHarvestTrigger(),!0}catch(t){return i.A.error("Failed to add event to buffer:",t.message),!1}}checkSmartHarvestTrigger(){const t=this.currentPayloadSize/this.maxPayloadSize,e=this.totalEvents/this.maxEventsPerBatch,r=this.currentPayloadSize>=this.overflowPayloadThreshold,n=this.totalEvents>=this.overflowEventThreshold;if(r||n){const n=r?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*t)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*e)}%)`;i.A.warn(`OVERFLOW PREVENTION: ${n} - Emergency harvest triggered`),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{const t=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,e=this.totalEvents>=this.smartHarvestEventThreshold;(t||e)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}setSmartHarvestCallback(t){this.onSmartHarvestTrigger=t}drain(){try{const t=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,t}catch(t){return i.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)i.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,i.A.warn("Event buffer full, oldest event removed.")}}}},374(t,e,r){r.d(e,{n:()=>d});var i=r(431),n=r(413),a=r(481),s=r(347),o=r(51),l=r(302),u=r(144);class d{constructor(t){this.eventBuffer=t,this.retryQueueHandler=new n.u,this.httpClient=new a.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof i.t&&this.eventBuffer.setSmartHarvestCallback(((t,e)=>this.triggerSmartHarvest(t,e))),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=o.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?u.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,u.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),u.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(t,e){if(u.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){u.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){u.A.error("Error during scheduled harvest:",t.message)}finally{this.scheduleNextHarvest()}}async triggerHarvest(t={}){if(this.isHarvesting)return{success:!1,reason:"harvest_in_progress"};this.isHarvesting=!0;try{let e=this.drainEvents(t);if(t.isFinalHarvest){const t=o.A.MAX_BEACON_SIZE;(0,s.Q3)(e)>t&&(e=this.trimEventsToFit(e,t))}const r=await this.sendChunk(e,t,!0);return{success:r.success,totalChunks:1,results:[r]}}catch(t){return u.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 r=[];let i=0;for(let n=t.length-1;n>=0;n--){const a=t[n],o=(0,s.Q3)({ins:[a,...r]});o>e||(r.unshift(a),i=o)}const n=t.length-r.length;if(n>0){const a=t.slice(0,n);u.A.warn(`Discarded ${n} events to fit beacon size limit`,{originalCount:t.length,trimmedCount:r.length,finalSize:i,maxSize:e}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(a)}return r}drainEvents(t={}){const e=window.NRVIDEO?.config?.qoeIntervalFactor??1,r=!!t.isFinalHarvest||this.forceNextQoeCycle,i=(this.qoeCycleCount-1)%e==0||r;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(t){u.A.error("Before drain callback failed:",t.message)}const n=this.eventBuffer.drain();let a;if(i)a=n;else{a=[];for(const t of n)t.actionName===l.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===l.A.Events.QOE_AGGREGATE&&(!r&&this._qoeKpisUnchanged(e)?a.splice(t,1):this._saveQoeKpis(e))}let d=[...a],c=(0,s.Q3)(a);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const t=o.A.MAX_PAYLOAD_SIZE-c,e=o.A.MAX_EVENTS_PER_BATCH-d.length;if(t>0&&e>0){const r=this.retryQueueHandler.getRetryEventsToFit(t,e);r.length>0&&(d=[...r,...d])}}return d}async sendChunk(t,e,r){const i={url:(0,s.c$)(this.fallBackUrl),payload:{body:{ins:t}},options:{...e,isLastChunk:r}};return new Promise((e=>{this.httpClient.send(i,(r=>{r.retry?this.handleRequestFailure(t):(this.retryCount=0,this.fallBackUrl=""),e({success:!r.retry,status:r.status,error:r.error,chunk:t,eventCount:t.length})}))}))}handleRequestFailure(t){this.retryQueueHandler.addFailedEvents(t),"US"===window.NRVIDEO?.info?.region&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=o.A.COLLECTOR.US[1]))}handleHarvestFailure(t){this.consecutiveFailures++,u.A.warn("Harvest failure handled",{error:t.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(t){"number"!=typeof t&&isNaN(t)?u.A.warn("Invalid newInterval provided to updateHarvestInterval"):t<1e3||t>3e5?u.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==t&&(this.harvestCycle=t,u.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 r of o.A.QOE_KPI_KEYS)if(t[r]!==e[r])return!1;return!0}_saveQoeKpis(t){const e={};for(const r of o.A.QOE_KPI_KEYS)e[r]=t[r];this._lastSentQoeKpis[t.viewId]=e}}},144(t,e,r){r.d(e,{A:()=>o});class i{static error(...t){n(t,i.Levels.ERROR,"darkred")}static warn(...t){n(t,i.Levels.WARNING,"darkorange")}static notice(...t){n([].slice.call(arguments),i.Levels.NOTICE,"darkcyan")}static debug(...t){n(t,i.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(t,e,r){try{if(i.level<=i.Levels.DEBUG){r=r||function(t){i.debug("Event: "+t.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];e&&(null===e[0]?(e.shift(),n=e):n=n.concat(e));for(var a=0;a<n.length;a++)"function"==typeof t?t.call(window,n[a],r):t.on?t.on(n[a],r):t.addEventListener?t.addEventListener(n[a],r):t.addEventHandler?t.addEventHandler(n[a],r):i.warn("debugCommonVideoEvents: No common listener function found for ",t)}}catch(t){i.warn(t)}}}function n(t,e,r){e=e||i.Levels.NOTICE,r=r||"darkcyan";var n,o,l=i.prefix;i.includeTime&&(l+="["+("0"+(n=new Date).getDate()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+"] "),l+=function(t){return s[t]}(e)+":",i.level<=e&&e!==i.Levels.SILENT&&(!i.colorful||"undefined"!=typeof document&&document.documentMode?a(t,l):(o=e===i.Levels.ERROR&&console.error?console.error:e===i.Levels.WARNING&&console.warn?console.warn:e===i.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,l="%c"+l,t.splice(0,0,l,"color: "+r),o.apply(console,t)))}function a(t,e){if(t instanceof Array)for(var r in t)a(t[r],e);else"string"==typeof t?console.log(e+" "+t):(console.log(e+"↵"),console.log(t))}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 s={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var t=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==t&&("true"===t[1]?i.level=i.Levels.ALL:i.level=t[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(i.colorful=!1)}}();const o=i},481(t,e,r){r.d(e,{X:()=>a});var i=r(347),n=r(144);class a{async send(t,e){const{url:r,payload:i,options:a={}}=t;try{if(!r||!i)throw new Error("URL and payload are required");const t={url:r,payload:i,options:a,callback:e};await this.executeRequest(t)}catch(t){n.A.error("Failed to send request:",t.message),e({retry:!1,status:0,error:t.message})}}async executeRequest(t){const{url:e,payload:r,options:i,callback:a}=t,s=Date.now();try{const a=(o=JSON.stringify(r.body),l=window.NRVIDEO?.config?.obfuscate,l&&0!==l.length?l.reduce(((t,e)=>{let r;try{if(e.regex instanceof RegExp){const t=e.regex.flags.includes("g")?e.regex.flags:e.regex.flags+"g";r=new RegExp(e.regex.source,t)}else r=new RegExp(e.regex,"g")}catch(r){return n.A.warn("applyObfuscationRules: invalid regex, skipping rule:",e.regex,r.message),t}return t.replace(r,e.replacement)}),o):o);if(i.isFinalHarvest&&navigator.sendBeacon){const r=await this.sendWithBeacon(e,a),i={success:r,status:r?204:0};return void this.handleRequestComplete(t,i,s)}const u=await this.fetchWithTimeout(e,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:i.isFinalHarvest},1e4),d={success:u.ok,status:u.status,statusText:u.statusText};this.handleRequestComplete(t,d,s)}catch(e){const r={success:!1,status:0,error:e.message};this.handleRequestComplete(t,r,s)}var o,l}handleRequestComplete(t,e){const{callback:r}=t;r({retry:!e.success&&(0===e.status||(0,i.Sc)(e.status)),status:e.status,error:e.error})}async sendWithBeacon(t,e){try{return navigator.sendBeacon(t,e)}catch(t){return n.A.warn("sendBeacon failed, falling back to fetch:",t.message),!1}}async fetchWithTimeout(t,e,r){const i=new AbortController,n=setTimeout((()=>i.abort()),r);try{const r=await fetch(t,{...e,signal:i.signal});return clearTimeout(n),r}catch(t){if(clearTimeout(n),"AbortError"===t.name)throw new Error(`Request timeout after ${r}ms`);throw t}}}},413(t,e,r){r.d(e,{u:()=>l});var i=r(144),n=r(347),a=r(51);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=a.A;class l{constructor(){this.retryQueue=[],this.maxQueueSize=o,this.maxQueueSizeBytes=s}addFailedEvents(t){try{const e=Array.isArray(t)?t:[t];i.A.notice(`Adding ${e.length} failed events to retry queue`,{queueSizeBefore:this.retryQueue.length});for(const t of e){this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();const e=(0,n.Q3)(t);for(;(0,n.Q3)(this.retryQueue)+e>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...t})}}catch(t){i.A.error("Failed to add events to retry queue:",t.message)}}discardEvent(t,e){i.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 r=[];let i=0,a=0;for(let s=this.retryQueue.length-1;s>=0;s--){const o=this.retryQueue[s];if(a>=e)break;const l=(0,n.Q3)(o);if(i+l>t)break;r.unshift(o),i+=l,a++,this.retryQueue.splice(s,1)}return r}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(t,e,r){r.d(e,{A:()=>d});var i=r(330),n=r(568),a=r(455),s=r(51),o=r(487),l=r(144);class u extends n.A{constructor(t){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new a.A,this._trackerReadyChrono.start(),this._actionTable=s.A.ACTION_TABLE,this._actionAdTable=s.A.ACTION_AD_TABLE,t=t||{},this.setOptions(t)}setOptions(t){t&&(t.parentTracker&&(this.parentTracker=t.parentTracker),t.customData&&(this.customData=t.customData),t.heartbeat&&(this.heartbeat=t.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(t){this.sendVideoAction(u.Events.HEARTBEAT,t)}getAttributes(t,e){(t=t||{}).trackerName=this.getTrackerName(),t.trackerVersion=this.getTrackerVersion(),t.coreVersion=i.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 i.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 r=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",t,this.getAttributes(e,r))}sendVideoCustomAction(t,e){this.emit("VideoCustomAction",t,this.getAttributes(e,"customAction"))}setHarvestInterval(t){if(o.videoAnalyticsHarvester)try{o.videoAnalyticsHarvester.setHarvestInterval(t)}catch(t){return void l.A.error("Failed to set harvest interval:",t.message)}else l.A.error("VideoAnalyticsHarvester is not available")}}u.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const d=u},347(t,e,r){r.d(e,{Q3:()=>s,Sc:()=>o,c$:()=>a,z8:()=>l});var i=r(330),n=r(144);function a(t){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:e,licenseKey:r,applicationID:n}=window.NRVIDEO.info;if(!e||!r)throw new Error("Options object provided by New Relic is not correctly initialized");return n?`https://${t||e}/ins/1/${r}?a=${n}&v=${i.rE}&ref=${window.location.href}&ca=VA`:`https://${t||e}/ins/1/${r}?&v=${i.rE}&ref=${window.location.href}&ca=VA`}catch(t){return console.error(t.message),null}}function s(t){if("string"==typeof t&&t.length)return t.length;if("object"==typeof t){if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&t.byteLength)return t.byteLength;if("undefined"!=typeof Blob&&t instanceof Blob&&t.size)return t.size;if(!("undefined"!=typeof FormData&&t instanceof FormData))try{return function(t){try{return JSON.stringify(t,(()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}})())??""}catch(t){return n.A.error("Error stringifying value:",t.message),""}}(t).length}catch(t){return}}}function o(t){switch(t){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return t>=502&&t<=504||t>=512&&t<=530}function l(t,e){return t&&Array.isArray(t)&&0!==t.length?e&&"object"==typeof e?t.reduce(((t,r)=>(r in e&&(t[r]=e[r]),t)),{}):{}:e}},330(t){t.exports={rE:"4.1.5"}}},n={};function a(t){var e=n[t];if(void 0!==e)return e.exports;var r=n[t]={exports:{}};return i[t](r,r.exports,a),r.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s=a(144),o=a(487),l=a(51),u=a(302),d=a(347);function c(t,e={}){try{if(!l.A.VALID_EVENT_TYPES.includes(t))return s.A.warn("Invalid event type provided to recordEvent",{eventType:t}),!1;if(!window?.NRVIDEO?.info)return;const{appName:r,applicationID:i}=window.NRVIDEO.info,{qoe:n,...a}=e,c=n?{...n}:{},h={...i?{}:{appName:r},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},f={...a,eventType:t,...h},p=(0,d.z8)(l.A.QOE_AGGREGATE_KEYS,e);let m=null;"VideoAction"===t&&(m={eventType:"VideoAction",actionName:u.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...c,...p,...h});const g=o.videoAnalyticsHarvester.addEvent(f);if(m&&window?.NRVIDEO?.config?.qoeAggregate){const t=o.videoAnalyticsHarvester.addEvent(m);return g&&t}return g}catch(t){return s.A.error("Failed to record event:",t.message),!1}}const{COLLECTOR:h}=l.A,f=new class{setConfiguration(t,e){return!!this.validateRequiredFields(t)&&!!this.validateConfigFields(e)&&(this.initializeGlobalConfig(t,e),s.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(t){if(!t||"object"!=typeof t)return s.A.error("Configuration must be an object"),!1;const{licenseKey:e,appName:r,region:i,applicationID:n,beacon:a}=t;if(!e)return s.A.error("licenseKey is required"),!1;if(n){if(!a)return s.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(h).flatMap((t=>t)).includes(a))return s.A.error(`Invalid beacon: ${a}`),!1}else{if(!r||!i)return s.A.error("appName and region are required when applicationID is not provided"),!1;if(!h[i])return s.A.error(`Invalid region: ${i}. Valid regions are: ${Object.keys(h).join(", ")}`),!1}return!0}validateConfigFields(t){if(null==t)return!0;if("object"!=typeof t||Array.isArray(t))return s.A.error("config must be an object"),!1;const{qoeAggregate:e,obfuscate:r}=t;return void 0!==e&&"boolean"!=typeof e?(s.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==r&&!Array.isArray(r)&&(s.A.error("obfuscate must be an array"),1))}filterObfuscateRules(t){return t?t.filter((t=>{const e=void 0!==t.regex&&("string"==typeof t.regex||t.regex instanceof RegExp),r=void 0!==t.replacement&&"string"==typeof t.replacement;return!(!e||!r)||(s.A.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",t),!1)})):[]}sanitizeQoeIntervalFactor(t){return null==t?1:"number"==typeof t&&Number.isInteger(t)&&t>=1?t:(console.warn(`[nrvideo] Invalid qoeIntervalFactor "${t}" — must be a positive integer. Defaulting to 1.`),1)}initializeGlobalConfig(t,e){let{licenseKey:r,appName:i,region:n,beacon:a,applicationID:s}=t;a="US"===n?l.A.COLLECTOR.US[0]:a||h[n],window.NRVIDEO={info:{...n?{region:n}:{},beacon:a,licenseKey:r,applicationID:s,...s?{}:{appName:i}},config:{qoeAggregate:e?.qoeAggregate??!1,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(e?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(e?.obfuscate)}}}};class p{static addTracker(t,e){var r,i;e?.info&&(r=e.info,i=e?.config,f.setConfiguration(r,i)),t.on&&t.emit?(m.push(t),t.on("*",g),"function"==typeof t.trackerInit&&t.trackerInit()):s.A.error("Tried to load a non-tracker.",t)}static removeTracker(t){t.off("*",g),t.dispose();let e=m.indexOf(t);-1!==e&&m.splice(e,1)}static getTrackers(){return m}static send(t,e,r){return c(t,{actionName:e,...r})}static sendError(t){return c("VideoErrorAction",{actionName:"ERROR",...t})}static async forceHarvest(){try{const{videoAnalyticsHarvester:t}=a(487);return await t.forceHarvest()}catch(t){return s.A.error("Failed to force harvest:",t.message),{success:!1,error:t.message}}}}let m=[];function g(t){try{let e=function(t){let e={};for(let r in t)null!==t[r]&&void 0!==t[r]&&(e[r]=t[r]);return e}(t.data);s.A.level<=s.A.Levels.DEBUG?s.A.notice("Sent",t.type,e):s.A.notice("Sent",t.type),p.send(t.eventType,t.type,e)}catch(t){s.A.error("Error in event handler:",t.message)}}const y=p;var v=a(455),A=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 v.A,this.timeSinceStarted=new v.A,this.timeSincePaused=new v.A,this.timeSinceSeekBegin=new v.A,this.timeSinceBufferBegin=new v.A,this.timeSinceAdBreakStart=new v.A,this.timeSinceLastDownload=new v.A,this.timeSinceLastHeartbeat=new v.A,this.timeSinceLastRenditionChange=new v.A,this.timeSinceLastAdQuartile=new v.A,this.timeSinceLastAd=new v.A,this.timeSinceLastError=new v.A,this.timeSinceLastAdError=new v.A,this.timeSinceResumed=new v.A,this.timeSinceSeekEnd=new v.A,this.playtimeSinceLastEvent=new v.A,this.customTimeSinceAttributes={},this.elapsedTime=new v.A,this.bufferElapsedTime=new v.A,this._totalAdPlaytime=new v.A}isAd(){return this._isAd}setIsAd(t){this._isAd=t}setTimeSinceAttribute(t){this.customTimeSinceAttributes[t]=new v.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,r]of Object.entries(this.customTimeSinceAttributes))t[e]=r.getDeltaTime();return t}getQoeAttributes(t){t=t||{};const e={};try{null!==this.startupTime&&(e.startupTime=this.startupTime),this.peakBitrate>0&&(e.peakBitrate=this.peakBitrate),e.hadStartupError=this.hadStartupError,e.hadPlaybackError=this.hadPlaybackError,e.totalRebufferingTime=this.totalRebufferingTime,e.rebufferingRatio=this.totalPlaytime>0?this.totalRebufferingTime/this.totalPlaytime*100:0,e.totalPlaytime=this.totalPlaytime,e.averageBitrate=this.weightedBitrate,e.numberOfErrors=this.numberOfErrors}catch(t){s.A.error("Failed to add attributes for QOE KPIs",t.message)}return t.qoe=e,t}calculateBufferType(t){let e="";return e=t?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",s.A.debug("Buffer Type = "+e),e}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}goPause(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}goResume(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),!this.isAd()&&this.initialBufferingHappened&&(this.totalRebufferingTime+=this.timeSinceBufferBegin.stopTime-this.timeSinceBufferBegin.startTime),0))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}goLastAd(){this.timeSinceLastAd.start()}trackContentBitrateState(t){if(t&&"number"==typeof t){this.peakBitrate=Math.max(this.peakBitrate,t);const e=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){const t=e-this._lastBitrateChangeTimestamp;t>0&&(this.partialAverageBitrate+=this._lastBitrate*t,this._totalBitrateDuration+=t),this._lastBitrateChangeTimestamp=null}return void(this._lastBitrate=t)}if(null===this._lastBitrateChangeTimestamp&&null!==this._lastBitrate&&(this._lastBitrateChangeTimestamp=e),null!==this._lastBitrate&&this._lastBitrate!==t&&null!==this._lastBitrateChangeTimestamp){const t=e-this._lastBitrateChangeTimestamp;t>0&&(this.partialAverageBitrate+=this._lastBitrate*t,this._totalBitrateDuration+=t),this._lastBitrateChangeTimestamp=e}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=e),this._lastBitrate=t;let r=this.partialAverageBitrate,i=this._totalBitrateDuration;const n=e-this._lastBitrateChangeTimestamp;n>0&&(r+=t*n,i+=n),this.weightedBitrate=i>0?Math.round(r/i):t}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){s.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return s.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return s.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(t){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-t,0))}};var E=a(330);class S extends u.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),s.A.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(t){this._userId=t}setOptions(t){t&&(t.adsTracker&&this.setAdsTracker(t.adsTracker),"boolean"==typeof t.isAd&&this.setIsAd(t.isAd),u.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("*",b.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",b),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,r=this.getHeartbeat()/1e3;t=Math.round(e/r*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,t||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(t){let e,r=this.getRenditionBitrate();return this.isAd()?(e=this._lastAdRendition,t&&(this._lastAdRendition=r)):(e=this._lastRendition,t&&(this._lastRendition=r)),r&&e?r>e?"up":r<e?"down":null:null}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 E.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=u.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,r){r=r||{},this.sendVideoCustomAction(t,r),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 r=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),r=this.adsTracker.state.totalAdTime()??0),this.state.setStartupTime(r),this.sendVideoAction(e,t),o.videoAnalyticsHarvester.setBeforeDrainCallback((()=>{if(this.state){const t=this.state.getQoeAttributes({}).qoe;o.videoAnalyticsHarvester.refreshQoeKpis(t,this.getViewId())}}))}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(t){if(this.state.goEnd()){let e;t=t||{},this.isAd()?(e=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()||(o.videoAnalyticsHarvester.forceNextQoeCycle(),o.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(t){if(this.state.goPause()){let e=this.isAd()?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||s.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,r=this.getHeartbeat();this.state._hb=!0,r=this.adjustElapsedTimeForPause(r),this.isAd()?(e=S.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(e,t):this.sendVideoAdAction(e,{elapsedTime:r,...t})):(e=S.Events.CONTENT_HEARTBEAT,this.sendVideoAction(e,{elapsedTime:r,...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||s.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||s.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(S.Events.AD_CLICK,t))}}function b(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 k=S;var _=a(431),D=a(413),P=a(481),I=a(374);const R={Constants:l.A,Chrono:v.A,Log:s.A,Emitter:A.A,Tracker:u.A,VideoTracker:k,VideoTrackerState:T,Core:y,version:E.rE,NrVideoEventAggregator:_.t,RetryQueueHandler:D.u,OptimizedHttpClient:P.X,HarvestScheduler:I.n,recordEvent:c}},612:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.buildTrackingEndpointUrl=function(t){var e=t.match(n.REGEX_SESSION_ID);if(!e)return null;var r=e[1];return t.replace(n.REGEX_TRACKING_PATH_SEGMENT,"/v1/tracking/").replace(n.REGEX_MANIFEST_FILE_SUFFIX,"/".concat(r))},e.calculateQuartiles=h,e.detectAdBreaksFromVhsPlaylist=function(t){var e=t.segments,r=t.discontinuityStarts||[],i=[],a=null,s=null,o=0;return e.forEach((function(t,e){var l=c(t),u=r.includes(e);if(l){u&&s&&(s.endTime=o,s.duration>n.MIN_AD_DURATION&&a.pods.push(s),s=null),a||(a={id:"avail-".concat(o),startTime:o,duration:0,endTime:null,source:"vhs-discontinuity",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}),s||(s={startTime:o,duration:0,endTime:null,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1});var d=t.duration||0;a.duration+=d,s.duration+=d}else a&&(s&&(s.endTime=o,s.duration>n.MIN_AD_DURATION&&a.pods.push(s),s=null),a.endTime=o,a.duration>n.MIN_AD_DURATION&&i.push(a),a=null);o+=t.duration||0})),a&&(s&&(s.endTime=o,s.duration>n.MIN_AD_DURATION&&a.pods.push(s)),a.endTime=o,a.duration>n.MIN_AD_DURATION&&i.push(a)),i},e.detectManifestFormatFromUrl=function(t){return t.includes(n.HLS_MANIFEST_EXTENSION)?n.MANIFEST_TYPE.HLS:t.includes(n.DASH_MANIFEST_EXTENSION)?n.MANIFEST_TYPE.DASH:n.MANIFEST_TYPE.HLS},e.detectPlaybackStreamType=function(t){return t===1/0?n.STREAM_TYPE.LIVE:n.STREAM_TYPE.VOD},e.determineAdPosition=function(t,e,r){return r===n.STREAM_TYPE.LIVE?null:0===t?n.AD_POSITION.PRE_ROLL:t===e-1?n.AD_POSITION.POST_ROLL:n.AD_POSITION.MID_ROLL},e.enrichAdScheduleWithTrackingMetadata=function(t,e){var r=new Map;t.forEach((function(t){var e=Math.round(t.startTime);r.set(e,t)}));var i=[];return e.forEach((function(t){var e=t.ads&&t.ads.length>0?t.ads[0]:null;if(e){var n=Math.round(e.startTimeInSeconds),a=r.get(n);a?(a.id=t.availId,a.creativeId=e.adId,a.title=e.adTitle,a.confirmedByTracking=!0,t.ads&&t.ads.length>0&&a.pods&&t.ads.forEach((function(t,e){a.pods[e]?(a.pods[e].title=t.adTitle,a.pods[e].creativeId=t.adId,a.pods[e].trackingStartTime=t.startTimeInSeconds,a.pods[e].trackingDuration=t.durationInSeconds):a.pods.push({startTime:t.startTimeInSeconds,duration:t.durationInSeconds,endTime:t.startTimeInSeconds+t.durationInSeconds,title:t.adTitle,creativeId:t.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1})}))):i.push({id:t.availId,startTime:e.startTimeInSeconds,duration:t.durationInSeconds,endTime:e.startTimeInSeconds+t.durationInSeconds,title:e.adTitle,creativeId:e.adId,source:"tracking-api",confirmedByTracking:!0,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:t.ads.map((function(t){return{startTime:t.startTimeInSeconds,duration:t.durationInSeconds,endTime:t.startTimeInSeconds+t.durationInSeconds,title:t.adTitle,creativeId:t.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1}}))})}})),i},e.extractDashMinimumUpdatePeriodSeconds=function(t){var e=t.match(n.REGEX_DASH_MINIMUM_UPDATE_PERIOD);return e?v(e[1]):null},e.extractHlsTargetDurationSeconds=function(t){var e=t.match(n.REGEX_HLS_TARGET_DURATION);return e?parseInt(e[1],10):null},e.extractMediaPlaylistUrl=function(t,e){var r,i=l(t.split("\n"));try{for(i.s();!(r=i.n()).done;){var a=r.value;if(!a.startsWith(n.HLS_TAG_PREFIX)&&a.includes(n.HLS_MANIFEST_EXTENSION))return new URL(a.trim(),e).href}}catch(t){i.e(t)}finally{i.f()}return null},e.fetchDashManifest=function(t){return y.apply(this,arguments)},e.fetchHlsMasterManifest=function(t){return m.apply(this,arguments)},e.fetchHlsMediaPlaylist=function(t){return g.apply(this,arguments)},e.findActiveAdBreak=function(t,e){return t.find((function(t){return e>=t.startTime&&e<t.endTime}))},e.findActivePod=function(t,e){return t&&t.pods&&0!==t.pods.length?t.pods.find((function(t){return e>=t.startTime&&e<t.endTime})):null},e.findAdBreakIndex=function(t,e){return t.findIndex((function(t){return Math.abs(t.startTime-e)<n.AD_TIMING_TOLERANCE}))},e.getQuartilesToFire=function(t,e,r){var i=h(e),n=[];return t>=i.q1&&!r.q1&&n.push({quartile:1,key:"q1"}),t>=i.q2&&!r.q2&&n.push({quartile:2,key:"q2"}),t>=i.q3&&!r.q3&&n.push({quartile:3,key:"q3"}),n},e.getTimestamp=function(){return(new Date).toISOString().substring(11,23)},e.getTrackingMetadata=function(t){return A.apply(this,arguments)},e.isMediaTailorSegment=c,e.isValidAdBreak=function(t){return t.duration>n.MIN_AD_DURATION},e.mergeAdSchedules=function(t,e){var r=new Map;t.forEach((function(t){var e=Math.round(t.startTime);r.set(e,t)}));var i=[];e.forEach((function(t){var e=Math.round(t.startTime),n=r.get(e);n?!n.confirmedByTracking&&t.confirmedByTracking&&Object.assign(n,t):(i.push(t),r.set(e,t))}));var n,a=[].concat(function(t){if(Array.isArray(t))return d(t)}(n=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||u(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i);return a.sort((function(t,e){return t.startTime-e.startTime})),a},e.parseDashManifestForAdBreaks=function(t){var e=(new DOMParser).parseFromString(t,"text/xml"),r=[],i=e.querySelector("parsererror");if(i)return console.error("[MT] DASH XML parse error:",i.textContent),r;var a=e.querySelectorAll("Period");if(console.log("[MT] Found ".concat(a.length," Period(s) in DASH manifest")),a.length>1)a.forEach((function(t){var e=t.querySelector("BaseURL");if((e?e.textContent.trim():"").includes(n.MT_SEGMENT_PATTERN)){var i=t.getAttribute("id")||"",a=v(t.getAttribute("start")||"PT0S"),s=v(t.getAttribute("duration")||"");s<n.MIN_AD_DURATION?console.log("[MT] Skipping period ".concat(i," - duration too short (").concat(s,"s)")):(console.log("[MT] Ad period detected: ".concat(i),{startTime:a,duration:s}),r.push({id:i,startTime:a,duration:s,endTime:a+s,source:n.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))}}));else{var s=e.querySelectorAll(n.DASH_SCTE35_EVENT_STREAM_SELECTOR);console.log("[MT] Found ".concat(s.length," SCTE-35 EventStream(s) in single-period manifest")),s.forEach((function(t){var e=parseFloat(t.getAttribute("timescale")||"1");t.querySelectorAll("Event").forEach((function(t){var i=parseFloat(t.getAttribute("presentationTime")||0),a=parseFloat(t.getAttribute("duration")||0),s=t.getAttribute("id")||"".concat(n.SCTE35_SCHEME_MARKER,"-").concat(i),o=1!==e?i/e:i,l=1!==e?a/e:a;l<n.MIN_AD_DURATION?console.log("[MT] Skipping event ".concat(s," - duration too short (").concat(l,"s)")):(console.log("[MT] SCTE-35 event detected: ".concat(s),{startTime:o,durationSeconds:l}),r.push({id:s,startTime:o,duration:l,endTime:o+l,source:n.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))}))}))}return console.log("[MT] Parsed ".concat(r.length," valid ad break(s) from DASH manifest")),r},e.parseHlsManifestForAdBreaks=function(t){var e,r=[],i=0,a=null,s=null,o=null,u=[],d=!1,c=l(t.split("\n"));try{for(c.s();!(e=c.n()).done;){var h=e.value;if(n.REGEX_DISCONTINUITY.test(h)&&d&&o){var f=h.match(n.REGEX_MAP),p=f?f[1]:null;if(p&&p!==o){if(null!==s){var m=i-s;u.push({startTime:s,duration:m,endTime:i,mapUrl:o})}s=i,o=p}}var g=h.match(n.REGEX_MAP);if(g&&d){var y=g[1];if(y&&y!==o){if(null!==s){var v=i-s;u.push({startTime:s,duration:v,endTime:i,mapUrl:o})}s=i,o=y}}if(h.startsWith(n.MT_HLS_CUE_OUT_TAG)){var A=h.match(n.REGEX_CUE_OUT),T=A?parseFloat(A[1]):null;d=!0,u=[],a={id:"avail-".concat(i),startTime:i,duration:T,endTime:null,pods:[],hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,confirmedByTracking:!1}}if(h.startsWith(n.MT_HLS_CUE_IN_TAG)&&a){if(null!==s){var E=i-s;u.push({startTime:s,duration:E,endTime:i,mapUrl:o})}var S=i-a.startTime;S>=n.MIN_AD_DURATION&&(a.duration=S,a.endTime=i,a.pods=u,r.push(a)),a=null,d=!1,s=null,o=null,u=[]}if(h.startsWith(n.HLS_SEGMENT_DURATION_TAG)){var b=parseFloat(h.split(":")[1]);isNaN(b)||(i+=b)}}}catch(t){c.e(t)}finally{c.f()}return a&&a.duration&&(a.endTime=a.startTime+a.duration,a.pods=u,r.push(a)),r},e.parseIsoDuration=v;var n=r(324);function a(){a=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function d(t,e,r,i){return Object.defineProperty(t,e,{value:r,enumerable:!i,configurable:!i,writable:!i})}try{d({},"")}catch(t){d=function(t,e,r){return t[e]=r}}function c(e,r,i,n){var a=r&&r.prototype instanceof p?r:p,s=Object.create(a.prototype);return d(s,"_invoke",function(e,r,i){var n=1;return function(a,s){if(3===n)throw Error("Generator is already running");if(4===n){if("throw"===a)throw s;return{value:t,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=b(o,i);if(l){if(l===f)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(1===n)throw n=4,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=3;var u=h(e,r,i);if("normal"===u.type){if(n=i.done?4:2,u.arg===f)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(n=4,i.method="throw",i.arg=u.arg)}}}(e,i,new D(n||[])),!0),s}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var f={};function p(){}function m(){}function g(){}var y={};d(y,o,(function(){return this}));var v=Object.getPrototypeOf,A=v&&v(v(P([])));A&&A!==r&&n.call(A,o)&&(y=A);var T=g.prototype=p.prototype=Object.create(y);function E(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(a,s,o,l){var u=h(t[a],t,s);if("throw"!==u.type){var d=u.arg,c=d.value;return c&&"object"==i(c)&&n.call(c,"__await")?e.resolve(c.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(c).then((function(t){d.value=t,o(d)}),(function(t){return r("throw",t,o,l)}))}l(u.arg)}var a;d(this,"_invoke",(function(t,i){function n(){return new e((function(e,n){r(t,i,e,n)}))}return a=a?a.then(n,n):n()}),!0)}function b(e,r){var i=r.method,n=e.i[i];if(n===t)return r.delegate=null,"throw"===i&&e.i.return&&(r.method="return",r.arg=t,b(e,r),"throw"===r.method)||"return"!==i&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+i+"' method")),f;var a=h(n,e.i,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,f;var s=a.arg;return s?s.done?(r[e.r]=s.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,f):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function k(t){this.tryEntries.push(t)}function _(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function D(t){this.tryEntries=[[-1]],t.forEach(k,this),this.reset(!0)}function P(e){if(null!=e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,s=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return s.next=s}}throw new TypeError(i(e)+" is not iterable")}return m.prototype=g,d(T,"constructor",g),d(g,"constructor",m),m.displayName=d(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,d(t,u,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},E(S.prototype),d(S.prototype,l,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new S(c(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(T),d(T,u,"Generator"),d(T,o,(function(){return this})),d(T,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var i in e)r.unshift(i);return function t(){for(;r.length;)if((i=r.pop())in e)return t.value=i,t.done=!1,t;return t.done=!0,t}},e.values=P,D.prototype={constructor:D,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(t){s.type="throw",s.arg=e,r.next=t}for(var n=r.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a[4],o=this.prev,l=a[1],u=a[2];if(-1===a[0])return i("end"),!1;if(!l&&!u)throw Error("try statement without catch or finally");if(null!=a[0]&&a[0]<=o){if(o<l)return this.method="next",this.arg=t,i(l),!0;if(o<u)return i(u),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i[0]>-1&&i[0]<=this.prev&&this.prev<i[2]){var n=i;break}}n&&("break"===t||"continue"===t)&&n[0]<=e&&e<=n[2]&&(n=null);var a=n?n[4]:{};return a.type=t,a.arg=e,n?(this.method="next",this.next=n[2],f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),_(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var i=r[4];if("throw"===i.type){var n=i.arg;_(r)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,r,i){return this.delegate={i:P(e),r,n:i},"next"===this.method&&(this.arg=t),f}},e}function s(t,e,r,i,n,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(i,n)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(i,n){var a=t.apply(e,r);function o(t){s(a,i,n,o,l,"next",t)}function l(t){s(a,i,n,o,l,"throw",t)}o(void 0)}))}}function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=u(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,n=function(){};return{s:n,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}function u(t,e){if(t){if("string"==typeof t)return d(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(t,e):void 0}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function c(t){return!!(t.map&&t.map.uri&&t.map.uri.includes(n.MT_SEGMENT_PATTERN))||!(!t.uri||!t.uri.includes(n.MT_SEGMENT_PATTERN))}function h(t){return{q1:t*n.QUARTILES.Q1,q2:t*n.QUARTILES.Q2,q3:t*n.QUARTILES.Q3}}function f(t){return p.apply(this,arguments)}function p(){return(p=o(a().mark((function t(e){var r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e,{credentials:"include"});case 2:if(!1!==(r=t.sent).ok){t.next=5;break}throw new Error("Manifest request failed: ".concat(r.status||"unknown"," ").concat(r.statusText||"Request failed"));case 5:return t.next=7,r.text();case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function m(){return(m=o(a().mark((function t(e){var r,i,s,o,u,d;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f(e);case 2:r=t.sent,i=r.split("\n"),s=null,o=l(i),t.prev=6,o.s();case 8:if((u=o.n()).done){t.next=15;break}if((d=u.value).startsWith(n.HLS_TAG_PREFIX)||!d.includes(n.HLS_MANIFEST_EXTENSION)){t.next=13;break}return s=new URL(d.trim(),e).href,t.abrupt("break",15);case 13:t.next=8;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(6),o.e(t.t0);case 20:return t.prev=20,o.f(),t.finish(20);case 23:return t.abrupt("return",{masterText:r,mediaPlaylistUrl:s});case 24:case"end":return t.stop()}}),t,null,[[6,17,20,23]])})))).apply(this,arguments)}function g(){return(g=o(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function y(){return(y=o(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function v(t){if(!t)return 0;var e=t.match(n.REGEX_ISO_8601_DURATION);return e?3600*parseFloat(e[1]||0)+60*parseFloat(e[2]||0)+parseFloat(e[3]||0):0}function A(){return A=o(a().mark((function t(e){var r,i,n,s,o,l,u=arguments;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:8e3,i=u.length>2&&void 0!==u[2]?u[2]:null,n=new AbortController,s=setTimeout((function(){return n.abort()}),r),o=function(){return n.abort()},i&&i.addEventListener("abort",o),t.prev=6,t.next=9,fetch("".concat(e,"?t=").concat(Date.now()),{signal:n.signal,credentials:"include"});case 9:if(l=t.sent,clearTimeout(s),i&&i.removeEventListener("abort",o),l.ok){t.next=14;break}throw new Error("Tracking API error: ".concat(l.status));case 14:return t.next=16,l.json();case 16:return t.abrupt("return",t.sent);case 19:throw t.prev=19,t.t0=t.catch(6),clearTimeout(s),i&&i.removeEventListener("abort",o),t.t0;case 24:case"end":return t.stop()}}),t,null,[[6,19]])}))),A.apply(this,arguments)}},687:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=l(r(555)),a=l(r(472)),s=r(324),o=r(612);function l(t){return t&&t.__esModule?t:{default:t}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function d(){d=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(t,e,r,i){return Object.defineProperty(t,e,{value:r,enumerable:!i,configurable:!i,writable:!i})}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(e,r,i,n){var a=r&&r.prototype instanceof p?r:p,s=Object.create(a.prototype);return u(s,"_invoke",function(e,r,i){var n=1;return function(a,s){if(3===n)throw Error("Generator is already running");if(4===n){if("throw"===a)throw s;return{value:t,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=b(o,i);if(l){if(l===f)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(1===n)throw n=4,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=3;var u=h(e,r,i);if("normal"===u.type){if(n=i.done?4:2,u.arg===f)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(n=4,i.method="throw",i.arg=u.arg)}}}(e,i,new D(n||[])),!0),s}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var f={};function p(){}function m(){}function g(){}var y={};u(y,s,(function(){return this}));var v=Object.getPrototypeOf,A=v&&v(v(P([])));A&&A!==r&&n.call(A,s)&&(y=A);var T=g.prototype=p.prototype=Object.create(y);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(a,s,o,l){var u=h(t[a],t,s);if("throw"!==u.type){var d=u.arg,c=d.value;return c&&"object"==i(c)&&n.call(c,"__await")?e.resolve(c.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(c).then((function(t){d.value=t,o(d)}),(function(t){return r("throw",t,o,l)}))}l(u.arg)}var a;u(this,"_invoke",(function(t,i){function n(){return new e((function(e,n){r(t,i,e,n)}))}return a=a?a.then(n,n):n()}),!0)}function b(e,r){var i=r.method,n=e.i[i];if(n===t)return r.delegate=null,"throw"===i&&e.i.return&&(r.method="return",r.arg=t,b(e,r),"throw"===r.method)||"return"!==i&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+i+"' method")),f;var a=h(n,e.i,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,f;var s=a.arg;return s?s.done?(r[e.r]=s.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,f):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function k(t){this.tryEntries.push(t)}function _(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function D(t){this.tryEntries=[[-1]],t.forEach(k,this),this.reset(!0)}function P(e){if(null!=e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return m.prototype=g,u(T,"constructor",g),u(g,"constructor",m),m.displayName=u(g,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,l,"GeneratorFunction")),t.prototype=Object.create(T),t},e.awrap=function(t){return{__await:t}},E(S.prototype),u(S.prototype,o,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new S(c(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(T),u(T,l,"Generator"),u(T,s,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var i in e)r.unshift(i);return function t(){for(;r.length;)if((i=r.pop())in e)return t.value=i,t.done=!1,t;return t.done=!0,t}},e.values=P,D.prototype={constructor:D,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(t){s.type="throw",s.arg=e,r.next=t}for(var n=r.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a[4],o=this.prev,l=a[1],u=a[2];if(-1===a[0])return i("end"),!1;if(!l&&!u)throw Error("try statement without catch or finally");if(null!=a[0]&&a[0]<=o){if(o<l)return this.method="next",this.arg=t,i(l),!0;if(o<u)return i(u),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i[0]>-1&&i[0]<=this.prev&&this.prev<i[2]){var n=i;break}}n&&("break"===t||"continue"===t)&&n[0]<=e&&e<=n[2]&&(n=null);var a=n?n[4]:{};return a.type=t,a.arg=e,n?(this.method="next",this.next=n[2],f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),_(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var i=r[4];if("throw"===i.type){var n=i.arg;_(r)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,r,i){return this.delegate={i:P(e),r,n:i},"next"===this.method&&(this.arg=t),f}},e}function c(t,e,r,i,n,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(i,n)}function h(t){return function(){var e=this,r=arguments;return new Promise((function(i,n){var a=t.apply(e,r);function s(t){c(a,i,n,s,o,"next",t)}function o(t){c(a,i,n,s,o,"throw",t)}s(void 0)}))}}function f(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,p(i.key),i)}}function p(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(m=function(){return!!t})()}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}function y(t,e,r,i){var n=v(A(1&i?t.prototype:t),e,r);return 2&i&&"function"==typeof n?function(t){return n.apply(r,t)}:n}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=A(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(arguments.length<3?t:r):n.value}},v.apply(null,arguments)}function A(t){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},A(t)}(n.default.default||n.default).Log,e.default=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=function(t,e,r){return e=A(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,m()?Reflect.construct(e,r||[],A(t).constructor):e.apply(t,r))}(this,e,[t])).streamType=null,r.manifestFormat=null,r.playbackManifestUrl=t.currentSrc(),r.adSchedule=[],r.currentAdBreak=null,r.currentAdPod=null,r.hasEndedContent=!1,r.isDisposed=!1,r.trackingAbortController=null,r.manifestAbortController=null,r.isFetchingTracking=!1,r.isFetchingManifest=!1,r.trackingEndpointUrl=null,r.hasAttemptedTrackingFetch=!1,r.trackingFetchRetries=0,r.maxTrackingRetries=1,r.manifestPollTimer=null,r.trackingPollTimer=null,r.liveRefreshIntervalSeconds=null,r.mediaPlaylistUrl=null,r.lastMediaPlaylistText=null,console.log("[MT - ".concat((0,o.getTimestamp)(),"] MediaTailorAdsTracker initialized"),{endpoint:r.playbackManifestUrl,trackingAPITimeout:s.TRACKING_API_TIMEOUT_MS}),r.manifestFormat=(0,o.detectManifestFormatFromUrl)(r.playbackManifestUrl),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Manifest type: ").concat(r.manifestFormat.toUpperCase())),r.player.one("loadedmetadata",(function(){r.streamType=(0,o.detectPlaybackStreamType)(r.player.duration()),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Stream type: ").concat(r.streamType.toUpperCase())),r.initializeTracking()})),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}(e,t),r=e,n=[{key:"getTrackerName",value:function(){return"aws-media-tailor"}},{key:"getPlayerVersion",value:function(){return"MediaTailor"}},{key:"getAdPosition",value:function(){return this.currentAdBreak&&this.currentAdBreak.adPosition?this.currentAdBreak.adPosition:y(e,"getAdPosition",this,3)([])}},{key:"initializeTracking",value:function(){console.log("[MT - ".concat((0,o.getTimestamp)(),"] Initializing ").concat(this.manifestFormat.toUpperCase()," ").concat(this.streamType.toUpperCase()," tracking")),this.trackingEndpointUrl=(0,o.buildTrackingEndpointUrl)(this.playbackManifestUrl),this.trackingEndpointUrl?console.log("[MT - ".concat((0,o.getTimestamp)(),"] Tracking URL extracted:"),this.trackingEndpointUrl):console.warn("[MT - ".concat((0,o.getTimestamp)(),"] No sessionId found - user must initialize session externally")),this.streamType===s.STREAM_TYPE.VOD?this.setupVODTracking():this.setupLiveTracking()}},{key:"registerListeners",value:function(){y(e,"registerListeners",this,3)([]),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onEnded=this.onEnded.bind(this),this.onTimeUpdate=this.onTimeUpdate.bind(this),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("waiting",this.onWaiting),this.player.on("ended",this.onEnded),this.player.on("timeupdate",this.onTimeUpdate),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Event listeners registered"))}},{key:"unregisterListeners",value:function(){y(e,"unregisterListeners",this,3)([]),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("waiting",this.onWaiting),this.player.off("ended",this.onEnded),this.player.off("timeupdate",this.onTimeUpdate),this.stopLivePolling()}},{key:"stopLivePolling",value:function(){this.manifestPollTimer&&(clearTimeout(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null)}},{key:"setupVODTracking",value:function(){console.log("[MT - ".concat((0,o.getTimestamp)(),"] VOD mode: Single manifest parse")),this.hookPlayerManifest()}},{key:"setupLiveTracking",value:function(){var t=this;console.log("[MT - ".concat((0,o.getTimestamp)(),"] Live mode: Continuous polling")),this.hookPlayerManifest();var e=this.getLiveRefreshIntervalMs();this.manifestPollTimer=setInterval((function(){t.pollManifestForNewAds()}),e),this.trackingPollTimer=setInterval((function(){t.getAndProcessTrackingMetadata()}),e),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Live polling started"),{pollingInterval:e})}},{key:"getLiveRefreshIntervalMs",value:function(){return this.liveRefreshIntervalSeconds?1e3*this.liveRefreshIntervalSeconds:s.DEFAULT_LIVE_POLL_INTERVAL_MS}},{key:"restartLivePollingTimers",value:function(){var t=this;if(this.liveRefreshIntervalSeconds){var e=this.getLiveRefreshIntervalMs();console.log("[MT - ".concat((0,o.getTimestamp)(),"] Updating live polling interval: ").concat(this.liveRefreshIntervalSeconds,"s")),this.manifestPollTimer&&clearInterval(this.manifestPollTimer),this.trackingPollTimer&&clearInterval(this.trackingPollTimer),this.manifestPollTimer=setInterval((function(){t.pollManifestForNewAds()}),e),this.trackingPollTimer=setInterval((function(){t.getAndProcessTrackingMetadata()}),e)}}},{key:"hookPlayerManifest",value:function(){var t=this.player.tech({IWillNotUseThisInPlugins:!0});if(!t)return console.log("[MT - ".concat((0,o.getTimestamp)(),"] No tech - using fallback fetch")),void this.getManifestDirectly();if(this.manifestFormat===s.MANIFEST_TYPE.HLS){if(this.hookHLSViaVHS(t)||this.hookHLSViaNative(t)||this.hookHLSViaContribHls(t))return}else if(this.manifestFormat===s.MANIFEST_TYPE.DASH&&(this.hookDASHViaShaka(t)||this.hookDASHViaDashJs(t)))return;console.log("[MT - ".concat((0,o.getTimestamp)(),"] Using fallback: direct manifest fetch")),this.getManifestDirectly()}},{key:"hookHLSViaVHS",value:function(t){var e=this;if(!t.vhs||!t.vhs.playlists)return!1;console.log("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: VHS"));var r=t.vhs.playlists.media();return r&&r.segments&&r.segments.length>0&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Parsing existing playlist")),this.parseVhsPlaylistForAdBreaks(r)),t.vhs.on("loadedplaylist",(function(){var r=t.vhs.playlists.media();r&&e.parseVhsPlaylistForAdBreaks(r)})),!0}},{key:"hookHLSViaNative",value:function(t){return!!(t.el_&&t.el_.canPlayType&&t.el_.canPlayType(s.HLS_MIME_TYPE))&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Native HLS detected - using fallback")),this.getManifestDirectly(),!0)}},{key:"hookHLSViaContribHls",value:function(t){var e=this;if(!t.hls||!t.hls.playlists)return!1;console.log("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: contrib-hls (legacy)"));var r=t.hls.playlists.media();return r&&r.segments&&r.segments.length>0&&this.parseVhsPlaylistForAdBreaks(r),t.hls.on("loadedplaylist",(function(){var r=t.hls.playlists.media();r&&e.parseVhsPlaylistForAdBreaks(r)})),!0}},{key:"hookDASHViaShaka",value:function(t){var e=this;return!!t.shakaPlayer&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: Shaka Player")),t.shakaPlayer.addEventListener("emsg",(function(t){e.handleDASHEmsgEvent(t)})),!0)}},{key:"hookDASHViaDashJs",value:function(t){var e=this;return!(!t.dash||!t.dash.on||(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: dash.js")),t.dash.on("EVENT_MODE_ON_RECEIVE",(function(t){e.handleDASHEventStream(t)})),0))}},{key:"getManifestDirectly",value:(T=h(d().mark((function t(){var e;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fallback: fetching manifest directly")),t.prev=1,e=this.playbackManifestUrl,this.manifestFormat!==s.MANIFEST_TYPE.HLS){t.next=8;break}return t.next=6,this.fetchAndParseHlsManifest(e);case 6:t.next=11;break;case 8:if(this.manifestFormat!==s.MANIFEST_TYPE.DASH){t.next=11;break}return t.next=11,this.fetchAndParseDashManifest(e);case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fallback fetch error:"),t.t0);case 16:case"end":return t.stop()}}),t,this,[[1,13]])}))),function(){return T.apply(this,arguments)})},{key:"fetchAndParseHlsManifest",value:(v=h(d().mark((function t(e){var r,i,n,a,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fetching HLS master manifest")),t.next=4,(0,o.fetchHlsMasterManifest)(e);case 4:if(r=t.sent,i=r.mediaPlaylistUrl){t.next=9;break}return console.log("[MT - ".concat((0,o.getTimestamp)(),"] No media playlist found")),t.abrupt("return");case 9:return console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fetching media playlist")),t.next=12,(0,o.fetchHlsMediaPlaylist)(i);case 12:n=t.sent,a=(0,o.extractHlsTargetDurationSeconds)(n),this.updateLiveRefreshIntervalFromManifest(a,"hls target duration"),(s=(0,o.parseHlsManifestForAdBreaks)(n)).length>0&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Detected ").concat(s.length," ad break(s)")),this.mergeNewAds(s)),t.next=22;break;case 19:t.prev=19,t.t0=t.catch(0),console.log("[MT - ".concat((0,o.getTimestamp)(),"] HLS fetch error:"),t.t0);case 22:case"end":return t.stop()}}),t,this,[[0,19]])}))),function(t){return v.apply(this,arguments)})},{key:"fetchAndParseDashManifest",value:(p=h(d().mark((function t(e){var r,i,n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fetching DASH manifest")),t.next=4,(0,o.fetchDashManifest)(e);case 4:r=t.sent,i=(0,o.extractDashMinimumUpdatePeriodSeconds)(r),this.updateLiveRefreshIntervalFromManifest(i,"dash minimumUpdatePeriod"),n=(0,o.parseDashManifestForAdBreaks)(r),console.log("[MT - ".concat((0,o.getTimestamp)(),"] DASH: ").concat(n.length," ad break(s) found")),n.length>0?this.mergeNewAds(n):this.streamType===s.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] DASH: no manifest cues, fetching tracking API")),this.hasAttemptedTrackingFetch=!0,this.getAndProcessTrackingMetadata()),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(0),console.log("[MT - ".concat((0,o.getTimestamp)(),"] DASH fetch error:"),t.t0);case 15:case"end":return t.stop()}}),t,this,[[0,12]])}))),function(t){return p.apply(this,arguments)})},{key:"handleDASHEmsgEvent",value:function(t){console.log("[MT - ".concat((0,o.getTimestamp)(),"] DASH emsg event:"),t);try{var e=t.detail;if(!e)return void console.log("[MT - ".concat((0,o.getTimestamp)(),"] No emsg data in event"));var r=e.schemeIdUri||"";if(!r.includes(s.SCTE35_SCHEME_MARKER))return void console.log("[MT - ".concat((0,o.getTimestamp)(),"] Non-SCTE-35 emsg, skipping:"),r);console.log("[MT - ".concat((0,o.getTimestamp)(),"] SCTE-35 emsg detected:"),{schemeIdUri:e.schemeIdUri,value:e.value,timescale:e.timescale,presentationTime:e.presentationTime,presentationTimeDelta:e.presentationTimeDelta,eventDuration:e.eventDuration});var i=e.timescale||1,n=e.presentationTime||0,a=e.eventDuration||0,l=n/i,u=a/i;if(e.messageData&&u>0){var d={id:"dash-emsg-".concat(l),startTime:l,duration:u,endTime:l+u,source:"dash-emsg",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};console.log("[MT - ".concat((0,o.getTimestamp)(),"] Adding ad break from DASH emsg:"),d),this.mergeNewAds([d])}}catch(t){console.log("[MT - ".concat((0,o.getTimestamp)(),"] Error parsing DASH emsg event:"),t)}}},{key:"handleDASHEventStream",value:function(t){console.log("[MT - ".concat((0,o.getTimestamp)(),"] DASH event stream:"),t);try{var e=t.event||t;if(!e)return void console.log("[MT - ".concat((0,o.getTimestamp)(),"] No event data"));var r=e.schemeIdUri||"";if(!r.includes(s.SCTE35_SCHEME_MARKER))return void console.log("[MT - ".concat((0,o.getTimestamp)(),"] Non-SCTE-35 event, skipping:"),r);console.log("[MT - ".concat((0,o.getTimestamp)(),"] SCTE-35 event stream detected:"),{id:e.id,schemeIdUri:e.schemeIdUri,presentationTime:e.presentationTime,duration:e.duration,messageData:e.messageData});var i=parseFloat(e.presentationTime||0),n=parseFloat(e.duration||0);if(n>0){var a={id:e.id||"dash-event-".concat(i),startTime:i,duration:n,endTime:i+n,source:"dash-event-stream",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};console.log("[MT - ".concat((0,o.getTimestamp)(),"] Adding ad break from DASH event stream:"),a),this.mergeNewAds([a])}}catch(t){console.log("[MT - ".concat((0,o.getTimestamp)(),"] Error parsing DASH event stream:"),t)}}},{key:"parseVhsPlaylistForAdBreaks",value:function(t){var e;if(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Parsing VHS playlist (").concat((null===(e=t.segments)||void 0===e?void 0:e.length)||0," segments)")),t.segments&&0!==t.segments.length){this.updateLiveRefreshIntervalFromManifest(t.targetDuration,"vhs target duration");var r=(0,o.detectAdBreaksFromVhsPlaylist)(t);r.length>0?(console.log("[MT - ".concat((0,o.getTimestamp)(),"] VHS detected ").concat(r.length," ad break(s), ").concat(r.reduce((function(t,e){return t+e.pods.length}),0)," pod(s)")),this.mergeNewAds(r)):console.log("[MT - ".concat((0,o.getTimestamp)(),"] No ads detected in VHS playlist"))}else console.log("[MT - ".concat((0,o.getTimestamp)(),"] No segments in playlist"))}},{key:"pollManifestForNewAds",value:(c=h(d().mark((function t(){var e,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isDisposed){t.next=2;break}return t.abrupt("return");case 2:if(this.streamType===s.STREAM_TYPE.LIVE){t.next=4;break}return t.abrupt("return");case 4:if(!this.isFetchingManifest){t.next=7;break}return console.log("[MT - ".concat((0,o.getTimestamp)(),"] Manifest fetch already in progress, skipping")),t.abrupt("return");case 7:if(this.isFetchingManifest=!0,t.prev=8,!(e=this.player.tech({IWillNotUseThisInPlugins:!0}))||!e.vhs){t.next=15;break}(r=e.vhs.playlists.media())&&this.parseVhsPlaylistForAdBreaks(r),t.next=18;break;case 15:if(this.manifestFormat!==s.MANIFEST_TYPE.DASH){t.next=18;break}return t.next=18,this.fetchAndParseDashManifest(this.playbackManifestUrl);case 18:t.next=23;break;case 20:t.prev=20,t.t0=t.catch(8),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Manifest poll error:"),t.t0);case 23:return t.prev=23,this.isFetchingManifest=!1,t.finish(23);case 26:case"end":return t.stop()}}),t,this,[[8,20,23,26]])}))),function(){return c.apply(this,arguments)})},{key:"mergeNewAds",value:function(t){this.adSchedule=(0,o.mergeAdSchedules)(this.adSchedule,t),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Ad schedule: ").concat(this.adSchedule.length," ad break(s)")),this.streamType===s.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(this.hasAttemptedTrackingFetch=!0,console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fetching tracking metadata (first manifest parse)")),this.getAndProcessTrackingMetadata())}},{key:"updateLiveRefreshIntervalFromManifest",value:function(t,e){this.streamType!==s.STREAM_TYPE.LIVE||!t||t<=0||this.liveRefreshIntervalSeconds!==t&&(this.liveRefreshIntervalSeconds=t,console.log("[MT - ".concat((0,o.getTimestamp)(),"] Derived live polling interval from ").concat(e,": ").concat(t,"s")),(this.manifestPollTimer||this.trackingPollTimer)&&this.restartLivePollingTimers())}},{key:"getAndProcessTrackingMetadata",value:(l=h(d().mark((function t(){var e;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isDisposed&&this.trackingEndpointUrl){t.next=2;break}return t.abrupt("return");case 2:if(!this.isFetchingTracking){t.next=5;break}return console.log("[MT - ".concat((0,o.getTimestamp)(),"] Tracking fetch already in progress, skipping")),t.abrupt("return");case 5:return this.isFetchingTracking=!0,t.prev=6,console.log("[MT - ".concat((0,o.getTimestamp)(),"] Fetching tracking metadata")),this.trackingAbortController=new AbortController,t.next=11,(0,o.getTrackingMetadata)(this.trackingEndpointUrl,s.TRACKING_API_TIMEOUT_MS,this.trackingAbortController.signal);case 11:if(e=t.sent,!this.isDisposed){t.next=15;break}return console.log("[MT - ".concat((0,o.getTimestamp)(),"] Disposed during tracking fetch, ignoring result")),t.abrupt("return");case 15:e.avails&&e.avails.length>0?(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Enriching with ").concat(e.avails.length," avail(s)")),this.enrichWithTrackingMetadata(e.avails),this.trackingFetchRetries=0):console.log("[MT - ".concat((0,o.getTimestamp)(),"] Tracking API returned 0 avails")),t.next=32;break;case 18:if(t.prev=18,t.t0=t.catch(6),"AbortError"!==t.t0.name&&!this.isDisposed){t.next=23;break}return console.log("[MT - ".concat((0,o.getTimestamp)(),"] Tracking fetch aborted")),t.abrupt("return");case 23:if(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Tracking API error: ").concat(t.t0.message),t.t0),!(this.trackingFetchRetries<this.maxTrackingRetries)){t.next=31;break}return this.trackingFetchRetries++,console.log("[MT - ".concat((0,o.getTimestamp)(),"] Retrying tracking fetch (").concat(this.trackingFetchRetries,"/").concat(this.maxTrackingRetries,")")),this.isFetchingTracking=!1,t.next=30,this.getAndProcessTrackingMetadata();case 30:return t.abrupt("return");case 31:console.log("[MT - ".concat((0,o.getTimestamp)(),"] Max retries reached, continuing with manifest data only"));case 32:return t.prev=32,this.isFetchingTracking=!1,this.trackingAbortController=null,t.finish(32);case 36:case"end":return t.stop()}}),t,this,[[6,18,32,36]])}))),function(){return l.apply(this,arguments)})},{key:"enrichWithTrackingMetadata",value:function(t){var e,r=(0,o.enrichAdScheduleWithTrackingMetadata)(this.adSchedule,t);r.length>0&&((e=this.adSchedule).push.apply(e,function(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(r)),this.adSchedule.sort((function(t,e){return t.startTime-e.startTime}))),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Enrichment complete: ").concat(this.adSchedule.length," ad break(s)")),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Enriched schedule:"),this.adSchedule.map((function(t){return{id:t.id,startTime:t.startTime,endTime:t.endTime,duration:t.duration,title:t.title,podCount:t.pods.length,pods:t.pods.map((function(t){return{title:t.title,startTime:t.startTime,endTime:t.endTime,duration:t.duration}}))}}))),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Current player time: ").concat(this.player.currentTime(),"s"))}},{key:"trackQuartiles",value:function(t,e){var r=this;!t.duration||t.duration<=0||(0,o.getQuartilesToFire)(e,t.duration,{q1:t.hasFiredQ1,q2:t.hasFiredQ2,q3:t.hasFiredQ3}).forEach((function(e){var i=e.quartile,n=e.key;console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_QUARTILE ").concat(25*i,"%")),r.sendAdQuartile({quartile:i}),t["hasFired".concat(n.toUpperCase())]=!0}))}},{key:"onTimeUpdate",value:function(){var t=this.player.currentTime(),e=(0,o.findActiveAdBreak)(this.adSchedule,t);if(this.adSchedule.length>0&&Math.floor(t)%5==0&&Math.floor(10*t)%10==0&&console.log("[MT - ".concat((0,o.getTimestamp)(),"] TimeUpdate: ").concat(t.toFixed(2),"s, Active break: ").concat(e?e.id:"none",", Schedule count: ").concat(this.adSchedule.length)),e){if(!e.hasFiredStart){var r;this.currentAdBreak=e,this.setIsAd(!0),console.log("[MT - ".concat((0,o.getTimestamp)(),"] setIsAd(true) - Entering ad break"));var i=this.adSchedule.findIndex((function(t){return Math.abs(t.startTime-e.startTime)<.5})),n=(0,o.determineAdPosition)(i,this.adSchedule.length,this.streamType);e.adPosition=n,console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_BREAK_START"),{startTime:e.startTime,duration:e.duration,podCount:(null===(r=e.pods)||void 0===r?void 0:r.length)||0,position:n,breakIndex:i,totalBreaks:this.adSchedule.length}),this.sendAdBreakStart(),e.hasFiredStart=!0}if(e.pods&&e.pods.length>0){var a=(0,o.findActivePod)(e,t);if(a){this.currentAdPod&&this.currentAdPod===a||(this.currentAdPod&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_END (pod transition)")),this.sendEnd()),this.currentAdPod=a,console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_START (new pod)"),{startTime:a.startTime,duration:a.duration,position:e.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:e.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:e.adPosition}),a.hasFiredStart=!0);var s=t-a.startTime;this.trackQuartiles(a,s)}}else{e.hasFiredAdStart||(console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_START (no pods)"),{startTime:e.startTime,duration:e.duration,position:e.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:e.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:e.adPosition}),e.hasFiredAdStart=!0);var l=t-e.startTime;this.trackQuartiles(e,l)}}else this.currentAdBreak&&(this.currentAdPod&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_END (final pod)")),this.sendEnd(),this.currentAdPod=null),this.currentAdBreak.hasFiredEnd||(console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_BREAK_END")),this.sendAdBreakEnd(),this.currentAdBreak.hasFiredEnd=!0),this.currentAdBreak=null,this.setIsAd(!1),console.log("[MT - ".concat((0,o.getTimestamp)(),"] setIsAd(false) - Exiting ad break")),this.player.ended()&&!this.hasEndedContent&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Video ended after last ad → CONTENT_END")),this.sendContentEnd(),this.hasEndedContent=!0))}},{key:"sendContentEnd",value:function(){this.parentTracker?this.parentTracker.sendEnd():y(e,"sendEnd",this,3)([])}},{key:"handleAdEvent",value:function(t,e){this.isAd()&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] → ").concat(t)),e.call(this))}},{key:"onPause",value:function(){this.handleAdEvent("AD_PAUSE",this.sendPause)}},{key:"onPlaying",value:function(){this.isAd()&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] → AD_RESUME")),this.sendResume(),this.sendBufferEnd())}},{key:"onSeeking",value:function(){this.handleAdEvent("AD_SEEK_START",this.sendSeekStart)}},{key:"onSeeked",value:function(){this.handleAdEvent("AD_SEEK_END",this.sendSeekEnd)}},{key:"onWaiting",value:function(){this.handleAdEvent("AD_BUFFER_START",this.sendBufferStart)}},{key:"onEnded",value:function(){this.hasEndedContent||(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Video ended → CONTENT_END")),this.sendContentEnd(),this.hasEndedContent=!0)}},{key:"getTitle",value:function(){var t,e,r;return this.currentAdPod?this.currentAdPod.title||(null===(r=this.currentAdBreak)||void 0===r?void 0:r.id)||null:(null===(t=this.currentAdBreak)||void 0===t?void 0:t.title)||(null===(e=this.currentAdBreak)||void 0===e?void 0:e.id)||null}},{key:"getVideoId",value:function(){var t,e,r;return this.currentAdPod?this.currentAdPod.creativeId||this.currentAdPod.title||(null===(r=this.currentAdBreak)||void 0===r?void 0:r.id)||null:(null===(t=this.currentAdBreak)||void 0===t?void 0:t.creativeId)||(null===(e=this.currentAdBreak)||void 0===e?void 0:e.id)||null}},{key:"getSrc",value:function(){return this.trackingEndpointUrl||this.playbackManifestUrl||null}},{key:"getDuration",value:function(){return this.currentAdPod?1e3*this.currentAdPod.duration:this.currentAdBreak?1e3*this.currentAdBreak.duration:null}},{key:"stopPolling",value:function(){this.manifestPollTimer&&(clearInterval(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null),console.log("[MT - ".concat((0,o.getTimestamp)(),"] Polling stopped"))}},{key:"dispose",value:function(){console.log("[MT - ".concat((0,o.getTimestamp)(),"] Disposing MediaTailorAdsTracker")),this.isDisposed=!0,this.trackingAbortController&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Aborting in-flight tracking fetch")),this.trackingAbortController.abort(),this.trackingAbortController=null),this.manifestAbortController&&(console.log("[MT - ".concat((0,o.getTimestamp)(),"] Aborting in-flight manifest fetch")),this.manifestAbortController.abort(),this.manifestAbortController=null),this.stopLivePolling(),this.unregisterListeners(),y(e,"dispose",this,1)&&y(e,"dispose",this,3)([])}}],a=[{key:"isUsing",value:function(t){return t&&"function"==typeof t.currentSrc&&t.currentSrc().includes(s.MEDIATAILOR_HOST_MARKER)}}],n&&f(r.prototype,n),a&&f(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,a,l,c,p,v,T}(a.default)},717:(t,e,r)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=s(r(555)),a=s(r(472));function s(t){return t&&t.__esModule?t:{default:t}}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,a,s,o=[],l=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){u=!0,n=t}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return l(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function u(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,c(i.key),i)}}function c(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(h=function(){return!!t})()}function f(t,e,r,i){var n=p(m(1&i?t.prototype:t),e,r);return 2&i&&"function"==typeof n?function(t){return n.apply(r,t)}:n}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=m(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(arguments.length<3?t:r):n.value}},p.apply(null,arguments)}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},m(t)}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}var y={DAI_STREAM_INITIALIZED:"dai-stream-initialized",DAI_STREAM_LOADED:"dai-stream-loaded",DAI_STREAM_ERROR:"dai-stream-error",DAI_AD_BREAK_STARTED:"dai-ad-break-started",DAI_AD_BREAK_ENDED:"dai-ad-break-ended",DAI_AD_PERIOD_STARTED:"dai-ad-period-started",DAI_AD_PERIOD_ENDED:"dai-ad-period-ended",DAI_AD_STARTED:"dai-ad-started",DAI_AD_FIRST_QUARTILE:"dai-ad-first-quartile",DAI_AD_MIDPOINT:"dai-ad-midpoint",DAI_AD_THIRD_QUARTILE:"dai-ad-third-quartile",DAI_AD_COMPLETE:"dai-ad-complete",DAI_AD_SKIPPED:"dai-ad-skipped",DAI_AD_PAUSED:"dai-ad-paused",DAI_AD_RESUMED:"dai-ad-resumed",DAI_AD_CLICKED:"dai-ad-clicked",DAI_AD_ERROR:"dai-ad-error",DAI_CUEPOINTS_CHANGED:"dai-cuepoints-changed",DAI_TIMED_METADATA:"dai-timed-metadata"};e.default=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=function(t,e,r){return e=m(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,h()?Reflect.construct(e,r||[],m(t).constructor):e.apply(t,r))}(this,e,[t])).streamManager=null,r.currentAdData=null,r.adBreakData=null,r.streamData=null,r.cuePoints=[],r.initialized=!1,r.eventHandlers=null,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}(e,t),r=e,s=[{key:"isUsing",value:function(t){return t.imaDai&&"function"==typeof t.imaDai||t.dai&&void 0!==t.dai.VERSION||t.ima&&t.ima.dai||t.streamManager}}],(a=[{key:"setStreamManager",value:function(t){this.streamManager=t,this.setupStreamManagerListeners(),this.initialized=!0,n.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}},{key:"setupStreamManagerListeners",value:function(){var t,e,r=this;if(this.streamManager&&null!==(t=google)&&void 0!==t&&null!==(t=t.ima)&&void 0!==t&&null!==(t=t.dai)&&void 0!==t&&null!==(t=t.api)&&void 0!==t&&t.StreamEvent){var i=google.ima.dai.api.StreamEvent.Type;this.eventHandlers=(u(u(u(u(u(u(u(u(u(u(e={},i.LOADED,this.onStreamLoaded.bind(this)),i.STREAM_INITIALIZED,this.onStreamInitialized.bind(this)),i.ERROR,this.onStreamError.bind(this)),i.AD_BREAK_STARTED,this.onAdBreakStarted.bind(this)),i.AD_BREAK_ENDED,this.onAdBreakEnded.bind(this)),i.AD_PERIOD_STARTED,this.onAdPeriodStarted.bind(this)),i.AD_PERIOD_ENDED,this.onAdPeriodEnded.bind(this)),i.STARTED,this.onAdStarted.bind(this)),i.FIRST_QUARTILE,this.onAdFirstQuartile.bind(this)),i.MIDPOINT,this.onAdMidpoint.bind(this)),u(u(u(u(u(u(u(u(u(e,i.THIRD_QUARTILE,this.onAdThirdQuartile.bind(this)),i.COMPLETE,this.onAdComplete.bind(this)),i.SKIPPED,this.onAdSkipped.bind(this)),i.PAUSED,this.onAdPaused.bind(this)),i.RESUMED,this.onAdResumed.bind(this)),i.CLICK,this.onAdClicked.bind(this)),i.VIDEO_CLICKED,this.onAdClicked.bind(this)),i.CUEPOINTS_CHANGED,this.onCuePointsChanged.bind(this)),i.TIMED_METADATA,this.onTimedMetadata.bind(this))),Object.entries(this.eventHandlers).forEach((function(t){var e=o(t,2),i=e[0],n=e[1];r.streamManager.addEventListener(i,n)})),n.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}else n.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available")}},{key:"registerListeners",value:function(){f(e,"registerListeners",this,3)([]),n.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(y)])}},{key:"unregisterListeners",value:function(){var t=this;f(e,"unregisterListeners",this,3)([]),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach((function(e){var r=o(e,2),i=r[0],n=r[1];t.streamManager.removeEventListener(i,n)})),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}},{key:"onStreamLoaded",value:function(t){this.streamData=this.extractStreamData(t),n.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}},{key:"onStreamInitialized",value:function(t){n.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}},{key:"onStreamError",value:function(t){var e=this.extractErrorData(t);n.default.Log.error("DaiAdsTracker: Stream error",e),this.sendError(e)}},{key:"onAdBreakStarted",value:function(t){this.adBreakData=this.extractAdBreakData(t),n.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}},{key:"onAdBreakEnded",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}},{key:"onAdPeriodStarted",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(t)}},{key:"onAdPeriodEnded",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad period ended")}},{key:"onAdStarted",value:function(t){this.currentAdData=this.extractAdData(t),n.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}},{key:"onAdFirstQuartile",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}},{key:"onAdMidpoint",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}},{key:"onAdThirdQuartile",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}},{key:"onAdComplete",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}},{key:"onAdSkipped",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}},{key:"onAdPaused",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}},{key:"onAdResumed",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}},{key:"onAdClicked",value:function(t){n.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}},{key:"onCuePointsChanged",value:function(t){this.cuePoints=this.extractCuePoints(t),n.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}},{key:"onTimedMetadata",value:function(t){var e=this.extractTimedMetadata(t);n.default.Log.debug("DaiAdsTracker: Timed metadata",e)}},{key:"extractStreamData",value:function(t){try{var e=t.getStreamData();return{streamId:null==e?void 0:e.streamId,url:null==e?void 0:e.url,adTagParameters:null==e?void 0:e.adTagParameters,streamType:this.getStreamType()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract stream data",t),{}}}},{key:"extractAdBreakData",value:function(t){try{var e,r=t.getAdBreak();return{adBreakId:null==r?void 0:r.id,adBreakTitle:null==r?void 0:r.title,adCount:(null==r||null===(e=r.ads)||void 0===e?void 0:e.length)||0,position:this.getAdPosition()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",t),{}}}},{key:"extractAdData",value:function(t){try{var e=t.getAd();return{adId:null==e?void 0:e.getAdId(),creativeId:null==e?void 0:e.getCreativeId(),duration:null==e?void 0:e.getDuration(),title:null==e?void 0:e.getTitle(),description:null==e?void 0:e.getDescription(),advertiserName:null==e?void 0:e.getAdvertiserName(),clickThroughUrl:null==e?void 0:e.getClickThroughUrl(),dealId:null==e?void 0:e.getDealId(),wrapperAdIds:null==e?void 0:e.getWrapperAdIds(),position:this.getAdPosition()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad data",t),{}}}},{key:"extractErrorData",value:function(t){try{var e=t.getError();return{errorCode:null==e?void 0:e.getErrorCode(),errorMessage:null==e?void 0:e.getMessage(),innerError:null==e?void 0:e.getInnerError()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract error data",e),{errorMessage:"Unknown DAI error"}}}},{key:"extractCuePoints",value:function(t){try{return t.getCuepoints()||[]}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract cue points",t),[]}}},{key:"extractTimedMetadata",value:function(t){try{return{type:t.getType(),data:t.getData()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",t),{}}}},{key:"getTrackerName",value:function(){return"dai-ads"}},{key:"getPlayerName",value:function(){return"videojs-dai"}},{key:"getPlayerVersion",value:function(){var t,e;return null!==(t=this.player.dai)&&void 0!==t&&t.VERSION?this.player.dai.VERSION:null!==(e=this.player.ima)&&void 0!==e&&e.VERSION?"ima-dai: ".concat(this.player.ima.VERSION):"unknown"}},{key:"getAdCuePoints",value:function(){return this.cuePoints}},{key:"getAdPosition",value:function(){if(!this.currentAdData&&!this.adBreakData)return null;var t=this.player.currentTime(),e=this.player.duration();return t<5?"pre":e&&t>e-10?"post":"mid"}},{key:"getDuration",value:function(){var t;return void 0!==(null===(t=this.currentAdData)||void 0===t?void 0:t.duration)?1e3*this.currentAdData.duration:null}},{key:"getVideoId",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.adId)||null}},{key:"getAdCreativeId",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.creativeId)||null}},{key:"getTitle",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.title)||null}},{key:"getSrc",value:function(){var t;return(null===(t=this.streamData)||void 0===t?void 0:t.url)||null}},{key:"getPlayhead",value:function(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(t){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}},{key:"getAdPartner",value:function(){return"google-dai"}},{key:"getClickThroughUrl",value:function(){var t;return(null===(t=this.currentAdData)||void 0===t?void 0:t.clickThroughUrl)||null}},{key:"getStreamType",value:function(){var t;return null!==(t=this.streamData)&&void 0!==t&&t.streamType?this.streamData.streamType:this.player.duration()===1/0?"live":"vod"}},{key:"isLiveStream",value:function(){return"live"===this.getStreamType()}},{key:"getCurrentAdBreak",value:function(){return this.adBreakData}},{key:"getCurrentAd",value:function(){return this.currentAdData}},{key:"getStreamData",value:function(){return this.streamData}},{key:"getBitrate",value:function(){var t=this.getTech();return t&&t.tech&&t.tech.stats&&t.tech.stats.bandwidth?Math.round(t.tech.stats.bandwidth):null}},{key:"getRenditionBitrate",value:function(){var t=this.getTech();if(t&&t.getRenditionBitrate){var e=t.getRenditionBitrate();return null!==e?Math.round(e):null}return null}}])&&d(r.prototype,a),s&&d(r,s),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,a,s}(a.default)}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var a=e[i]={exports:{}};return t[i](a,a.exports,r),a.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{var t=i;t.default=void 0;var e,n=(e=r(302))&&e.__esModule?e:{default:e};t.default=n.default})(),i.default})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VideojsTracker=t():e.VideojsTracker=t()}(self,()=>(()=>{"use strict";var e={555(e,t,i){i.r(t),i.d(t,{default:()=>R});var r={487(e,t,i){i.d(t,{videoAnalyticsHarvester:()=>u});var r=i(374),n=i(431),a=i(51),s=i(144),o=i(302);const u=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)s.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new n.t,this.harvestScheduler=new r.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,s.A.notice("Video analytics agent initialized successfully")}catch(e){s.A.error("Failed to initialize video analytics agent:",e.message)}}addEvent(e){this.isInitialized||(s.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return e.actionName&&e.actionName===o.A.Events.QOE_AGGREGATE?e.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,e.viewId,e):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,e):this.eventBuffer.add(e)}catch(e){return s.A.error("Failed to add event to harvesting system:",e.message),!1}}setHarvestInterval(e){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(e)}forceNextQoeCycle(){this.harvestScheduler&&(this.harvestScheduler.forceNextQoeCycle=!0)}setBeforeDrainCallback(e){this.harvestScheduler&&(this.harvestScheduler.beforeDrainCallback=e)}refreshQoeKpis(e,t){if(!this.eventBuffer||!e)return;const i=t?this.eventBuffer.findByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,t):this.eventBuffer.findByActionName(o.A.Events.QOE_AGGREGATE);if(i){const r={...i};for(const t of a.A.QOE_KPI_KEYS)t in e&&(r[t]=e[t]);t?this.eventBuffer.addOrReplaceByActionNameAndViewId(o.A.Events.QOE_AGGREGATE,t,r):this.eventBuffer.addOrReplaceByActionName(o.A.Events.QOE_AGGREGATE,r)}}}},455(e,t,i){i.d(t,{A:()=>n});class r{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}getDuration(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(this.getDeltaTime()??0)}clone(){var e=new r;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e.accumulator=this.accumulator,e}}const n=r},51(e,t,i){i.d(t,{A:()=>n});class r{}r.AdPositions={PRE:"pre",MID:"mid",POST:"post"},r.COLLECTOR={US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},r.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],r.MAX_PAYLOAD_SIZE=1048576,r.MAX_BEACON_SIZE=61440,r.MAX_EVENTS_PER_BATCH=1e3,r.INTERVAL=1e4,r.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],r.QOE_AGGREGATE_KEYS=["coreVersion","instrumentation.name","instrumentation.provider","instrumentation.version","isBackgroundEvent","playerName","playerVersion","src","viewId","viewSession","contentIsAutoplayed","contentIsMuted","contentRenditionHeight","contentRenditionWidth","contentSrc","numberOfVideos","pageUrl","trackerName","trackerVersion","contentDuration","contentPlayrate","contentPlayhead","contentPreload","elapsedTime","contentTitle","contentId","contentIsLive","deviceType","deviceGroup","deviceManufacturer","deviceModel","deviceName","deviceSize","deviceUuid","contentRenditionName","contentIsFullscreen","contentCdn","contentFps","asnOrganization","asnLongitude","asnLatitude","asn","timeSinceRequested","timeSinceStarted"];const n=r},568(e,t,i){i.d(t,{A:()=>r});const r=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(r=>{r.call(this,{eventType:e,type:t,data:i,target:this})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(r=>{r.call(this,{eventType:e,type:t,data:i,target:this})}),this}}},431(e,t,i){i.d(t,{t:()=>u});var r=i(144),n=i(51),a=i(347);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=n.A;class u{constructor(){this.buffer=[],this.maxPayloadSize=s,this.maxEventsPerBatch=o,this.currentPayloadSize=0,this.totalEvents=0,this.smartHarvestPayloadThreshold=Math.floor(.6*this.maxPayloadSize),this.overflowPayloadThreshold=Math.floor(.9*this.maxPayloadSize),this.smartHarvestEventThreshold=Math.floor(.6*this.maxEventsPerBatch),this.overflowEventThreshold=Math.floor(.9*this.maxEventsPerBatch),this.onSmartHarvestTrigger=null}addOrReplaceByActionName(e,t){const i=this.buffer.findIndex(t=>t.actionName===e);try{return-1===i?this.add(t):this.add(t,i),!0}catch(e){return r.A.error("Failed to set or replace the event to buffer:",e.message),!1}}addOrReplaceByActionNameAndViewId(e,t,i){const n=this.buffer.findIndex(i=>i.actionName===e&&i.viewId===t);try{return-1===n?this.add(i):this.add(i,n),!0}catch(e){return r.A.error("Failed to set or replace the event to buffer:",e.message),!1}}findByActionNameAndViewId(e,t){return this.buffer.find(i=>i.actionName===e&&i.viewId===t)||null}findByActionName(e){return this.buffer.find(t=>t.actionName===e)||null}add(e,t){try{const i=(0,a.Q3)(e),r=this.currentPayloadSize+i>=this.maxPayloadSize,n=this.totalEvents+1>=this.maxEventsPerBatch;if((r||n)&&this.makeRoom(i),null!=t&&t>-1){const r=(0,a.Q3)(this.buffer[t]);this.buffer[t]=e,this.currentPayloadSize+=i-r}else this.buffer.push(e),this.totalEvents++,this.currentPayloadSize+=i;return this.checkSmartHarvestTrigger(),!0}catch(e){return r.A.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,n=this.totalEvents>=this.overflowEventThreshold;if(i||n){const n=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*e)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*t)}%)`;r.A.warn(`OVERFLOW PREVENTION: ${n} - 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 r.A.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)r.A.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.Q3)(e);this.totalEvents--,this.currentPayloadSize-=t,r.A.warn("Event buffer full, oldest event removed.")}}}},374(e,t,i){i.d(t,{n:()=>l});var r=i(431),n=i(413),a=i(481),s=i(347),o=i(51),u=i(302),d=i(144);class l{constructor(e){this.eventBuffer=e,this.retryQueueHandler=new n.u,this.httpClient=new a.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof r.t&&this.eventBuffer.setSmartHarvestCallback((e,t)=>this.triggerSmartHarvest(e,t)),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=o.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?d.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,d.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),d.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(e,t){if(d.A.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){d.A.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){d.A.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=o.A.MAX_BEACON_SIZE;(0,s.Q3)(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 d.A.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 r=0;for(let n=e.length-1;n>=0;n--){const a=e[n],o=(0,s.Q3)({ins:[a,...i]});o>t||(i.unshift(a),r=o)}const n=e.length-i.length;if(n>0){const a=e.slice(0,n);d.A.warn(`Discarded ${n} events to fit beacon size limit`,{originalCount:e.length,trimmedCount:i.length,finalSize:r,maxSize:t}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(a)}return i}drainEvents(e={}){const t=window.NRVIDEO?.config?.qoeIntervalFactor??1,i=!!e.isFinalHarvest||this.forceNextQoeCycle,r=(this.qoeCycleCount-1)%t==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(e){d.A.error("Before drain callback failed:",e.message)}const n=this.eventBuffer.drain();let a;if(r)a=n;else{a=[];for(const e of n)e.actionName===u.A.Events.QOE_AGGREGATE?this.eventBuffer.add(e):a.push(e)}this.qoeCycleCount++;for(let e=a.length-1;e>=0;e--){const t=a[e];t.actionName===u.A.Events.QOE_AGGREGATE&&(!i&&this._qoeKpisUnchanged(t)?a.splice(e,1):this._saveQoeKpis(t))}let l=[...a],c=(0,s.Q3)(a);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const e=o.A.MAX_PAYLOAD_SIZE-c,t=o.A.MAX_EVENTS_PER_BATCH-l.length;if(e>0&&t>0){const i=this.retryQueueHandler.getRetryEventsToFit(e,t);i.length>0&&(l=[...i,...l])}}return l}async sendChunk(e,t,i){const r={url:(0,s.c$)(this.fallBackUrl),payload:{body:{ins:e}},options:{...t,isLastChunk:i}};return new Promise(t=>{this.httpClient.send(r,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=o.A.COLLECTOR.US[1]))}handleHarvestFailure(e){this.consecutiveFailures++,d.A.warn("Harvest failure handled",{error:e.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(e){"number"!=typeof e&&isNaN(e)?d.A.warn("Invalid newInterval provided to updateHarvestInterval"):e<1e3||e>3e5?d.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==e&&(this.harvestCycle=e,d.A.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()})}_qoeKpisUnchanged(e){const t=this._lastSentQoeKpis[e.viewId];if(!t)return!1;for(const i of o.A.QOE_KPI_KEYS)if(e[i]!==t[i])return!1;return!0}_saveQoeKpis(e){const t={};for(const i of o.A.QOE_KPI_KEYS)t[i]=e[i];this._lastSentQoeKpis[e.viewId]=t}}},144(e,t,i){i.d(t,{A:()=>o});class r{static error(...e){n(e,r.Levels.ERROR,"darkred")}static warn(...e){n(e,r.Levels.WARNING,"darkorange")}static notice(...e){n([].slice.call(arguments),r.Levels.NOTICE,"darkcyan")}static debug(...e){n(e,r.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(e,t,i){try{if(r.level<=r.Levels.DEBUG){i=i||function(e){r.debug("Event: "+e.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];t&&(null===t[0]?(t.shift(),n=t):n=n.concat(t));for(var a=0;a<n.length;a++)"function"==typeof e?e.call(window,n[a],i):e.on?e.on(n[a],i):e.addEventListener?e.addEventListener(n[a],i):e.addEventHandler?e.addEventHandler(n[a],i):r.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){r.warn(e)}}}function n(e,t,i){t=t||r.Levels.NOTICE,i=i||"darkcyan";var n,o,u=r.prefix;r.includeTime&&(u+="["+("0"+(n=new Date).getDate()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+"] "),u+=function(e){return s[e]}(t)+":",r.level<=t&&t!==r.Levels.SILENT&&(!r.colorful||"undefined"!=typeof document&&document.documentMode?a(e,u):(o=t===r.Levels.ERROR&&console.error?console.error:t===r.Levels.WARNING&&console.warn?console.warn:t===r.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,u="%c"+u,e.splice(0,0,u,"color: "+i),o.apply(console,e)))}function a(e,t){if(e instanceof Array)for(var i in e)a(e[i],t);else"string"==typeof e?console.log(t+" "+e):(console.log(t+"↵"),console.log(e))}r.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},r.level=r.Levels.ERROR,r.colorful=!0,r.includeTime=!0,r.prefix="[nrvideo]";const s={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var e=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==e&&("true"===e[1]?r.level=r.Levels.ALL:r.level=e[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(r.colorful=!1)}}();const o=r},481(e,t,i){i.d(t,{X:()=>a});var r=i(347),n=i(144);class a{async send(e,t){const{url:i,payload:r,options:a={}}=e;try{if(!i||!r)throw new Error("URL and payload are required");const e={url:i,payload:r,options:a,callback:t};await this.executeRequest(e)}catch(e){n.A.error("Failed to send request:",e.message),t({retry:!1,status:0,error:e.message})}}async executeRequest(e){const{url:t,payload:i,options:r,callback:a}=e,s=Date.now();try{const a=(o=JSON.stringify(i.body),u=window.NRVIDEO?.config?.obfuscate,u&&0!==u.length?u.reduce((e,t)=>{let i;try{if(t.regex instanceof RegExp){const e=t.regex.flags.includes("g")?t.regex.flags:t.regex.flags+"g";i=new RegExp(t.regex.source,e)}else i=new RegExp(t.regex,"g")}catch(i){return n.A.warn("applyObfuscationRules: invalid regex, skipping rule:",t.regex,i.message),e}return e.replace(i,t.replacement)},o):o);if(r.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(t,a),r={success:i,status:i?204:0};return void this.handleRequestComplete(e,r,s)}const d=await this.fetchWithTimeout(t,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:r.isFinalHarvest},1e4),l={success:d.ok,status:d.status,statusText:d.statusText};this.handleRequestComplete(e,l,s)}catch(t){const i={success:!1,status:0,error:t.message};this.handleRequestComplete(e,i,s)}var o,u}handleRequestComplete(e,t){const{callback:i}=e;i({retry:!t.success&&(0===t.status||(0,r.Sc)(t.status)),status:t.status,error:t.error})}async sendWithBeacon(e,t){try{return navigator.sendBeacon(e,t)}catch(e){return n.A.warn("sendBeacon failed, falling back to fetch:",e.message),!1}}async fetchWithTimeout(e,t,i){const r=new AbortController,n=setTimeout(()=>r.abort(),i);try{const i=await fetch(e,{...t,signal:r.signal});return clearTimeout(n),i}catch(e){if(clearTimeout(n),"AbortError"===e.name)throw new Error(`Request timeout after ${i}ms`);throw e}}}},413(e,t,i){i.d(t,{u:()=>u});var r=i(144),n=i(347),a=i(51);const{MAX_PAYLOAD_SIZE:s,MAX_EVENTS_PER_BATCH:o}=a.A;class u{constructor(){this.retryQueue=[],this.maxQueueSize=o,this.maxQueueSizeBytes=s}addFailedEvents(e){try{const t=Array.isArray(e)?e:[e];r.A.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,n.Q3)(e);for(;(0,n.Q3)(this.retryQueue)+t>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...e})}}catch(e){r.A.error("Failed to add events to retry queue:",e.message)}}discardEvent(e,t){r.A.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 r=0,a=0;for(let s=this.retryQueue.length-1;s>=0;s--){const o=this.retryQueue[s];if(a>=t)break;const u=(0,n.Q3)(o);if(r+u>e)break;i.unshift(o),r+=u,a++,this.retryQueue.splice(s,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(e,t,i){i.d(t,{A:()=>l});var r=i(330),n=i(568),a=i(455),s=i(51),o=i(487),u=i(144);class d extends n.A{constructor(e){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new a.A,this._trackerReadyChrono.start(),this._actionTable=s.A.ACTION_TABLE,this._actionAdTable=s.A.ACTION_AD_TABLE,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(d.Events.HEARTBEAT,e)}getAttributes(e,t){(e=e||{}).trackerName=this.getTrackerName(),e.trackerVersion=this.getTrackerVersion(),e.coreVersion=r.rE,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 r.rE}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(o.videoAnalyticsHarvester)try{o.videoAnalyticsHarvester.setHarvestInterval(e)}catch(e){return void u.A.error("Failed to set harvest interval:",e.message)}else u.A.error("VideoAnalyticsHarvester is not available")}}d.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const l=d},347(e,t,i){i.d(t,{Q3:()=>s,Sc:()=>o,c$:()=>a,z8:()=>u});var r=i(330),n=i(144);function a(e){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:t,licenseKey:i,applicationID:n}=window.NRVIDEO.info;if(!t||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return n?`https://${e||t}/ins/1/${i}?a=${n}&v=${r.rE}&ref=${window.location.href}&ca=VA`:`https://${e||t}/ins/1/${i}?&v=${r.rE}&ref=${window.location.href}&ca=VA`}catch(e){return console.error(e.message),null}}function s(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,(()=>{const e=new WeakSet;return(t,i)=>{if("object"==typeof i&&null!==i){if(e.has(i))return;e.add(i)}return i}})())??""}catch(e){return n.A.error("Error stringifying value:",e.message),""}}(e).length}catch(e){return}}}function o(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}function u(e,t){return e&&Array.isArray(e)&&0!==e.length?t&&"object"==typeof t?e.reduce((e,i)=>(i in t&&(e[i]=t[i]),e),{}):{}:t}},330(e){e.exports={rE:"4.1.7"}}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s=a(144),o=a(487),u=a(51),d=a(302),l=a(347);function c(e,t={}){try{if(!u.A.VALID_EVENT_TYPES.includes(e))return s.A.warn("Invalid event type provided to recordEvent",{eventType:e}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:r}=window.NRVIDEO.info,{qoe:n,...a}=t,c=n?{...n}:{},h={...r?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},f={...a,eventType:e,...h},m=(0,l.z8)(u.A.QOE_AGGREGATE_KEYS,t);let p=null;"VideoAction"===e&&(p={eventType:"VideoAction",actionName:d.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...c,...m,...h});const g=o.videoAnalyticsHarvester.addEvent(f);if(p&&window?.NRVIDEO?.config?.qoeAggregate){const e=o.videoAnalyticsHarvester.addEvent(p);return g&&e}return g}catch(e){return s.A.error("Failed to record event:",e.message),!1}}const{COLLECTOR:h}=u.A,f=new class{setConfiguration(e,t){return!!this.validateRequiredFields(e)&&!!this.validateConfigFields(t)&&(this.initializeGlobalConfig(e,t),s.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(e){if(!e||"object"!=typeof e)return s.A.error("Configuration must be an object"),!1;const{licenseKey:t,appName:i,region:r,applicationID:n,beacon:a}=e;if(!t)return s.A.error("licenseKey is required"),!1;if(n){if(!a)return s.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(h).flatMap(e=>e).includes(a))return s.A.error(`Invalid beacon: ${a}`),!1}else{if(!i||!r)return s.A.error("appName and region are required when applicationID is not provided"),!1;if(!h[r])return s.A.error(`Invalid region: ${r}. Valid regions are: ${Object.keys(h).join(", ")}`),!1}return!0}validateConfigFields(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return s.A.error("config must be an object"),!1;const{qoeAggregate:t,obfuscate:i}=e;return void 0!==t&&"boolean"!=typeof t?(s.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(s.A.error("obfuscate must be an array"),1))}filterObfuscateRules(e){return e?e.filter(e=>{const t=void 0!==e.regex&&("string"==typeof e.regex||e.regex instanceof RegExp),i=void 0!==e.replacement&&"string"==typeof e.replacement;return!(!t||!i)||(s.A.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",e),!1)}):[]}sanitizeQoeIntervalFactor(e){return null==e?2:"number"==typeof e&&Number.isInteger(e)&&e>=1?e:(s.A.warn(`Invalid qoeIntervalFactor "${e}" — must be a positive integer. Defaulting to 2.`),2)}initializeGlobalConfig(e,t){let{licenseKey:i,appName:r,region:n,beacon:a,applicationID:s}=e;a="US"===n?u.A.COLLECTOR.US[0]:a||h[n],window.NRVIDEO={info:{...n?{region:n}:{},beacon:a,licenseKey:i,applicationID:s,...s?{}:{appName:r}},config:{qoeAggregate:t?.qoeAggregate??!0,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(t?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(t?.obfuscate)}}}};class m{static addTracker(e,t){var i,r;t?.info&&(i=t.info,r=t?.config,f.setConfiguration(i,r)),e.on&&e.emit?(p.push(e),e.on("*",g),"function"==typeof e.trackerInit&&e.trackerInit()):s.A.error("Tried to load a non-tracker.",e)}static removeTracker(e){e.off("*",g),e.dispose();let t=p.indexOf(e);-1!==t&&p.splice(t,1)}static getTrackers(){return p}static send(e,t,i){return c(e,{actionName:t,...i})}static sendError(e){return c("VideoErrorAction",{actionName:"ERROR",...e})}static async forceHarvest(){try{const{videoAnalyticsHarvester:e}=a(487);return await e.forceHarvest()}catch(e){return s.A.error("Failed to force harvest:",e.message),{success:!1,error:e.message}}}}let p=[];function g(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);s.A.level<=s.A.Levels.DEBUG?s.A.notice("Sent",e.type,t):s.A.notice("Sent",e.type),m.send(e.eventType,e.type,t)}catch(e){s.A.error("Error in event handler:",e.message)}}const y=m;var v=a(455),A=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 v.A,this.timeSinceStarted=new v.A,this.timeSincePaused=new v.A,this.timeSinceSeekBegin=new v.A,this.timeSinceBufferBegin=new v.A,this.timeSinceAdBreakStart=new v.A,this.timeSinceLastDownload=new v.A,this.timeSinceLastHeartbeat=new v.A,this.timeSinceLastRenditionChange=new v.A,this.timeSinceLastAdQuartile=new v.A,this.timeSinceLastAd=new v.A,this.timeSinceLastError=new v.A,this.timeSinceLastAdError=new v.A,this.timeSinceResumed=new v.A,this.timeSinceSeekEnd=new v.A,this.playtimeSinceLastEvent=new v.A,this.customTimeSinceAttributes={},this.elapsedTime=new v.A,this.bufferElapsedTime=new v.A,this._totalAdPlaytime=new v.A}isAd(){return this._isAd}setIsAd(e){this._isAd=e}setTimeSinceAttribute(e){this.customTimeSinceAttributes[e]=new v.A,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}getQoeAttributes(e){e=e||{};const t={};try{null!==this.startupTime&&(t.startupTime=this.startupTime),this.peakBitrate>0&&(t.peakBitrate=this.peakBitrate),t.hadStartupError=this.hadStartupError,t.hadPlaybackError=this.hadPlaybackError,t.totalRebufferingTime=this.totalRebufferingTime,t.rebufferingRatio=this.totalPlaytime>0?this.totalRebufferingTime/this.totalPlaytime*100:0,t.totalPlaytime=this.totalPlaytime,t.averageBitrate=this.weightedBitrate,t.numberOfErrors=this.numberOfErrors}catch(e){s.A.error("Failed to add attributes for QOE KPIs",e.message)}return e.qoe=t,e}calculateBufferType(e){let t="";return t=e?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",s.A.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(),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(e){if(e&&"number"==typeof e){this.peakBitrate=Math.max(this.peakBitrate,e);const t=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){const e=t-this._lastBitrateChangeTimestamp;e>0&&(this.partialAverageBitrate+=this._lastBitrate*e,this._totalBitrateDuration+=e),this._lastBitrateChangeTimestamp=null}return void(this._lastBitrate=e)}if(null===this._lastBitrateChangeTimestamp&&null!==this._lastBitrate&&(this._lastBitrateChangeTimestamp=t),null!==this._lastBitrate&&this._lastBitrate!==e&&null!==this._lastBitrateChangeTimestamp){const e=t-this._lastBitrateChangeTimestamp;e>0&&(this.partialAverageBitrate+=this._lastBitrate*e,this._totalBitrateDuration+=e),this._lastBitrateChangeTimestamp=t}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=t),this._lastBitrate=e;let i=this.partialAverageBitrate,r=this._totalBitrateDuration;const n=t-this._lastBitrateChangeTimestamp;n>0&&(i+=e*n,r+=n),this.weightedBitrate=r>0?Math.round(i/r):e}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){s.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return s.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return s.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(e){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-e,0))}};var E=a(330);class b extends d.A{constructor(e,t){super(),this.state=new T,this.adsTracker=null,this._lastBufferType=null,this._userId=null,t=t||{},this.setOptions(t),e&&this.setPlayer(e,t.tag),s.A.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),d.A.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("*",S.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",S),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getManifestBitrate(){return null}getSegmentDownloadBitrate(){return null}getNetworkDownloadBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let 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 E.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(e,t){if(void 0===(e=d.A.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(),this.state.isStarted&&(e.adBitrate=this.getBitrate()||0),e.adRenditionName=this.getRenditionName(),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(),this.state.isStarted&&(e.contentBitrate=this.getBitrate()||0,e.contentManifestBitrate=this.getManifestBitrate()||0,e.contentSegmentDownloadBitrate=this.getSegmentDownloadBitrate()||0,e.contentNetworkDownloadBitrate=this.getNetworkDownloadBitrate()||0),e.contentRenditionName=this.getRenditionName(),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),this.state.isStarted&&!this.isAd()&&this.state.trackContentBitrateState(e.contentBitrate);for(let t in this.customData)e[t]=this.customData[t];return this.addQoeAttributes(e),e}addQoeAttributes(e){const t=(e=this.state.getQoeAttributes(e)).qoe;for(let e in this.customData)t[e]=this.customData[e]}sendCustom(e,t,i){i=i||{},this.sendVideoCustomAction(e,i),this.state.setTimeSinceAttribute(t)}sendPlayerReady(e){this.state.goPlayerReady()&&(e=e||{},this.sendVideoAction(b.Events.PLAYER_READY,e))}sendRequest(e){if(this.state.goRequest()){let t;this.isAd()?(t=b.Events.AD_REQUEST,this.sendVideoAdAction(t,e)):(t=b.Events.CONTENT_REQUEST,this.sendVideoAction(t,e))}}sendStart(e){if(this.state.goStart()){let t;if(this.isAd())t=b.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(t,e),this.state.startAdsTime();else{t=b.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(t,e),o.videoAnalyticsHarvester.setBeforeDrainCallback(()=>{if(this.state){const e=this.state.getQoeAttributes({}).qoe;o.videoAnalyticsHarvester.refreshQoeKpis(e,this.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(e){if(this.state.goEnd()){let t;e=e||{},this.isAd()?(t=b.Events.AD_END,e.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.state.stopAdsTime()):(t=b.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,this.isAd()||(o.videoAnalyticsHarvester.forceNextQoeCycle(),o.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(e){if(this.state.goPause()){let t=this.isAd()?b.Events.AD_PAUSE:b.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=b.Events.AD_RESUME,e.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(t=b.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()?b.Events.AD_BUFFER_START:b.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=b.Events.AD_BUFFER_END,e.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(t=b.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()?b.Events.AD_SEEK_START:b.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=b.Events.AD_SEEK_END,e.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(t=b.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.A.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(b.Events.DOWNLOAD,e),this.state.goDownload()}sendError(e){(e=e||{}).isAd=this.isAd(),this.state.goError();let t=this.isAd()?b.Events.AD_ERROR:b.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()?b.Events.AD_RENDITION_CHANGE:b.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=b.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(t,e):this.sendVideoAdAction(t,{elapsedTime:i,...e})):(t=b.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(b.Events.AD_BREAK_START,e))}sendAdBreakEnd(e){this.isAd()&&this.state.goAdBreakEnd()&&((e=e||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(b.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.A.warn("Called sendAdQuartile without { quartile: xxxxx }."),e.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(b.Events.AD_QUARTILE,e),this.state.goAdQuartile())}sendAdClick(e){this.isAd()&&((e=e||{}).url||s.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(b.Events.AD_CLICK,e))}}function S(e){e.type!==b.Events.AD_ERROR?this.sendVideoAdAction(e.type,e.data):this.sendVideoErrorAction(e.type,e.data)}b.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"};const k=b;var _=a(431),D=a(413),P=a(481),I=a(374);const R={Constants:u.A,Chrono:v.A,Log:s.A,Emitter:A.A,Tracker:d.A,VideoTracker:k,VideoTrackerState:T,Core:y,version:E.rE,NrVideoEventAggregator:_.t,RetryQueueHandler:D.u,OptimizedHttpClient:P.X,HarvestScheduler:I.n,recordEvent:c}},64(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=s(i(555)),a=s(i(472));function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,u(r.key),r)}}function u(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function d(e,t,i){return t=c(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,i||[],c(e).constructor):t.apply(e,i))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}t.default=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),d(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(t,e),i=t,a=[{key:"isUsing",value:function(e){return!!e.ima3}}],(r=[{key:"getTrackerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayerName",value:function(){return"brightcove-ima-ads"}},{key:"getPlayhead",value:function(){var e;return null===(e=this.player)||void 0===e||null===(e=e.ima3)||void 0===e||null===(e=e.adPlayer)||void 0===e?void 0:e.currentTime()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ima3-ready","ima3error","ima3-ad-error","ima3-started","ima3-complete","ima3-paused","ima3-resumed","ads-request","ads-load","ads-ad-started","ads-ad-ended","ads-pause","ads-play","ads-click","ads-pod-started","ads-pod-ended","ads-allpods-completed"]),this.player.on("ima3-started",this.onStarted.bind(this)),this.player.on("ima3-paused",this.onPaused.bind(this)),this.player.on("ima3-resumed",this.onResume.bind(this)),this.player.on("ima3-complete",this.onComplete.bind(this)),this.player.on("ima3-skipped",this.onSkipped.bind(this)),this.player.on("adserror",this.onError.bind(this)),this.player.on("ads-click",this.onClick.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ima3-started",this.onStarted),this.player.off("ima3-paused",this.onPaused),this.player.off("ima3-resumed",this.onResume),this.player.off("ima3-complete",this.onComplete),this.player.off("ima3-skipped",this.onSkipped),this.player.off("adserror",this.onError),this.player.off("ads-click",this.onClick)}},{key:"onStarted",value:function(e){this.sendRequest(),this.sendStart()}},{key:"onPaused",value:function(e){this.sendPause()}},{key:"onResume",value:function(e){this.sendResume()}},{key:"onComplete",value:function(e){this.sendEnd()}},{key:"onSkipped",value:function(e){this.sendEnd({skipped:!0})}},{key:"onError",value:function(e){this.sendError()}},{key:"onClick",value:function(e){this.sendClick()}}])&&o(i.prototype,r),a&&o(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},717(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=s(i(555)),a=s(i(472));function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,n,a,s,o=[],u=!0,d=!1;try{if(a=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;u=!1}else for(;!(u=(r=a.call(i)).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){d=!0,n=e}finally{try{if(!u&&null!=i.return&&(s=i.return(),Object(s)!==s))return}finally{if(d)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function d(e,t,i){return(t=c(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function c(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function h(e,t,i){return t=g(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,f()?Reflect.construct(t,i||[],g(e).constructor):t.apply(e,i))}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function m(e,t,i,r){var n=p(g(1&r?e.prototype:e),t,i);return 2&r&&"function"==typeof n?function(e){return n.apply(i,e)}:n}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=g(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},p.apply(null,arguments)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}var v={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"};t.default=function(e){function t(e){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(i=h(this,t,[e])).streamManager=null,i.currentAdData=null,i.adBreakData=null,i.streamData=null,i.cuePoints=[],i.initialized=!1,i.eventHandlers=null,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}(t,e),i=t,a=[{key:"isUsing",value:function(e){return e.imaDai&&"function"==typeof e.imaDai||e.dai&&void 0!==e.dai.VERSION||e.ima&&e.ima.dai||e.streamManager}}],(r=[{key:"setStreamManager",value:function(e){this.streamManager=e,this.setupStreamManagerListeners(),this.initialized=!0,n.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}},{key:"setupStreamManagerListeners",value:function(){var e,t,i=this;if(this.streamManager&&null!==(e=google)&&void 0!==e&&null!==(e=e.ima)&&void 0!==e&&null!==(e=e.dai)&&void 0!==e&&null!==(e=e.api)&&void 0!==e&&e.StreamEvent){var r=google.ima.dai.api.StreamEvent.Type;this.eventHandlers=(d(d(d(d(d(d(d(d(d(d(t={},r.LOADED,this.onStreamLoaded.bind(this)),r.STREAM_INITIALIZED,this.onStreamInitialized.bind(this)),r.ERROR,this.onStreamError.bind(this)),r.AD_BREAK_STARTED,this.onAdBreakStarted.bind(this)),r.AD_BREAK_ENDED,this.onAdBreakEnded.bind(this)),r.AD_PERIOD_STARTED,this.onAdPeriodStarted.bind(this)),r.AD_PERIOD_ENDED,this.onAdPeriodEnded.bind(this)),r.STARTED,this.onAdStarted.bind(this)),r.FIRST_QUARTILE,this.onAdFirstQuartile.bind(this)),r.MIDPOINT,this.onAdMidpoint.bind(this)),d(d(d(d(d(d(d(d(d(t,r.THIRD_QUARTILE,this.onAdThirdQuartile.bind(this)),r.COMPLETE,this.onAdComplete.bind(this)),r.SKIPPED,this.onAdSkipped.bind(this)),r.PAUSED,this.onAdPaused.bind(this)),r.RESUMED,this.onAdResumed.bind(this)),r.CLICK,this.onAdClicked.bind(this)),r.VIDEO_CLICKED,this.onAdClicked.bind(this)),r.CUEPOINTS_CHANGED,this.onCuePointsChanged.bind(this)),r.TIMED_METADATA,this.onTimedMetadata.bind(this))),Object.entries(this.eventHandlers).forEach(function(e){var t=o(e,2),r=t[0],n=t[1];i.streamManager.addEventListener(r,n)}),n.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}else n.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available")}},{key:"registerListeners",value:function(){m(t,"registerListeners",this,3)([]),n.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(v)])}},{key:"unregisterListeners",value:function(){var e=this;m(t,"unregisterListeners",this,3)([]),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach(function(t){var i=o(t,2),r=i[0],n=i[1];e.streamManager.removeEventListener(r,n)}),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}},{key:"onStreamLoaded",value:function(e){this.streamData=this.extractStreamData(e),n.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}},{key:"onStreamInitialized",value:function(e){n.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}},{key:"onStreamError",value:function(e){var t=this.extractErrorData(e);n.default.Log.error("DaiAdsTracker: Stream error",t),this.sendError(t)}},{key:"onAdBreakStarted",value:function(e){this.adBreakData=this.extractAdBreakData(e),n.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}},{key:"onAdBreakEnded",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}},{key:"onAdPeriodStarted",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(e)}},{key:"onAdPeriodEnded",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad period ended")}},{key:"onAdStarted",value:function(e){this.currentAdData=this.extractAdData(e),n.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}},{key:"onAdFirstQuartile",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}},{key:"onAdMidpoint",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}},{key:"onAdThirdQuartile",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}},{key:"onAdComplete",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}},{key:"onAdSkipped",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}},{key:"onAdPaused",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}},{key:"onAdResumed",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}},{key:"onAdClicked",value:function(e){n.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}},{key:"onCuePointsChanged",value:function(e){this.cuePoints=this.extractCuePoints(e),n.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}},{key:"onTimedMetadata",value:function(e){var t=this.extractTimedMetadata(e);n.default.Log.debug("DaiAdsTracker: Timed metadata",t)}},{key:"extractStreamData",value:function(e){try{var t=e.getStreamData();return{streamId:null==t?void 0:t.streamId,url:null==t?void 0:t.url,adTagParameters:null==t?void 0:t.adTagParameters,streamType:this.getStreamType()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract stream data",e),{}}}},{key:"extractAdBreakData",value:function(e){try{var t,i=e.getAdBreak();return{adBreakId:null==i?void 0:i.id,adBreakTitle:null==i?void 0:i.title,adCount:(null==i||null===(t=i.ads)||void 0===t?void 0:t.length)||0,position:this.getAdPosition()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",e),{}}}},{key:"extractAdData",value:function(e){try{var t=e.getAd();return{adId:null==t?void 0:t.getAdId(),creativeId:null==t?void 0:t.getCreativeId(),duration:null==t?void 0:t.getDuration(),title:null==t?void 0:t.getTitle(),description:null==t?void 0:t.getDescription(),advertiserName:null==t?void 0:t.getAdvertiserName(),clickThroughUrl:null==t?void 0:t.getClickThroughUrl(),dealId:null==t?void 0:t.getDealId(),wrapperAdIds:null==t?void 0:t.getWrapperAdIds(),position:this.getAdPosition()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract ad data",e),{}}}},{key:"extractErrorData",value:function(e){try{var t=e.getError();return{errorCode:null==t?void 0:t.getErrorCode(),errorMessage:null==t?void 0:t.getMessage(),innerError:null==t?void 0:t.getInnerError()}}catch(t){return n.default.Log.warn("DaiAdsTracker: Failed to extract error data",t),{errorMessage:"Unknown DAI error"}}}},{key:"extractCuePoints",value:function(e){try{return e.getCuepoints()||[]}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract cue points",e),[]}}},{key:"extractTimedMetadata",value:function(e){try{return{type:e.getType(),data:e.getData()}}catch(e){return n.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",e),{}}}},{key:"getTrackerName",value:function(){return"dai-ads"}},{key:"getPlayerName",value:function(){return"videojs-dai"}},{key:"getPlayerVersion",value:function(){var e,t;return null!==(e=this.player.dai)&&void 0!==e&&e.VERSION?this.player.dai.VERSION:null!==(t=this.player.ima)&&void 0!==t&&t.VERSION?"ima-dai: ".concat(this.player.ima.VERSION):"unknown"}},{key:"getAdCuePoints",value:function(){return this.cuePoints}},{key:"getAdPosition",value:function(){if(!this.currentAdData&&!this.adBreakData)return null;var e=this.player.currentTime(),t=this.player.duration();return e<5?"pre":t&&e>t-10?"post":"mid"}},{key:"getDuration",value:function(){var e;return void 0!==(null===(e=this.currentAdData)||void 0===e?void 0:e.duration)?1e3*this.currentAdData.duration:null}},{key:"getVideoId",value:function(){var e;return(null===(e=this.currentAdData)||void 0===e?void 0:e.adId)||null}},{key:"getAdCreativeId",value:function(){var e;return(null===(e=this.currentAdData)||void 0===e?void 0:e.creativeId)||null}},{key:"getTitle",value:function(){var e;return(null===(e=this.currentAdData)||void 0===e?void 0:e.title)||null}},{key:"getSrc",value:function(){var e;return(null===(e=this.streamData)||void 0===e?void 0:e.url)||null}},{key:"getPlayhead",value:function(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(e){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}},{key:"getAdPartner",value:function(){return"google-dai"}},{key:"getClickThroughUrl",value:function(){var e;return(null===(e=this.currentAdData)||void 0===e?void 0:e.clickThroughUrl)||null}},{key:"getStreamType",value:function(){var e;return null!==(e=this.streamData)&&void 0!==e&&e.streamType?this.streamData.streamType:this.player.duration()===1/0?"live":"vod"}},{key:"isLiveStream",value:function(){return"live"===this.getStreamType()}},{key:"getCurrentAdBreak",value:function(){return this.adBreakData}},{key:"getCurrentAd",value:function(){return this.currentAdData}},{key:"getStreamData",value:function(){return this.streamData}},{key:"getBitrate",value:function(){var e=this.getTech();return e&&e.tech&&e.tech.stats&&e.tech.stats.bandwidth?Math.round(e.tech.stats.bandwidth):null}},{key:"getRenditionBitrate",value:function(){var e=this.getTech();if(e&&e.getRenditionBitrate){var t=e.getRenditionBitrate();return null!==t?Math.round(t):null}return null}}])&&l(i.prototype,r),a&&l(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},38(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,a=(n=i(472))&&n.__esModule?n:{default:n};function s(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function u(e,t,i){return t=l(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,d()?Reflect.construct(t,i||[],l(e).constructor):t.apply(e,i))}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}t.default=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),u(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(t,e),function(e,t,i){return t&&s(e.prototype,t),i&&s(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"getTrackerName",value:function(){return"freewheel-ads"}},{key:"getPlayerName",value:function(){return"freewheel-ads"}},{key:"getPlayerVersion",value:function(){return this.player.FreeWheelPlugin.VERSION}},{key:"getPlayhead",value:function(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}},{key:"getDuration",value:function(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}},{key:"getVideoId",value:function(){return this.player.ads.ad.id}},{key:"getAdPartner",value:function(){return"freewheel"}},{key:"getAdCreativeId",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(e){}}},{key:"getSrc",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(e){}}},{key:"getTitle",value:function(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(e){}}},{key:"getAdPosition",value:function(){switch(this.player.ads.ad.type){case"PREROLL":return nrvideo.Constants.AdPositions.PRE;case"MIDROLL":return nrvideo.Constants.AdPositions.MID;case"POSTROLL":return nrvideo.Constants.AdPositions.POST}}}],[{key:"isUsing",value:function(e){return!!e.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}}])}(a.default)},298(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=s(i(555)),a=s(i(472));function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,u(r.key),r)}}function u(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function d(e,t,i){return t=c(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,i||[],c(e).constructor):t.apply(e,i))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}t.default=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),d(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(t,e),i=t,r=[{key:"getTrackerName",value:function(){return"ima-ads"}},{key:"getPlayerName",value:function(){return"ima"}},{key:"getPlayerVersion",value:function(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}},{key:"getCuePoints",value:function(){return this.player.ima.getAdsManager().getCuePoints()}},{key:"getAdPosition",value:function(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){var e=this.lastAdData.podInfo.podIndex;return 0===e?"pre":-1===e?"post":"mid"}return null}},{key:"getDuration",value:function(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}},{key:"getVideoId",value:function(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}},{key:"getAdCreativeId",value:function(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}},{key:"getSrc",value:function(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}},{key:"getTitle",value:function(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}},{key:"getPlayhead",value:function(){var e=this.player.ima.getAdsManager();if(e)return 1e3*(this.getDuration()-e.getRemainingTime())}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"getAdPartner",value:function(){return"ima"}},{key:"getWebkitBitrate",value:function(){var e=this.getAdVideoElement();if(e&&e.webkitVideoDecodedByteCount){var t;if(this._lastAdWebkitBitrate>0){var i=e.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,r=this.getHeartbeat()/1e3;t=Math.round(i/r*8)}return this._lastAdWebkitBitrate=e.webkitVideoDecodedByteCount,null!=t?t:null}return null}},{key:"getRenditionBitrate",value:function(){return this.lastAdData&&this.lastAdData.renditionBitrate?Math.round(this.lastAdData.renditionBitrate):null}},{key:"registerListeners",value:function(){var e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,n.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))}},{key:"unregisterListeners",value:function(){var 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}},{key:"onLoaded",value:function(e){this.lastAdData=this.getAdData(),this.sendRequest()}},{key:"onStart",value:function(e){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}},{key:"onComplete",value:function(e){this.sendEnd(),this.lastAdData=null}},{key:"onSkipped",value:function(e){this.sendEnd({skipped:!0}),this.lastAdData=null}},{key:"onError",value:function(e){var t=e.getError(),i=t.getErrorCode(),r=t.getMessage();this.sendError({adError:t,errorCode:i,errorMessage:r})}},{key:"onClick",value:function(e){this.sendAdClick()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({adQuartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({adQuartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({adQuartile:3})}},{key:"onPaused",value:function(){this.sendPause()}},{key:"onResumed",value:function(){this.sendResume()}},{key:"getAdData",value:function(){try{var e=this.player.ima.getAdsManager();if(e){var t,i=e.getCurrentAd();if(i)return{adId:i.getAdId(),creativeId:i.getCreativeId(),duration:i.getDuration(),mediaUrl:i.getMediaUrl(),title:i.getTitle(),podInfo:null===(t=i.getAdPodInfo())||void 0===t?void 0:t.data,renditionBitrate:i.getVastMediaBitrate()}}return null}catch(e){return null}}},{key:"getAdVideoElement",value:function(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){var e=this.player.ima.controller.adUi.adContainerDiv;if(e){var t=e.querySelector("video");if(t)return t}}}}],a=[{key:"isUsing",value:function(e){return e.ima&&"undefined"!=typeof google}}],r&&o(i.prototype,r),a&&o(i,a),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,a}(a.default)},687(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=u(i(555)),a=u(i(472)),s=i(324),o=i(612);function u(e){return e&&e.__esModule?e:{default:e}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function l(){var e,t,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",n=i.toStringTag||"@@toStringTag";function a(i,r,n,a){var u=r&&r.prototype instanceof o?r:o,d=Object.create(u.prototype);return c(d,"_invoke",function(i,r,n){var a,o,u,d=0,l=n||[],c=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,i){return a=t,o=0,u=e,h.n=i,s}};function f(i,r){for(o=i,u=r,t=0;!c&&d&&!n&&t<l.length;t++){var n,a=l[t],f=h.p,m=a[2];i>3?(n=m===r)&&(u=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=e):a[0]<=f&&((n=i<2&&f<a[1])?(o=0,h.v=r,h.n=a[1]):f<m&&(n=i<3||a[0]>r||r>m)&&(a[4]=i,a[5]=r,h.n=m,o=0))}if(n||i>1)return s;throw c=!0,r}return function(n,l,m){if(d>1)throw TypeError("Generator is already running");for(c&&1===l&&f(l,m),o=l,u=m;(t=o<2?e:u)||!c;){a||(o?o<3?(o>1&&(h.n=-1),f(o,u)):h.n=u:h.v=u);try{if(d=2,a){if(o||(n="next"),t=a[n]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,o<2&&(o=0)}else 1===o&&(t=a.return)&&t.call(a),o<2&&(u=TypeError("The iterator does not provide a '"+n+"' method"),o=1);a=e}else if((t=(c=h.n<0)?u:i.call(r,h))!==s)break}catch(t){a=e,o=1,u=t}finally{d=1}}return{value:t,done:c}}}(i,n,a),!0),d}var s={};function o(){}function u(){}function d(){}t=Object.getPrototypeOf;var h=[][r]?t(t([][r]())):(c(t={},r,function(){return this}),t),f=d.prototype=o.prototype=Object.create(h);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,n,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=d,c(f,"constructor",d),c(d,"constructor",u),u.displayName="GeneratorFunction",c(d,n,"GeneratorFunction"),c(f),c(f,n,"Generator"),c(f,r,function(){return this}),c(f,"toString",function(){return"[object Generator]"}),(l=function(){return{w:a,m}})()}function c(e,t,i,r){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}c=function(e,t,i,r){function a(t,i){c(e,t,function(e){return this._invoke(t,i,e)})}t?n?n(e,t,{value:i,enumerable:!r,configurable:!r,writable:!r}):e[t]=i:(a("next",0),a("throw",1),a("return",2))},c(e,t,i,r)}function h(e,t,i,r,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void i(e)}o.done?t(u):Promise.resolve(u).then(r,n)}function f(e){return function(){var t=this,i=arguments;return new Promise(function(r,n){var a=e.apply(t,i);function s(e){h(a,r,n,s,o,"next",e)}function o(e){h(a,r,n,s,o,"throw",e)}s(void 0)})}}function m(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,p(r.key),r)}}function p(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function g(e,t,i){return t=E(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,y()?Reflect.construct(t,i||[],E(e).constructor):t.apply(e,i))}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}function A(e,t,i,r){var n=T(E(1&r?e.prototype:e),t,i);return 2&r&&"function"==typeof n?function(e){return n.apply(i,e)}:n}function T(){return T="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=E(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},T.apply(null,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}var b=(n.default.default||n.default).Log;t.default=function(e){function t(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=g(this,t,[e]);var n=!0===r.mediatailor?{}:r.mediatailor||{};return i.streamType=null,i.manifestFormat=null,i.playbackManifestUrl=e.currentSrc(),i.explicitTrackingUrl=n.trackingUrl||null,i.adSegmentPrefix=n.adSegmentPrefix||null,i.adSegmentPrefix?b.debug('[MT] ad segment detection: custom prefix "'.concat(i.adSegmentPrefix,'"')):b.debug("[MT] ad segment detection: default (segments.mediatailor hostname or /tm/ path)"),i.adSchedule=[],i.currentAdBreak=null,i.currentAdPod=null,i.hasEndedContent=!1,i.isDisposed=!1,i.trackingAbortController=null,i.manifestAbortController=null,i.isFetchingTracking=!1,i.isFetchingManifest=!1,i.trackingEndpointUrl=null,i.hasAttemptedTrackingFetch=!1,i.trackingFetchRetries=0,i.maxTrackingRetries=1,i.manifestPollTimer=null,i.trackingPollTimer=null,i.liveRefreshIntervalSeconds=null,i.mediaPlaylistUrl=null,i.lastMediaPlaylistText=null,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] MediaTailorAdsTracker initialized"),{endpoint:i.playbackManifestUrl,trackingAPITimeout:s.TRACKING_API_TIMEOUT_MS}),i.manifestFormat=(0,o.detectManifestFormatFromUrl)(i.playbackManifestUrl),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Manifest type: ").concat(i.manifestFormat.toUpperCase())),i.player.one("loadedmetadata",function(){i.streamType=(0,o.detectPlaybackStreamType)(i.player.duration()),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Stream type: ").concat(i.streamType.toUpperCase())),i.initializeTracking()}),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}(t,e),i=t,r=[{key:"getTrackerName",value:function(){return"aws-media-tailor"}},{key:"getPlayerVersion",value:function(){return"MediaTailor"}},{key:"getAdPosition",value:function(){return this.currentAdBreak&&this.currentAdBreak.adPosition?this.currentAdBreak.adPosition:A(t,"getAdPosition",this,3)([])}},{key:"initializeTracking",value:function(){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Initializing ").concat(this.manifestFormat.toUpperCase()," ").concat(this.streamType.toUpperCase()," tracking")),this.trackingEndpointUrl=this.explicitTrackingUrl||(0,o.buildTrackingEndpointUrl)(this.playbackManifestUrl),this.trackingEndpointUrl?b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Tracking URL extracted:"),this.trackingEndpointUrl):b.warn("[MT - ".concat((0,o.getTimestamp)(),"] Could not derive tracking URL from playback URL — pass trackingUrl in mediatailor options if needed")),this.streamType===s.STREAM_TYPE.VOD?this.setupVODTracking():this.setupLiveTracking()}},{key:"registerListeners",value:function(){A(t,"registerListeners",this,3)([]),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onEnded=this.onEnded.bind(this),this.onTimeUpdate=this.onTimeUpdate.bind(this),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("waiting",this.onWaiting),this.player.on("ended",this.onEnded),this.player.on("timeupdate",this.onTimeUpdate),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Event listeners registered"))}},{key:"unregisterListeners",value:function(){A(t,"unregisterListeners",this,3)([]),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("waiting",this.onWaiting),this.player.off("ended",this.onEnded),this.player.off("timeupdate",this.onTimeUpdate),this.stopLivePolling()}},{key:"stopLivePolling",value:function(){this.manifestPollTimer&&(clearTimeout(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null)}},{key:"setupVODTracking",value:function(){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] VOD mode: Single manifest parse")),this.hookPlayerManifest()}},{key:"setupLiveTracking",value:function(){var e=this;b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Live mode: Continuous polling")),this.hookPlayerManifest();var t=this.getLiveRefreshIntervalMs();this.manifestPollTimer=setInterval(function(){e.pollManifestForNewAds()},t),this.trackingPollTimer=setInterval(function(){e.getAndProcessTrackingMetadata()},t),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Live polling started"),{pollingInterval:t})}},{key:"getLiveRefreshIntervalMs",value:function(){return this.liveRefreshIntervalSeconds?1e3*this.liveRefreshIntervalSeconds:s.DEFAULT_LIVE_POLL_INTERVAL_MS}},{key:"restartLivePollingTimers",value:function(){var e=this;if(this.liveRefreshIntervalSeconds){var t=this.getLiveRefreshIntervalMs();b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Updating live polling interval: ").concat(this.liveRefreshIntervalSeconds,"s")),this.manifestPollTimer&&clearInterval(this.manifestPollTimer),this.trackingPollTimer&&clearInterval(this.trackingPollTimer),this.manifestPollTimer=setInterval(function(){e.pollManifestForNewAds()},t),this.trackingPollTimer=setInterval(function(){e.getAndProcessTrackingMetadata()},t)}}},{key:"hookPlayerManifest",value:function(){var e=this.player.tech({IWillNotUseThisInPlugins:!0});if(!e)return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] No tech - using fallback fetch")),void this.getManifestDirectly();if(this.manifestFormat===s.MANIFEST_TYPE.HLS){if(this.hookHLSViaVHS(e)||this.hookHLSViaNative(e)||this.hookHLSViaContribHls(e))return}else if(this.manifestFormat===s.MANIFEST_TYPE.DASH&&(this.hookDASHViaShaka(e)||this.hookDASHViaDashJs(e)))return;b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Using fallback: direct manifest fetch")),this.getManifestDirectly()}},{key:"hookHLSViaVHS",value:function(e){var t=this;if(!e.vhs||!e.vhs.playlists)return!1;b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: VHS"));var i=e.vhs.playlists.media();return i&&i.segments&&i.segments.length>0&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Parsing existing playlist")),this.parseVhsPlaylistForAdBreaks(i)),e.vhs.on("loadedplaylist",function(){var i=e.vhs.playlists.media();i&&t.parseVhsPlaylistForAdBreaks(i)}),!0}},{key:"hookHLSViaNative",value:function(e){return!!(e.el_&&e.el_.canPlayType&&e.el_.canPlayType(s.HLS_MIME_TYPE))&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Native HLS detected - using fallback")),this.getManifestDirectly(),!0)}},{key:"hookHLSViaContribHls",value:function(e){var t=this;if(!e.hls||!e.hls.playlists)return!1;b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: contrib-hls (legacy)"));var i=e.hls.playlists.media();return i&&i.segments&&i.segments.length>0&&this.parseVhsPlaylistForAdBreaks(i),e.hls.on("loadedplaylist",function(){var i=e.hls.playlists.media();i&&t.parseVhsPlaylistForAdBreaks(i)}),!0}},{key:"hookDASHViaShaka",value:function(e){var t=this;return!!e.shakaPlayer&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: Shaka Player")),e.shakaPlayer.addEventListener("emsg",function(e){t.handleDASHEmsgEvent(e)}),!0)}},{key:"hookDASHViaDashJs",value:function(e){var t=this;return!(!e.dash||!e.dash.on||(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Hooked: dash.js")),e.dash.on("EVENT_MODE_ON_RECEIVE",function(e){t.handleDASHEventStream(e)}),0))}},{key:"getManifestDirectly",value:(p=f(l().m(function e(){var t,i;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fallback: fetching manifest directly")),e.p=1,t=this.playbackManifestUrl,this.manifestFormat!==s.MANIFEST_TYPE.HLS){e.n=3;break}return e.n=2,this.fetchAndParseHlsManifest(t);case 2:e.n=4;break;case 3:if(this.manifestFormat!==s.MANIFEST_TYPE.DASH){e.n=4;break}return e.n=4,this.fetchAndParseDashManifest(t);case 4:e.n=6;break;case 5:e.p=5,i=e.v,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fallback fetch error:"),i);case 6:return e.a(2)}},e,this,[[1,5]])})),function(){return p.apply(this,arguments)})},{key:"fetchAndParseHlsManifest",value:(h=f(l().m(function e(t){var i,r,n,a,s,u;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fetching HLS master manifest")),e.n=1,(0,o.fetchHlsMasterManifest)(t);case 1:if(i=e.v,r=i.mediaPlaylistUrl){e.n=2;break}return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] No media playlist found")),e.a(2);case 2:return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fetching media playlist")),e.n=3,(0,o.fetchHlsMediaPlaylist)(r);case 3:n=e.v,a=(0,o.extractHlsTargetDurationSeconds)(n),this.updateLiveRefreshIntervalFromManifest(a,"hls target duration"),(s=(0,o.parseHlsManifestForAdBreaks)(n)).length>0&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Detected ").concat(s.length," ad break(s)")),this.mergeNewAds(s)),e.n=5;break;case 4:e.p=4,u=e.v,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] HLS fetch error:"),u);case 5:return e.a(2)}},e,this,[[0,4]])})),function(e){return h.apply(this,arguments)})},{key:"fetchAndParseDashManifest",value:(c=f(l().m(function e(t){var i,r,n,a;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fetching DASH manifest")),e.n=1,(0,o.fetchDashManifest)(t);case 1:i=e.v,r=(0,o.extractDashMinimumUpdatePeriodSeconds)(i),this.updateLiveRefreshIntervalFromManifest(r,"dash minimumUpdatePeriod"),n=(0,o.parseDashManifestForAdBreaks)(i),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] DASH: ").concat(n.length," ad break(s) found")),n.length>0?this.mergeNewAds(n):this.streamType===s.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] DASH: no manifest cues, fetching tracking API")),this.hasAttemptedTrackingFetch=!0,this.getAndProcessTrackingMetadata()),e.n=3;break;case 2:e.p=2,a=e.v,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] DASH fetch error:"),a);case 3:return e.a(2)}},e,this,[[0,2]])})),function(e){return c.apply(this,arguments)})},{key:"handleDASHEmsgEvent",value:function(e){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] DASH emsg event:"),e);try{var t=e.detail;if(!t)return void b.debug("[MT - ".concat((0,o.getTimestamp)(),"] No emsg data in event"));var i=t.schemeIdUri||"";if(!i.includes(s.SCTE35_SCHEME_MARKER))return void b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Non-SCTE-35 emsg, skipping:"),i);b.debug("[MT - ".concat((0,o.getTimestamp)(),"] SCTE-35 emsg detected:"),{schemeIdUri:t.schemeIdUri,value:t.value,timescale:t.timescale,presentationTime:t.presentationTime,presentationTimeDelta:t.presentationTimeDelta,eventDuration:t.eventDuration});var r=t.timescale||1,n=t.presentationTime||0,a=t.eventDuration||0,u=n/r,d=a/r;if(t.messageData&&d>0){var l={id:"dash-emsg-".concat(u),startTime:u,duration:d,endTime:u+d,source:"dash-emsg",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Adding ad break from DASH emsg:"),l),this.mergeNewAds([l])}}catch(e){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Error parsing DASH emsg event:"),e)}}},{key:"handleDASHEventStream",value:function(e){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] DASH event stream:"),e);try{var t=e.event||e;if(!t)return void b.debug("[MT - ".concat((0,o.getTimestamp)(),"] No event data"));var i=t.schemeIdUri||"";if(!i.includes(s.SCTE35_SCHEME_MARKER))return void b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Non-SCTE-35 event, skipping:"),i);b.debug("[MT - ".concat((0,o.getTimestamp)(),"] SCTE-35 event stream detected:"),{id:t.id,schemeIdUri:t.schemeIdUri,presentationTime:t.presentationTime,duration:t.duration,messageData:t.messageData});var r=parseFloat(t.presentationTime||0),n=parseFloat(t.duration||0);if(n>0){var a={id:t.id||"dash-event-".concat(r),startTime:r,duration:n,endTime:r+n,source:"dash-event-stream",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Adding ad break from DASH event stream:"),a),this.mergeNewAds([a])}}catch(e){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Error parsing DASH event stream:"),e)}}},{key:"parseVhsPlaylistForAdBreaks",value:function(e){var t,i=this;if(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Parsing VHS playlist (").concat((null===(t=e.segments)||void 0===t?void 0:t.length)||0," segments)")),e.segments&&0!==e.segments.length){this.updateLiveRefreshIntervalFromManifest(e.targetDuration,"vhs target duration");var r=(0,o.detectAdBreaksFromVhsPlaylist)(e,{adSegmentPrefix:this.adSegmentPrefix});if(r.length>0){if(!this._detectionPathLogged){var n=e.segments&&e.segments.find(function(e){return(0,o.whichAdSegmentMarker)(e,{adSegmentPrefix:i.adSegmentPrefix})});if(n){var a=(0,o.whichAdSegmentMarker)(n,{adSegmentPrefix:this.adSegmentPrefix});b.debug("[MT] ad segment detection matched via: ".concat(a)),this._detectionPathLogged=!0}}b.debug("[MT - ".concat((0,o.getTimestamp)(),"] VHS detected ").concat(r.length," ad break(s), ").concat(r.reduce(function(e,t){return e+t.pods.length},0)," pod(s)")),this.mergeNewAds(r)}else b.debug("[MT - ".concat((0,o.getTimestamp)(),"] No ads detected in VHS playlist"))}else b.debug("[MT - ".concat((0,o.getTimestamp)(),"] No segments in playlist"))}},{key:"pollManifestForNewAds",value:(u=f(l().m(function e(){var t,i,r;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isDisposed){e.n=1;break}return e.a(2);case 1:if(this.streamType===s.STREAM_TYPE.LIVE){e.n=2;break}return e.a(2);case 2:if(!this.isFetchingManifest){e.n=3;break}return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Manifest fetch already in progress, skipping")),e.a(2);case 3:if(this.isFetchingManifest=!0,e.p=4,!(t=this.player.tech({IWillNotUseThisInPlugins:!0}))||!t.vhs){e.n=5;break}(i=t.vhs.playlists.media())&&this.parseVhsPlaylistForAdBreaks(i),e.n=6;break;case 5:if(this.manifestFormat!==s.MANIFEST_TYPE.DASH){e.n=6;break}return e.n=6,this.fetchAndParseDashManifest(this.playbackManifestUrl);case 6:e.n=8;break;case 7:e.p=7,r=e.v,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Manifest poll error:"),r);case 8:return e.p=8,this.isFetchingManifest=!1,e.f(8);case 9:return e.a(2)}},e,this,[[4,7,8,9]])})),function(){return u.apply(this,arguments)})},{key:"mergeNewAds",value:function(e){this.adSchedule=(0,o.mergeAdSchedules)(this.adSchedule,e),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Ad schedule: ").concat(this.adSchedule.length," ad break(s)")),this.streamType===s.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(this.hasAttemptedTrackingFetch=!0,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fetching tracking metadata (first manifest parse)")),this.getAndProcessTrackingMetadata())}},{key:"updateLiveRefreshIntervalFromManifest",value:function(e,t){this.streamType!==s.STREAM_TYPE.LIVE||!e||e<=0||this.liveRefreshIntervalSeconds!==e&&(this.liveRefreshIntervalSeconds=e,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Derived live polling interval from ").concat(t,": ").concat(e,"s")),(this.manifestPollTimer||this.trackingPollTimer)&&this.restartLivePollingTimers())}},{key:"getAndProcessTrackingMetadata",value:(a=f(l().m(function e(){var t,i;return l().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isDisposed&&this.trackingEndpointUrl){e.n=1;break}return e.a(2);case 1:if(!this.isFetchingTracking){e.n=2;break}return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Tracking fetch already in progress, skipping")),e.a(2);case 2:return this.isFetchingTracking=!0,e.p=3,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Fetching tracking metadata")),this.trackingAbortController=new AbortController,e.n=4,(0,o.getTrackingMetadata)(this.trackingEndpointUrl,s.TRACKING_API_TIMEOUT_MS,this.trackingAbortController.signal);case 4:if(t=e.v,!this.isDisposed){e.n=5;break}return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Disposed during tracking fetch, ignoring result")),e.a(2);case 5:t.avails&&t.avails.length>0?(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Enriching with ").concat(t.avails.length," avail(s)")),this.enrichWithTrackingMetadata(t.avails),this.trackingFetchRetries=0):b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Tracking API returned 0 avails")),e.n=10;break;case 6:if(e.p=6,"AbortError"!==(i=e.v).name&&!this.isDisposed){e.n=7;break}return b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Tracking fetch aborted")),e.a(2);case 7:if(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Tracking API error: ").concat(i.message),i),!(this.trackingFetchRetries<this.maxTrackingRetries)){e.n=9;break}return this.trackingFetchRetries++,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Retrying tracking fetch (").concat(this.trackingFetchRetries,"/").concat(this.maxTrackingRetries,")")),this.isFetchingTracking=!1,e.n=8,this.getAndProcessTrackingMetadata();case 8:return e.a(2);case 9:b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Max retries reached, continuing with manifest data only"));case 10:return e.p=10,this.isFetchingTracking=!1,this.trackingAbortController=null,e.f(10);case 11:return e.a(2)}},e,this,[[3,6,10,11]])})),function(){return a.apply(this,arguments)})},{key:"enrichWithTrackingMetadata",value:function(e){var t,i=(0,o.enrichAdScheduleWithTrackingMetadata)(this.adSchedule,e);i.length>0&&((t=this.adSchedule).push.apply(t,function(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(i)),this.adSchedule.sort(function(e,t){return e.startTime-t.startTime})),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Enrichment complete: ").concat(this.adSchedule.length," ad break(s)")),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Enriched schedule:"),this.adSchedule.map(function(e){return{id:e.id,startTime:e.startTime,endTime:e.endTime,duration:e.duration,title:e.title,podCount:e.pods.length,pods:e.pods.map(function(e){return{title:e.title,startTime:e.startTime,endTime:e.endTime,duration:e.duration}})}})),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Current player time: ").concat(this.player.currentTime(),"s"))}},{key:"trackQuartiles",value:function(e,t){var i=this;!e.duration||e.duration<=0||(0,o.getQuartilesToFire)(t,e.duration,{q1:e.hasFiredQ1,q2:e.hasFiredQ2,q3:e.hasFiredQ3}).forEach(function(t){var r=t.quartile,n=t.key;b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_QUARTILE ").concat(25*r,"%")),i.sendAdQuartile({quartile:r}),e["hasFired".concat(n.toUpperCase())]=!0})}},{key:"onTimeUpdate",value:function(){var e=this.player.currentTime(),t=(0,o.findActiveAdBreak)(this.adSchedule,e);if(this.adSchedule.length>0&&Math.floor(e)%5==0&&Math.floor(10*e)%10==0&&b.debug("[MT - ".concat((0,o.getTimestamp)(),"] TimeUpdate: ").concat(e.toFixed(2),"s, Active break: ").concat(t?t.id:"none",", Schedule count: ").concat(this.adSchedule.length)),t){if(!t.hasFiredStart){var i;this.currentAdBreak=t,this.setIsAd(!0),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] setIsAd(true) - Entering ad break"));var r=this.adSchedule.findIndex(function(e){return Math.abs(e.startTime-t.startTime)<.5}),n=(0,o.determineAdPosition)(r,this.adSchedule.length,this.streamType);t.adPosition=n,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_BREAK_START"),{startTime:t.startTime,duration:t.duration,podCount:(null===(i=t.pods)||void 0===i?void 0:i.length)||0,position:n,breakIndex:r,totalBreaks:this.adSchedule.length}),this.sendAdBreakStart(),t.hasFiredStart=!0}if(t.pods&&t.pods.length>0){var a=(0,o.findActivePod)(t,e);if(a){this.currentAdPod&&this.currentAdPod===a||(this.currentAdPod&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_END (pod transition)")),this.sendEnd()),this.currentAdPod=a,b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_START (new pod)"),{startTime:a.startTime,duration:a.duration,position:t.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:t.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:t.adPosition}),a.hasFiredStart=!0);var s=e-a.startTime;this.trackQuartiles(a,s)}}else{t.hasFiredAdStart||(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_START (no pods)"),{startTime:t.startTime,duration:t.duration,position:t.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:t.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:t.adPosition}),t.hasFiredAdStart=!0);var u=e-t.startTime;this.trackQuartiles(t,u)}}else this.currentAdBreak&&(this.currentAdPod&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_END (final pod)")),this.sendEnd(),this.currentAdPod=null),this.currentAdBreak.hasFiredEnd||(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_BREAK_END")),this.sendAdBreakEnd(),this.currentAdBreak.hasFiredEnd=!0),this.currentAdBreak=null,this.setIsAd(!1),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] setIsAd(false) - Exiting ad break")),this.player.ended()&&!this.hasEndedContent&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Video ended after last ad → CONTENT_END")),this.sendContentEnd(),this.hasEndedContent=!0))}},{key:"sendContentEnd",value:function(){this.parentTracker?this.parentTracker.sendEnd():A(t,"sendEnd",this,3)([])}},{key:"handleAdEvent",value:function(e,t){this.isAd()&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → ").concat(e)),t.call(this))}},{key:"onPause",value:function(){this.handleAdEvent("AD_PAUSE",this.sendPause)}},{key:"onPlaying",value:function(){this.isAd()&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] → AD_RESUME")),this.sendResume(),this.sendBufferEnd())}},{key:"onSeeking",value:function(){this.handleAdEvent("AD_SEEK_START",this.sendSeekStart)}},{key:"onSeeked",value:function(){this.handleAdEvent("AD_SEEK_END",this.sendSeekEnd)}},{key:"onWaiting",value:function(){this.handleAdEvent("AD_BUFFER_START",this.sendBufferStart)}},{key:"onEnded",value:function(){this.hasEndedContent||(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Video ended → CONTENT_END")),this.sendContentEnd(),this.hasEndedContent=!0)}},{key:"getTitle",value:function(){var e,t,i;return this.currentAdPod?this.currentAdPod.title||(null===(i=this.currentAdBreak)||void 0===i?void 0:i.id)||null:(null===(e=this.currentAdBreak)||void 0===e?void 0:e.title)||(null===(t=this.currentAdBreak)||void 0===t?void 0:t.id)||null}},{key:"getVideoId",value:function(){var e,t,i;return this.currentAdPod?this.currentAdPod.creativeId||this.currentAdPod.title||(null===(i=this.currentAdBreak)||void 0===i?void 0:i.id)||null:(null===(e=this.currentAdBreak)||void 0===e?void 0:e.creativeId)||(null===(t=this.currentAdBreak)||void 0===t?void 0:t.id)||null}},{key:"getSrc",value:function(){return this.trackingEndpointUrl||this.playbackManifestUrl||null}},{key:"getDuration",value:function(){return this.currentAdPod?1e3*this.currentAdPod.duration:this.currentAdBreak?1e3*this.currentAdBreak.duration:null}},{key:"stopPolling",value:function(){this.manifestPollTimer&&(clearInterval(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null),b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Polling stopped"))}},{key:"dispose",value:function(){b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Disposing MediaTailorAdsTracker")),this.isDisposed=!0,this.trackingAbortController&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Aborting in-flight tracking fetch")),this.trackingAbortController.abort(),this.trackingAbortController=null),this.manifestAbortController&&(b.debug("[MT - ".concat((0,o.getTimestamp)(),"] Aborting in-flight manifest fetch")),this.manifestAbortController.abort(),this.manifestAbortController=null),this.stopLivePolling(),this.unregisterListeners(),A(t,"dispose",this,1)&&A(t,"dispose",this,3)([])}}],n=[{key:"isUsing",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Boolean(t&&t.mediatailor)}}],r&&m(i.prototype,r),n&&m(i,n),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r,n,a,u,c,h,p}(a.default)},324(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.TRACKING_API_TIMEOUT_MS=t.STREAM_TYPE=t.SCTE35_SCHEME_MARKER=t.REGEX_TRACKING_PATH_SEGMENT=t.REGEX_SESSION_ID=t.REGEX_MAP=t.REGEX_MANIFEST_FILE_SUFFIX=t.REGEX_ISO_8601_DURATION=t.REGEX_HLS_TARGET_DURATION=t.REGEX_DISCONTINUITY=t.REGEX_DASH_MINIMUM_UPDATE_PERIOD=t.REGEX_CUE_OUT=t.QUARTILES=t.POST_AD_PAUSE_THRESHOLD=t.MT_SEGMENT_PATTERN=t.MT_HLS_CUE_OUT_TAG=t.MT_HLS_CUE_IN_TAG=t.MT_DEFAULT_AD_SEGMENT_PATH=t.MIN_AD_DURATION=t.MEDIATAILOR_HOST_MARKER=t.MANIFEST_TYPE=t.HLS_TAG_PREFIX=t.HLS_SEGMENT_DURATION_TAG=t.HLS_MIME_TYPE=t.HLS_MANIFEST_EXTENSION=t.DEFAULT_LIVE_POLL_INTERVAL_MS=t.DASH_SCTE35_EVENT_STREAM_SELECTOR=t.DASH_MANIFEST_EXTENSION=t.AD_TIMING_TOLERANCE=t.AD_SOURCE=t.AD_POSITION=void 0,t.REGEX_CUE_OUT=/#EXT-X-CUE-OUT:DURATION=([\d.]+)/,t.REGEX_DISCONTINUITY=/#EXT-X-DISCONTINUITY/,t.REGEX_MAP=/#EXT-X-MAP:URI="([^"]+)"/,t.REGEX_SESSION_ID=/sessionId=([^&]+)/,t.REGEX_TRACKING_PATH_SEGMENT=/\/v1\/(master|session|dash)\//,t.REGEX_MANIFEST_FILE_SUFFIX=/\/[^/]*\.(m3u8|mpd).*$/,t.REGEX_HLS_TARGET_DURATION=/#EXT-X-TARGETDURATION:(\d+)/,t.REGEX_DASH_MINIMUM_UPDATE_PERIOD=/minimumUpdatePeriod="([^"]+)"/,t.REGEX_ISO_8601_DURATION=/PT(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?/,t.HLS_MANIFEST_EXTENSION=".m3u8",t.DASH_MANIFEST_EXTENSION=".mpd",t.MEDIATAILOR_HOST_MARKER=".mediatailor.",t.MT_HLS_CUE_OUT_TAG="#EXT-X-CUE-OUT",t.MT_HLS_CUE_IN_TAG="#EXT-X-CUE-IN",t.HLS_SEGMENT_DURATION_TAG="#EXTINF:",t.HLS_TAG_PREFIX="#",t.SCTE35_SCHEME_MARKER="scte35",t.DASH_SCTE35_EVENT_STREAM_SELECTOR='EventStream[schemeIdUri*="scte35"], EventStream[schemeIdUri*="SCTE35"]',t.HLS_MIME_TYPE="application/vnd.apple.mpegurl",t.MT_SEGMENT_PATTERN="segments.mediatailor",t.MT_DEFAULT_AD_SEGMENT_PATH="/tm/",t.TRACKING_API_TIMEOUT_MS=5e3,t.DEFAULT_LIVE_POLL_INTERVAL_MS=5e3,t.MIN_AD_DURATION=.5,t.AD_TIMING_TOLERANCE=.5,t.POST_AD_PAUSE_THRESHOLD=500,t.STREAM_TYPE={VOD:"vod",LIVE:"live"},t.MANIFEST_TYPE={HLS:"hls",DASH:"dash"},t.AD_POSITION={PRE_ROLL:"pre",MID_ROLL:"mid",POST_ROLL:"post"},t.AD_SOURCE={MANIFEST_CUE:"manifest-cue",VHS_DISCONTINUITY:"vhs-discontinuity",TRACKING_API:"tracking-api",MANIFEST_AND_TRACKING:"manifest+tracking",DASH_EMSG:"dash-emsg",DASH_EVENT_STREAM:"dash-event-stream"},t.QUARTILES={Q1:.25,Q2:.5,Q3:.75}},612(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.buildTrackingEndpointUrl=function(e){var t=e.match(a.REGEX_SESSION_ID);if(!t)return null;var i=t[1];return e.replace(a.REGEX_TRACKING_PATH_SEGMENT,"/v1/tracking/").replace(a.REGEX_MANIFEST_FILE_SUFFIX,"/".concat(i))},t.calculateQuartiles=p,t.detectAdBreaksFromVhsPlaylist=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).adSegmentPrefix,i=e.segments,r=e.discontinuityStarts||[],n=[],s=null,o=null,u=0;return i.forEach(function(e,i){var d=m(e,{adSegmentPrefix:t}),l=r.includes(i);if(d){l&&o&&(o.endTime=u,o.duration>a.MIN_AD_DURATION&&s.pods.push(o),o=null),s||(s={id:"avail-".concat(u),startTime:u,duration:0,endTime:null,source:"vhs-discontinuity",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}),o||(o={startTime:u,duration:0,endTime:null,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1});var c=e.duration||0;s.duration+=c,o.duration+=c}else s&&(o&&(o.endTime=u,o.duration>a.MIN_AD_DURATION&&s.pods.push(o),o=null),s.endTime=u,s.duration>a.MIN_AD_DURATION&&n.push(s),s=null);u+=e.duration||0}),s&&(o&&(o.endTime=u,o.duration>a.MIN_AD_DURATION&&s.pods.push(o)),s.endTime=u,s.duration>a.MIN_AD_DURATION&&n.push(s)),n},t.detectManifestFormatFromUrl=function(e){return e.includes(a.HLS_MANIFEST_EXTENSION)?a.MANIFEST_TYPE.HLS:e.includes(a.DASH_MANIFEST_EXTENSION)?a.MANIFEST_TYPE.DASH:a.MANIFEST_TYPE.HLS},t.detectPlaybackStreamType=function(e){return e===1/0?a.STREAM_TYPE.LIVE:a.STREAM_TYPE.VOD},t.determineAdPosition=function(e,t,i){return i===a.STREAM_TYPE.LIVE?null:0===e?a.AD_POSITION.PRE_ROLL:e===t-1?a.AD_POSITION.POST_ROLL:a.AD_POSITION.MID_ROLL},t.enrichAdScheduleWithTrackingMetadata=function(e,t){var i=new Map;e.forEach(function(e){var t=Math.round(e.startTime);i.set(t,e)});var r=[];return t.forEach(function(e){var t=e.ads&&e.ads.length>0?e.ads[0]:null;if(t){var n=Math.round(t.startTimeInSeconds),a=i.get(n);a?(a.id=e.availId,a.creativeId=t.adId,a.title=t.adTitle,a.confirmedByTracking=!0,e.ads&&e.ads.length>0&&a.pods&&e.ads.forEach(function(e,t){a.pods[t]?(a.pods[t].title=e.adTitle,a.pods[t].creativeId=e.adId,a.pods[t].trackingStartTime=e.startTimeInSeconds,a.pods[t].trackingDuration=e.durationInSeconds):a.pods.push({startTime:e.startTimeInSeconds,duration:e.durationInSeconds,endTime:e.startTimeInSeconds+e.durationInSeconds,title:e.adTitle,creativeId:e.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1})})):r.push({id:e.availId,startTime:t.startTimeInSeconds,duration:e.durationInSeconds,endTime:t.startTimeInSeconds+e.durationInSeconds,title:t.adTitle,creativeId:t.adId,source:"tracking-api",confirmedByTracking:!0,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:e.ads.map(function(e){return{startTime:e.startTimeInSeconds,duration:e.durationInSeconds,endTime:e.startTimeInSeconds+e.durationInSeconds,title:e.adTitle,creativeId:e.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1}})})}}),r},t.extractDashMinimumUpdatePeriodSeconds=function(e){var t=e.match(a.REGEX_DASH_MINIMUM_UPDATE_PERIOD);return t?E(t[1]):null},t.extractHlsTargetDurationSeconds=function(e){var t=e.match(a.REGEX_HLS_TARGET_DURATION);return t?parseInt(t[1],10):null},t.extractMediaPlaylistUrl=function(e,t){var i,r=l(e.split("\n"));try{for(r.s();!(i=r.n()).done;){var n=i.value;if(!n.startsWith(a.HLS_TAG_PREFIX)&&n.includes(a.HLS_MANIFEST_EXTENSION))return new URL(n.trim(),t).href}}catch(e){r.e(e)}finally{r.f()}return null},t.fetchDashManifest=function(e){return T.apply(this,arguments)},t.fetchHlsMasterManifest=function(e){return v.apply(this,arguments)},t.fetchHlsMediaPlaylist=function(e){return A.apply(this,arguments)},t.findActiveAdBreak=function(e,t){return e.find(function(e){return t>=e.startTime&&t<e.endTime})},t.findActivePod=function(e,t){return e&&e.pods&&0!==e.pods.length?e.pods.find(function(e){return t>=e.startTime&&t<e.endTime}):null},t.findAdBreakIndex=function(e,t){return e.findIndex(function(e){return Math.abs(e.startTime-t)<a.AD_TIMING_TOLERANCE})},t.getQuartilesToFire=function(e,t,i){var r=p(t),n=[];return e>=r.q1&&!i.q1&&n.push({quartile:1,key:"q1"}),e>=r.q2&&!i.q2&&n.push({quartile:2,key:"q2"}),e>=r.q3&&!i.q3&&n.push({quartile:3,key:"q3"}),n},t.getTimestamp=function(){return(new Date).toISOString().substring(11,23)},t.getTrackingMetadata=function(e){return b.apply(this,arguments)},t.isMediaTailorSegment=m,t.isValidAdBreak=function(e){return e.duration>a.MIN_AD_DURATION},t.mergeAdSchedules=function(e,t){var i=new Map;e.forEach(function(e){var t=Math.round(e.startTime);i.set(t,e)});var r=[];t.forEach(function(e){var t=Math.round(e.startTime),n=i.get(t);n?!n.confirmedByTracking&&e.confirmedByTracking&&Object.assign(n,e):(r.push(e),i.set(t,e))});var n,a=[].concat(function(e){if(Array.isArray(e))return h(e)}(n=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||c(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r);return a.sort(function(e,t){return e.startTime-t.startTime}),a},t.parseDashManifestForAdBreaks=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).adSegmentPrefix,i=(new DOMParser).parseFromString(e,"text/xml"),r=[],n=i.querySelector("parsererror");if(n)return f.error("[MT] DASH XML parse error:",n.textContent),r;var s=i.querySelectorAll("Period");if(f.debug("[MT] Found ".concat(s.length," Period(s) in DASH manifest")),s.length>1)s.forEach(function(e){var i=e.querySelector("BaseURL"),n=i?i.textContent.trim():"",s=[a.MT_SEGMENT_PATTERN,a.MT_DEFAULT_AD_SEGMENT_PATH];if(t&&s.push(t),s.some(function(e){return n.includes(e)})){var o=e.getAttribute("id")||"",u=E(e.getAttribute("start")||"PT0S"),d=E(e.getAttribute("duration")||"");d<a.MIN_AD_DURATION?f.debug("[MT] Skipping period ".concat(o," - duration too short (").concat(d,"s)")):(f.debug("[MT] Ad period detected: ".concat(o),{startTime:u,duration:d}),r.push({id:o,startTime:u,duration:d,endTime:u+d,source:a.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))}});else{var o=i.querySelectorAll(a.DASH_SCTE35_EVENT_STREAM_SELECTOR);f.debug("[MT] Found ".concat(o.length," SCTE-35 EventStream(s) in single-period manifest")),o.forEach(function(e){var t=parseFloat(e.getAttribute("timescale")||"1");e.querySelectorAll("Event").forEach(function(e){var i=parseFloat(e.getAttribute("presentationTime")||0),n=parseFloat(e.getAttribute("duration")||0),s=e.getAttribute("id")||"".concat(a.SCTE35_SCHEME_MARKER,"-").concat(i),o=1!==t?i/t:i,u=1!==t?n/t:n;u<a.MIN_AD_DURATION?f.debug("[MT] Skipping event ".concat(s," - duration too short (").concat(u,"s)")):(f.debug("[MT] SCTE-35 event detected: ".concat(s),{startTime:o,durationSeconds:u}),r.push({id:s,startTime:o,duration:u,endTime:o+u,source:a.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))})})}return f.debug("[MT] Parsed ".concat(r.length," valid ad break(s) from DASH manifest")),r},t.parseHlsManifestForAdBreaks=function(e){var t,i=[],r=0,n=null,s=null,o=null,u=[],d=!1,c=l(e.split("\n"));try{for(c.s();!(t=c.n()).done;){var h=t.value;if(a.REGEX_DISCONTINUITY.test(h)&&d&&o){var f=h.match(a.REGEX_MAP),m=f?f[1]:null;if(m&&m!==o){if(null!==s){var p=r-s;u.push({startTime:s,duration:p,endTime:r,mapUrl:o})}s=r,o=m}}var g=h.match(a.REGEX_MAP);if(g&&d){var y=g[1];if(y&&y!==o){if(null!==s){var v=r-s;u.push({startTime:s,duration:v,endTime:r,mapUrl:o})}s=r,o=y}}if(h.startsWith(a.MT_HLS_CUE_OUT_TAG)){var A=h.match(a.REGEX_CUE_OUT),T=A?parseFloat(A[1]):null;d=!0,u=[],n={id:"avail-".concat(r),startTime:r,duration:T,endTime:null,pods:[],hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,confirmedByTracking:!1}}if(h.startsWith(a.MT_HLS_CUE_IN_TAG)&&n){if(null!==s){var E=r-s;u.push({startTime:s,duration:E,endTime:r,mapUrl:o})}var b=r-n.startTime;b>=a.MIN_AD_DURATION&&(n.duration=b,n.endTime=r,n.pods=u,i.push(n)),n=null,d=!1,s=null,o=null,u=[]}if(h.startsWith(a.HLS_SEGMENT_DURATION_TAG)){var S=parseFloat(h.split(":")[1]);isNaN(S)||(r+=S)}}}catch(e){c.e(e)}finally{c.f()}return n&&n.duration&&(n.endTime=n.startTime+n.duration,n.pods=u,i.push(n)),i},t.parseIsoDuration=E,t.whichAdSegmentMarker=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).adSegmentPrefix,i=[{marker:a.MT_SEGMENT_PATTERN,label:"aws-hostname (segments.mediatailor)"},{marker:a.MT_DEFAULT_AD_SEGMENT_PATH,label:"default-cdn-path (/tm/)"}];t&&i.push({marker:t,label:"custom-prefix (".concat(t,")")});var r=e.map&&e.map.uri||"",n=e.uri||"",s=i.find(function(e){var t=e.marker;return r.includes(t)||n.includes(t)});return s?s.label:null};var r,n=(r=i(555))&&r.__esModule?r:{default:r},a=i(324);function s(){var e,t,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",n=i.toStringTag||"@@toStringTag";function a(i,r,n,a){var s=r&&r.prototype instanceof d?r:d,l=Object.create(s.prototype);return o(l,"_invoke",function(i,r,n){var a,s,o,d=0,l=n||[],c=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,i){return a=t,s=0,o=e,h.n=i,u}};function f(i,r){for(s=i,o=r,t=0;!c&&d&&!n&&t<l.length;t++){var n,a=l[t],f=h.p,m=a[2];i>3?(n=m===r)&&(o=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=f&&((n=i<2&&f<a[1])?(s=0,h.v=r,h.n=a[1]):f<m&&(n=i<3||a[0]>r||r>m)&&(a[4]=i,a[5]=r,h.n=m,s=0))}if(n||i>1)return u;throw c=!0,r}return function(n,l,m){if(d>1)throw TypeError("Generator is already running");for(c&&1===l&&f(l,m),s=l,o=m;(t=s<2?e:o)||!c;){a||(s?s<3?(s>1&&(h.n=-1),f(s,o)):h.n=o:h.v=o);try{if(d=2,a){if(s||(n="next"),t=a[n]){if(!(t=t.call(a,o)))throw TypeError("iterator result is not an object");if(!t.done)return t;o=t.value,s<2&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),s<2&&(o=TypeError("The iterator does not provide a '"+n+"' method"),s=1);a=e}else if((t=(c=h.n<0)?o:i.call(r,h))!==u)break}catch(t){a=e,s=1,o=t}finally{d=1}}return{value:t,done:c}}}(i,n,a),!0),l}var u={};function d(){}function l(){}function c(){}t=Object.getPrototypeOf;var h=[][r]?t(t([][r]())):(o(t={},r,function(){return this}),t),f=c.prototype=d.prototype=Object.create(h);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,o(e,n,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=c,o(f,"constructor",c),o(c,"constructor",l),l.displayName="GeneratorFunction",o(c,n,"GeneratorFunction"),o(f),o(f,n,"Generator"),o(f,r,function(){return this}),o(f,"toString",function(){return"[object Generator]"}),(s=function(){return{w:a,m}})()}function o(e,t,i,r){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}o=function(e,t,i,r){function a(t,i){o(e,t,function(e){return this._invoke(t,i,e)})}t?n?n(e,t,{value:i,enumerable:!r,configurable:!r,writable:!r}):e[t]=i:(a("next",0),a("throw",1),a("return",2))},o(e,t,i,r)}function u(e,t,i,r,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void i(e)}o.done?t(u):Promise.resolve(u).then(r,n)}function d(e){return function(){var t=this,i=arguments;return new Promise(function(r,n){var a=e.apply(t,i);function s(e){u(a,r,n,s,o,"next",e)}function o(e){u(a,r,n,s,o,"throw",e)}s(void 0)})}}function l(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=c(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==i.return||i.return()}finally{if(o)throw a}}}}function c(e,t){if(e){if("string"==typeof e)return h(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?h(e,t):void 0}}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}var f=(n.default.default||n.default).Log;function m(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).adSegmentPrefix,i=[a.MT_SEGMENT_PATTERN,a.MT_DEFAULT_AD_SEGMENT_PATH];t&&i.push(t);var r=e.map&&e.map.uri||"",n=e.uri||"";return i.some(function(e){return r.includes(e)||n.includes(e)})}function p(e){return{q1:e*a.QUARTILES.Q1,q2:e*a.QUARTILES.Q2,q3:e*a.QUARTILES.Q3}}function g(e){return y.apply(this,arguments)}function y(){return(y=d(s().m(function e(t){var i;return s().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,fetch(t,{credentials:"include"});case 1:if(!1!==(i=e.v).ok){e.n=2;break}throw new Error("Manifest request failed: ".concat(i.status||"unknown"," ").concat(i.statusText||"Request failed"));case 2:return e.n=3,i.text();case 3:return e.a(2,e.v)}},e)}))).apply(this,arguments)}function v(){return(v=d(s().m(function e(t){var i,r,n,o,u,d,c;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.n=1,g(t);case 1:i=e.v,r=i.split("\n"),n=null,o=l(r),e.p=2,o.s();case 3:if((u=o.n()).done){e.n=5;break}if((d=u.value).startsWith(a.HLS_TAG_PREFIX)||!d.includes(a.HLS_MANIFEST_EXTENSION)){e.n=4;break}return n=new URL(d.trim(),t).href,e.a(3,5);case 4:e.n=3;break;case 5:e.n=7;break;case 6:e.p=6,c=e.v,o.e(c);case 7:return e.p=7,o.f(),e.f(7);case 8:return e.a(2,{masterText:i,mediaPlaylistUrl:n})}},e,null,[[2,6,7,8]])}))).apply(this,arguments)}function A(){return(A=d(s().m(function e(t){return s().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,g(t);case 1:return e.a(2,e.v)}},e)}))).apply(this,arguments)}function T(){return(T=d(s().m(function e(t){return s().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,g(t);case 1:return e.a(2,e.v)}},e)}))).apply(this,arguments)}function E(e){if(!e)return 0;var t=e.match(a.REGEX_ISO_8601_DURATION);return t?3600*parseFloat(t[1]||0)+60*parseFloat(t[2]||0)+parseFloat(t[3]||0):0}function b(){return b=d(s().m(function e(t){var i,r,n,a,o,u,d,l=arguments;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=l.length>1&&void 0!==l[1]?l[1]:8e3,r=l.length>2&&void 0!==l[2]?l[2]:null,n=new AbortController,a=setTimeout(function(){return n.abort()},i),o=function(){return n.abort()},r&&r.addEventListener("abort",o),e.p=1,e.n=2,fetch("".concat(t,"?t=").concat(Date.now()),{signal:n.signal,credentials:"include"});case 2:if(u=e.v,clearTimeout(a),r&&r.removeEventListener("abort",o),u.ok){e.n=3;break}throw new Error("Tracking API error: ".concat(u.status));case 3:return e.n=4,u.json();case 4:return e.a(2,e.v);case 5:throw e.p=5,d=e.v,clearTimeout(a),r&&r.removeEventListener("abort",o),d;case 6:return e.a(2)}},e,null,[[1,5]])})),b.apply(this,arguments)}},472(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=d(i(555)),a=d(i(330)),s=d(i(409)),o=d(i(257)),u=d(i(338));function d(e){return e&&e.__esModule?e:{default:e}}function l(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function c(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function h(e,t,i){return t=m(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,f()?Reflect.construct(t,i||[],m(e).constructor):t.apply(e,i))}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}t.default=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),h(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(t,e),i=t,(r=[{key:"getTech",value:function(){var e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(s.default.isUsing(e))return new s.default(e);if(o.default.isUsing(e))return new o.default(e);if(u.default.isUsing(e))return new u.default(e)}}},{key:"getTrackerName",value:function(){return"videojs-ads"}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getRenditionHeight",value:function(){return null}},{key:"getRenditionWidth",value:function(){return null}},{key:"getPlayerName",value:function(){return"videojs-ads"}},{key:"getPlayerVersion",value:function(){return this.player.ads.VERSION}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,[null,"ads-request","ads-load","adstart","adend","adskip","adserror","ads-click","ads-pod-started","ads-pod-ended","ads-first-quartile","ads-midpoint","ads-third-quartile","ads-pause","ads-play","adtimeout"]),this.player.on("ads-request",this.onAdrequest.bind(this)),this.player.on("ads-load",this.onAdload.bind(this)),this.player.on("adstart",this.onAdstart.bind(this)),this.player.on("adend",this.onAdend.bind(this)),this.player.on("adskip",this.onAdskip.bind(this)),this.player.on("adserror",this.onAdserror.bind(this)),this.player.on("ads-click",this.onAdsClick.bind(this)),this.player.on("ads-pod-started",this.onPodStart.bind(this)),this.player.on("ads-pod-ended",this.onPodEnd.bind(this)),this.player.on("ads-first-quartile",this.onFirstQuartile.bind(this)),this.player.on("ads-midpoint",this.onMidpoint.bind(this)),this.player.on("ads-third-quartile",this.onThirdQuartile.bind(this)),this.player.on("ads-pause",this.onAdspause.bind(this)),this.player.on("ads-play",this.onAdsplay.bind(this))}},{key:"unregisterListeners",value:function(){this.player.off("ads-request",this.onAdrequest),this.player.off("ads-load",this.onAdload),this.player.off("adstart",this.onAdstart),this.player.off("adend",this.onAdend),this.player.off("adskip",this.onAdskip),this.player.off("adserror",this.onAdserror),this.player.off("ads-click",this.onAdsClick),this.player.off("ads-pod-started",this.onPodStart),this.player.off("ads-pod-ended",this.onPodEnd),this.player.off("ads-first-quartile",this.onFirstQuartile),this.player.off("ads-midpoint",this.onMidpoint),this.player.off("ads-third-quartile",this.onThirdQuartile),this.player.off("ads-pause",this.onAdspause),this.player.off("ads-play",this.onAdsplay)}},{key:"onAdrequest",value:function(e){this.sendRequest(),this.sendDownload({state:"ads-request"})}},{key:"onAdload",value:function(e){this.sendDownload({state:"ads-load"})}},{key:"onAdstart",value:function(e){this.sendRequest(),this.sendStart()}},{key:"onAdend",value:function(e){this.sendEnd()}},{key:"onAdskip",value:function(e){this.sendEnd({skipped:!0})}},{key:"onAdserror",value:function(e){this.sendError()}},{key:"onAdsClick",value:function(e){this.sendAdClick({url:"unknown"})}},{key:"onPodStart",value:function(e){this.sendAdBreakStart()}},{key:"onPodEnd",value:function(e){this.sendAdBreakEnd()}},{key:"onFirstQuartile",value:function(){this.sendAdQuartile({quartile:1})}},{key:"onMidpoint",value:function(){this.sendAdQuartile({quartile:2})}},{key:"onThirdQuartile",value:function(){this.sendAdQuartile({quartile:3})}},{key:"onAdspause",value:function(){this.sendPause()}},{key:"onAdsplay",value:function(){this.sendResume()}}])&&l(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(n.default.VideoTracker)},409(e,t){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function n(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,(t.default=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tech=t.vhs,this.player=t.el().player},(t=[{key:"getRenditionName",value:function(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return e.attributes.NAME}catch(e){}return null}},{key:"getRenditionBitrate",value:function(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return Math.round(e.attributes.BANDWIDTH)}catch(e){}return null}},{key:"getRenditionWidth",value:function(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.width}catch(e){}return null}},{key:"getRenditionHeight",value:function(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.height}catch(e){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getManifestBitrate",value:function(){try{var e=this.tech.playlists.master.playlists;if(e&&e.length>0)return Math.round(Math.max.apply(Math,function(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e.map(function(e){return e.attributes.BANDWIDTH}))))}catch(e){}return null}},{key:"getSegmentDownloadBitrate",value:function(){var e;return void 0!==(null===(e=this.tech.stats)||void 0===e?void 0:e.bandwidth)&&this.tech.stats.bandwidth>0?Math.round(this.tech.stats.bandwidth):null}},{key:"getNetworkDownloadBitrate",value:function(){return void 0!==this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}},{key:"getContentBitratePlayback",value:function(){try{var e=this.tech.playlists.media();if(e&&e.attributes){var t=e.attributes["AVERAGE-BANDWIDTH"]||e.attributes.BANDWIDTH||null;return null!==t?Math.round(t):null}}catch(e){}return null}}])&&n(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()).isUsing=function(e){return!!e.vhs}},257(e,t){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function n(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,(t.default=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tech=t.vhs_,this.player=t.el().player},(t=[{key:"getResource",value:function(e){return this.tech.url}},{key:"getRenditionName",value:function(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.name)return t.name}catch(e){}return null}},{key:"getRenditionBitrate",value:function(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return Math.round(t.bitrate)}catch(e){}return null}},{key:"getRenditionWidth",value:function(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.width)return t.width}catch(e){}return null}},{key:"getRenditionHeight",value:function(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.height)return t.height}catch(e){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return Math.round(e.bitrate)}catch(e){}return null}},{key:"getManifestBitrate",value:function(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.round(Math.max.apply(Math,function(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this.tech.levels.map(function(e){return e.bitrate}))))}catch(e){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return Math.round(this.tech.stats.bandwidth)}catch(e){}return null}},{key:"getNetworkDownloadBitrate",value:function(){return this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}}])&&n(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()).isUsing=function(e){return!!e.vhs_}},338(e,t){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function n(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,(t.default=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tech=t.shakaPlayer,this.player=t.el().player},t=[{key:"getSrc",value:function(e){try{return this.tech.getManifestUri()}catch(e){}return null}},{key:"getRenditionBitrate",value:function(e){try{var t=this.tech.getStats().streamBandwidth;return t?Math.round(t):null}catch(e){}return null}},{key:"getManifestBitrate",value:function(){try{var e=this.tech.getVariantTracks();if(e&&e.length>0)return Math.round(Math.max.apply(Math,function(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e.map(function(e){return e.videoBandwidth+(e.audioBandwidth||0)}))))}catch(e){}return null}},{key:"getRenditionWidth",value:function(e){try{var t=this.tech.getVariantTracks();for(var i in t){var r=t[i];if(r.active&&"video"===r.type)return r.width}}catch(e){}return null}},{key:"getRenditionHeight",value:function(e){try{var t=this.tech.getVariantTracks();for(var i in t){var r=t[i];if(r.active&&"video"===r.type)return r.height}}catch(e){}return null}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var e=this.tech.getStats();if(e&&e.streamBandwidth&&e.streamBandwidth>0)return Math.round(e.streamBandwidth)}catch(e){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var e=this.tech.getStats();if(e&&e.estimatedBandwidth>0)return Math.round(e.estimatedBandwidth)}catch(e){}return null}},{key:"getNetworkDownloadBitrate",value:function(){try{var e=this.tech.getStats();if(e&&e.estimatedBandwidth>0)return Math.round(e.estimatedBandwidth)}catch(e){}return null}}],t&&n(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()).isUsing=function(e){return!!e.shakaPlayer}},302(e,t,i){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.AD_TRACKING=void 0,Object.defineProperty(t,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(t,"ContribHlsTech",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(t,"DaiAdsTracker",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(t,"FreewheelAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(t,"HlsJsTech",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"ImaAdsTracker",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"MediaTailorAdsTracker",{enumerable:!0,get:function(){return m.default}}),Object.defineProperty(t,"ShakaTech",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"VideojsAdsTracker",{enumerable:!0,get:function(){return d.default}}),t.default=void 0;var n=p(i(555)),a=p(i(330)),s=p(i(409)),o=p(i(257)),u=p(i(338)),d=p(i(472)),l=p(i(298)),c=p(i(64)),h=p(i(38)),f=p(i(717)),m=p(i(687));function p(e){return e&&e.__esModule?e:{default:e}}function g(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return y(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?y(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function v(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)}return i}function A(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?v(Object(i),!0).forEach(function(t){T(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):v(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function T(e,t,i){return(t=b(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function E(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,b(r.key),r)}}function b(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}function S(e,t,i){return t=_(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,k()?Reflect.construct(t,i||[],_(e).constructor):t.apply(e,i))}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(k=function(){return!!e})()}function _(e){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_(e)}function D(e,t){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},D(e,t)}var P=t.AD_TRACKING={CSAI:"csai",SSAI:Object.freeze({DAI:"ssai:dai",MT:"ssai:mt"})},I=t.default=function(e){function t(e,i){var r,a;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(a=S(this,t,[e,i])).options=i,a.isContentEnd=!1,a.imaAdCuePoints="",a.daiInitialized=!1,a.adTracking=(null==i||null===(r=i.config)||void 0===r||null===(r=r.ad)||void 0===r?void 0:r.type)||null,a.previousBitrate=null,i&&!a.adTracking&&n.default.Log.warn("VideojsTracker: config.ad not set — no ad tracking will run. Set config.ad.type to enable it (e.g. AD_TRACKING.CSAI, AD_TRACKING.SSAI.MT)."),a.adTracking===P.SSAI.MT){var s,o,u=(null==i||null===(s=i.config)||void 0===s?void 0:s.ad)||{};a.options=Object.assign({},a.options,{mediatailor:A({segmentPrefix:u.segmentPrefix,trackingUrl:u.trackingUrl},null===(o=a.options)||void 0===o?void 0:o.mediatailor)})}return n.default.Core.addTracker(a,i),a}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&D(e,t)}(t,e),i=t,r=[{key:"setAdTracking",value:function(e){var t=[P.CSAI].concat(g(Object.values(P.SSAI)));t.includes(e)?(this.adTracking=e,n.default.Log.debug('VideojsTracker: adTracking set to "'.concat(e,'"'))):n.default.Log.warn('VideojsTracker.setAdTracking: unknown value "'.concat(e,'". Valid values: ').concat(t.join(", ")))}},{key:"getTech",value:function(){var e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(s.default.isUsing(e))return new s.default(e);if(o.default.isUsing(e))return new o.default(e);if(u.default.isUsing(e))return new u.default(e)}}},{key:"getTrackerName",value:function(){return"videojs"}},{key:"getInstrumentationProvider",value:function(){return"New Relic"}},{key:"getInstrumentationName",value:function(){return this.getPlayerName()}},{key:"getInstrumentationVersion",value:function(){return this.getPlayerVersion()}},{key:"getTrackerVersion",value:function(){return a.default.version}},{key:"getPlayhead",value:function(){return this.player.ads&&"ads-playback"===this.player.ads.state&&this.player.ads.snapshot&&this.player.ads.snapshot.currentTime?1e3*this.player.ads.snapshot.currentTime:this.player.absoluteTime?1e3*this.player.absoluteTime():1e3*this.player.currentTime()}},{key:"getDuration",value:function(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}},{key:"getTitle",value:function(){var e;return null===(e=this.player)||void 0===e||null===(e=e.mediainfo)||void 0===e?void 0:e.name}},{key:"getId",value:function(){var e;return null===(e=this.player)||void 0===e||null===(e=e.mediainfo)||void 0===e?void 0:e.id}},{key:"getLanguage",value:function(){var e;return null===(e=this.player)||void 0===e?void 0:e.language()}},{key:"getSrc",value:function(){var e=this.getTech();return e&&e.getSrc?e.getSrc():this.player.currentSrc()}},{key:"getPlayerName",value:function(){var e;return(null===(e=this.player)||void 0===e?void 0:e.name())||"videojs"}},{key:"getPlayerVersion",value:function(){var e;return(null===(e=this.player)||void 0===e?void 0:e.version)||videojs.VERSION}},{key:"isMuted",value:function(){return this.player.muted()}},{key:"getBitrate",value:function(){return this.getContentBitratePlayback()}},{key:"getContentBitratePlayback",value:function(){try{var e,t=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=t&&null!==(e=t.vhs)&&void 0!==e&&null!==(e=e.playlists)&&void 0!==e&&e.media()){var i=t.vhs.playlists.media(),r=i.attributes["AVERAGE-BANDWIDTH"]||i.attributes.BANDWIDTH||null;return null!==r?Math.round(r):null}var n=this.getTech();if(null!=n&&n.getBitrate){var a=n.getBitrate();return null!==a?Math.round(a):null}}catch(e){}return null}},{key:"getRenditionName",value:function(){var e=this.getTech();if(e&&e.getRenditionName)return e.getRenditionName()}},{key:"getManifestBitrate",value:function(){try{var e,t=this.player.tech({IWillNotUseThisInPlugins:!0}),i=null==t||null===(e=t.vhs)||void 0===e||null===(e=e.playlists)||void 0===e||null===(e=e.master)||void 0===e?void 0:e.playlists;if(i&&i.length>0){var r=Math.max.apply(Math,g(i.map(function(e){return e.attributes.BANDWIDTH||0})));return r>0?Math.round(r):null}var n=this.getTech();if(null!=n&&n.getManifestBitrate){var a=n.getManifestBitrate();return null!==a?Math.round(a):null}}catch(e){}return null}},{key:"getSegmentDownloadBitrate",value:function(){try{var e,t=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=t&&null!==(e=t.vhs)&&void 0!==e&&null!==(e=e.stats)&&void 0!==e&&e.bandwidth&&t.vhs.stats.bandwidth>0)return Math.round(t.vhs.stats.bandwidth);var i=this.getTech();if(null!=i&&i.getSegmentDownloadBitrate){var r=i.getSegmentDownloadBitrate();return null!==r?Math.round(r):null}}catch(e){}return null}},{key:"getNetworkDownloadBitrate",value:function(){var e,t=this.player.tech({IWillNotUseThisInPlugins:!0});if(null!=t&&null!==(e=t.vhs)&&void 0!==e&&e.throughput&&t.vhs.throughput>0)return Math.round(t.vhs.throughput);var i=this.getTech();if(null!=i&&i.getNetworkDownloadBitrate){var r=i.getNetworkDownloadBitrate();return null!==r?Math.round(r):null}return null}},{key:"getRenditionHeight",value:function(){var e=this.getTech();return e&&e.getRenditionHeight?e.getRenditionHeight():this.player.videoHeight()}},{key:"getRenditionWidth",value:function(){var e=this.getTech();return e&&e.getRenditionWidth?e.getRenditionWidth():this.player.videoWidth()}},{key:"getPlayrate",value:function(){return this.player.playbackRate()}},{key:"isAutoplayed",value:function(){return this.player.autoplay()}},{key:"isFullscreen",value:function(){return this.player.isFullscreen()}},{key:"getPreload",value:function(){return this.player.preload()}},{key:"registerListeners",value:function(){n.default.Log.debugCommonVideoEvents(this.player,["adstart","adend","adskip","adsready","adserror","dispose"]),this.onDownload=this.onDownload.bind(this),this.onAdsready=this.onAdsready.bind(this),this.onAdStart=this.onAdStart.bind(this),this.onAdEnd=this.onAdEnd.bind(this),this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onAbort=this.onAbort.bind(this),this.onEnded=this.onEnded.bind(this),this.onDispose=this.onDispose.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onError=this.onError.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onTimeupdate=this.onTimeupdate.bind(this),this.OnAdsAllpodsCompleted=this.OnAdsAllpodsCompleted.bind(this),this.onStreamManager=this.onStreamManager.bind(this),this.onCanPlayThrough=this.onCanPlayThrough.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),this.player.on("canplaythrough",this.onCanPlayThrough),this.onQualityLevelChange=this.onQualityLevelChange.bind(this),"function"==typeof this.player.qualityLevels&&(this.qualityLevels=this.player.qualityLevels(),this.qualityLevels&&this.qualityLevels.on("change",this.onQualityLevelChange))}},{key:"unregisterListeners",value:function(){this.player.off("loadstart",this.onDownload),this.player.off("loadeddata",this.onDownload),this.player.off("loadedmetadata",this.onDownload),this.player.off("adsready",this.onAdsready),this.player.off("adstart",this.onAdStart),this.player.off("adend",this.onAdEnd),this.player.off("play",this.onPlay),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("abort",this.onAbort),this.player.off("ended",this.onEnded),this.player.off("dispose",this.onDispose),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("error",this.onError),this.player.off("waiting",this.onWaiting),this.player.off("timeupdate",this.onTimeupdate),this.player.off("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.off("stream-manager",this.onStreamManager),this.player.off("canplaythrough",this.onCanPlayThrough),this.qualityLevels&&this.qualityLevels.off("change",this.onQualityLevelChange)}},{key:"onDownload",value:function(e){this.sendDownload({state:e.type}),this.adTracking!==P.SSAI.MT||this.adsTracker||"loadstart"!==e.type||(n.default.Log.debug("VideojsTracker: Creating MediaTailorAdsTracker"),this.setAdsTracker(new m.default(this.player,this.options)),this.adsTracker.setIsAd(!1))}},{key:"onStreamManager",value:function(e){if(this.adTracking===P.SSAI.DAI&&!this.adsTracker&&e.StreamManager){var t=new f.default(this.player);t.setStreamManager(e.StreamManager),this.setAdsTracker(t)}}},{key:"onAdsready",value:function(){Object.values(P.SSAI).includes(this.adTracking)||(this.adTracking||n.default.Log.warn("VideojsTracker: adsready fired but config.ad.type is not set — attempting CSAI auto-detection for backward compatibility."),this.adsTracker||(c.default.isUsing(this.player)?(n.default.Log.debug("VideojsTracker: auto-detected BrightcoveImaAdsTracker"),this.setAdsTracker(new c.default(this.player))):l.default.isUsing(this.player)?(n.default.Log.debug("VideojsTracker: auto-detected ImaAdsTracker"),this.setAdsTracker(new l.default(this.player))):h.default.isUsing(this.player)?(n.default.Log.debug("VideojsTracker: auto-detected FreewheelAdsTracker"),this.setAdsTracker(new h.default(this.player))):(n.default.Log.debug("VideojsTracker: no specific CSAI framework detected, using generic VideojsAdsTracker"),this.setAdsTracker(new d.default(this.player)))))}},{key:"onAdStart",value:function(){var e;this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=null===(e=this.player)||void 0===e||null===(e=e.ima)||void 0===e?void 0:e.getAdsManager().getCuePoints())}},{key:"onAdEnd",value:function(){this.isContentEnd&&this.sendEnd()}},{key:"OnAdsAllpodsCompleted",value:function(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}},{key:"isAdsTrackerActive",value:function(){return this.player.ads?"ads-playback"===this.player.ads.state:this.adsTracker&&this.adsTracker.isAd&&this.adsTracker.isAd()}},{key:"onPlay",value:function(){this.sendRequest()}},{key:"onPause",value:function(){this.isAdsTrackerActive()||this.player.ended()||this.sendPause()}},{key:"onCanPlayThrough",value:function(){this.isAdsTrackerActive()||this.sendBufferEnd()}},{key:"onPlaying",value:function(){this.isAdsTrackerActive()||(this.sendResume(),this.sendBufferEnd())}},{key:"onAbort",value:function(){this.sendEnd()}},{key:"onEnded",value:function(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}},{key:"onDispose",value:function(){this.sendEnd()}},{key:"onSeeking",value:function(){this.isAdsTrackerActive()||this.sendSeekStart()}},{key:"onSeeked",value:function(){this.isAdsTrackerActive()||this.sendSeekEnd()}},{key:"onError",value:function(){var e=this.player.error(),t=e.code,i=e.message;this.player.error&&this.player.error()&&this.sendError({errorCode:t,errorMessage:i})}},{key:"onWaiting",value:function(e){this.isAdsTrackerActive()||this.sendBufferStart()}},{key:"onTimeupdate",value:function(e){this.getPlayhead()>.1&&this.sendStart()}},{key:"onQualityLevelChange",value:function(e){if(this.qualityLevels&&this.qualityLevels.selectedIndex>=0){var t=this.qualityLevels[this.qualityLevels.selectedIndex];if(t){var i=t.bitrate,r=this.previousBitrate;this.sendRenditionChanged({oldBitrate:r,newBitrate:i}),this.previousBitrate=i}}}}],r&&E(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(n.default.VideoTracker);I.AD_TRACKING=P,I.Log=n.default.Log},330(e){e.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.2.1","description":"New relic tracker for Videojs","main":"dist/cjs/index.js","module":"dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch --mode development","prezip":"npm run build","zip":"zip -P newrelic -x \'*.DS_Store\' -x \'samples/agent.js\' -r videojs.zip dist samples README.md CHANGELOG.md EULA.md","clean":"rm -rf dist *.zip","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-videojs-js.git"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop","Bharat Saraswat","Malay Chandan"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@newrelic/newrelic-oss-cli":"^0.1.2","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^12.0.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^10.0.3","@semantic-release/npm":"^12.0.0","@semantic-release/release-notes-generator":"^13.0.0","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","semantic-release":"^23.0.8","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.1.5"}}')}},t={};function i(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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 r={};return(()=>{var e=r;e.default=void 0;var t,n=(t=i(302))&&t.__esModule?t:{default:t};e.default=n.default})(),r.default})());
3
3
  //# sourceMappingURL=newrelic-video-videojs.min.js.map