UNPKG

cloudinary-video-player

Version:

Cloudinary Video Player

65 lines (51 loc) 241 kB
/*! * Cloudinary Video Player v3.2.1 * Built on 2025-08-12T18:54:00.175Z * https://github.com/cloudinary/cloudinary-video-player */ /* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ (self["cloudinaryVideoPlayerChunkLoading"] = self["cloudinaryVideoPlayerChunkLoading"] || []).push([["ima"],{ /***/ "./plugins/ima/ima.js": /*!****************************!*\ !*** ./plugins/ima/ima.js ***! \****************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var videojs_contrib_ads__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! videojs-contrib-ads */ \"../node_modules/videojs-contrib-ads/dist/videojs-contrib-ads.es.js\");\n/* harmony import */ var videojs_ima__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! videojs-ima */ \"../node_modules/videojs-ima/dist/videojs.ima.es.js\");\n/* harmony import */ var videojs_ima_dist_videojs_ima_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! videojs-ima/dist/videojs.ima.scss */ \"../node_modules/videojs-ima/dist/videojs.ima.scss\");\n\n\n\n\n//# sourceURL=webpack://cloudinary-video-player/./plugins/ima/ima.js?"); /***/ }), /***/ "../node_modules/global/document.js": /*!******************************************!*\ !*** ../node_modules/global/document.js ***! \******************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { eval("var topLevel = typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g :\n typeof window !== 'undefined' ? window : {}\nvar minDoc = __webpack_require__(/*! min-document */ \"?9835\");\n\nvar doccy;\n\nif (typeof document !== 'undefined') {\n doccy = document;\n} else {\n doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];\n\n if (!doccy) {\n doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;\n }\n}\n\nmodule.exports = doccy;\n\n\n//# sourceURL=webpack://cloudinary-video-player/../node_modules/global/document.js?"); /***/ }), /***/ "../node_modules/global/window.js": /*!****************************************!*\ !*** ../node_modules/global/window.js ***! \****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { eval("var win;\n\nif (typeof window !== \"undefined\") {\n win = window;\n} else if (typeof __webpack_require__.g !== \"undefined\") {\n win = __webpack_require__.g;\n} else if (typeof self !== \"undefined\"){\n win = self;\n} else {\n win = {};\n}\n\nmodule.exports = win;\n\n\n//# sourceURL=webpack://cloudinary-video-player/../node_modules/global/window.js?"); /***/ }), /***/ "../node_modules/videojs-ima/dist/videojs.ima.scss": /*!*********************************************************!*\ !*** ../node_modules/videojs-ima/dist/videojs.ima.scss ***! \*********************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://cloudinary-video-player/../node_modules/videojs-ima/dist/videojs.ima.scss?"); /***/ }), /***/ "../node_modules/videojs-contrib-ads/dist/videojs-contrib-ads.es.js": /*!**************************************************************************!*\ !*** ../node_modules/videojs-contrib-ads/dist/videojs-contrib-ads.es.js ***! \**************************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! video.js */ \"../node_modules/video.js/dist/alt/video.core-exposed.js\");\n/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(video_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! global/window */ \"../node_modules/global/window.js\");\n/* harmony import */ var global_window__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(global_window__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var global_document__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! global/document */ \"../node_modules/global/document.js\");\n/* harmony import */ var global_document__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(global_document__WEBPACK_IMPORTED_MODULE_2__);\n/*! @name videojs-contrib-ads @version 7.5.2 @license Apache-2.0 */\n\n\n\n\nvar version = \"7.5.2\";\n\n/*\n * Implements the public API available in `player.ads` as well as application state.\n */\nfunction getAds(player) {\n return {\n disableNextSnapshotRestore: false,\n // This is true if we have finished actual content playback but haven't\n // dealt with postrolls and officially ended yet\n _contentEnding: false,\n // This is set to true if the content has officially ended at least once.\n // After that, the user can seek backwards and replay content, but _contentHasEnded\n // remains true.\n _contentHasEnded: false,\n // Tracks if loadstart has happened yet for the initial source. It is not reset\n // on source changes because loadstart is the event that signals to the ad plugin\n // that the source has changed. Therefore, no special signaling is needed to know\n // that there has been one for subsequent sources.\n _hasThereBeenALoadStartDuringPlayerLife: false,\n // Tracks if loadeddata has happened yet for the current source.\n _hasThereBeenALoadedData: false,\n // Tracks if loadedmetadata has happened yet for the current source.\n _hasThereBeenALoadedMetaData: false,\n // Are we after startLinearAdMode and before endLinearAdMode?\n _inLinearAdMode: false,\n // Should we block calls to play on the content player?\n _shouldBlockPlay: false,\n // Was play blocked by the plugin's playMiddleware feature?\n _playBlocked: false,\n // Tracks whether play has been requested for this source,\n // either by the play method or user interaction\n _playRequested: false,\n // Contains error information when an error occurs in contrib-ads.\n // When set, will contain an object with a type and metadata.\n _error: null,\n // This is an estimation of the current ad type being played\n // This is experimental currently. Do not rely on its presence or behavior!\n adType: null,\n VERSION: version,\n reset: function reset() {\n player.ads.disableNextSnapshotRestore = false;\n player.ads._contentEnding = false;\n player.ads._contentHasEnded = false;\n player.ads.snapshot = null;\n player.ads.adType = null;\n player.ads._hasThereBeenALoadedData = false;\n player.ads._hasThereBeenALoadedMetaData = false;\n player.ads._cancelledPlay = false;\n player.ads._shouldBlockPlay = false;\n player.ads._playBlocked = false;\n player.ads.nopreroll_ = false;\n player.ads.nopostroll_ = false;\n player.ads._playRequested = false;\n player.ads._error = null;\n },\n // Call this when an ad response has been received and there are\n // linear ads ready to be played.\n startLinearAdMode: function startLinearAdMode() {\n player.ads._state.startLinearAdMode();\n },\n // Call this when a linear ad pod has finished playing.\n endLinearAdMode: function endLinearAdMode() {\n player.ads._state.endLinearAdMode();\n },\n // Call this when an ad response has been received but there are no\n // linear ads to be played (i.e. no ads available, or overlays).\n // This has no effect if we are already in an ad break. Always\n // use endLinearAdMode() to exit from linear ad-playback state.\n skipLinearAdMode: function skipLinearAdMode() {\n player.ads._state.skipLinearAdMode();\n },\n // With no arguments, returns a boolean value indicating whether or not\n // contrib-ads is set to treat ads as stitched with content in a single\n // stream. With arguments, treated as a setter, but this behavior is\n // deprecated.\n stitchedAds: function stitchedAds(arg) {\n if (arg !== undefined) {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.warn('Using player.ads.stitchedAds() as a setter is deprecated, ' + 'it should be set as an option upon initialization of contrib-ads.');\n\n // Keep the private property and the settings in sync. When this\n // setter is removed, we can probably stop using the private property.\n this.settings.stitchedAds = !!arg;\n }\n return this.settings.stitchedAds;\n },\n // Returns whether the video element has been modified since the\n // snapshot was taken.\n // We test both src and currentSrc because changing the src attribute to a URL that\n // AdBlocker is intercepting doesn't update currentSrc.\n videoElementRecycled: function videoElementRecycled() {\n if (player.ads.shouldPlayContentBehindAd(player)) {\n return false;\n }\n if (!this.snapshot) {\n throw new Error('You cannot use videoElementRecycled while there is no snapshot.');\n }\n var srcChanged = player.tech_.src() !== this.snapshot.src;\n var currentSrcChanged = player.currentSrc() !== this.snapshot.currentSrc;\n return srcChanged || currentSrcChanged;\n },\n // Returns a boolean indicating if given player is in live mode.\n // One reason for this: https://github.com/videojs/video.js/issues/3262\n // Also, some live content can have a duration.\n isLive: function isLive(somePlayer) {\n if (somePlayer === void 0) {\n somePlayer = player;\n }\n if (typeof somePlayer.ads.settings.contentIsLive === 'boolean') {\n return somePlayer.ads.settings.contentIsLive;\n } else if (somePlayer.duration() === Infinity) {\n return true;\n } else if ((video_js__WEBPACK_IMPORTED_MODULE_0___default().browser).IOS_VERSION === '8' && somePlayer.duration() === 0) {\n return true;\n }\n return false;\n },\n // Return true if content playback should mute and continue during ad breaks.\n // This is only done during live streams on platforms where it's supported.\n // This improves speed and accuracy when returning from an ad break.\n shouldPlayContentBehindAd: function shouldPlayContentBehindAd(somePlayer) {\n if (somePlayer === void 0) {\n somePlayer = player;\n }\n if (!somePlayer) {\n throw new Error('shouldPlayContentBehindAd requires a player as a param');\n } else if (!somePlayer.ads.settings.liveCuePoints) {\n return false;\n } else {\n return !(video_js__WEBPACK_IMPORTED_MODULE_0___default().browser).IS_IOS && !(video_js__WEBPACK_IMPORTED_MODULE_0___default().browser).IS_ANDROID && somePlayer.duration() === Infinity;\n }\n },\n // Return true if the ads plugin should save and restore snapshots of the\n // player state when moving into and out of ad mode.\n shouldTakeSnapshots: function shouldTakeSnapshots(somePlayer) {\n if (somePlayer === void 0) {\n somePlayer = player;\n }\n return !this.shouldPlayContentBehindAd(somePlayer) && !this.stitchedAds();\n },\n // Returns true if player is in ad mode.\n //\n // Ad mode definition:\n // If content playback is blocked by the ad plugin.\n //\n // Examples of ad mode:\n //\n // * Waiting to find out if an ad is going to play while content would normally be\n // playing.\n // * Waiting for an ad to start playing while content would normally be playing.\n // * An ad is playing (even if content is also playing)\n // * An ad has completed and content is about to resume, but content has not resumed\n // yet.\n //\n // Examples of not ad mode:\n //\n // * Content playback has not been requested\n // * Content playback is paused\n // * An asynchronous ad request is ongoing while content is playing\n // * A non-linear ad is active\n isInAdMode: function isInAdMode() {\n return this._state.isAdState();\n },\n // Returns true if in ad mode but an ad break hasn't started yet.\n isWaitingForAdBreak: function isWaitingForAdBreak() {\n return this._state.isWaitingForAdBreak();\n },\n // Returns true if content is resuming after an ad. This is part of ad mode.\n isContentResuming: function isContentResuming() {\n return this._state.isContentResuming();\n },\n // Deprecated because the name was misleading. Use inAdBreak instead.\n isAdPlaying: function isAdPlaying() {\n return this._state.inAdBreak();\n },\n // Returns true if an ad break is ongoing. This is part of ad mode.\n // An ad break is the time between startLinearAdMode and endLinearAdMode.\n inAdBreak: function inAdBreak() {\n return this._state.inAdBreak();\n },\n /*\n * Remove the poster attribute from the video element tech, if present. When\n * reusing a video element for multiple videos, the poster image will briefly\n * reappear while the new source loads. Removing the attribute ahead of time\n * prevents the poster from showing up between videos.\n *\n * @param {Object} player The videojs player object\n */\n removeNativePoster: function removeNativePoster() {\n var tech = player.$('.vjs-tech');\n if (tech) {\n tech.removeAttribute('poster');\n }\n },\n debug: function debug() {\n if (this.settings.debug) {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n if (args.length === 1 && typeof args[0] === 'string') {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log('ADS: ' + args[0]);\n } else {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.apply((video_js__WEBPACK_IMPORTED_MODULE_0___default()), ['ADS:'].concat(args));\n }\n }\n },\n /**\n * Set or get the current ads error.\n *\n * @fires Player#vjsadserror\n *\n * @param {import('video.js/dist/types/media-error').ErrorMetadata|null} [err]\n * The error to be set. This can either be a string\n * of the error type, or it can be an object containing the\n * type, along with error metadata.\n * If nothing is passed in, this function will return the current error.\n * @param {string} err.errorType The error type.\n *\n * @return {Object|null|undefined}\n * The current ads error. The function will return undefined if the function\n * is used to set an error. It will return null if there is no error.\n */\n error: function error(err) {\n // If `err` doesn't exist, return the current error.\n if (err === undefined) {\n return this._error || null;\n }\n\n // If `err` is null or not a valid error, reset the ads error.\n if (err === null || !err.errorType) {\n this._error = null;\n return;\n }\n this._error = err;\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.error(\"An error with Ads occured. Type: \" + err.errorType + \".\");\n\n /**\n * @event Player#vjsadserror\n * @type {Event}\n */\n player.trigger({\n type: 'vjsadserror',\n error: this._error\n });\n }\n };\n}\n\n/*\nThe goal of this feature is to make player events work as an integrator would\nexpect despite the presense of ads. For example, an integrator would expect\nan `ended` event to happen once the content is ended. If an `ended` event is sent\nas a result of a preroll ending, that is a bug. The `redispatch` method should recognize\nsuch `ended` events and prefix them so they are sent as `adended`, and so on with\nall other player events.\n*/\n\n// Cancel an event.\n// Video.js wraps native events. This technique stops propagation for the Video.js event\n// (AKA player event or wrapper event) while native events continue propagating.\nvar cancelEvent = function cancelEvent(player, event) {\n event.isImmediatePropagationStopped = function () {\n return true;\n };\n event.cancelBubble = true;\n event.isPropagationStopped = function () {\n return true;\n };\n};\n\n// Redispatch an event with a prefix.\n// Cancels the event, then sends a new event with the type of the original\n// event with the given prefix added.\n// The inclusion of the \"state\" property should be removed in a future\n// major version update with instructions to migrate any code that relies on it.\n// It is an implementation detail and relying on it creates fragility.\nvar prefixEvent = function prefixEvent(player, prefix, event) {\n cancelEvent(player, event);\n player.trigger({\n type: prefix + event.type,\n originalEvent: event\n });\n};\n\n// Playing event\n// Requirements:\n// * Normal playing event when there is no preroll\n// * No playing event before preroll\n// * At least one playing event after preroll\nvar handlePlaying = function handlePlaying(player, event) {\n if (player.ads.isInAdMode()) {\n if (player.ads.isContentResuming()) {\n // Prefix playing event when switching back to content after postroll.\n if (player.ads._contentEnding) {\n prefixEvent(player, 'content', event);\n }\n\n // Prefix all other playing events during ads.\n } else {\n prefixEvent(player, 'ad', event);\n }\n }\n};\n\n// Ended event\n// Requirements:\n// * A single ended event when there is no postroll\n// * No ended event before postroll\n// * A single ended event after postroll\nvar handleEnded = function handleEnded(player, event) {\n if (player.ads.isInAdMode()) {\n // Cancel ended events during content resuming. Normally we would\n // prefix them, but `contentended` has a special meaning. In the\n // future we'd like to rename the existing `contentended` to\n // `readyforpostroll`, then we could remove the special `resumeended`\n // and do a conventional content prefix here.\n if (player.ads.isContentResuming()) {\n cancelEvent(player, event);\n\n // Important: do not use this event outside of videojs-contrib-ads.\n // It will be removed and your code will break.\n // Ideally this would simply be `contentended`, but until\n // `contentended` no longer has a special meaning it cannot be\n // changed.\n player.trigger('resumeended');\n\n // Ad prefix in ad mode\n } else {\n prefixEvent(player, 'ad', event);\n }\n\n // Prefix ended due to content ending before postroll check\n } else if (!player.ads._contentHasEnded && !player.ads.stitchedAds()) {\n // This will change to cancelEvent after the contentended deprecation\n // period (contrib-ads 7)\n prefixEvent(player, 'content', event);\n\n // Content ended for the first time, time to check for postrolls\n player.trigger('readyforpostroll');\n }\n};\n\n// handleLoadEvent is used for loadstart, loadeddata, and loadedmetadata\n// Requirements:\n// * Initial event is not prefixed\n// * Event due to ad loading is prefixed\n// * Event due to content source change is not prefixed\n// * Event due to content resuming is prefixed\nvar handleLoadEvent = function handleLoadEvent(player, event) {\n // Initial event\n if (event.type === 'loadstart' && !player.ads._hasThereBeenALoadStartDuringPlayerLife || event.type === 'loadeddata' && !player.ads._hasThereBeenALoadedData || event.type === 'loadedmetadata' && !player.ads._hasThereBeenALoadedMetaData) {\n return;\n\n // Ad playing\n } else if (player.ads.inAdBreak()) {\n prefixEvent(player, 'ad', event);\n\n // Source change\n } else if (player.currentSrc() !== player.ads.contentSrc) {\n return;\n\n // Content resuming\n } else {\n prefixEvent(player, 'content', event);\n }\n};\n\n// Play event\n// Requirements:\n// * Play events have the \"ad\" prefix when an ad is playing\n// * Play events have the \"content\" prefix when content is resuming\n// Play requests are unique because they represent user intention to play. They happen\n// because the user clicked play, or someone called player.play(), etc. It could happen\n// multiple times during ad loading, regardless of where we are in the process. With our\n// current architecture, this could cause the content to start playing.\n// Therefore, contrib-ads must always either:\n// - cancelContentPlay if there is any possible chance the play caused the\n// content to start playing, even if we are technically in ad mode. In order for\n// that to happen, play events need to be unprefixed until the last possible moment.\n// - use playMiddleware to stop the play from reaching the Tech so there is no risk\n// of the content starting to play.\n// Currently, playMiddleware is only supported on desktop browsers with\n// video.js after version 6.7.1.\nvar handlePlay = function handlePlay(player, event) {\n if (player.ads.inAdBreak()) {\n prefixEvent(player, 'ad', event);\n\n // Content resuming\n } else if (player.ads.isContentResuming()) {\n prefixEvent(player, 'content', event);\n }\n};\n\n// Handle a player event, either by redispatching it with a prefix, or by\n// letting it go on its way without any meddling.\nfunction redispatch(event) {\n // Events with special treatment\n if (event.type === 'playing') {\n handlePlaying(this, event);\n } else if (event.type === 'ended') {\n handleEnded(this, event);\n } else if (event.type === 'loadstart' || event.type === 'loadeddata' || event.type === 'loadedmetadata') {\n handleLoadEvent(this, event);\n } else if (event.type === 'play') {\n handlePlay(this, event);\n\n // Standard handling for all other events\n } else if (this.ads.isInAdMode()) {\n if (this.ads.isContentResuming()) {\n // Event came from snapshot restore after an ad, use \"content\" prefix\n prefixEvent(this, 'content', event);\n } else {\n // Event came from ad playback, use \"ad\" prefix\n prefixEvent(this, 'ad', event);\n }\n }\n}\n\n/*\nThis feature sends a `contentupdate` event when the player source changes.\n*/\n\n// Start sending contentupdate events\nfunction initializeContentupdate(player) {\n // Keep track of the current content source\n // If you want to change the src of the video without triggering\n // the ad workflow to restart, you can update this variable before\n // modifying the player's source\n player.ads.contentSrc = player.currentSrc();\n player.ads._seenInitialLoadstart = false;\n\n // Check if a new src has been set, if so, trigger contentupdate\n var checkSrc = function checkSrc() {\n if (!player.ads.inAdBreak()) {\n var src = player.currentSrc();\n if (src !== player.ads.contentSrc) {\n if (player.ads._seenInitialLoadstart) {\n player.trigger({\n type: 'contentchanged'\n });\n }\n player.trigger({\n type: 'contentupdate',\n oldValue: player.ads.contentSrc,\n newValue: src\n });\n player.ads.contentSrc = src;\n }\n player.ads._seenInitialLoadstart = true;\n }\n };\n\n // loadstart reliably indicates a new src has been set\n player.on('loadstart', checkSrc);\n}\n\nfunction _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n _setPrototypeOf(subClass, superClass);\n}\nfunction _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}\n\n/**\n * Current tcfData returned from CMP\n * Updated on event listener rather than having to make an asyc\n * check within the macro resolver\n */\nvar tcData = {};\n\n/**\n * Sets up a proxy for the TCF API in an iframed player, if a parent frame\n * that has implemented the TCF API is detected\n * https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#is-there-a-sample-iframe-script-call-to-the-cmp-api\n */\nvar proxyTcfApi = function proxyTcfApi(_) {\n if (video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.isInFrame() && typeof (global_window__WEBPACK_IMPORTED_MODULE_1___default().__tcfapi) !== 'function') {\n var frame = (global_window__WEBPACK_IMPORTED_MODULE_1___default());\n var cmpFrame;\n var cmpCallbacks = {};\n while (frame) {\n try {\n if (frame.frames.__tcfapiLocator) {\n cmpFrame = frame;\n break;\n }\n } catch (ignore) {\n // empty\n }\n if (frame === (global_window__WEBPACK_IMPORTED_MODULE_1___default().top)) {\n break;\n }\n frame = frame.parent;\n }\n if (!cmpFrame) {\n return;\n }\n (global_window__WEBPACK_IMPORTED_MODULE_1___default().__tcfapi) = function (cmd, version, callback, arg) {\n var callId = Math.random() + '';\n var msg = {\n __tcfapiCall: {\n command: cmd,\n parameter: arg,\n version: version,\n callId: callId\n }\n };\n cmpCallbacks[callId] = callback;\n cmpFrame.postMessage(msg, '*');\n };\n global_window__WEBPACK_IMPORTED_MODULE_1___default().addEventListener('message', function (event) {\n var json = {};\n try {\n json = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;\n } catch (ignore) {\n // empty\n }\n var payload = json.__tcfapiReturn;\n if (payload) {\n if (typeof cmpCallbacks[payload.callId] === 'function') {\n cmpCallbacks[payload.callId](payload.returnValue, payload.success);\n cmpCallbacks[payload.callId] = null;\n }\n }\n }, false);\n }\n};\n\n/**\n * Sets up event listener for changes to consent data.\n */\nvar listenToTcf = function listenToTcf() {\n proxyTcfApi();\n if (typeof (global_window__WEBPACK_IMPORTED_MODULE_1___default().__tcfapi) === 'function') {\n global_window__WEBPACK_IMPORTED_MODULE_1___default().__tcfapi('addEventListener', 2, function (data, success) {\n if (success) {\n tcData = data;\n }\n });\n }\n};\n\nvar findUspApiLocatorWindow = function findUspApiLocatorWindow(windowObj) {\n var targetWindow = windowObj.parent;\n while (targetWindow !== windowObj.top) {\n try {\n if (targetWindow.frames && targetWindow.frames.__uspapiLocator) {\n return targetWindow;\n }\n } catch (ignore) {\n // do nothing\n }\n targetWindow = targetWindow.parent;\n }\n\n // Check for the __uspapiLocator frame in the top window\n try {\n if (windowObj.top.frames && windowObj.top.frames.__uspapiLocator) {\n return windowObj.top;\n }\n } catch (ignore) {\n // do nothing\n }\n\n // Return null if no __uspapiLocator frame is found in any window\n return null;\n};\nvar uspString = '';\nvar getCurrentUspString = function getCurrentUspString() {\n return uspString;\n};\n\n// Call the USP API to get the US Privacy String, either by invoking it directly or via postMessage() if inside an iframe.\n// In the former case the callback is synchronous, if the latter it is asynchronous, so to be safe it should always be\n// assumed to be asynchronous.\n// The window is passable as an argument for ease of testing\nvar obtainUsPrivacyString = function obtainUsPrivacyString(callback, windowObj) {\n if (windowObj === void 0) {\n windowObj = (global_window__WEBPACK_IMPORTED_MODULE_1___default());\n }\n if (windowObj.__uspapi) {\n windowObj.__uspapi('getUSPData', 1, function (uspData, success) {\n var privacyString = success ? uspData.uspString : null;\n uspString = privacyString;\n callback(privacyString);\n });\n } else {\n var targetWindow = findUspApiLocatorWindow(windowObj);\n\n // If no __uspapiLocator frame is found, execute the callback with a null privacy string\n if (!targetWindow) {\n callback(null);\n return;\n }\n var uniqueId = Math.random().toString(36).substring(2);\n var message = {\n __uspapiCall: {\n command: 'getUSPData',\n version: 1,\n callId: uniqueId\n }\n };\n var handleMessageEvent = function handleMessageEvent(event) {\n if (event && event.data && event.data.__uspapiReturn && event.data.__uspapiReturn.callId === uniqueId) {\n windowObj.removeEventListener('message', handleMessageEvent, false);\n var _event$data$__uspapiR = event.data.__uspapiReturn,\n returnValue = _event$data$__uspapiR.returnValue,\n success = _event$data$__uspapiR.success;\n var privacyString = success ? returnValue.uspString : null;\n uspString = privacyString;\n callback(privacyString);\n }\n };\n windowObj.addEventListener('message', handleMessageEvent, false);\n targetWindow.postMessage(message, '*');\n }\n};\n\nvar Error$1 = {\n AdsBeforePrerollError: 'ads-before-preroll-error',\n AdsPrerollError: 'ads-preroll-error',\n AdsMidrollError: 'ads-midroll-error',\n AdsPostrollError: 'ads-postroll-error',\n AdsMacroReplacementFailed: 'ads-macro-replacement-failed',\n AdsResumeContentFailed: 'ads-resume-content-failed'\n};\n\nvar uriEncodeIfNeeded = function uriEncodeIfNeeded(value, uriEncode) {\n return uriEncode ? encodeURIComponent(value) : value;\n};\n\n// Add custom field macros to macros object\n// based on given name for custom fields property of mediainfo object.\nvar customFields = function customFields(mediainfo, macros, customFieldsName) {\n if (mediainfo && mediainfo[customFieldsName]) {\n var fields = mediainfo[customFieldsName];\n var fieldNames = Object.keys(fields);\n for (var i = 0; i < fieldNames.length; i++) {\n var tag = '{mediainfo.' + customFieldsName + '.' + fieldNames[i] + '}';\n macros[tag] = fields[fieldNames[i]];\n }\n }\n};\nvar getMediaInfoMacros = function getMediaInfoMacros(mediainfo, defaults) {\n var macros = {};\n ['description', 'tags', 'reference_id', 'ad_keys'].forEach(function (prop) {\n if (mediainfo && mediainfo[prop]) {\n macros[\"{mediainfo.\" + prop + \"}\"] = mediainfo[prop];\n } else if (defaults[\"{mediainfo.\" + prop + \"}\"]) {\n macros[\"{mediainfo.\" + prop + \"}\"] = defaults[\"{mediainfo.\" + prop + \"}\"];\n } else {\n macros[\"{mediainfo.\" + prop + \"}\"] = '';\n }\n });\n ['custom_fields', 'customFields'].forEach(function (customFieldProp) {\n customFields(mediainfo, macros, customFieldProp);\n });\n return macros;\n};\nvar getDefaultValues = function getDefaultValues(string) {\n var defaults = {};\n var modifiedString = string.replace(/{([^}=]+)=([^}]*)}/g, function (match, name, defaultVal) {\n defaults[\"{\" + name + \"}\"] = defaultVal;\n return \"{\" + name + \"}\";\n });\n return {\n defaults: defaults,\n modifiedString: modifiedString\n };\n};\nvar getStaticMacros = function getStaticMacros(player) {\n return {\n '{player.id}': player.options_['data-player'] || player.id_,\n '{player.height}': player.currentHeight(),\n '{player.width}': player.currentWidth(),\n '{player.heightInt}': Math.round(player.currentHeight()),\n '{player.widthInt}': Math.round(player.currentWidth()),\n '{player.autoplay}': player.autoplay() ? 1 : 0,\n '{player.muted}': player.muted() ? 1 : 0,\n '{player.language}': player.language() || '',\n '{mediainfo.id}': player.mediainfo ? player.mediainfo.id : '',\n '{mediainfo.name}': player.mediainfo ? player.mediainfo.name : '',\n '{mediainfo.duration}': player.mediainfo ? player.mediainfo.duration : '',\n '{player.duration}': player.duration(),\n '{player.durationInt}': Math.round(player.duration()),\n '{player.live}': player.duration() === Infinity ? 1 : 0,\n '{player.pageUrl}': video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.isInFrame() ? (global_document__WEBPACK_IMPORTED_MODULE_2___default().referrer) : (global_window__WEBPACK_IMPORTED_MODULE_1___default().location).href,\n '{playlistinfo.id}': player.playlistinfo ? player.playlistinfo.id : '',\n '{playlistinfo.name}': player.playlistinfo ? player.playlistinfo.name : '',\n '{timestamp}': new Date().getTime(),\n '{document.referrer}': (global_document__WEBPACK_IMPORTED_MODULE_2___default().referrer),\n '{window.location.href}': (global_window__WEBPACK_IMPORTED_MODULE_1___default().location).href,\n '{random}': Math.floor(Math.random() * 1000000000000)\n };\n};\nvar getTcfMacros = function getTcfMacros(tcDataObj) {\n var tcfMacros = {};\n Object.keys(tcDataObj).forEach(function (key) {\n tcfMacros[\"{tcf.\" + key + \"}\"] = tcDataObj[key];\n });\n tcfMacros['{tcf.gdprAppliesInt}'] = tcDataObj.gdprApplies ? 1 : 0;\n return tcfMacros;\n};\nvar getUspMacros = function getUspMacros() {\n return {\n '{usp.uspString}': getCurrentUspString()\n };\n};\n\n// This extracts and evaluates variables from the `window` object for macro replacement. While replaceMacros() handles generic macro name\n// overriding for other macro types, this function also needs to reference the overrides in order to map custom macro names in the string\n// to their corresponding default pageVariable names, so they can be evaluated on the `window` and stored for later replacement in replaceMacros().\nvar getPageVariableMacros = function getPageVariableMacros(string, defaults, macroNameOverrides) {\n var pageVarRegex = new RegExp('{pageVariable\\\\.([^}]+)}', 'g');\n var pageVariablesMacros = {};\n\n // Aggregate any default pageVariable macros found in the string with any pageVariable macros that have custom names specified in\n // macroNameOverrides.\n var pageVariables = (string.match(pageVarRegex) || []).concat(Object.keys(macroNameOverrides).filter(function (macroName) {\n return pageVarRegex.test(macroName) && string.includes(macroNameOverrides[macroName]);\n }));\n if (!pageVariables) {\n return;\n }\n pageVariables.forEach(function (pageVar) {\n var key = pageVar;\n var name = pageVar.slice(14, -1);\n var names = name.split('.');\n var context = (global_window__WEBPACK_IMPORTED_MODULE_1___default());\n var value;\n\n // Iterate down multiple levels of selector without using eval\n // This makes things like pageVariable.foo.bar work\n for (var i = 0; i < names.length; i++) {\n if (i === names.length - 1) {\n value = context[names[i]];\n } else {\n context = context[names[i]];\n if (typeof context === 'undefined') {\n break;\n }\n }\n }\n var type = typeof value;\n\n // Only allow certain types of values. Anything else is probably a mistake.\n if (value === null) {\n pageVariablesMacros[key] = 'null';\n } else if (value === undefined) {\n if (defaults[key]) {\n pageVariablesMacros[key] = defaults[key];\n } else {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.warn(\"Page variable \\\"\" + name + \"\\\" not found\");\n pageVariablesMacros[key] = '';\n }\n } else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.warn(\"Page variable \\\"\" + name + \"\\\" is not a supported type\");\n pageVariablesMacros[key] = '';\n } else {\n pageVariablesMacros[key] = value;\n }\n });\n return pageVariablesMacros;\n};\nvar replaceMacros = function replaceMacros(string, macros, uriEncode, overrides, player) {\n if (overrides === void 0) {\n overrides = {};\n }\n for (var macroName in macros) {\n // The resolvedMacroName is the macro as it is expected to appear in the actual string, or regex if it has been provided.\n var resolvedMacroName = overrides.hasOwnProperty(macroName) ? overrides[macroName] : macroName;\n if (resolvedMacroName.startsWith('r:')) {\n try {\n var regex = new RegExp(resolvedMacroName.slice(2), 'g');\n string = string.replace(regex, uriEncodeIfNeeded(macros[macroName], uriEncode));\n } catch (error) {\n player.ads.error({\n errorType: Error$1.AdsMacroReplacementFailed,\n macro: macroName,\n error: error\n });\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.warn(\"Unable to replace macro with regex \\\"\" + resolvedMacroName + \"\\\". The provided regex may be invalid.\");\n }\n } else {\n string = string.split(resolvedMacroName).join(uriEncodeIfNeeded(macros[macroName], uriEncode));\n }\n }\n return string;\n};\n\n/**\n *\n * @param {string} string\n * Any string with macros to be replaced\n * @param {boolean} uriEncode\n * A Boolean value indicating whether the macros should be replaced with URI-encoded values\n * @param {object} customMacros\n * An object with custom macros and values to map them to. For example: {'{five}': 5}\n * @param {boolean} customMacros.disableDefaultMacros\n * A boolean indicating whether replacement of default macros should be forgone in favor of only customMacros\n * @param {object} customMacros.macroNameOverrides\n * An object that specifies custom names for default macros, following the following format:\n * // {'{default-macro-name}': '{new-macro-name}'}\n * {'{player.id}': '{{PLAYER_ID}}', ...}\n * @returns {string}\n * The provided string with all macros replaced. For example: adMacroReplacement('{player.id}') returns a string of the player id\n */\nfunction adMacroReplacement(string, uriEncode, customMacros) {\n if (uriEncode === void 0) {\n uriEncode = false;\n }\n if (customMacros === void 0) {\n customMacros = {};\n }\n var disableDefaultMacros = customMacros.disableDefaultMacros || false;\n var macroNameOverrides = customMacros.macroNameOverrides || {};\n\n // Remove special properties from customMacros\n delete customMacros.disableDefaultMacros;\n delete customMacros.macroNameOverrides;\n var macros = customMacros;\n if (disableDefaultMacros) {\n return replaceMacros(string, macros, uriEncode, macroNameOverrides);\n }\n\n // Get macros with defaults e.g. {x=y}, store the values in `defaults` and replace with standard macros in the string\n var _getDefaultValues = getDefaultValues(string),\n defaults = _getDefaultValues.defaults,\n modifiedString = _getDefaultValues.modifiedString;\n string = modifiedString;\n\n // Get all macro values\n _extends(macros, getStaticMacros(this), getMediaInfoMacros(this.mediainfo, defaults), getTcfMacros(tcData), getUspMacros(), getPageVariableMacros(string, defaults, macroNameOverrides));\n\n // Perform macro replacement\n string = replaceMacros(string, macros, uriEncode, macroNameOverrides, this);\n\n // Replace any remaining default values that have not already been replaced. This includes mediainfo custom fields.\n for (var macro in defaults) {\n string = string.replace(macro, defaults[macro]);\n }\n return string;\n}\n\n/*\n* This feature allows metadata text tracks to be manipulated once available\n* @see processMetadataTracks.\n* It also allows ad implementations to leverage ad cues coming through\n* text tracks, @see processAdTrack\n**/\nvar cueTextTracks = {};\n\n/*\n* This feature allows metadata text tracks to be manipulated once they are available,\n* usually after the 'loadstart' event is observed on the player\n* @param player A reference to a player\n* @param processMetadataTrack A callback that performs some operations on a\n* metadata text track\n**/\ncueTextTracks.processMetadataTracks = function (player, processMetadataTrack) {\n var tracks = player.textTracks();\n var setModeAndProcess = function setModeAndProcess(track) {\n if (track.kind === 'metadata') {\n player.ads.cueTextTracks.setMetadataTrackMode(track);\n processMetadataTrack(player, track);\n }\n };\n\n // Text tracks are available\n for (var i = 0; i < tracks.length; i++) {\n setModeAndProcess(tracks[i]);\n }\n\n // Wait until text tracks are added\n tracks.addEventListener('addtrack', function (event) {\n setModeAndProcess(event.track);\n });\n};\n\n/*\n* Sets the track mode to one of 'disabled', 'hidden' or 'showing'\n* @see https://github.com/videojs/video.js/blob/master/docs/guides/text-tracks.md\n* Default behavior is to do nothing, @override if this is not desired\n* @param track The text track to set the mode on\n*/\ncueTextTracks.setMetadataTrackMode = function (track) {\n return;\n};\n\n/*\n* Determines whether cue is an ad cue and returns the cue data.\n* @param player A reference to the player\n* @param cue The full cue object\n* Returns the given cue by default @override if futher processing is required\n* @return {Object} a useable ad cue or null if not supported\n**/\ncueTextTracks.getSupportedAdCue = function (player, cue) {\n return cue;\n};\n\n/*\n* Defines whether a cue is supported or not, potentially\n* based on the player settings\n* @param player A reference to the player\n* @param cue The cue to be checked\n* Default behavior is to return true, @override if this is not desired\n* @return {Boolean}\n*/\ncueTextTracks.isSupportedAdCue = function (player, cue) {\n return true;\n};\n\n/*\n* Gets the id associated with a cue.\n* @param cue The cue to extract an ID from\n* @returns The first occurance of 'id' in the object,\n* @override if this is not the desired cue id\n**/\ncueTextTracks.getCueId = function (player, cue) {\n return cue.id;\n};\n\n/*\n* Checks whether a cue has already been used\n* @param cueId The Id associated with a cue\n**/\nvar cueAlreadySeen = function cueAlreadySeen(player, cueId) {\n return cueId !== undefined && player.ads.includedCues[cueId];\n};\n\n/*\n* Indicates that a cue has been used\n* @param cueId The Id associated with a cue\n**/\nvar setCueAlreadySeen = function setCueAlreadySeen(player, cueId) {\n if (cueId !== undefined && cueId !== '') {\n player.ads.includedCues[cueId] = true;\n }\n};\n\n/*\n* This feature allows ad metadata tracks to be manipulated in ad implementations\n* @param player A reference to the player\n* @param cues The set of cues to work with\n* @param processCue A method that uses a cue to make some\n* ad request in the ad implementation\n* @param [cancelAdsHandler] A method that dynamically cancels ads in the ad implementation\n**/\ncueTextTracks.processAdTrack = function (player, cues, processCue, cancelAdsHandler) {\n player.ads.includedCues = {};\n\n // loop over set of cues\n for (var i = 0; i < cues.length; i++) {\n var cue = cues[i];\n var cueData = this.getSupportedAdCue(player, cue);\n\n // Exit if this is not a supported cue\n if (!this.isSupportedAdCue(player, cue)) {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log.warn('Skipping as this is not a supported ad cue.', cue);\n return;\n }\n\n // Continue processing supported cue\n var cueId = this.getCueId(player, cue);\n var startTime = cue.startTime;\n\n // Skip ad if cue was already used\n if (cueAlreadySeen(player, cueId)) {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log('Skipping ad already seen with ID ' + cueId);\n return;\n }\n\n // Optional dynamic ad cancellation\n if (cancelAdsHandler) {\n cancelAdsHandler(player, cueData, cueId, startTime);\n }\n\n // Process cue as an ad cue\n processCue(player, cueData, cueId, startTime);\n\n // Indicate that this cue has been used\n setCueAlreadySeen(player, cueId);\n }\n};\n\nfunction initCancelContentPlay(player, debug) {\n if (debug) {\n video_js__WEBPACK_IMPORTED_MODULE_0___default().log('Using cancelContentPlay to block content playback');\n }\n\n // Listen to play events to \"cancel\" them afterward\n player.on('play', cancelContentPlay);\n}\n\n/*\nThis feature makes sure the player is paused during ad loading.\n\nIt does this by pausing the player immediately after a \"play\" where ads will be requested,\nthen signalling that we should play after the ad is done.\n*/\n\nfunction cancelContentPlay() {\n // this function is in the player's context\n\n if (this.ads._shouldBlockPlay === false) {\n // Only block play if the ad plugin is in a state when content\n // playback should be blocked. This currently means during\n // BeforePrerollState and PrerollState.\n return;\n }\n\n // pause playback so ads can be handled.\n if (!this.paused()) {\n this.ads.debug('Playback was canceled by cancelContentPlay');\n this.pause();\n }\n\n // When the 'content-playback' state is entered, this will let us know to play.\n // This is needed if there is no preroll or if it errors, times out, etc.\n this.ads._cancelledPlay = true;\n}\n\nvar obj = {};\n// This reference allows videojs to be mocked in unit tests\n// while still using the available videojs import in the source code\n// @see obj.testHook\nvar videojsReference = (video_js__WEBPACK_IMPORTED_MODULE_0___default());\n\n/**\n * Checks if middleware mediators are available and\n * can be used on this platform.\n * Currently we can only use mediators on desktop platforms.\n */\nobj.isMiddlewareMediatorSupported = function () {\n if (videojsReference.browser.IS_IOS || videojsReference.browser.IS_ANDROID) {\n return false;\n } else if (\n // added when middleware was introduced in video.js\n videojsReference.use &&\n // added when mediators were introduced in video.js\n videojsReference.middleware && videojsReference.middleware.TERMINATOR) {\n return true;\n }\n return false;\n};\nobj.playMiddleware = function (player) {\n return {\n setSource: function setSource(srcObj, next) {\n next(null, srcObj);\n },\n callPlay: function callPlay() {\n // Block play calls while waiting for an ad, only if this is an\n // ad supported player\n if (player.ads && player.ads._shouldBlockPlay === true) {\n player.ads.debug('Using playMiddleware to block content playback');\n player.ads._playBlocked = true;\n return videojsReference.middleware.TERMINATOR;\n }\n },\n play: function play(terminated, playPromise) {\n if (player.ads && player.ads._playBlocked && terminated) {\n player.ads.debug('Play call to Tech was terminated.');\n // Trigger play event to match the user's intent to play.\n // The call to play on the Tech has been blocked, so triggering\n // the event on the Player will not affect the Tech's playback state.\n player.trigger('play');\n // At this point the player has technically started\n player.addClass('vjs-has-started');\n // Reset playBlocked\n player.ads._playBlocked = false;\n\n // Safari issues a pause event when autoplay is blocked but other browsers\n // do not, so we send a pause for consistency in those cases. This keeps the\n // play button in the correct state if play is rejected.\n } else if (playPromise && playPromise.catch) {\n playPromise.catch(function (e) {\n if (e.name === 'NotAllowedError' && !(video_js__WEBPACK_IMPORTED_MODULE_0___default().browser).IS_SAFARI) {\n player.trigger('pause');\n }\n });\n }\n }\n };\n};\nobj.testHook = function (testVjs) {\n videojsReference = testVjs;\n};\n\nvar playMiddleware = obj.playMiddleware,\n isMiddlewareMediatorSupported = obj.isMiddlewareMediatorSupported;\n\n/**\n * Whether or not this copy of Video.js has the ads plugin.\n *\n * @return {boolean}\n * If `true`, has the plugin. `false` otherwise.\n */\nvar hasAdsPlugin = function hasAdsPlugin() {\n // Video.js 6 and 7 have a getPlugin method.\n if ((video_js__WEBPACK_IMPORTED_MODULE_0___default().getPlugin)) {\n return Boolean(video_js__WEBPACK_IMPORTED_MODULE_0___default().getPlugin('ads'));\n }\n\n // Video.js 5 does not have a getPlugin method, so check the player prototype.\n var Player = video_js__WEBPACK_IMPORTED_MODULE_0___default().getComponent('Player');\n return Boolean(Player && Player.prototype.ads);\n};\n\n/**\n * Register contrib-ads with Video.js, but provide protection for duplicate\n * copies of the plugin. This could happen if, for example, a stitched ads\n * plugin and a client-side ads plugin are included simultaneously with their\n * own copies of contrib-ads.\n *\n * If contrib-ads d