From 05ae8567d431220c6cfcb56d9498aba63695d0bb Mon Sep 17 00:00:00 2001 From: Paul Berberian Date: Thu, 15 Jun 2023 16:54:21 +0200 Subject: [PATCH 1/3] Update builds and version --- VERSION | 2 +- dist/rx-player.js | 2744 +++++++++++++++++++----------------- dist/rx-player.min.js | 2 +- package-lock.json | 4 +- package.json | 2 +- sonar-project.properties | 2 +- src/core/api/public_api.ts | 4 +- 7 files changed, 1440 insertions(+), 1320 deletions(-) diff --git a/VERSION b/VERSION index d9351e5882a..2f9037bc3fc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.31.0 +4.0.0-beta.2 diff --git a/dist/rx-player.js b/dist/rx-player.js index 1fdc0f10779..7c75fc08872 100644 --- a/dist/rx-player.js +++ b/dist/rx-player.js @@ -1222,11 +1222,12 @@ if (!_is_node__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z) { /* harmony export */ Dl: function() { return /* binding */ onKeyError; }, /* harmony export */ M4: function() { return /* binding */ onEnded; }, /* harmony export */ N8: function() { return /* binding */ onSourceEnded; }, -/* harmony export */ O0: function() { return /* binding */ getVideoWidthRef; }, /* harmony export */ Q$: function() { return /* binding */ onSeeking; }, /* harmony export */ RV: function() { return /* binding */ onKeyMessage; }, /* harmony export */ Zl: function() { return /* binding */ onEncrypted; }, +/* harmony export */ bD: function() { return /* binding */ getElementResolutionRef; }, /* harmony export */ bQ: function() { return /* binding */ onSeeked; }, +/* harmony export */ c9: function() { return /* binding */ getScreenResolutionRef; }, /* harmony export */ it: function() { return /* binding */ getVideoVisibilityRef; }, /* harmony export */ k6: function() { return /* binding */ onSourceClose; }, /* harmony export */ kk: function() { return /* binding */ onKeyAdded; }, @@ -1237,13 +1238,12 @@ if (!_is_node__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z) { /* harmony export */ y4: function() { return /* binding */ onSourceBufferUpdate; } /* harmony export */ }); /* unused harmony exports addEventListener, onLoadedMetadata, onTimeUpdate, onTextTrackAdded, onTextTrackRemoved */ -/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6872); -/* harmony import */ var _utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6923); -/* harmony import */ var _utils_is_null_or_undefined__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1946); -/* harmony import */ var _utils_noop__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8894); -/* harmony import */ var _utils_reference__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5095); -/* harmony import */ var _is_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2203); -/* harmony import */ var _should_favour_custom_safari_EME__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5059); +/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6872); +/* harmony import */ var _utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6923); +/* harmony import */ var _utils_is_null_or_undefined__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1946); +/* harmony import */ var _utils_noop__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8894); +/* harmony import */ var _utils_reference__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5095); +/* harmony import */ var _should_favour_custom_safari_EME__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5059); /** * Copyright 2015 CANAL+ Group * @@ -1266,9 +1266,7 @@ if (!_is_node__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z) { - var BROWSER_PREFIXES = ["", "webkit", "moz", "ms"]; -var pixelRatio = _is_node__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z || window.devicePixelRatio == null || window.devicePixelRatio === 0 ? 1 : window.devicePixelRatio; /** * Find the first supported event from the list given. * @param {HTMLElement} element @@ -1332,7 +1330,7 @@ function createCompatibleEventListener(eventNames, prefixes) { if (typeof mem === "undefined") { mem = findSupportedEvent(element, prefixedEvents); } - if ((0,_utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(mem)) { + if ((0,_utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)(mem)) { element.addEventListener(mem, listener); cancelSignal.register(function () { if (mem !== undefined) { @@ -1390,29 +1388,16 @@ function getDocumentVisibilityRef(stopListening) { } else if (doc.webkitHidden != null) { prefix = "webkit"; } - var hidden = (0,_utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(prefix) ? prefix + "Hidden" : "hidden"; - var visibilityChangeEvent = (0,_utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(prefix) ? prefix + "visibilitychange" : "visibilitychange"; + var hidden = (0,_utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)(prefix) ? prefix + "Hidden" : "hidden"; + var visibilityChangeEvent = (0,_utils_is_non_empty_string__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)(prefix) ? prefix + "visibilitychange" : "visibilitychange"; var isHidden = document[hidden]; - var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP)(!isHidden, stopListening); + var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP)(!isHidden, stopListening); addEventListener(document, visibilityChangeEvent, function () { var isVisible = !document[hidden]; ref.setValueIfChanged(isVisible); }, stopListening); return ref; } -/** - * Get video width from Picture-in-Picture window - * @param {HTMLMediaElement} mediaElement - * @param {Object} pipWindow - * @returns {number} - */ -function getVideoWidthFromPIPWindow(mediaElement, pipWindow) { - var width = pipWindow.width, - height = pipWindow.height; - var videoRatio = mediaElement.clientHeight / mediaElement.clientWidth; - var calcWidth = height / videoRatio; - return Math.min(width, calcWidth); -} /** * Emit when video enters and leaves Picture-In-Picture mode. * @param {HTMLMediaElement} elt @@ -1423,7 +1408,7 @@ function getPictureOnPictureStateRef(elt, stopListening) { var mediaElement = elt; if (mediaElement.webkitSupportsPresentationMode === true && typeof mediaElement.webkitSetPresentationMode === "function") { var isWebKitPIPEnabled = mediaElement.webkitPresentationMode === "picture-in-picture"; - var _ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP)({ + var _ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP)({ isEnabled: isWebKitPIPEnabled, pipWindow: null }, stopListening); @@ -1437,7 +1422,7 @@ function getPictureOnPictureStateRef(elt, stopListening) { return _ref; } var isPIPEnabled = document.pictureInPictureElement === mediaElement; - var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP)({ + var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP)({ isEnabled: isPIPEnabled, pipWindow: null }, stopListening); @@ -1469,7 +1454,7 @@ function getPictureOnPictureStateRef(elt, stopListening) { function getVideoVisibilityRef(pipStatus, stopListening) { var isDocVisibleRef = getDocumentVisibilityRef(stopListening); var currentTimeout; - var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP)(true, stopListening); + var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP)(true, stopListening); stopListening.register(function () { clearTimeout(currentTimeout); currentTimeout = undefined; @@ -1488,7 +1473,7 @@ function getVideoVisibilityRef(pipStatus, stopListening) { if (pipStatus.getValue().isEnabled || isDocVisibleRef.getValue()) { ref.setValueIfChanged(true); } else { - var _config$getCurrent = _config__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.getCurrent(), + var _config$getCurrent = _config__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z.getCurrent(), INACTIVITY_DELAY = _config$getCurrent.INACTIVITY_DELAY; currentTimeout = window.setTimeout(function () { ref.setValueIfChanged(false); @@ -1497,46 +1482,104 @@ function getVideoVisibilityRef(pipStatus, stopListening) { } } /** - * Get video width from HTML video element, or video estimated dimensions - * when Picture-in-Picture is activated. + * Get video width and height from the screen dimensions. + * @param {Object} stopListening + * @returns {Object} + */ +function getScreenResolutionRef(stopListening) { + var pixelRatio = window.devicePixelRatio == null || window.devicePixelRatio === 0 ? 1 : window.devicePixelRatio; + var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP)({ + width: window.screen.width, + height: window.screen.height, + pixelRatio: pixelRatio + }, stopListening); + var interval = window.setInterval(checkScreenResolution, 20000); + stopListening.register(function stopUpdating() { + clearInterval(interval); + }); + return ref; + function checkScreenResolution() { + var oldVal = ref.getValue(); + if (oldVal.width !== screen.width || oldVal.height !== screen.height || oldVal.pixelRatio !== pixelRatio) { + ref.setValue({ + width: screen.width, + height: screen.height, + pixelRatio: pixelRatio + }); + } + } +} +/** + * Get video width and height from HTML media element, or video estimated + * dimensions when Picture-in-Picture is activated. * @param {HTMLMediaElement} mediaElement * @param {Object} pipStatusRef * @param {Object} stopListening * @returns {Object} */ -function getVideoWidthRef(mediaElement, pipStatusRef, stopListening) { - var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP)(mediaElement.clientWidth * pixelRatio, stopListening); - var _clearPreviousEventListener = _utils_noop__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z; - pipStatusRef.onUpdate(checkVideoWidth, { +function getElementResolutionRef(mediaElement, pipStatusRef, stopListening) { + var pixelRatio = window.devicePixelRatio == null || window.devicePixelRatio === 0 ? 1 : window.devicePixelRatio; + var ref = (0,_utils_reference__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP)({ + width: mediaElement.clientWidth, + height: mediaElement.clientHeight, + pixelRatio: pixelRatio + }, stopListening); + var _clearPreviousEventListener = _utils_noop__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z; + pipStatusRef.onUpdate(checkElementResolution, { clearSignal: stopListening }); - addEventListener(window, "resize", checkVideoWidth, stopListening); - var interval = window.setInterval(checkVideoWidth, 20000); - checkVideoWidth(); - stopListening.register(function stopUpdatingVideoWidthRef() { + addEventListener(window, "resize", checkElementResolution, stopListening); + addEventListener(mediaElement, "enterpictureinpicture", checkElementResolution, stopListening); + addEventListener(mediaElement, "leavepictureinpicture", checkElementResolution, stopListening); + var interval = window.setInterval(checkElementResolution, 20000); + checkElementResolution(); + stopListening.register(function stopUpdating() { _clearPreviousEventListener(); clearInterval(interval); }); return ref; - function checkVideoWidth() { + function checkElementResolution() { _clearPreviousEventListener(); var pipStatus = pipStatusRef.getValue(); + var pipWindow = pipStatus.pipWindow; if (!pipStatus.isEnabled) { - ref.setValueIfChanged(mediaElement.clientWidth * pixelRatio); - } else if (!(0,_utils_is_null_or_undefined__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)(pipStatus.pipWindow)) { - var pipWindow = pipStatus.pipWindow; - var firstWidth = getVideoWidthFromPIPWindow(mediaElement, pipWindow); + var oldVal = ref.getValue(); + if (oldVal.width !== mediaElement.clientWidth || oldVal.height !== mediaElement.clientHeight || oldVal.pixelRatio !== pixelRatio) { + ref.setValue({ + width: mediaElement.clientWidth, + height: mediaElement.clientHeight, + pixelRatio: pixelRatio + }); + } + } else if (!(0,_utils_is_null_or_undefined__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)(pipWindow)) { var onPipResize = function onPipResize() { - ref.setValueIfChanged(getVideoWidthFromPIPWindow(mediaElement, pipWindow) * pixelRatio); + updateToPipWindowResolution(); }; pipWindow.addEventListener("resize", onPipResize); _clearPreviousEventListener = function clearPreviousEventListener() { pipWindow.removeEventListener("resize", onPipResize); - _clearPreviousEventListener = _utils_noop__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z; + _clearPreviousEventListener = _utils_noop__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z; }; - ref.setValueIfChanged(firstWidth * pixelRatio); + updateToPipWindowResolution(); } else { - ref.setValueIfChanged(Infinity); + var _oldVal = ref.getValue(); + if (_oldVal.width !== undefined || _oldVal.height !== undefined || _oldVal.pixelRatio !== pixelRatio) { + ref.setValue({ + width: undefined, + height: undefined, + pixelRatio: pixelRatio + }); + } + } + function updateToPipWindowResolution() { + var oldVal = ref.getValue(); + if (oldVal.width !== (pipWindow === null || pipWindow === void 0 ? void 0 : pipWindow.width) || oldVal.height !== (pipWindow === null || pipWindow === void 0 ? void 0 : pipWindow.height) || oldVal.pixelRatio !== pixelRatio) { + ref.setValue({ + width: pipWindow === null || pipWindow === void 0 ? void 0 : pipWindow.width, + height: pipWindow === null || pipWindow === void 0 ? void 0 : pipWindow.height, + pixelRatio: pixelRatio + }); + } } } } @@ -1589,7 +1632,7 @@ var onRemoveSourceBuffers = createCompatibleEventListener(["removesourcebuffer"] /** * @param {HTMLMediaElement} mediaElement */ -var onEncrypted = createCompatibleEventListener((0,_should_favour_custom_safari_EME__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)() ? ["needkey"] : ["encrypted", "needkey"]); +var onEncrypted = createCompatibleEventListener((0,_should_favour_custom_safari_EME__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)() ? ["needkey"] : ["encrypted", "needkey"]); /** * @param {MediaKeySession} mediaKeySession */ @@ -1868,17 +1911,6 @@ var DEFAULT_CONFIG = { * @type {Object|null} */ DEFAULT_TEXT_TRACK_MODE: "native", - /** - * Strategy to adopt when manually setting the current bitrate. - * Can be either: - * - "seamless": transitions are very smooth but not immediate. - * - "direct": the quality switch happens immediately but to achieve that, - * the player will need to set a new MediaSource on the media element in - * some cases. This often leads to a black screen + unavailable APIs - * during a short moment. - * @type {string} - */ - DEFAULT_MANUAL_BITRATE_SWITCHING_MODE: "seamless", /** * Default behavior for the `enableFastSwitching` loadVideo options. * @@ -2018,54 +2050,7 @@ var DEFAULT_CONFIG = { * play will always take the last set one. * @type {Object} */ - DEFAULT_INITIAL_BITRATES: { - audio: 0, - video: 0, - other: 0 // tracks which are not audio/video (like text). - // Though those are generally at a single bitrate, so no adaptive - // mechanism is triggered for them. - }, - - /* eslint-disable @typescript-eslint/consistent-type-assertions */ - /** - * Default bitrate floor initially set to dictate the minimum bitrate the - * adaptive logic can automatically switch to. - * - * If no track is found with a quality superior or equal to the - * bitrate there, the lowest bitrate will be taken instead. - * - * Set to Infinity to discard any limit in the ABR strategy. - * @type {Object} - */ - DEFAULT_MIN_BITRATES: { - audio: 0, - video: 0, - other: 0 // tracks which are not audio/video - // Though those are generally at a single bitrate, so no - // adaptive mechanism is triggered for them. - }, - - /* eslint-enable @typescript-eslint/consistent-type-assertions */ - /* eslint-disable @typescript-eslint/consistent-type-assertions */ - /** - * Default bitrate ceil initially set to dictate the maximum bitrate the - * adaptive logic can automatically switch to. - * - * If no track is found with a quality inferior or equal to the - * bitrate there, the lowest bitrate will be taken instead. - * - * Set to Infinity to discard any limit in the ABR strategy. - * @type {Object} - */ - DEFAULT_MAX_BITRATES: { - audio: Infinity, - video: Infinity, - other: Infinity // tracks which are not audio/video - // Though those are generally at a single bitrate, so no - // adaptive mechanism is triggered for them. - }, - - /* eslint-enable @typescript-eslint/consistent-type-assertions */ + DEFAULT_BASE_BANDWIDTH: 0, /** * Delay after which, if the page is hidden, the user is considered inactive * on the current video. @@ -2083,14 +2068,15 @@ var DEFAULT_CONFIG = { */ DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN: false, /** - * If true, the video representations you can switch to in adaptive mode - * are limited by the video element's width. + * Default video resolution limit behavior. * - * Basically in that case, we won't switch to a video Representation with - * a width higher than the current width of the video HTMLElement. + * This option allows for example to throttle the video resolution so it + * does not exceed the screen resolution. + * + * Here set to "none" by default to disable throttling. * @type {Boolean} */ - DEFAULT_LIMIT_VIDEO_WIDTH: false, + DEFAULT_VIDEO_RESOLUTION_LIMIT: "none", /** * Default initial live gap considered if no presentation delay has been * suggested, in seconds. @@ -2165,8 +2151,6 @@ var DEFAULT_CONFIG = { * - if the error is not due to the xhr, no retry will be peformed * - if the error is an HTTP error code, but not a 500-smthg or a 404, no * retry will be performed. - * - if it has a high chance of being due to the user being offline, a - * separate counter is used (see DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE). * @type Number */ DEFAULT_MAX_MANIFEST_REQUEST_RETRY: 4, @@ -2189,23 +2173,9 @@ var DEFAULT_CONFIG = { * - if the error is not due to the xhr, no retry will be peformed * - if the error is an HTTP error code, but not a 500-smthg or a 404, no * retry will be performed. - * - if it has a high chance of being due to the user being offline, a - * separate counter is used (see DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE). * @type Number */ DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR: 4, - /** - * Under some circonstances, we're able to tell that the user is offline (see - * the compat files). - * When this happens, and xhr requests fails due to an error event (you might - * still be able to perform xhr offline, e.g. on localhost), you might want to - * retry indefinitely or with a higher number of retry than if the error is - * due to a CDN problem. - * - * A capped exponential backoff will still be used (like for an error code). - * @type {Number} - */ - DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE: Infinity, /** * Initial backoff delay when a segment / manifest download fails, in * milliseconds. @@ -2714,12 +2684,12 @@ var DEFAULT_CONFIG = { * Robustnesses used in the {audio,video}Capabilities of the * MediaKeySystemConfiguration (DRM). * - * Only used for "com.microsoft.playready.recommendation" key system. + * Only used for "com.microsoft.playready.recommendation" keysystems. * * Defined in order of importance (first will be tested first etc.) * @type {Array.} */ - EME_DEFAULT_PLAYREADY_ROBUSTNESSES: ["3000", "2000"], + EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES: ["3000", "2000"], /** * Link canonical key systems names to their respective reverse domain name, * used in the EME APIs. @@ -3821,7 +3791,7 @@ function disableVideoTracks(videoTracks) { /***/ }), -/***/ 1960: +/***/ 276: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4621,10 +4591,10 @@ function checkCachedMediaKeySystemAccess(keySystems, currentKeySystemAccess, cur if (ks.type !== currentKeySystemOptions.type) { return false; } - if ((ks.persistentLicense === true || ks.persistentStateRequired === true) && mksConfiguration.persistentState !== "required") { + if ((!(0,is_null_or_undefined/* default */.Z)(ks.persistentLicenseConfig) || ks.persistentState === "required") && mksConfiguration.persistentState !== "required") { return false; } - if (ks.distinctiveIdentifierRequired === true && mksConfiguration.distinctiveIdentifier !== "required") { + if (ks.distinctiveIdentifier === "required" && mksConfiguration.distinctiveIdentifier !== "required") { return false; } return true; @@ -4656,65 +4626,32 @@ function findKeySystemCanonicalName(ksType) { /** * Build configuration for the requestMediaKeySystemAccess EME API, based * on the current keySystem object. - * @param {string|undefined} ksName - Generic name for the key system. e.g. - * "clearkey", "widevine", "playready". Can be used to make exceptions depending - * on it. - * @param {string|undefined} ksType - KeySystem complete type (e.g. - * "com.widevine.alpha"). - * @param {Object} keySystem + * @param {Object} keySystemTypeInfo * @returns {Array.} - Configuration to give to the * requestMediaKeySystemAccess API. */ -function buildKeySystemConfigurations(ksName, ksType, keySystem) { +function buildKeySystemConfigurations(keySystemTypeInfo) { + var keyName = keySystemTypeInfo.keyName, + keyType = keySystemTypeInfo.keyType, + keySystem = keySystemTypeInfo.keySystemOptions; var sessionTypes = ["temporary"]; var persistentState = "optional"; var distinctiveIdentifier = "optional"; - if (keySystem.persistentLicense === true) { + if (!(0,is_null_or_undefined/* default */.Z)(keySystem.persistentLicenseConfig)) { persistentState = "required"; sessionTypes.push("persistent-license"); } - if (keySystem.persistentStateRequired === true) { - persistentState = "required"; + if (!(0,is_null_or_undefined/* default */.Z)(keySystem.persistentState)) { + persistentState = keySystem.persistentState; } - if (keySystem.distinctiveIdentifierRequired === true) { - distinctiveIdentifier = "required"; + if (!(0,is_null_or_undefined/* default */.Z)(keySystem.distinctiveIdentifier)) { + distinctiveIdentifier = keySystem.distinctiveIdentifier; } var _config$getCurrent2 = config/* default */.Z.getCurrent(), EME_DEFAULT_AUDIO_CODECS = _config$getCurrent2.EME_DEFAULT_AUDIO_CODECS, EME_DEFAULT_VIDEO_CODECS = _config$getCurrent2.EME_DEFAULT_VIDEO_CODECS, EME_DEFAULT_WIDEVINE_ROBUSTNESSES = _config$getCurrent2.EME_DEFAULT_WIDEVINE_ROBUSTNESSES, - EME_DEFAULT_PLAYREADY_ROBUSTNESSES = _config$getCurrent2.EME_DEFAULT_PLAYREADY_ROBUSTNESSES; - // Set robustness, in order of consideration: - // 1. the user specified its own robustnesses - // 2. a "widevine" key system is used, in that case set the default widevine - // robustnesses as defined in the config - // 3. set an undefined robustness - var videoRobustnesses; - if (!(0,is_null_or_undefined/* default */.Z)(keySystem.videoRobustnesses)) { - videoRobustnesses = keySystem.videoRobustnesses; - } else if (ksName === "widevine") { - videoRobustnesses = EME_DEFAULT_WIDEVINE_ROBUSTNESSES; - } else if (ksType === "com.microsoft.playready.recommendation") { - videoRobustnesses = EME_DEFAULT_PLAYREADY_ROBUSTNESSES; - } else { - videoRobustnesses = []; - } - var audioRobustnesses; - if (!(0,is_null_or_undefined/* default */.Z)(keySystem.audioRobustnesses)) { - audioRobustnesses = keySystem.audioRobustnesses; - } else if (ksName === "widevine") { - audioRobustnesses = EME_DEFAULT_WIDEVINE_ROBUSTNESSES; - } else if (ksType === "com.microsoft.playready.recommendation") { - audioRobustnesses = EME_DEFAULT_PLAYREADY_ROBUSTNESSES; - } else { - audioRobustnesses = []; - } - if (videoRobustnesses.length === 0) { - videoRobustnesses.push(undefined); - } - if (audioRobustnesses.length === 0) { - audioRobustnesses.push(undefined); - } + EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES = _config$getCurrent2.EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES; // From the W3 EME spec, we have to provide videoCapabilities and // audioCapabilities. // These capabilities must specify a codec (even though you can use a @@ -4726,26 +4663,66 @@ function buildKeySystemConfigurations(ksName, ksType, keySystem) { // More details here: // https://storage.googleapis.com/wvdocs/Chrome_EME_Changes_and_Best_Practices.pdf // https://www.w3.org/TR/encrypted-media/#get-supported-configuration-and-consent - var videoCapabilities = (0,flat_map/* default */.Z)(videoRobustnesses, function (robustness) { - return EME_DEFAULT_VIDEO_CODECS.map(function (contentType) { - return robustness === undefined ? { - contentType: contentType - } : { - contentType: contentType, - robustness: robustness - }; + var audioCapabilities; + var videoCapabilities; + var audioCapabilitiesConfig = keySystem.audioCapabilitiesConfig, + videoCapabilitiesConfig = keySystem.videoCapabilitiesConfig; + if ((audioCapabilitiesConfig === null || audioCapabilitiesConfig === void 0 ? void 0 : audioCapabilitiesConfig.type) === "full") { + audioCapabilities = audioCapabilitiesConfig.value; + } else { + var audioRobustnesses; + if ((audioCapabilitiesConfig === null || audioCapabilitiesConfig === void 0 ? void 0 : audioCapabilitiesConfig.type) === "robustness") { + audioRobustnesses = audioCapabilitiesConfig.value; + } else if (keyName === "widevine") { + audioRobustnesses = EME_DEFAULT_WIDEVINE_ROBUSTNESSES; + } else if (keyType === "com.microsoft.playready.recommendation") { + audioRobustnesses = EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES; + } else { + audioRobustnesses = []; + } + if (audioRobustnesses.length === 0) { + audioRobustnesses.push(undefined); + } + var audioCodecs = (audioCapabilitiesConfig === null || audioCapabilitiesConfig === void 0 ? void 0 : audioCapabilitiesConfig.type) === "contentType" ? audioCapabilitiesConfig.value : EME_DEFAULT_AUDIO_CODECS; + audioCapabilities = (0,flat_map/* default */.Z)(audioRobustnesses, function (robustness) { + return audioCodecs.map(function (contentType) { + return robustness !== undefined ? { + contentType: contentType, + robustness: robustness + } : { + contentType: contentType + }; + }); }); - }); - var audioCapabilities = (0,flat_map/* default */.Z)(audioRobustnesses, function (robustness) { - return EME_DEFAULT_AUDIO_CODECS.map(function (contentType) { - return robustness === undefined ? { - contentType: contentType - } : { - contentType: contentType, - robustness: robustness - }; + } + if ((videoCapabilitiesConfig === null || videoCapabilitiesConfig === void 0 ? void 0 : videoCapabilitiesConfig.type) === "full") { + videoCapabilities = videoCapabilitiesConfig.value; + } else { + var videoRobustnesses; + if ((videoCapabilitiesConfig === null || videoCapabilitiesConfig === void 0 ? void 0 : videoCapabilitiesConfig.type) === "robustness") { + videoRobustnesses = videoCapabilitiesConfig.value; + } else if (keyName === "widevine") { + videoRobustnesses = EME_DEFAULT_WIDEVINE_ROBUSTNESSES; + } else if (keyType === "com.microsoft.playready.recommendation") { + videoRobustnesses = EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES; + } else { + videoRobustnesses = []; + } + if (videoRobustnesses.length === 0) { + videoRobustnesses.push(undefined); + } + var videoCodecs = (videoCapabilitiesConfig === null || videoCapabilitiesConfig === void 0 ? void 0 : videoCapabilitiesConfig.type) === "contentType" ? videoCapabilitiesConfig.value : EME_DEFAULT_VIDEO_CODECS; + videoCapabilities = (0,flat_map/* default */.Z)(videoRobustnesses, function (robustness) { + return videoCodecs.map(function (contentType) { + return robustness !== undefined ? { + contentType: contentType, + robustness: robustness + } : { + contentType: contentType + }; + }); }); - }); + } var wantedMediaKeySystemConfiguration = { initDataTypes: ["cenc"], videoCapabilities: videoCapabilities, @@ -4775,7 +4752,7 @@ function buildKeySystemConfigurations(ksName, ksType, keySystem) { * - reject if no compatible key system has been found. * * @param {HTMLMediaElement} mediaElement - * @param {Array.} keySystems - The keySystems you want to test. + * @param {Array.} keySystemsConfigs - The keySystems you want to test. * @param {Object} cancelSignal * @returns {Promise.} */ @@ -4846,7 +4823,7 @@ function getMediaKeySystemAccess(mediaElement, keySystemsConfigs, cancelSignal) } function _recursivelyTestKeySystems() { _recursivelyTestKeySystems = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(index) { - var _keySystemsType$index, keyName, keyType, keySystemOptions, keySystemConfigurations, keySystemAccess; + var chosenType, keyType, keySystemOptions, keySystemConfigurations, keySystemAccess; return regenerator_default().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: @@ -4862,13 +4839,14 @@ function getMediaKeySystemAccess(mediaElement, keySystemsConfigs, cancelSignal) } throw new Error("requestMediaKeySystemAccess is not implemented in your browser."); case 4: - _keySystemsType$index = keySystemsType[index], keyName = _keySystemsType$index.keyName, keyType = _keySystemsType$index.keyType, keySystemOptions = _keySystemsType$index.keySystemOptions; - keySystemConfigurations = buildKeySystemConfigurations(keyName, keyType, keySystemOptions); + chosenType = keySystemsType[index]; + keyType = chosenType.keyType, keySystemOptions = chosenType.keySystemOptions; + keySystemConfigurations = buildKeySystemConfigurations(chosenType); log/* default */.Z.debug("DRM: Request keysystem access " + keyType + "," + (index + 1 + " of " + keySystemsType.length)); - _context.prev = 7; - _context.next = 10; + _context.prev = 8; + _context.next = 11; return (0,custom_media_keys/* requestMediaKeySystemAccess */.N)(keyType, keySystemConfigurations); - case 10: + case 11: keySystemAccess = _context.sent; log/* default */.Z.info("DRM: Found compatible keysystem", keyType, index + 1); return _context.abrupt("return", { @@ -4878,22 +4856,22 @@ function getMediaKeySystemAccess(mediaElement, keySystemsConfigs, cancelSignal) mediaKeySystemAccess: keySystemAccess } }); - case 15: - _context.prev = 15; - _context.t0 = _context["catch"](7); + case 16: + _context.prev = 16; + _context.t0 = _context["catch"](8); log/* default */.Z.debug("DRM: Rejected access to keysystem", keyType, index + 1); if (!(cancelSignal.cancellationError !== null)) { - _context.next = 20; + _context.next = 21; break; } throw cancelSignal.cancellationError; - case 20: - return _context.abrupt("return", recursivelyTestKeySystems(index + 1)); case 21: + return _context.abrupt("return", recursivelyTestKeySystems(index + 1)); + case 22: case "end": return _context.stop(); } - }, _callee, null, [[7, 15]]); + }, _callee, null, [[8, 16]]); })); return _recursivelyTestKeySystems.apply(this, arguments); } @@ -6046,8 +6024,49 @@ function _safelyCloseMediaKeySession() { } // EXTERNAL MODULE: ./src/utils/base64.ts var utils_base64 = __webpack_require__(9689); -// EXTERNAL MODULE: ./src/utils/hash_buffer.ts -var hash_buffer = __webpack_require__(2870); +;// CONCATENATED MODULE: ./src/utils/hash_buffer.ts +/** + * Copyright 2015 CANAL+ Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Convert given buffer to a 32bit integer hash + * + * This algorithm is the same one that Java `String.hashCode()` one which + * is a fast hashing function adapted to short ASCII strings. + * This consequently might not be the most adapted to buffers of various length + * containing a various amount of data but still has the advantage of being + * fast. + * + * As this function is used in persistent MediaKeySession storage, we probably + * should keep this function somewhere as long as we want to support + * MediaKeySessions persisted in old versions of the RxPlayer. + * + * @param {Array.|TypedArray} buffer + * @returns {number} + */ +function hashBuffer(buffer) { + var hash = 0; + var _char; + for (var i = 0; i < buffer.length; i++) { + _char = buffer[i]; + hash = (hash << 5) - hash + _char; + hash = hash & hash; // Convert to 32bit integer + } + + return hash; +} // EXTERNAL MODULE: ./src/utils/is_non_empty_string.ts var is_non_empty_string = __webpack_require__(6923); ;// CONCATENATED MODULE: ./src/core/decrypt/utils/serializable_bytes.ts @@ -6243,11 +6262,11 @@ function checkStorage(storage) { (0,assert/* assertInterface */.u)(storage, { save: "function", load: "function" - }, "licenseStorage"); + }, "persistentLicenseConfig"); } /** - * Set representing persisted licenses. Depends on a simple local- - * storage implementation with a `save`/`load` synchronous interface + * Set representing persisted licenses. Depends on a simple + * implementation with a `save`/`load` synchronous interface * to persist information on persisted sessions. * * This set is used only for a cdm/keysystem with license persistency @@ -6426,7 +6445,7 @@ var PersistentSessionsStore = /*#__PURE__*/function () { var concatInitData = initData.values.constructRequestData(); lazyConcatenatedData = { initData: concatInitData, - initDataHash: (0,hash_buffer/* default */.Z)(concatInitData) + initDataHash: hashBuffer(concatInitData) }; } return lazyConcatenatedData; @@ -6540,7 +6559,8 @@ var PersistentSessionsStore = /*#__PURE__*/function () { try { this._storage.save(this._entries); } catch (e) { - log/* default */.Z.warn("DRM-PSS: Could not save licenses in localStorage"); + var err = e instanceof Error ? e : undefined; + log/* default */.Z.warn("DRM-PSS: Could not save MediaKeySession information", err); } }; return PersistentSessionsStore; @@ -6626,7 +6646,7 @@ var serverCertificateHashesMap = new WeakMap(); */ set: function set(mediaKeys, serverCertificate) { var formattedServerCertificate = serverCertificate instanceof Uint8Array ? serverCertificate : new Uint8Array(serverCertificate instanceof ArrayBuffer ? serverCertificate : serverCertificate.buffer); - var hash = (0,hash_buffer/* default */.Z)(formattedServerCertificate); + var hash = hashBuffer(formattedServerCertificate); serverCertificateHashesMap.set(mediaKeys, { hash: hash, serverCertificate: formattedServerCertificate @@ -6661,7 +6681,7 @@ var serverCertificateHashesMap = new WeakMap(); var oldHash = serverCertificateHash.hash, oldServerCertificate = serverCertificateHash.serverCertificate; var newServerCertificate = serverCertificate instanceof Uint8Array ? serverCertificate : new Uint8Array(serverCertificate instanceof ArrayBuffer ? serverCertificate : serverCertificate.buffer); - var newHash = (0,hash_buffer/* default */.Z)(newServerCertificate); + var newHash = hashBuffer(newServerCertificate); if (newHash !== oldHash || oldServerCertificate.length !== newServerCertificate.length) { return false; } @@ -6706,15 +6726,15 @@ var serverCertificateHashesMap = new WeakMap(); * @returns {Object|null} */ function createPersistentSessionsStorage(keySystemOptions) { - if (keySystemOptions.persistentLicense !== true) { + if ((0,is_null_or_undefined/* default */.Z)(keySystemOptions.persistentLicenseConfig)) { return null; } - var licenseStorage = keySystemOptions.licenseStorage; - if (licenseStorage == null) { - throw new encrypted_media_error/* default */.Z("INVALID_KEY_SYSTEM", "No license storage found for persistent license."); + var persistentLicenseConfig = keySystemOptions.persistentLicenseConfig; + if (persistentLicenseConfig == null) { + throw new encrypted_media_error/* default */.Z("INVALID_KEY_SYSTEM", "No `persistentLicenseConfig` found for " + "persistent license."); } log/* default */.Z.debug("DRM: Set the given license storage"); - return new PersistentSessionsStore(licenseStorage); + return new PersistentSessionsStore(persistentLicenseConfig); } /** * Create a MediaKeys instance and associated structures (or just return the @@ -7111,9 +7131,8 @@ var KEY_STATUSES = { * @returns {Object} - Warnings to send, whitelisted and blacklisted key ids. */ function checkKeyStatuses(session, options, keySystem) { - var _options$fallbackOn = options.fallbackOn, - fallbackOn = _options$fallbackOn === void 0 ? {} : _options$fallbackOn, - throwOnLicenseExpiration = options.throwOnLicenseExpiration, + var onKeyInternalError = options.onKeyInternalError, + onKeyOutputRestricted = options.onKeyOutputRestricted, onKeyExpiration = options.onKeyExpiration; var blacklistedKeyIds = []; var whitelistedKeyIds = []; @@ -7140,7 +7159,7 @@ function checkKeyStatuses(session, options, keySystem) { var error = new encrypted_media_error/* default */.Z("KEY_STATUS_CHANGE_ERROR", "A decryption key expired (" + (0,string_parsing/* bytesToHex */.ci)(keyId) + ")", { keyStatuses: [keyStatusObj].concat(badKeyStatuses) }); - if (onKeyExpiration === "error" || onKeyExpiration === undefined && throwOnLicenseExpiration === false) { + if (onKeyExpiration === "error" || onKeyExpiration === undefined) { throw error; } switch (onKeyExpiration) { @@ -7165,24 +7184,58 @@ function checkKeyStatuses(session, options, keySystem) { } case KEY_STATUSES.INTERNAL_ERROR: { - if (fallbackOn.keyInternalError !== true) { - throw new encrypted_media_error/* default */.Z("KEY_STATUS_CHANGE_ERROR", "A \"" + keyStatus + "\" status has been encountered (" + (0,string_parsing/* bytesToHex */.ci)(keyId) + ")", { - keyStatuses: [keyStatusObj].concat(badKeyStatuses) - }); + var _error = new encrypted_media_error/* default */.Z("KEY_STATUS_CHANGE_ERROR", "A \"" + keyStatus + "\" status has been encountered (" + (0,string_parsing/* bytesToHex */.ci)(keyId) + ")", { + keyStatuses: [keyStatusObj].concat(badKeyStatuses) + }); + switch (onKeyInternalError) { + case undefined: + case "error": + throw _error; + case "close-session": + throw new DecommissionedSessionError(_error); + case "fallback": + blacklistedKeyIds.push(keyId); + break; + case "continue": + whitelistedKeyIds.push(keyId); + break; + default: + // Weirdly enough, TypeScript is not checking properly + // `case undefined` (bug?) + if (onKeyInternalError !== undefined) { + (0,assert_unreachable/* default */.Z)(onKeyInternalError); + } else { + throw _error; + } } badKeyStatuses.push(keyStatusObj); - blacklistedKeyIds.push(keyId); break; } case KEY_STATUSES.OUTPUT_RESTRICTED: { - if (fallbackOn.keyOutputRestricted !== true) { - throw new encrypted_media_error/* default */.Z("KEY_STATUS_CHANGE_ERROR", "A \"" + keyStatus + "\" status has been encountered (" + (0,string_parsing/* bytesToHex */.ci)(keyId) + ")", { - keyStatuses: [keyStatusObj].concat(badKeyStatuses) - }); + var _error2 = new encrypted_media_error/* default */.Z("KEY_STATUS_CHANGE_ERROR", "A \"" + keyStatus + "\" status has been encountered (" + (0,string_parsing/* bytesToHex */.ci)(keyId) + ")", { + keyStatuses: [keyStatusObj].concat(badKeyStatuses) + }); + switch (onKeyOutputRestricted) { + case undefined: + case "error": + throw _error2; + case "fallback": + blacklistedKeyIds.push(keyId); + break; + case "continue": + whitelistedKeyIds.push(keyId); + break; + default: + // Weirdly enough, TypeScript is not checking properly + // `case undefined` (bug?) + if (onKeyOutputRestricted !== undefined) { + (0,assert_unreachable/* default */.Z)(onKeyOutputRestricted); + } else { + throw _error2; + } } badKeyStatuses.push(keyStatusObj); - blacklistedKeyIds.push(keyId); break; } default: @@ -7265,14 +7318,16 @@ function SessionEventsListener(session, keySystemOptions, keySystem, callbacks, manualCanceller.cancel(); callbacks.onError(new encrypted_media_error/* default */.Z("KEY_ERROR", evt.type)); }, manualCanceller.signal); - onKeyStatusesChange(session, function (keyStatusesEvent) { - handleKeyStatusesChangeEvent(keyStatusesEvent)["catch"](function (error) { + onKeyStatusesChange(session, function () { + try { + checkAndHandleCurrentKeyStatuses(); + } catch (error) { if (cancelSignal.isCancelled() || manualCanceller.isUsed() && error instanceof task_canceller/* CancellationSignal */.XG) { return; } manualCanceller.cancel(); callbacks.onError(error); - }); + } }, manualCanceller.signal); onKeyMessage(session, function (evt) { var messageEvent = evt; @@ -7315,102 +7370,14 @@ function SessionEventsListener(session, keySystemOptions, keySystem, callbacks, }, manualCanceller.signal); checkAndHandleCurrentKeyStatuses(); return; - /** - * @param {Event} keyStatusesEvent - * @returns {Promise} - */ - function handleKeyStatusesChangeEvent(_x) { - return _handleKeyStatusesChangeEvent.apply(this, arguments); - } /** * Check current MediaKeyStatus for each key in the given MediaKeySession and: * - throw if at least one status is a non-recoverable error * - call warning callback for recoverable errors * - call onKeyUpdate callback when the MediaKeyStatus of any key is updated */ - function _handleKeyStatusesChangeEvent() { - _handleKeyStatusesChangeEvent = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee2(keyStatusesEvent) { - var runOnKeyStatusesChangeCallback, _runOnKeyStatusesChangeCallback; - return regenerator_default().wrap(function _callee2$(_context2) { - while (1) switch (_context2.prev = _context2.next) { - case 0: - _runOnKeyStatusesChangeCallback = function _runOnKeyStatusesChan2() { - _runOnKeyStatusesChangeCallback = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() { - var ret, err; - return regenerator_default().wrap(function _callee$(_context) { - while (1) switch (_context.prev = _context.next) { - case 0: - if (!manualCanceller.isUsed()) { - _context.next = 2; - break; - } - return _context.abrupt("return"); - case 2: - if (!(typeof keySystemOptions.onKeyStatusesChange === "function")) { - _context.next = 24; - break; - } - _context.prev = 3; - _context.next = 6; - return keySystemOptions.onKeyStatusesChange(keyStatusesEvent, session); - case 6: - ret = _context.sent; - if (!manualCanceller.isUsed()) { - _context.next = 9; - break; - } - return _context.abrupt("return"); - case 9: - _context.next = 18; - break; - case 11: - _context.prev = 11; - _context.t0 = _context["catch"](3); - if (!cancelSignal.isCancelled()) { - _context.next = 15; - break; - } - return _context.abrupt("return"); - case 15: - err = new encrypted_media_error/* default */.Z("KEY_STATUS_CHANGE_ERROR", "Unknown `onKeyStatusesChange` error"); - if (!(0,is_null_or_undefined/* default */.Z)(_context.t0) && (0,is_non_empty_string/* default */.Z)(_context.t0.message)) { - err.message = _context.t0.message; - } - throw err; - case 18: - if (!(0,is_null_or_undefined/* default */.Z)(ret)) { - _context.next = 22; - break; - } - log/* default */.Z.info("DRM: No license given, skipping session.update"); - _context.next = 24; - break; - case 22: - _context.next = 24; - return updateSessionWithMessage(session, ret); - case 24: - case "end": - return _context.stop(); - } - }, _callee, null, [[3, 11]]); - })); - return _runOnKeyStatusesChangeCallback.apply(this, arguments); - }; - runOnKeyStatusesChangeCallback = function _runOnKeyStatusesChan() { - return _runOnKeyStatusesChangeCallback.apply(this, arguments); - }; - log/* default */.Z.info("DRM: keystatuseschange event received", session.sessionId); - _context2.next = 5; - return Promise.all([runOnKeyStatusesChangeCallback(), Promise.resolve(checkAndHandleCurrentKeyStatuses())]); - case 5: - case "end": - return _context2.stop(); - } - }, _callee2); - })); - return _handleKeyStatusesChangeEvent.apply(this, arguments); - } function checkAndHandleCurrentKeyStatuses() { + log/* default */.Z.info("DRM: keystatuseschange event received", session.sessionId); if (manualCanceller.isUsed() || session.keyStatuses.size === 0) { return; } @@ -7501,7 +7468,7 @@ function formatGetLicenseError(error) { * @param {ArrayBuffer|TypedArray|null} message * @returns {Promise} */ -function updateSessionWithMessage(_x2, _x3) { +function updateSessionWithMessage(_x, _x2) { return _updateSessionWithMessage.apply(this, arguments); } /** @@ -7512,30 +7479,30 @@ function updateSessionWithMessage(_x2, _x3) { * @extends Error */ function _updateSessionWithMessage() { - _updateSessionWithMessage = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee3(session, message) { + _updateSessionWithMessage = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(session, message) { var reason; - return regenerator_default().wrap(function _callee3$(_context3) { - while (1) switch (_context3.prev = _context3.next) { + return regenerator_default().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { case 0: log/* default */.Z.info("DRM: Updating MediaKeySession with message"); - _context3.prev = 1; - _context3.next = 4; + _context.prev = 1; + _context.next = 4; return session.update(message); case 4: - _context3.next = 10; + _context.next = 10; break; case 6: - _context3.prev = 6; - _context3.t0 = _context3["catch"](1); - reason = _context3.t0 instanceof Error ? _context3.t0.toString() : "`session.update` failed"; + _context.prev = 6; + _context.t0 = _context["catch"](1); + reason = _context.t0 instanceof Error ? _context.t0.toString() : "`session.update` failed"; throw new encrypted_media_error/* default */.Z("KEY_UPDATE_ERROR", reason); case 10: log/* default */.Z.info("DRM: MediaKeySession update succeeded."); case 11: case "end": - return _context3.stop(); + return _context.stop(); } - }, _callee3, null, [[1, 6]]); + }, _callee, null, [[1, 6]]); })); return _updateSessionWithMessage.apply(this, arguments); } @@ -7878,7 +7845,7 @@ function formatInitDataValues(initialValues) { return { systemId: systemId, data: data, - hash: (0,hash_buffer/* default */.Z)(data) + hash: hashBuffer(data) }; }); } @@ -7990,7 +7957,7 @@ var ContentDecryptor = /*#__PURE__*/function (_EventEmitter) { * MediaKeySessions persisted in older RxPlayer's versions. */ var systemId; - if ((0,is_null_or_undefined/* default */.Z)(options.licenseStorage) || options.licenseStorage.disableRetroCompatibility === true) { + if ((0,is_null_or_undefined/* default */.Z)(options.persistentLicenseConfig) || options.persistentLicenseConfig.disableRetroCompatibility === true) { systemId = getDrmSystemId(mediaKeySystemAccess.keySystem); } _this.systemId = systemId; @@ -8278,7 +8245,7 @@ var ContentDecryptor = /*#__PURE__*/function (_EventEmitter) { // persistent sessions. // Can we find a better strategy? this._lockInitDataQueue(); - if (options.persistentLicense !== true) { + if ((0,is_null_or_undefined/* default */.Z)(options.persistentLicenseConfig)) { wantedSessionType = "temporary"; } else if (!canCreatePersistentSession(mediaKeySystemAccess)) { log/* default */.Z.warn("DRM: Cannot create \"persistent-license\" session: not supported"); @@ -8905,7 +8872,7 @@ function addKeyIdsFromPeriod(set, period) { /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var _content_decryptor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1960); +/* harmony import */ var _content_decryptor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(276); /** * Copyright 2015 CANAL+ Group * @@ -9075,7 +9042,7 @@ var DirectFileContentInitializer = /*#__PURE__*/function (_ContentInitializer) { * Class trying to avoid various stalling situations, emitting "stalled" * events when it cannot, as well as "unstalled" events when it get out of one. */ - var rebufferingController = new _utils_rebuffering_controller__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z(playbackObserver, null, speed); + var rebufferingController = new _utils_rebuffering_controller__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z(playbackObserver, null, null, speed); rebufferingController.addEventListener("stalled", function (evt) { return _this2.trigger("stalled", evt); }); @@ -9553,8 +9520,8 @@ var reference = __webpack_require__(5095); var task_canceller = __webpack_require__(288); // EXTERNAL MODULE: ./src/core/decrypt/index.ts var decrypt = __webpack_require__(1266); -// EXTERNAL MODULE: ./src/core/decrypt/content_decryptor.ts + 31 modules -var content_decryptor = __webpack_require__(1960); +// EXTERNAL MODULE: ./src/core/decrypt/content_decryptor.ts + 32 modules +var content_decryptor = __webpack_require__(276); ;// CONCATENATED MODULE: ./src/core/init/utils/initialize_content_decryption.ts @@ -9756,6 +9723,9 @@ var ranges = __webpack_require__(2829); var task_canceller = __webpack_require__(288); ;// CONCATENATED MODULE: ./src/core/init/utils/rebuffering_controller.ts +function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /** * Copyright 2015 CANAL+ Group * @@ -9798,15 +9768,17 @@ var RebufferingController = /*#__PURE__*/function (_EventEmitter) { * @param {Object} manifest - The Manifest of the currently-played content. * @param {Object} speed - The last speed set by the user */ - function RebufferingController(playbackObserver, manifest, speed) { + function RebufferingController(playbackObserver, manifest, segmentBuffersStore, speed) { var _this; _this = _EventEmitter.call(this) || this; _this._playbackObserver = playbackObserver; _this._manifest = manifest; + _this._segmentBuffersStore = segmentBuffersStore; _this._speed = speed; _this._discontinuitiesStore = []; _this._isStarted = false; _this._canceller = new task_canceller/* default */.ZP(); + _this._currentFreezeTimestamp = null; return _this; } var _proto = RebufferingController.prototype; @@ -9866,6 +9838,9 @@ var RebufferingController = /*#__PURE__*/function (_EventEmitter) { ignoredStallTimeStamp = now; } lastSeekingPosition = observation.seeking ? Math.max((_a = observation.pendingInternalSeek) !== null && _a !== void 0 ? _a : 0, observation.position) : null; + if (_this2._checkDecipherabilityFreeze(observation)) { + return; + } if (freezing !== null) { var _now = performance.now(); var referenceTimestamp = prevFreezingState === null ? freezing.timestamp : prevFreezingState.attemptTimestamp; @@ -9916,7 +9891,7 @@ var RebufferingController = /*#__PURE__*/function (_EventEmitter) { _this2.trigger("stalled", stalledReason); return; } else { - log/* default */.Z.warn("Init: ignored stall for too long, checking discontinuity", _now2 - ignoredStallTimeStamp); + log/* default */.Z.warn("Init: ignored stall for too long, considering it", _now2 - ignoredStallTimeStamp); } } ignoredStallTimeStamp = null; @@ -10023,6 +9998,75 @@ var RebufferingController = /*#__PURE__*/function (_EventEmitter) { */; _proto.destroy = function destroy() { this._canceller.cancel(); + } + /** + * Support of contents with DRM on all the platforms out there is a pain in + * the *ss considering all the DRM-related bugs there are. + * + * We found out a frequent issue which is to be unable to play despite having + * all the decryption keys to play what is currently buffered. + * When this happens, re-creating the buffers from scratch, with a reload, is + * usually sufficient to unlock the situation. + * + * Although we prefer providing more targeted fixes or telling to platform + * developpers to fix their implementation, it's not always possible. + * We thus resorted to developping an heuristic which detects such situation + * and reload in that case. + * + * @param {Object} observation - The last playback observation produced, it + * has to be recent (just triggered for example). + * @returns {boolean} - Returns `true` if it seems to be such kind of + * decipherability freeze, in which case this method already performed the + * right handling steps. + */; + _proto._checkDecipherabilityFreeze = function _checkDecipherabilityFreeze(observation) { + var readyState = observation.readyState, + rebuffering = observation.rebuffering, + freezing = observation.freezing; + var bufferGap = observation.bufferGap !== undefined && isFinite(observation.bufferGap) ? observation.bufferGap : 0; + if (this._segmentBuffersStore === null || bufferGap < 6 || rebuffering === null && freezing === null || readyState > 1) { + this._currentFreezeTimestamp = null; + return false; + } + var now = performance.now(); + if (this._currentFreezeTimestamp === null) { + this._currentFreezeTimestamp = now; + } + var rebufferingForTooLong = rebuffering !== null && now - rebuffering.timestamp > 4000; + var frozenForTooLong = freezing !== null && now - freezing.timestamp > 4000; + if ((rebufferingForTooLong || frozenForTooLong) && performance.now() - this._currentFreezeTimestamp > 4000) { + var statusAudio = this._segmentBuffersStore.getStatus("audio"); + var statusVideo = this._segmentBuffersStore.getStatus("video"); + var hasOnlyDecipherableSegments = true; + var isClear = true; + for (var _i = 0, _arr = [statusAudio, statusVideo]; _i < _arr.length; _i++) { + var status = _arr[_i]; + if (status.type === "initialized") { + for (var _iterator = _createForOfIteratorHelperLoose(status.value.getInventory()), _step; !(_step = _iterator()).done;) { + var segment = _step.value; + var representation = segment.infos.representation; + if (representation.decipherable === false) { + log/* default */.Z.warn("Init: we have undecipherable segments left in the buffer, reloading"); + this._currentFreezeTimestamp = null; + this.trigger("needsReload", null); + return true; + } else if (representation.contentProtections !== undefined) { + isClear = false; + if (representation.decipherable !== true) { + hasOnlyDecipherableSegments = false; + } + } + } + } + } + if (!isClear && hasOnlyDecipherableSegments) { + log/* default */.Z.warn("Init: we are frozen despite only having decipherable " + "segments left in the buffer, reloading"); + this._currentFreezeTimestamp = null; + this.trigger("needsReload", null); + return true; + } + } + return false; }; return RebufferingController; }(event_emitter/* default */.Z); @@ -11035,12 +11079,24 @@ var HTMLTextSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { _this.autoRefreshSubtitles(_this._canceller.signal); return _this; } + /** + * @param {string} uniqueId + */ + var _proto = HTMLTextSegmentBuffer.prototype; + _proto.declareInitSegment = function declareInitSegment(uniqueId) { + log/* default */.Z.warn("ISB: Declaring initialization segment for image SegmentBuffer", uniqueId); + } + /** + * @param {string} uniqueId + */; + _proto.freeInitSegment = function freeInitSegment(uniqueId) { + log/* default */.Z.warn("ISB: Freeing initialization segment for image SegmentBuffer", uniqueId); + } /** * Push text segment to the HTMLTextSegmentBuffer. * @param {Object} infos * @returns {Promise} - */ - var _proto = HTMLTextSegmentBuffer.prototype; + */; _proto.pushChunk = function pushChunk(infos) { try { this.pushChunkSync(infos); @@ -11574,10 +11630,22 @@ var NativeTextSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { return _this; } /** - * @param {Object} infos - * @returns {Promise} + * @param {string} uniqueId */ var _proto = NativeTextSegmentBuffer.prototype; + _proto.declareInitSegment = function declareInitSegment(uniqueId) { + log/* default */.Z.warn("ISB: Declaring initialization segment for image SegmentBuffer", uniqueId); + } + /** + * @param {string} uniqueId + */; + _proto.freeInitSegment = function freeInitSegment(uniqueId) { + log/* default */.Z.warn("ISB: Freeing initialization segment for image SegmentBuffer", uniqueId); + } + /** + * @param {Object} infos + * @returns {Promise} + */; _proto.pushChunk = function pushChunk(infos) { var _a, _b; log/* default */.Z.debug("NTSB: Appending new native text tracks"); @@ -12965,10 +13033,9 @@ var CustomLoaderError = /*#__PURE__*/function (_Error) { /** * @param {string} message * @param {boolean} canRetry - * @param {boolean} isOfflineError * @param {XMLHttpRequest} xhr */ - function CustomLoaderError(message, canRetry, isOfflineError, xhr) { + function CustomLoaderError(message, canRetry, xhr) { var _this; _this = _Error.call(this) || this; // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class @@ -12976,7 +13043,6 @@ var CustomLoaderError = /*#__PURE__*/function (_Error) { _this.name = "CustomLoaderError"; _this.message = message; _this.canRetry = canRetry; - _this.isOfflineError = isOfflineError; _this.xhr = xhr; return _this; } @@ -13783,6 +13849,8 @@ function isCodecSupported(mimeType) { } // EXTERNAL MODULE: ./src/utils/are_arrays_of_numbers_equal.ts var are_arrays_of_numbers_equal = __webpack_require__(4791); +// EXTERNAL MODULE: ./src/utils/id_generator.ts +var id_generator = __webpack_require__(908); ;// CONCATENATED MODULE: ./src/manifest/representation.ts function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } @@ -13805,6 +13873,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len + +var generateRepresentationUniqueId = (0,id_generator/* default */.Z)(); /** * Normalized Representation structure. * @class Representation @@ -13815,6 +13885,7 @@ var Representation = /*#__PURE__*/function () { */ function Representation(args, opts) { this.id = args.id; + this.uniqueId = generateRepresentationUniqueId(); this.bitrate = args.bitrate; this.codec = args.codecs; if (args.height !== undefined) { @@ -14173,23 +14244,37 @@ var Adaptation = /*#__PURE__*/function () { var representation = new manifest_representation(argsRepresentations[i], { type: this.type }); - var shouldAdd = (0,is_null_or_undefined/* default */.Z)(representationFilter) || representationFilter({ - id: representation.id, - bitrate: representation.bitrate, - codec: representation.codec, - height: representation.height, - width: representation.width, - frameRate: representation.frameRate, - hdrInfo: representation.hdrInfo - }, { - bufferType: this.type, - language: this.language, - normalizedLanguage: this.normalizedLanguage, - isClosedCaption: this.isClosedCaption, - isDub: this.isDub, - isAudioDescription: this.isAudioDescription, - isSignInterpreted: this.isSignInterpreted - }); + var shouldAdd = true; + if (!(0,is_null_or_undefined/* default */.Z)(representationFilter)) { + var reprObject = { + id: representation.id, + bitrate: representation.bitrate, + codec: representation.codec, + height: representation.height, + width: representation.width, + frameRate: representation.frameRate, + hdrInfo: representation.hdrInfo + }; + if (representation.contentProtections !== undefined) { + reprObject.contentProtections = {}; + if (representation.contentProtections.keyIds !== undefined) { + var keyIds = representation.contentProtections.keyIds.map(function (_ref) { + var keyId = _ref.keyId; + return keyId; + }); + reprObject.contentProtections.keyIds = keyIds; + } + } + shouldAdd = representationFilter(reprObject, { + trackType: this.type, + language: this.language, + normalizedLanguage: this.normalizedLanguage, + isClosedCaption: this.isClosedCaption, + isDub: this.isDub, + isAudioDescription: this.isAudioDescription, + isSignInterpreted: this.isSignInterpreted + }); + } if (shouldAdd) { representations.push(representation); if (!isSupported && representation.isSupported) { @@ -14224,8 +14309,8 @@ var Adaptation = /*#__PURE__*/function () { * @returns {Object|undefined} */; _proto.getRepresentation = function getRepresentation(wantedId) { - return (0,array_find/* default */.Z)(this.representations, function (_ref) { - var id = _ref.id; + return (0,array_find/* default */.Z)(this.representations, function (_ref2) { + var id = _ref2.id; return wantedId === id; }); } @@ -14399,7 +14484,9 @@ var Period = /*#__PURE__*/function () { if (filteredAdaptations.every(function (adaptation) { return !adaptation.isSupported; }) && adaptationsForType.length > 0 && (type === "video" || type === "audio")) { - throw new media_error/* default */.Z("MANIFEST_PARSE_ERROR", "No supported " + type + " adaptations"); + throw new media_error/* default */.Z("MANIFEST_INCOMPATIBLE_CODECS_ERROR", "No supported " + type + " adaptations", { + adaptation: undefined + }); } if (filteredAdaptations.length > 0) { acc[type] = filteredAdaptations; @@ -14961,10 +15048,10 @@ var Manifest = /*#__PURE__*/function (_EventEmitter) { /** * Returns the most important URL from which the Manifest can be refreshed. * `undefined` if no URL is found. - * @returns {string|undefined} + * @returns {Array.} */; - _proto.getUrl = function getUrl() { - return this.uris[0]; + _proto.getUrls = function getUrls() { + return this.uris; } /** * Update the current Manifest properties by giving a new updated version. @@ -15241,7 +15328,7 @@ function updateDeciperability(manifest, isDecipherable) { * @returns {boolean} */ function areSameContent(content1, content2) { - return content1.segment.id === content2.segment.id && content1.representation.id === content2.representation.id && content1.adaptation.id === content2.adaptation.id && content1.period.id === content2.period.id; + return content1.segment.id === content2.segment.id && content1.representation.uniqueId === content2.representation.uniqueId; } /** * Get string describing a given ISegment, useful for log functions. @@ -28126,7 +28213,7 @@ function generateSegmentLoader(_ref) { * @param {*} err - The corresponding error encountered */ var reject = function reject(err) { - var _a, _b, _c; + var _a, _b; if (hasFinished || cancelSignal.isCancelled()) { return; } @@ -28135,7 +28222,7 @@ function generateSegmentLoader(_ref) { // Format error and send it var castedErr = err; var message = (_a = castedErr === null || castedErr === void 0 ? void 0 : castedErr.message) !== null && _a !== void 0 ? _a : "Unknown error when fetching a DASH segment through a " + "custom segmentLoader."; - var emittedErr = new custom_loader_error/* default */.Z(message, (_b = castedErr === null || castedErr === void 0 ? void 0 : castedErr.canRetry) !== null && _b !== void 0 ? _b : false, (_c = castedErr === null || castedErr === void 0 ? void 0 : castedErr.isOfflineError) !== null && _c !== void 0 ? _c : false, castedErr === null || castedErr === void 0 ? void 0 : castedErr.xhr); + var emittedErr = new custom_loader_error/* default */.Z(message, (_b = castedErr === null || castedErr === void 0 ? void 0 : castedErr.canRetry) !== null && _b !== void 0 ? _b : false, castedErr === null || castedErr === void 0 ? void 0 : castedErr.xhr); rej(emittedErr); }; var progress = function progress(_args) { @@ -28166,12 +28253,18 @@ function generateSegmentLoader(_ref) { progress: progress, fallback: fallback }; + var byteRanges; + if (context.segment.range !== undefined) { + byteRanges = [context.segment.range]; + if (context.segment.indexRange !== undefined) { + byteRanges.push(context.segment.indexRange); + } + } var args = { isInit: context.segment.isInit, timeout: options.timeout, - range: context.segment.range, - indexRange: context.segment.indexRange, - type: context.type, + byteRanges: byteRanges, + trackType: context.type, url: url }; var abort = customSegmentLoader(args, customCallbacks); @@ -32034,7 +32127,7 @@ var generateSegmentLoader = function generateSegmentLoader(_ref) { * @param {*} err - The corresponding error encountered */ var reject = function reject(err) { - var _a, _b, _c; + var _a, _b; if (hasFinished || cancelSignal.isCancelled()) { return; } @@ -32043,7 +32136,7 @@ var generateSegmentLoader = function generateSegmentLoader(_ref) { // Format error and send it var castedErr = err; var message = (_a = castedErr === null || castedErr === void 0 ? void 0 : castedErr.message) !== null && _a !== void 0 ? _a : "Unknown error when fetching a Smooth segment through a " + "custom segmentLoader."; - var emittedErr = new custom_loader_error/* default */.Z(message, (_b = castedErr === null || castedErr === void 0 ? void 0 : castedErr.canRetry) !== null && _b !== void 0 ? _b : false, (_c = castedErr === null || castedErr === void 0 ? void 0 : castedErr.isOfflineError) !== null && _c !== void 0 ? _c : false, castedErr === null || castedErr === void 0 ? void 0 : castedErr.xhr); + var emittedErr = new custom_loader_error/* default */.Z(message, (_b = castedErr === null || castedErr === void 0 ? void 0 : castedErr.canRetry) !== null && _b !== void 0 ? _b : false, castedErr === null || castedErr === void 0 ? void 0 : castedErr.xhr); rej(emittedErr); }; var progress = function progress(_args) { @@ -32070,12 +32163,18 @@ var generateSegmentLoader = function generateSegmentLoader(_ref) { fallback: fallback, progress: progress }; + var byteRanges; + if (context.segment.range !== undefined) { + byteRanges = [context.segment.range]; + if (context.segment.indexRange !== undefined) { + byteRanges.push(context.segment.indexRange); + } + } var args = { isInit: context.segment.isInit, timeout: loaderOptions.timeout, - range: context.segment.range, - indexRange: context.segment.indexRange, - type: context.type, + byteRanges: byteRanges, + trackType: context.type, url: url }; var abort = customSegmentLoader(args, customCallbacks); @@ -32688,7 +32787,7 @@ function callCustomManifestLoader(customManifestLoader, fallbackManifestLoader) * @param {*} err - The corresponding error encountered */ var reject = function reject(err) { - var _a, _b, _c; + var _a, _b; if (hasFinished || cancelSignal.isCancelled()) { return; } @@ -32697,7 +32796,7 @@ function callCustomManifestLoader(customManifestLoader, fallbackManifestLoader) // Format error and send it var castedErr = err; var message = (_a = castedErr === null || castedErr === void 0 ? void 0 : castedErr.message) !== null && _a !== void 0 ? _a : "Unknown error when fetching the Manifest through a " + "custom manifestLoader."; - var emittedErr = new custom_loader_error/* default */.Z(message, (_b = castedErr === null || castedErr === void 0 ? void 0 : castedErr.canRetry) !== null && _b !== void 0 ? _b : false, (_c = castedErr === null || castedErr === void 0 ? void 0 : castedErr.isOfflineError) !== null && _c !== void 0 ? _c : false, castedErr === null || castedErr === void 0 ? void 0 : castedErr.xhr); + var emittedErr = new custom_loader_error/* default */.Z(message, (_b = castedErr === null || castedErr === void 0 ? void 0 : castedErr.canRetry) !== null && _b !== void 0 ? _b : false, castedErr === null || castedErr === void 0 ? void 0 : castedErr.xhr); rej(emittedErr); }; /** @@ -33352,7 +33451,6 @@ function base64ToBytes(str) { /* harmony export */ O_: function() { return /* binding */ itole4; }, /* harmony export */ QI: function() { return /* binding */ be3toi; }, /* harmony export */ XT: function() { return /* binding */ itobe2; }, -/* harmony export */ _f: function() { return /* binding */ toUint8Array; }, /* harmony export */ dN: function() { return /* binding */ le4toi; }, /* harmony export */ el: function() { return /* binding */ itobe8; }, /* harmony export */ kh: function() { return /* binding */ itobe4; }, @@ -33362,7 +33460,7 @@ function base64ToBytes(str) { /* harmony export */ zK: function() { return /* binding */ be2toi; }, /* harmony export */ zo: function() { return /* binding */ concat; } /* harmony export */ }); -/* unused harmony exports le8toi, itole2, isABEqualBytes */ +/* unused harmony exports le8toi, itole2, isABEqualBytes, toUint8Array */ /** * Copyright 2015 CANAL+ Group * @@ -33859,58 +33957,6 @@ function getFuzzedDelay(retryDelay) { /***/ }), -/***/ 2870: -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ Z: function() { return /* binding */ hashBuffer; } -/* harmony export */ }); -/** - * Copyright 2015 CANAL+ Group - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Convert given buffer to a 32bit integer hash - * - * This algorithm is the same one that Java `String.hashCode()` one which - * is a fast hashing function adapted to short ASCII strings. - * This consequently might not be the most adapted to buffers of various length - * containing a various amount of data but still has the advantage of being - * fast. - * - * As this function is used in persistent MediaKeySession storage, we probably - * should keep this function somewhere as long as we want to support - * MediaKeySessions persisted in old versions of the RxPlayer. - * - * @param {Array.|TypedArray} buffer - * @returns {number} - */ -function hashBuffer(buffer) { - var hash = 0; - var _char; - for (var i = 0; i < buffer.length; i++) { - _char = buffer[i]; - hash = (hash << 5) - hash + _char; - hash = hash & hash; // Convert to 32bit integer - } - - return hash; -} - -/***/ }), - /***/ 908: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { @@ -37289,6 +37335,8 @@ var media_error = __webpack_require__(3714); var error_codes = __webpack_require__(5992); // EXTERNAL MODULE: ./src/features/index.ts var features = __webpack_require__(7874); +// EXTERNAL MODULE: ./src/utils/array_find.ts +var array_find = __webpack_require__(3274); // EXTERNAL MODULE: ./src/utils/array_includes.ts var array_includes = __webpack_require__(7714); // EXTERNAL MODULE: ./src/utils/assert.ts @@ -37309,8 +37357,6 @@ var ranges = __webpack_require__(2829); var utils_reference = __webpack_require__(5095); // EXTERNAL MODULE: ./src/utils/task_canceller.ts var task_canceller = __webpack_require__(288); -// EXTERNAL MODULE: ./src/utils/warn_once.ts -var warn_once = __webpack_require__(8806); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js var asyncToGenerator = __webpack_require__(5861); // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js @@ -37407,17 +37453,6 @@ function get_key_system_configuration_getKeySystemConfiguration(mediaElement) { } return [currentState.mediaKeySystemAccess.keySystem, currentState.mediaKeySystemAccess.getConfiguration()]; } -/** - * Returns the name of the current key system used, as originally indicated by - * the user. - * @deprecated - * @param {HTMLMediaElement} mediaElement - * @returns {string|null} - */ -function get_key_system_configuration_getCurrentKeySystem(mediaElement) { - var currentState = media_keys_infos_store/* default */.Z.getState(mediaElement); - return currentState == null ? null : currentState.keySystemOptions.type; -} ;// CONCATENATED MODULE: ./src/compat/should_unset_media_keys.ts /** * Copyright 2015 CANAL+ Group @@ -37744,8 +37779,6 @@ var BufferBasedChooser = /*#__PURE__*/function () { return BufferBasedChooser; }(); -// EXTERNAL MODULE: ./src/utils/array_find.ts -var array_find = __webpack_require__(3274); ;// CONCATENATED MODULE: ./src/core/adaptive/utils/ewma.ts /** * Copyright 2015 CANAL+ Group @@ -38489,7 +38522,7 @@ function filterByBitrate(representations, bitrate) { return representations.slice(0, firstSuperiorBitrateIndex); } -;// CONCATENATED MODULE: ./src/core/adaptive/utils/filter_by_width.ts +;// CONCATENATED MODULE: ./src/core/adaptive/utils/filter_by_resolution.ts /** * Copyright 2015 CANAL+ Group * @@ -38508,20 +38541,26 @@ function filterByBitrate(representations, bitrate) { /** - * Filter representations based on their width: - * - the highest width considered will be the one linked to the first - * representation which has a superior width to the one given. + * Filter representations based on their resolution. + * - the highest resolution considered will be the one linked to the first + * representation which has a superior resolution or equal to the one + * given. * @param {Array.} representations - The representations array - * @param {Number} width + * @param {Object} resolution * @returns {Array.} */ -function filterByWidth(representations, width) { +function filterByResolution(representations, resolution) { + if (resolution.width === undefined || resolution.height === undefined) { + return representations; + } + var width = resolution.width * resolution.pixelRatio; + var height = resolution.height * resolution.pixelRatio; var sortedRepsByWidth = representations.slice() // clone .sort(function (a, b) { return (0,take_first_set/* default */.Z)(a.width, 0) - (0,take_first_set/* default */.Z)(b.width, 0); }); var repWithMaxWidth = (0,array_find/* default */.Z)(sortedRepsByWidth, function (representation) { - return typeof representation.width === "number" && representation.width >= width; + return typeof representation.width === "number" && representation.width >= width && typeof representation.height === "number" && representation.height >= height; }); if (repWithMaxWidth === undefined) { return representations; @@ -38797,18 +38836,11 @@ var RepresentationScoreCalculator = /*#__PURE__*/function () { * bitrates. * @param {Array.} representations - The representations array, * sorted in bitrate ascending order. - * @param {Number} optimalBitrate - The optimal bitrate the Representation + * @param {Number} wantedBitrate - The optimal bitrate the Representation * should have under the current condition. - * @param {Number} minBitrate - The minimum bitrate the chosen Representation - * should have. We will take the Representation with the maximum bitrate if none - * is found. - * @param {Number} maxBitrate - The maximum bitrate the chosen Representation - * should have. We will take the Representation with the minimum bitrate if none - * is found. * @returns {Representation|undefined} */ -function selectOptimalRepresentation(representations, optimalBitrate, minBitrate, maxBitrate) { - var wantedBitrate = optimalBitrate <= minBitrate ? minBitrate : optimalBitrate >= maxBitrate ? maxBitrate : optimalBitrate; +function selectOptimalRepresentation(representations, wantedBitrate) { var firstIndexTooHigh = (0,array_find_index/* default */.Z)(representations, function (representation) { return representation.bitrate > wantedBitrate; }); @@ -38853,12 +38885,6 @@ function selectOptimalRepresentation(representations, optimalBitrate, minBitrate // Create default shared references -var manualBitrateDefaultRef = (0,utils_reference/* default */.ZP)(-1); -manualBitrateDefaultRef.finish(); -var minAutoBitrateDefaultRef = (0,utils_reference/* default */.ZP)(0); -minAutoBitrateDefaultRef.finish(); -var maxAutoBitrateDefaultRef = (0,utils_reference/* default */.ZP)(Infinity); -maxAutoBitrateDefaultRef.finish(); var limitWidthDefaultRef = (0,utils_reference/* default */.ZP)(undefined); limitWidthDefaultRef.finish(); var throttleBitrateDefaultRef = (0,utils_reference/* default */.ZP)(Infinity); @@ -38877,10 +38903,7 @@ function createAdaptiveRepresentationSelector(options) { * One per active media type. */ var bandwidthEstimators = {}; - var manualBitrates = options.manualBitrates, - minAutoBitrates = options.minAutoBitrates, - maxAutoBitrates = options.maxAutoBitrates, - initialBitrates = options.initialBitrates, + var initialBitrates = options.initialBitrates, throttlers = options.throttlers, lowLatencyMode = options.lowLatencyMode; /** @@ -38898,12 +38921,9 @@ function createAdaptiveRepresentationSelector(options) { return function getEstimates(context, currentRepresentation, representations, playbackObserver, stopAllEstimates) { var type = context.adaptation.type; var bandwidthEstimator = _getBandwidthEstimator(type); - var manualBitrate = (0,take_first_set/* default */.Z)(manualBitrates[type], manualBitrateDefaultRef); - var minAutoBitrate = (0,take_first_set/* default */.Z)(minAutoBitrates[type], minAutoBitrateDefaultRef); - var maxAutoBitrate = (0,take_first_set/* default */.Z)(maxAutoBitrates[type], maxAutoBitrateDefaultRef); var initialBitrate = (0,take_first_set/* default */.Z)(initialBitrates[type], 0); var filters = { - limitWidth: (0,take_first_set/* default */.Z)(throttlers.limitWidth[type], limitWidthDefaultRef), + limitResolution: (0,take_first_set/* default */.Z)(throttlers.limitResolution[type], limitWidthDefaultRef), throttleBitrate: (0,take_first_set/* default */.Z)(throttlers.throttleBitrate[type], throttleBitrateDefaultRef) }; return getEstimateReference({ @@ -38912,9 +38932,6 @@ function createAdaptiveRepresentationSelector(options) { currentRepresentation: currentRepresentation, filters: filters, initialBitrate: initialBitrate, - manualBitrate: manualBitrate, - minAutoBitrate: minAutoBitrate, - maxAutoBitrate: maxAutoBitrate, playbackObserver: playbackObserver, representations: representations, lowLatencyMode: lowLatencyMode @@ -38962,9 +38979,6 @@ function getEstimateReference(_ref, stopAllEstimates) { filters = _ref.filters, initialBitrate = _ref.initialBitrate, lowLatencyMode = _ref.lowLatencyMode, - manualBitrate = _ref.manualBitrate, - maxAutoBitrate = _ref.maxAutoBitrate, - minAutoBitrate = _ref.minAutoBitrate, playbackObserver = _ref.playbackObserver, representationsRef = _ref.representations; var scoreCalculator = new RepresentationScoreCalculator(); @@ -38988,10 +39002,7 @@ function getEstimateReference(_ref, stopAllEstimates) { var currentEstimatesCanceller = new task_canceller/* default */.ZP(); currentEstimatesCanceller.linkToSignal(stopAllEstimates); // Create `ISharedReference` on which estimates will be emitted. - var estimateRef = createEstimateReference(manualBitrate.getValue(), representationsRef.getValue(), currentEstimatesCanceller.signal); - manualBitrate.onUpdate(restartEstimatesProductionFromCurrentConditions, { - clearSignal: stopAllEstimates - }); + var estimateRef = createEstimateReference(representationsRef.getValue(), currentEstimatesCanceller.signal); representationsRef.onUpdate(restartEstimatesProductionFromCurrentConditions, { clearSignal: stopAllEstimates }); @@ -38999,35 +39010,12 @@ function getEstimateReference(_ref, stopAllEstimates) { estimates: estimateRef, callbacks: callbacks }; - function createEstimateReference(manualBitrateVal, representations, innerCancellationSignal) { - if (representations.length === 0) { - // No Representation given, return `null` as documented - return (0,utils_reference/* default */.ZP)({ - representation: null, - bitrate: undefined, - knownStableBitrate: undefined, - manual: false, - urgent: true - }); - } - if (manualBitrateVal >= 0) { - // A manual bitrate has been set. Just choose Representation according to it. - var manualRepresentation = selectOptimalRepresentation(representations, manualBitrateVal, 0, Infinity); - return (0,utils_reference/* default */.ZP)({ - representation: manualRepresentation, - bitrate: undefined, - knownStableBitrate: undefined, - manual: true, - urgent: true // a manual bitrate switch should happen immediately - }); - } - + function createEstimateReference(representations, innerCancellationSignal) { if (representations.length === 1) { // There's only a single Representation. Just choose it. return (0,utils_reference/* default */.ZP)({ bitrate: undefined, representation: representations[0], - manual: false, urgent: true, knownStableBitrate: undefined }); @@ -39092,16 +39080,10 @@ function getEstimateReference(_ref, stopAllEstimates) { innerCancellationSignal.register(function () { onAddedSegment = noop/* default */.Z; }); - minAutoBitrate.onUpdate(updateEstimate, { - clearSignal: innerCancellationSignal - }); - maxAutoBitrate.onUpdate(updateEstimate, { - clearSignal: innerCancellationSignal - }); - filters.limitWidth.onUpdate(updateEstimate, { + filters.throttleBitrate.onUpdate(updateEstimate, { clearSignal: innerCancellationSignal }); - filters.limitWidth.onUpdate(updateEstimate, { + filters.limitResolution.onUpdate(updateEstimate, { clearSignal: innerCancellationSignal }); return innerEstimateRef; @@ -39114,12 +39096,10 @@ function getEstimateReference(_ref, stopAllEstimates) { bufferGap = _lastPlaybackObservat2.bufferGap, position = _lastPlaybackObservat2.position, maximumPosition = _lastPlaybackObservat2.maximumPosition; - var widthLimit = filters.limitWidth.getValue(); + var resolutionLimit = filters.limitResolution.getValue(); var bitrateThrottle = filters.throttleBitrate.getValue(); var currentRepresentationVal = currentRepresentation.getValue(); - var minAutoBitrateVal = minAutoBitrate.getValue(); - var maxAutoBitrateVal = maxAutoBitrate.getValue(); - var filteredReps = getFilteredRepresentations(representations, widthLimit, bitrateThrottle); + var filteredReps = getFilteredRepresentations(representations, resolutionLimit, bitrateThrottle); var requests = requestsStore.getRequests(); var _networkAnalyzer$getB = networkAnalyzer.getBandwidthEstimate(lastPlaybackObservation, bandwidthEstimator, currentRepresentationVal, requests, prevEstimate.bandwidth), bandwidthEstimate = _networkAnalyzer$getB.bandwidthEstimate, @@ -39140,7 +39120,7 @@ function getEstimateReference(_ref, stopAllEstimates) { * This is a safe enough choice but might be lower than what the user * could actually profit from. */ - var chosenRepFromBandwidth = selectOptimalRepresentation(filteredReps, bitrateChosen, minAutoBitrateVal, maxAutoBitrateVal); + var chosenRepFromBandwidth = selectOptimalRepresentation(filteredReps, bitrateChosen); var currentBestBitrate = chosenRepFromBandwidth.bitrate; /** * Representation chosen when considering the current buffer size. @@ -39154,7 +39134,7 @@ function getEstimateReference(_ref, stopAllEstimates) { */ var chosenRepFromBufferSize = null; if (allowBufferBasedEstimates && currentBufferBasedEstimate !== undefined && currentBufferBasedEstimate > currentBestBitrate) { - chosenRepFromBufferSize = selectOptimalRepresentation(filteredReps, currentBufferBasedEstimate, minAutoBitrateVal, maxAutoBitrateVal); + chosenRepFromBufferSize = selectOptimalRepresentation(filteredReps, currentBufferBasedEstimate); currentBestBitrate = chosenRepFromBufferSize.bitrate; } /** @@ -39183,7 +39163,6 @@ function getEstimateReference(_ref, stopAllEstimates) { bitrate: bandwidthEstimate, representation: chosenRepFromGuessMode, urgent: currentRepresentationVal === null || chosenRepFromGuessMode.bitrate < currentRepresentationVal.bitrate, - manual: false, knownStableBitrate: knownStableBitrate }; } else if (chosenRepFromBufferSize !== null) { @@ -39193,7 +39172,6 @@ function getEstimateReference(_ref, stopAllEstimates) { bitrate: bandwidthEstimate, representation: chosenRepFromBufferSize, urgent: networkAnalyzer.isUrgent(chosenRepFromBufferSize.bitrate, currentRepresentationVal, requests, lastPlaybackObservation), - manual: false, knownStableBitrate: knownStableBitrate }; } else { @@ -39203,7 +39181,6 @@ function getEstimateReference(_ref, stopAllEstimates) { bitrate: bandwidthEstimate, representation: chosenRepFromBandwidth, urgent: networkAnalyzer.isUrgent(chosenRepFromBandwidth.bitrate, currentRepresentationVal, requests, lastPlaybackObservation), - manual: false, knownStableBitrate: knownStableBitrate }; } @@ -39211,15 +39188,14 @@ function getEstimateReference(_ref, stopAllEstimates) { } /** * Stop previous estimate production (if one) and restart it considering new - * conditions (such as a manual bitrate and/or a new list of Representations). + * conditions (such as a new list of Representations). */ function restartEstimatesProductionFromCurrentConditions() { - var manualBitrateVal = manualBitrate.getValue(); var representations = representationsRef.getValue(); currentEstimatesCanceller.cancel(); currentEstimatesCanceller = new task_canceller/* default */.ZP(); currentEstimatesCanceller.linkToSignal(stopAllEstimates); - var newRef = createEstimateReference(manualBitrateVal, representations, currentEstimatesCanceller.signal); + var newRef = createEstimateReference(representations, currentEstimatesCanceller.signal); newRef.onUpdate(function onNewEstimate(newEstimate) { estimateRef.setValue(newEstimate); }, { @@ -39266,16 +39242,17 @@ function getEstimateReference(_ref, stopAllEstimates) { /** * Filter representations given through filters options. * @param {Array.} representations - * @param {number | undefined} widthLimit - Filter Object. + * @param {Object | undefined} resolutionLimit + * @param {number | undefined} bitrateThrottle * @returns {Array.} */ -function getFilteredRepresentations(representations, widthLimit, bitrateThrottle) { +function getFilteredRepresentations(representations, resolutionLimit, bitrateThrottle) { var filteredReps = representations; - if (bitrateThrottle < Infinity) { + if (bitrateThrottle !== undefined && bitrateThrottle < Infinity) { filteredReps = filterByBitrate(filteredReps, bitrateThrottle); } - if (widthLimit !== undefined) { - filteredReps = filterByWidth(filteredReps, widthLimit); + if (resolutionLimit !== undefined) { + filteredReps = filterByResolution(filteredReps, resolutionLimit); } return filteredReps; } @@ -39335,50 +39312,6 @@ function errorSelector(error) { defaultReason: "Unknown error when fetching the Manifest" }); } -;// CONCATENATED MODULE: ./src/compat/is_offline.ts -/** - * Copyright 2015 CANAL+ Group - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Some browsers have a builtin API to know if it's connected at least to a - * LAN network, at most to the internet. - * - * /!\ This feature can be dangerous as you can both have false positives and - * false negatives. - * - * False positives: - * - you can still play local contents (on localhost) if isOffline == true - * - on some browsers isOffline might be true even if we're connected to a LAN - * or a router (it would mean we're just not able to connect to the - * Internet). So we can eventually play LAN contents if isOffline == true - * - * False negatives: - * - in some cases, we even might have isOffline at false when we do not have - * any connection: - * - in browsers that do not support the feature - * - in browsers running in some virtualization softwares where the - * network adapters are always connected. - * - * Use with these cases in mind. - * @returns {Boolean} - */ -function isOffline() { - /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ - return navigator.onLine === false; - /* eslint-enable @typescript-eslint/no-unnecessary-boolean-literal-compare */ -} // EXTERNAL MODULE: ./src/errors/custom_loader_error.ts var custom_loader_error = __webpack_require__(7839); // EXTERNAL MODULE: ./src/errors/is_known_error.ts @@ -39411,7 +39344,6 @@ var get_fuzzed_delay = __webpack_require__(2572); - /** * Called on a loader error. * Returns whether the loader request should be retried. @@ -39449,28 +39381,6 @@ function shouldRetry(error) { } return (0,is_known_error/* default */.Z)(error) && error.code === "INTEGRITY_ERROR"; } -/** - * Returns true if we're pretty sure that the current error is due to the - * user being offline. - * @param {Error} error - * @returns {Boolean} - */ -function isOfflineRequestError(error) { - if (error instanceof request_error/* default */.Z) { - return error.type === error_codes/* NetworkErrorTypes */.br.ERROR_EVENT && isOffline(); - } else if (error instanceof custom_loader_error/* default */.Z) { - return error.isOfflineError; - } - return false; // under doubt, return false -} -/** - * Guess the type of error obtained. - * @param {*} error - * @returns {number} - */ -function getRequestErrorType(error) { - return isOfflineRequestError(error) ? 2 /* REQUEST_ERROR_TYPES.Offline */ : 1 /* REQUEST_ERROR_TYPES.Regular */; -} /** * Specific algorithm used to perform segment and manifest requests. * @@ -39534,7 +39444,7 @@ function scheduleRequestWithCdns(_x, _x2, _x3, _x4, _x5) { */ function _scheduleRequestWithCdns() { _scheduleRequestWithCdns = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee3(cdns, cdnPrioritizer, performRequest, options, cancellationSignal) { - var baseDelay, maxDelay, maxRetryRegular, maxRetryOffline, onRetry, missedAttempts, initialCdnToRequest, getCdnToRequest, requestCdn, _requestCdn, retryWithNextCdn, _retryWithNextCdn, waitPotentialBackoffAndRequest, getPrioritaryRequestableCdnFromSortedList; + var baseDelay, maxDelay, maxRetry, onRetry, missedAttempts, initialCdnToRequest, getCdnToRequest, requestCdn, _requestCdn, retryWithNextCdn, _retryWithNextCdn, waitPotentialBackoffAndRequest, getPrioritaryRequestableCdnFromSortedList; return regenerator_default().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: @@ -39645,7 +39555,7 @@ function _scheduleRequestWithCdns() { }; _requestCdn = function _requestCdn3() { _requestCdn = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(cdn) { - var res, currentErrorType, missedAttemptsObj, maxRetry, errorCounter, delay, fuzzedDelay; + var res, missedAttemptsObj, errorCounter, delay, fuzzedDelay; return regenerator_default().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: @@ -39669,33 +39579,25 @@ function _scheduleRequestWithCdns() { // Globally give priority to the next CDN through the CdnPrioritizer. cdnPrioritizer.downgradeCdn(cdn); } - currentErrorType = getRequestErrorType(_context.t0); missedAttemptsObj = missedAttempts.get(cdn); if (missedAttemptsObj === undefined) { missedAttemptsObj = { errorCounter: 1, - lastErrorType: currentErrorType, blockedUntil: undefined, isBlacklisted: false }; missedAttempts.set(cdn, missedAttemptsObj); } else { - if (currentErrorType !== missedAttemptsObj.lastErrorType) { - missedAttemptsObj.errorCounter = 1; - missedAttemptsObj.lastErrorType = currentErrorType; - } else { - missedAttemptsObj.errorCounter++; - } + missedAttemptsObj.errorCounter++; } if (shouldRetry(_context.t0)) { - _context.next = 19; + _context.next = 18; break; } missedAttemptsObj.blockedUntil = undefined; missedAttemptsObj.isBlacklisted = true; return _context.abrupt("return", retryWithNextCdn(_context.t0)); - case 19: - maxRetry = currentErrorType === 2 /* REQUEST_ERROR_TYPES.Offline */ ? maxRetryOffline : maxRetryRegular; + case 18: if (missedAttemptsObj.errorCounter > maxRetry) { missedAttemptsObj.blockedUntil = undefined; missedAttemptsObj.isBlacklisted = true; @@ -39706,7 +39608,7 @@ function _scheduleRequestWithCdns() { missedAttemptsObj.blockedUntil = performance.now() + fuzzedDelay; } return _context.abrupt("return", retryWithNextCdn(_context.t0)); - case 22: + case 20: case "end": return _context.stop(); } @@ -39737,7 +39639,7 @@ function _scheduleRequestWithCdns() { } return _context3.abrupt("return", Promise.reject(cancellationSignal.cancellationError)); case 9: - baseDelay = options.baseDelay, maxDelay = options.maxDelay, maxRetryRegular = options.maxRetryRegular, maxRetryOffline = options.maxRetryOffline, onRetry = options.onRetry; + baseDelay = options.baseDelay, maxDelay = options.maxDelay, maxRetry = options.maxRetry, onRetry = options.onRetry; if (cdns !== null && cdns.length === 0) { log/* default */.Z.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."); } @@ -40110,23 +40012,19 @@ var ManifestFetcher = /*#__PURE__*/function (_EventEmitter) { _proto._getBackoffSetting = function _getBackoffSetting(onRetry) { var _config$getCurrent = config/* default */.Z.getCurrent(), DEFAULT_MAX_MANIFEST_REQUEST_RETRY = _config$getCurrent.DEFAULT_MAX_MANIFEST_REQUEST_RETRY, - DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE = _config$getCurrent.DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE, INITIAL_BACKOFF_DELAY_BASE = _config$getCurrent.INITIAL_BACKOFF_DELAY_BASE, MAX_BACKOFF_DELAY_BASE = _config$getCurrent.MAX_BACKOFF_DELAY_BASE; var _this$_settings = this._settings, lowLatencyMode = _this$_settings.lowLatencyMode, - ogRegular = _this$_settings.maxRetryRegular, - ogOffline = _this$_settings.maxRetryOffline; + ogRegular = _this$_settings.maxRetry; var baseDelay = lowLatencyMode ? INITIAL_BACKOFF_DELAY_BASE.LOW_LATENCY : INITIAL_BACKOFF_DELAY_BASE.REGULAR; var maxDelay = lowLatencyMode ? MAX_BACKOFF_DELAY_BASE.LOW_LATENCY : MAX_BACKOFF_DELAY_BASE.REGULAR; - var maxRetryRegular = ogRegular !== null && ogRegular !== void 0 ? ogRegular : DEFAULT_MAX_MANIFEST_REQUEST_RETRY; - var maxRetryOffline = ogOffline !== null && ogOffline !== void 0 ? ogOffline : DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE; + var maxRetry = ogRegular !== null && ogRegular !== void 0 ? ogRegular : DEFAULT_MAX_MANIFEST_REQUEST_RETRY; return { onRetry: onRetry, baseDelay: baseDelay, maxDelay: maxDelay, - maxRetryRegular: maxRetryRegular, - maxRetryOffline: maxRetryOffline + maxRetry: maxRetry }; } /** @@ -40278,7 +40176,7 @@ var ManifestFetcher = /*#__PURE__*/function (_EventEmitter) { this._prioritizedContentUrl = null; } else { fullRefresh = !enablePartialRefresh || manifestUpdateUrl === undefined; - refreshURL = fullRefresh ? manifest.getUrl() : manifestUpdateUrl; + refreshURL = fullRefresh ? manifest.getUrls()[0] : manifestUpdateUrl; } var externalClockOffset = manifest.clockOffset; if (unsafeMode) { @@ -40984,19 +40882,16 @@ function segment_fetcher_createSegmentFetcher(bufferType, pipeline, cdnPrioritiz * @returns {Object} */ function getSegmentFetcherOptions(_ref) { - var maxRetryRegular = _ref.maxRetryRegular, - maxRetryOffline = _ref.maxRetryOffline, + var maxRetry = _ref.maxRetry, lowLatencyMode = _ref.lowLatencyMode, requestTimeout = _ref.requestTimeout; var _config$getCurrent = config/* default */.Z.getCurrent(), DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR = _config$getCurrent.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR, DEFAULT_REQUEST_TIMEOUT = _config$getCurrent.DEFAULT_REQUEST_TIMEOUT, - DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE = _config$getCurrent.DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE, INITIAL_BACKOFF_DELAY_BASE = _config$getCurrent.INITIAL_BACKOFF_DELAY_BASE, MAX_BACKOFF_DELAY_BASE = _config$getCurrent.MAX_BACKOFF_DELAY_BASE; return { - maxRetryRegular: maxRetryRegular !== null && maxRetryRegular !== void 0 ? maxRetryRegular : DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR, - maxRetryOffline: maxRetryOffline !== null && maxRetryOffline !== void 0 ? maxRetryOffline : DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE, + maxRetry: maxRetry !== null && maxRetry !== void 0 ? maxRetry : DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR, baseDelay: lowLatencyMode ? INITIAL_BACKOFF_DELAY_BASE.LOW_LATENCY : INITIAL_BACKOFF_DELAY_BASE.REGULAR, maxDelay: lowLatencyMode ? MAX_BACKOFF_DELAY_BASE.LOW_LATENCY : MAX_BACKOFF_DELAY_BASE.REGULAR, requestTimeout: (0,is_null_or_undefined/* default */.Z)(requestTimeout) ? DEFAULT_REQUEST_TIMEOUT : requestTimeout @@ -41440,12 +41335,6 @@ function tryToChangeSourceBufferType(sourceBuffer, codec) { } return false; } -// EXTERNAL MODULE: ./src/utils/are_arrays_of_numbers_equal.ts -var are_arrays_of_numbers_equal = __webpack_require__(4791); -// EXTERNAL MODULE: ./src/utils/byte_parsing.ts -var byte_parsing = __webpack_require__(6968); -// EXTERNAL MODULE: ./src/utils/hash_buffer.ts -var hash_buffer = __webpack_require__(2870); // EXTERNAL MODULE: ./src/core/segment_buffers/implementations/types.ts + 3 modules var types = __webpack_require__(9612); ;// CONCATENATED MODULE: ./src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts @@ -41476,9 +41365,6 @@ var types = __webpack_require__(9612); - - - /** * Allows to push and remove new segments to a SourceBuffer in a FIFO queue (not * doing so can lead to browser Errors) while keeping an inventory of what has @@ -41507,8 +41393,9 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { _this._sourceBuffer = sourceBuffer; _this._queue = []; _this._pendingTask = null; - _this._lastInitSegment = null; + _this._lastInitSegmentUniqueId = null; _this.codec = codec; + _this._initSegmentsMap = new Map(); var onError = _this._onPendingTaskError.bind((0,assertThisInitialized/* default */.Z)(_this)); var reCheck = _this._flush.bind((0,assertThisInitialized/* default */.Z)(_this)); // Some browsers (happened with firefox 66) sometimes "forget" to send us @@ -41529,6 +41416,14 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { }); return _this; } + var _proto = AudioVideoSegmentBuffer.prototype; + _proto.declareInitSegment = function declareInitSegment(uniqueId, initSegmentData) { + assertDataIsBufferSource(initSegmentData); + this._initSegmentsMap.set(uniqueId, initSegmentData); + }; + _proto.freeInitSegment = function freeInitSegment(uniqueId) { + this._initSegmentsMap["delete"](uniqueId); + } /** * Push a chunk of the media segment given to the attached SourceBuffer, in a * FIFO queue. @@ -41555,10 +41450,9 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { * @param {Object} infos * @param {Object} cancellationSignal * @returns {Promise} - */ - var _proto = AudioVideoSegmentBuffer.prototype; + */; _proto.pushChunk = function pushChunk(infos, cancellationSignal) { - assertPushedDataIsBufferSource(infos); + assertDataIsBufferSource(infos.data.chunk); log/* default */.Z.debug("AVSB: receiving order to push data to the SourceBuffer", this.bufferType, (0,utils/* getLoggableSegmentId */.K)(infos.inventoryInfos)); return this._addToQueue({ type: types/* SegmentBufferOperation */.f.Push, @@ -41667,7 +41561,7 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { * @param {Event} err */; _proto._onPendingTaskError = function _onPendingTaskError(err) { - this._lastInitSegment = null; // initialize init segment as a security + this._lastInitSegmentUniqueId = null; // initialize init segment as a security if (this._pendingTask !== null) { var error = err instanceof Error ? err : new Error("An unknown error occured when doing operations " + "on the SourceBuffer"); this._pendingTask.reject(error); @@ -41757,7 +41651,7 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { inventoryData: itemValue.inventoryInfos }, nextItem); var error = e instanceof Error ? e : new Error("An unknown error occured when preparing a push operation"); - this._lastInitSegment = null; // initialize init segment as a security + this._lastInitSegmentUniqueId = null; // initialize init segment as a security nextItem.reject(error); return; } @@ -41847,15 +41741,14 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { } else if (appendWindow[1] !== this._sourceBuffer.appendWindowEnd) { this._sourceBuffer.appendWindowEnd = appendWindow[1]; } - if (data.initSegment !== null && (hasUpdatedSourceBufferType || !this._isLastInitSegment(data.initSegment))) { + if (data.initSegmentUniqueId !== null && (hasUpdatedSourceBufferType || !this._isLastInitSegment(data.initSegmentUniqueId))) { // Push initialization segment before the media segment - var segmentData = data.initSegment; + var segmentData = this._initSegmentsMap.get(data.initSegmentUniqueId); + if (segmentData === undefined) { + throw new Error("Invalid initialization segment uniqueId"); + } dataToPush.push(segmentData); - var initU8 = (0,byte_parsing/* toUint8Array */._f)(segmentData); - this._lastInitSegment = { - data: initU8, - hash: (0,hash_buffer/* default */.Z)(initU8) - }; + this._lastInitSegmentUniqueId = data.initSegmentUniqueId; } if (data.chunk !== null) { dataToPush.push(data.chunk); @@ -41863,26 +41756,16 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { return dataToPush; } /** - * Return `true` if the given `segmentData` is the same segment than the last + * Return `true` if the given `uniqueId` is the identifier of the last * initialization segment pushed to the `AudioVideoSegmentBuffer`. - * @param {BufferSource} segmentData + * @param {string} uniqueId * @returns {boolean} */; - _proto._isLastInitSegment = function _isLastInitSegment(segmentData) { - if (this._lastInitSegment === null) { + _proto._isLastInitSegment = function _isLastInitSegment(uniqueId) { + if (this._lastInitSegmentUniqueId === null) { return false; } - if (this._lastInitSegment.data === segmentData) { - return true; - } - var oldInit = this._lastInitSegment.data; - if (oldInit.byteLength === segmentData.byteLength) { - var newInitU8 = (0,byte_parsing/* toUint8Array */._f)(segmentData); - if ((0,hash_buffer/* default */.Z)(newInitU8) === this._lastInitSegment.hash && (0,are_arrays_of_numbers_equal/* default */.Z)(oldInit, newInitU8)) { - return true; - } - } - return false; + return this._lastInitSegmentUniqueId === uniqueId; }; return AudioVideoSegmentBuffer; }(types/* SegmentBuffer */.C); @@ -41890,17 +41773,14 @@ var AudioVideoSegmentBuffer = /*#__PURE__*/function (_SegmentBuffer) { * Throw if the given input is not in the expected format. * Allows to enforce runtime type-checking as compile-time type-checking here is * difficult to enforce. - * @param {Object} pushedData + * @param {Object} data */ -function assertPushedDataIsBufferSource(pushedData) { +function assertDataIsBufferSource(data) { if (true) { return; } - var _pushedData$data = pushedData.data, - chunk = _pushedData$data.chunk, - initSegment = _pushedData$data.initSegment; - if (typeof chunk !== "object" || typeof initSegment !== "object" || chunk !== null && !(chunk instanceof ArrayBuffer) && !(chunk.buffer instanceof ArrayBuffer) || initSegment !== null && !(initSegment instanceof ArrayBuffer) && !(initSegment.buffer instanceof ArrayBuffer)) { + if (typeof data !== "object" || data !== null && !(data instanceof ArrayBuffer) && !(data.buffer instanceof ArrayBuffer)) { throw new Error("Invalid data given to the AudioVideoSegmentBuffer"); } } @@ -44270,26 +44150,20 @@ function pushInitSegment(_x, _x2) { } function _pushInitSegment() { _pushInitSegment = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(_ref, cancelSignal) { - var playbackObserver, content, segment, segmentData, segmentBuffer, codec, data, inventoryInfos, buffered; + var playbackObserver, content, initSegmentUniqueId, segment, segmentData, segmentBuffer, codec, data, inventoryInfos, buffered; return regenerator_default().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: - playbackObserver = _ref.playbackObserver, content = _ref.content, segment = _ref.segment, segmentData = _ref.segmentData, segmentBuffer = _ref.segmentBuffer; - if (!(segmentData === null)) { - _context.next = 3; - break; - } - return _context.abrupt("return", null); - case 3: + playbackObserver = _ref.playbackObserver, content = _ref.content, initSegmentUniqueId = _ref.initSegmentUniqueId, segment = _ref.segment, segmentData = _ref.segmentData, segmentBuffer = _ref.segmentBuffer; if (!(cancelSignal.cancellationError !== null)) { - _context.next = 5; + _context.next = 3; break; } throw cancelSignal.cancellationError; - case 5: + case 3: codec = content.representation.getMimeTypeString(); data = { - initSegment: segmentData, + initSegmentUniqueId: initSegmentUniqueId, chunk: null, timestampOffset: 0, appendWindow: [undefined, undefined], @@ -44301,12 +44175,12 @@ function _pushInitSegment() { start: 0, end: 0 }, content); - _context.next = 10; + _context.next = 8; return appendSegmentToBuffer(playbackObserver, segmentBuffer, { data: data, inventoryInfos: inventoryInfos }, cancelSignal); - case 10: + case 8: buffered = segmentBuffer.getBufferedRanges(); return _context.abrupt("return", { content: content, @@ -44314,7 +44188,7 @@ function _pushInitSegment() { buffered: buffered, segmentData: segmentData }); - case 12: + case 10: case "end": return _context.stop(); } @@ -44354,11 +44228,11 @@ function pushMediaSegment(_x, _x2) { } function _pushMediaSegment() { _pushMediaSegment = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(_ref, cancelSignal) { - var playbackObserver, content, initSegmentData, parsedSegment, segment, segmentBuffer, _a, _b, chunkData, chunkInfos, chunkOffset, chunkSize, appendWindow, codec, _config$getCurrent, APPEND_WINDOW_SECURITIES, safeAppendWindow, data, estimatedStart, estimatedDuration, estimatedEnd, inventoryInfos, buffered; + var playbackObserver, content, initSegmentUniqueId, parsedSegment, segment, segmentBuffer, _a, _b, chunkData, chunkInfos, chunkOffset, chunkSize, appendWindow, codec, _config$getCurrent, APPEND_WINDOW_SECURITIES, safeAppendWindow, data, estimatedStart, estimatedDuration, estimatedEnd, inventoryInfos, buffered; return regenerator_default().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: - playbackObserver = _ref.playbackObserver, content = _ref.content, initSegmentData = _ref.initSegmentData, parsedSegment = _ref.parsedSegment, segment = _ref.segment, segmentBuffer = _ref.segmentBuffer; + playbackObserver = _ref.playbackObserver, content = _ref.content, initSegmentUniqueId = _ref.initSegmentUniqueId, parsedSegment = _ref.parsedSegment, segment = _ref.segment, segmentBuffer = _ref.segmentBuffer; if (!(parsedSegment.chunkData === null)) { _context.next = 3; break; @@ -44378,7 +44252,7 @@ function _pushMediaSegment() { // To work-around that, we add a small offset before and after those. safeAppendWindow = [appendWindow[0] !== undefined ? Math.max(0, appendWindow[0] - APPEND_WINDOW_SECURITIES.START) : undefined, appendWindow[1] !== undefined ? appendWindow[1] + APPEND_WINDOW_SECURITIES.END : undefined]; data = { - initSegment: initSegmentData, + initSegmentUniqueId: initSegmentUniqueId, chunk: chunkData, timestampOffset: chunkOffset, appendWindow: safeAppendWindow, @@ -44520,9 +44394,15 @@ function RepresentationStream(_ref, callbacks, parentCancelSignal) { /** Saved initialization segment state for this representation. */ var initSegmentState = { segment: representation.index.getInitSegment(), - segmentData: null, + uniqueId: null, isLoaded: false }; + globalCanceller.signal.register(function () { + // Free initialization segment if one has been declared + if (initSegmentState.uniqueId !== null) { + segmentBuffer.freeInitSegment(initSegmentState.uniqueId); + } + }); /** Emit the last scheduled downloading queue for segments. */ var lastSegmentQueue = (0,utils_reference/* createSharedReference */.$l)({ initSegment: null, @@ -44531,7 +44411,6 @@ function RepresentationStream(_ref, callbacks, parentCancelSignal) { /** If `true`, the current Representation has a linked initialization segment. */ var hasInitSegment = initSegmentState.segment !== null; if (!hasInitSegment) { - initSegmentState.segmentData = null; initSegmentState.isLoaded = true; } /** @@ -44755,19 +44634,24 @@ function RepresentationStream(_ref, callbacks, parentCancelSignal) { if (!representation.index.isInitialized() && evt.segmentList !== undefined) { representation.index.initialize(evt.segmentList); } - initSegmentState.segmentData = evt.initializationData; initSegmentState.isLoaded = true; - pushInitSegment({ - playbackObserver: playbackObserver, - content: content, - segment: evt.segment, - segmentData: evt.initializationData, - segmentBuffer: segmentBuffer - }, globalCanceller.signal).then(function (result) { - if (result !== null) { - callbacks.addedSegment(result); - } - })["catch"](onFatalBufferError); + if (evt.initializationData !== null) { + var initSegmentUniqueId = representation.uniqueId; + initSegmentState.uniqueId = initSegmentUniqueId; + segmentBuffer.declareInitSegment(initSegmentUniqueId, evt.initializationData); + pushInitSegment({ + playbackObserver: playbackObserver, + content: content, + initSegmentUniqueId: initSegmentUniqueId, + segment: evt.segment, + segmentData: evt.initializationData, + segmentBuffer: segmentBuffer + }, globalCanceller.signal).then(function (result) { + if (result !== null) { + callbacks.addedSegment(result); + } + })["catch"](onFatalBufferError); + } // Sometimes the segment list is only known once the initialization segment // is parsed. Thus we immediately re-check if there's new segments to load. checkStatus(); @@ -44793,11 +44677,11 @@ function RepresentationStream(_ref, callbacks, parentCancelSignal) { } } - var initSegmentData = initSegmentState.segmentData; + var _initSegmentUniqueId = initSegmentState.uniqueId; pushMediaSegment({ playbackObserver: playbackObserver, content: content, - initSegmentData: initSegmentData, + initSegmentUniqueId: _initSegmentUniqueId, parsedSegment: evt, segment: evt.segment, segmentBuffer: segmentBuffer @@ -44844,6 +44728,67 @@ function RepresentationStream(_ref, callbacks, parentCancelSignal) { /* harmony default export */ var stream_representation = (RepresentationStream); +;// CONCATENATED MODULE: ./src/core/stream/utils/create_reload_request.ts + +/** + * Function to facilitate the task of asking for the MediaSource to be reloaded. + * + * @param {Object} playbackObserver - Regularly emits the current playback + * conditions. + * @param {Function} fn - Function that will be called regularly with the + * position and auto-play status that you should ask to reload to. + * @param {number} deltaPos - This value, in seconds, will be added to the + * actual current position (respecting the `timeBounds` given) to indicate the + * position we should reload at. + * This value allows to give back context (by replaying some media data) after + * a switch. + * @param {Object} timeBounds - Bounds that should not be exceeded on the + * position to reload to. Both `start` and `end` bounds can be set to + * `undefined` to disable them. + * @param {Object} cancelSignal - When it emits, we stop asking for the + * MediaSource to be reloaded. + */ +function createReloadRequest(playbackObserver, fn, deltaPos, timeBounds, cancelSignal) { + if (cancelSignal.isCancelled()) { + return; + } + // We begin by scheduling a micro-task to reduce the possibility of race + // conditions. + // + // For example `createReloadRequest` could be called synchronously + // before the next observation (which may reflect very different + // playback conditions) is actually received. This can happen when + // `createReloadRequest` is called as a side-effect of the same event + // that triggers the playback observation to be emitted. In that situation, + // scheduling a micro task ensures that the true last observation is + // considered. + // + // Other races conditions could also happen for when example multiple + // modules of the player handle some events (I can think for example of the + // case where the `Adaptation` disappears on a Manifest update) where we + // want the reloading operation to be a last resort situation, so we prefer + // to postpone it after other potential synchronous solutions from other + // modules have been tested. + // + // At last, because reloading is such an aggressive situation, we prefer to + // trigger it always asynchronously so behavior is better predictible. + next_tick_default()(function () { + playbackObserver.listen(function (observation) { + var _a, _b, _c; + var currentTime = playbackObserver.getCurrentTime(); + var position = currentTime + deltaPos; + position = Math.min(Math.max((_a = timeBounds.start) !== null && _a !== void 0 ? _a : 0, position), (_b = timeBounds.end) !== null && _b !== void 0 ? _b : Infinity); + var autoPlay = !((_c = observation.paused.pending) !== null && _c !== void 0 ? _c : playbackObserver.getIsPaused()); + fn({ + position: position, + autoPlay: autoPlay + }); + }, { + includeLastObservation: true, + clearSignal: cancelSignal + }); + }); +} ;// CONCATENATED MODULE: ./src/core/segment_buffers/inventory/utils.ts /** * Copyright 2015 CANAL+ Group @@ -45143,11 +45088,57 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { var currentRepresentation = (0,utils_reference/* createSharedReference */.$l)(null, adapStreamCanceller.signal); /** Stores the last emitted bitrate. */ var previouslyEmittedBitrate; - /** When triggered, cancel all `RepresentationStream`s currently created. */ + /** Emit the list of Representation for the adaptive logic. */ + var representationsList = (0,utils_reference/* createSharedReference */.$l)(content.representations.getValue().representations, adapStreamCanceller.signal); + // Start-up Adaptive logic + var _representationEstima = representationEstimator({ + manifest: manifest, + period: period, + adaptation: adaptation + }, currentRepresentation, representationsList, playbackObserver, adapStreamCanceller.signal), + estimateRef = _representationEstima.estimates, + abrCallbacks = _representationEstima.callbacks; + /** Allows a `RepresentationStream` to easily fetch media segments. */ + var segmentFetcher = segmentFetcherCreator.createSegmentFetcher(adaptation.type, /* eslint-disable @typescript-eslint/unbound-method */ + { + onRequestBegin: abrCallbacks.requestBegin, + onRequestEnd: abrCallbacks.requestEnd, + onProgress: abrCallbacks.requestProgress, + onMetrics: abrCallbacks.metrics + }); + /* eslint-enable @typescript-eslint/unbound-method */ + /** Used to determine when "fast-switching" is possible. */ + var fastSwitchThreshold = (0,utils_reference/* createSharedReference */.$l)(0); + estimateRef.onUpdate(function (_ref2) { + var bitrate = _ref2.bitrate, + knownStableBitrate = _ref2.knownStableBitrate; + if (options.enableFastSwitching) { + fastSwitchThreshold.setValueIfChanged(knownStableBitrate); + } + if (bitrate === undefined || bitrate === previouslyEmittedBitrate) { + return; + } + previouslyEmittedBitrate = bitrate; + log/* default */.Z.debug("Stream: new " + adaptation.type + " bitrate estimate", bitrate); + callbacks.bitrateEstimateChange({ + type: adaptation.type, + bitrate: bitrate + }); + }, { + emitCurrentValue: true, + clearSignal: adapStreamCanceller.signal + }); + /** + * When triggered, cancel all `RepresentationStream`s currently created. + * Set to `undefined` initially. + */ var cancelCurrentStreams; // Each time the list of wanted Representations changes, we restart the logic content.representations.onUpdate(function (val) { - cancelCurrentStreams === null || cancelCurrentStreams === void 0 ? void 0 : cancelCurrentStreams.cancel(); + if (cancelCurrentStreams !== undefined) { + cancelCurrentStreams.cancel(); + } + representationsList.setValueIfChanged(val.representations); cancelCurrentStreams = new task_canceller/* default */.ZP(); cancelCurrentStreams.linkToSignal(adapStreamCanceller.signal); onRepresentationsChoiceChange(val, cancelCurrentStreams.signal)["catch"](function (err) { @@ -45181,16 +45172,12 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { * estimate performed. * Each time a new estimate is made, this function will create a new * `RepresentationStream` corresponding to that new estimate. - * @param {Object} estimateRef - Reference through which ABR estimates are - * set. May be updated at any time. - * @param {Object} abrCallbacks - Callbacks defined by the ABR logic that have - * to be called at the right time. * @param {Object} fnCancelSignal - `CancellationSignal` which will abort * anything this function is doing and free allocated resources. */ function _onRepresentationsChoiceChange() { _onRepresentationsChoiceChange = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(choice, fnCancelSignal) { - var switchStrat, _iterator, _step, range, representationsList, _representationEstima, estimateRef, abrCallbacks; + var switchStrat, _config$getCurrent, DELTA_POSITION_AFTER_RELOAD, bufferType, _iterator3, _step3, range; return regenerator_default().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: @@ -45198,95 +45185,62 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { // in the buffer switchStrat = getRepresentationsSwitchingStrategy(period, adaptation, choice, segmentBuffer, playbackObserver); _context.t0 = switchStrat.type; - _context.next = _context.t0 === "continue" ? 4 : _context.t0 === "needs-reload" ? 5 : _context.t0 === "flush-buffer" ? 6 : _context.t0 === "clean-buffer" ? 6 : 20; + _context.next = _context.t0 === "continue" ? 4 : _context.t0 === "needs-reload" ? 5 : _context.t0 === "flush-buffer" ? 8 : _context.t0 === "clean-buffer" ? 8 : 22; break; case 4: - return _context.abrupt("break", 21); + return _context.abrupt("break", 23); case 5: - return _context.abrupt("return", next_tick_default()(function () { - var _config$getCurrent = config/* default */.Z.getCurrent(), - DELTA_POSITION_AFTER_RELOAD = _config$getCurrent.DELTA_POSITION_AFTER_RELOAD; - playbackObserver.listen(function (observation) { - var _a, _b; - var currentTime = playbackObserver.getCurrentTime(); - var pos = currentTime + DELTA_POSITION_AFTER_RELOAD.bitrateSwitch; - // Bind to Period start and end - var position = Math.min(Math.max(period.start, pos), (_a = period.end) !== null && _a !== void 0 ? _a : Infinity); - var autoPlay = !((_b = observation.paused.pending) !== null && _b !== void 0 ? _b : playbackObserver.getIsPaused()); - callbacks.waitingMediaSourceReload({ - bufferType: adaptation.type, - period: period, - position: position, - autoPlay: autoPlay - }); - }, { - includeLastObservation: true, - clearSignal: fnCancelSignal + // Just ask to reload + _config$getCurrent = config/* default */.Z.getCurrent(), DELTA_POSITION_AFTER_RELOAD = _config$getCurrent.DELTA_POSITION_AFTER_RELOAD; + bufferType = adaptation.type; + return _context.abrupt("return", createReloadRequest(playbackObserver, function (_ref4) { + var position = _ref4.position, + autoPlay = _ref4.autoPlay; + callbacks.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay }); - })); - case 6: - _iterator = adaptation_stream_createForOfIteratorHelperLoose(switchStrat.value); - case 7: - if ((_step = _iterator()).done) { - _context.next = 15; + }, DELTA_POSITION_AFTER_RELOAD.bitrateSwitch, period, fnCancelSignal)); + case 8: + _iterator3 = adaptation_stream_createForOfIteratorHelperLoose(switchStrat.value); + case 9: + if ((_step3 = _iterator3()).done) { + _context.next = 17; break; } - range = _step.value; - _context.next = 11; + range = _step3.value; + _context.next = 13; return segmentBuffer.removeBuffer(range.start, range.end, fnCancelSignal); - case 11: + case 13: if (!fnCancelSignal.isCancelled()) { - _context.next = 13; + _context.next = 15; break; } return _context.abrupt("return"); - case 13: - _context.next = 7; - break; case 15: + _context.next = 9; + break; + case 17: if (!(switchStrat.type === "flush-buffer")) { - _context.next = 19; + _context.next = 21; break; } callbacks.needsBufferFlush(); if (!fnCancelSignal.isCancelled()) { - _context.next = 19; + _context.next = 21; break; } return _context.abrupt("return"); - case 19: - return _context.abrupt("break", 21); - case 20: + case 21: + return _context.abrupt("break", 23); + case 22: // Should be impossible (0,assert_unreachable/* default */.Z)(switchStrat); - case 21: - // TODO not as reference anymore? There seem to be no need anymore - representationsList = (0,utils_reference/* createSharedReference */.$l)(choice.representations); - representationsList.finish(); - // Start-up Adaptive logic - _representationEstima = representationEstimator({ - manifest: manifest, - period: period, - adaptation: adaptation - }, currentRepresentation, representationsList, playbackObserver, fnCancelSignal), estimateRef = _representationEstima.estimates, abrCallbacks = _representationEstima.callbacks; - /** Emit at each bitrate estimate done by the IRepresentationEstimator. */ - estimateRef.onUpdate(function (_ref2) { - var bitrate = _ref2.bitrate; - if (bitrate === undefined || bitrate === previouslyEmittedBitrate) { - return; - } - previouslyEmittedBitrate = bitrate; - log/* default */.Z.debug("Stream: new " + adaptation.type + " bitrate estimate", bitrate); - callbacks.bitrateEstimationChange({ - type: adaptation.type, - bitrate: bitrate - }); - }, { - emitCurrentValue: true, - clearSignal: fnCancelSignal - }); - recursivelyCreateRepresentationStreams(estimateRef, abrCallbacks, fnCancelSignal); - case 26: + case 23: + recursivelyCreateRepresentationStreams(fnCancelSignal); + case 24: case "end": return _context.stop(); } @@ -45294,16 +45248,7 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { })); return _onRepresentationsChoiceChange.apply(this, arguments); } - function recursivelyCreateRepresentationStreams(estimateRef, abrCallbacks, fnCancelSignal) { - /** Allows a `RepresentationStream` to easily fetch media segments. */ - var segmentFetcher = segmentFetcherCreator.createSegmentFetcher(adaptation.type, /* eslint-disable @typescript-eslint/unbound-method */ - { - onRequestBegin: abrCallbacks.requestBegin, - onRequestEnd: abrCallbacks.requestEnd, - onProgress: abrCallbacks.requestProgress, - onMetrics: abrCallbacks.metrics - }); - /* eslint-enable @typescript-eslint/unbound-method */ + function recursivelyCreateRepresentationStreams(fnCancelSignal) { /** * `TaskCanceller` triggered when the current `RepresentationStream` is * terminating and as such the next one might be immediately created @@ -45342,19 +45287,6 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { clearSignal: repStreamTerminatingCanceller.signal, emitCurrentValue: true }); - /** - * Recursively create `RepresentationStream`s according to the last - * Representation estimate. - */ - var fastSwitchThreshold = (0,utils_reference/* createSharedReference */.$l)(0); - if (options.enableFastSwitching) { - estimateRef.onUpdate(function (estimate) { - fastSwitchThreshold.setValueIfChanged(estimate === null || estimate === void 0 ? void 0 : estimate.knownStableBitrate); - }, { - clearSignal: repStreamTerminatingCanceller.signal, - emitCurrentValue: true - }); - } var repInfo = { type: adaptation.type, period: period, @@ -45394,36 +45326,29 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { } repStreamTerminatingCanceller.cancel(); - return recursivelyCreateRepresentationStreams(estimateRef, abrCallbacks, fnCancelSignal); + return recursivelyCreateRepresentationStreams(fnCancelSignal); } }; - createRepresentationStream(representation, segmentFetcher, terminateCurrentStream, fastSwitchThreshold, representationStreamCallbacks, fnCancelSignal); + createRepresentationStream(representation, terminateCurrentStream, representationStreamCallbacks, fnCancelSignal); } /** * Create and returns a new `RepresentationStream`, linked to the * given Representation. * @param {Object} representation - The Representation the * `RepresentationStream` has to be created for. - * @param {Object} segmentFetcher - Allows to easily fetch segments. * @param {Object} terminateCurrentStream - Gives termination orders, * indicating that the `RepresentationStream` should stop what it's doing. - * @param {Object} fastSwitchThreshold - Used to determine when - * "fast-switching" is possible. * @param {Object} representationStreamCallbacks - Callbacks to call on * various `RepresentationStream` events. * @param {Object} fnCancelSignal - `CancellationSignal` which will abort * anything this function is doing and free allocated resources. */ - function createRepresentationStream(representation, segmentFetcher, terminateCurrentStream, fastSwitchThreshold, representationStreamCallbacks, fnCancelSignal) { - /** - * `TaskCanceller` triggered when the `RepresentationStream` calls its - * `terminating` callback. - */ - var terminatingRepStreamCanceller = new task_canceller/* default */.ZP(); - terminatingRepStreamCanceller.linkToSignal(fnCancelSignal); + function createRepresentationStream(representation, terminateCurrentStream, representationStreamCallbacks, fnCancelSignal) { + var bufferGoalCanceller = new task_canceller/* default */.ZP(); + bufferGoalCanceller.linkToSignal(fnCancelSignal); var bufferGoal = (0,utils_reference/* createMappedReference */.lR)(wantedBufferAhead, function (prev) { return prev * getBufferGoalRatio(representation); - }, terminatingRepStreamCanceller.signal); + }, bufferGoalCanceller.signal); var maxBufferSize = adaptation.type === "video" ? maxVideoBufferSize : (0,utils_reference/* createSharedReference */.$l)(Infinity); log/* default */.Z.info("Stream: changing representation", adaptation.type, representation.id, representation.bitrate); var updatedCallbacks = (0,object_assign/* default */.Z)({}, representationStreamCallbacks, { @@ -45447,12 +45372,12 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { // We wait 4 seconds to let the situation evolve by itself before // retrying loading segments with a lower buffer goal (0,cancellable_sleep/* default */.Z)(4000, adapStreamCanceller.signal).then(function () { - return createRepresentationStream(representation, segmentFetcher, terminateCurrentStream, fastSwitchThreshold, representationStreamCallbacks, fnCancelSignal); + return createRepresentationStream(representation, terminateCurrentStream, representationStreamCallbacks, fnCancelSignal); })["catch"](noop/* default */.Z); } }, terminating: function terminating() { - terminatingRepStreamCanceller.cancel(); + bufferGoalCanceller.cancel(); representationStreamCallbacks.terminating(); } }); @@ -45474,6 +45399,38 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) { fastSwitchThreshold: fastSwitchThreshold } }, updatedCallbacks, fnCancelSignal); + // reload if the Representation disappears from the Manifest + manifest.addEventListener("manifestUpdate", function (updates) { + for (var _iterator = adaptation_stream_createForOfIteratorHelperLoose(updates.updatedPeriods), _step; !(_step = _iterator()).done;) { + var element = _step.value; + if (element.period.id === period.id) { + var _loop = function _loop() { + var adap = _step2.value; + if (adap.id === adaptation.id) { + var bufferType = adaptation.type; + return { + v: createReloadRequest(playbackObserver, function (_ref3) { + var position = _ref3.position, + autoPlay = _ref3.autoPlay; + callbacks.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay + }); + }, 0, period, fnCancelSignal) + }; + } + }; + for (var _iterator2 = adaptation_stream_createForOfIteratorHelperLoose(element.result.removedAdaptations), _step2; !(_step2 = _iterator2()).done;) { + var _ret = _loop(); + if (typeof _ret === "object") return _ret.v; + } + } else if (element.period.start > period.start) { + break; + } + } + }, fnCancelSignal); } /** * @param {Object} representation @@ -45860,7 +45817,7 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { adaptationRef.onUpdate(function (choice) { // As an IIFE to profit from async/await while respecting onUpdate's signature (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() { - var _a, streamCanceller, segmentBufferStatus, periodEnd, _config$getCurrent, DELTA_POSITION_AFTER_RELOAD, relativePosAfterSwitch, adaptation, representations, readyState, segmentBuffer, playbackInfos, strategy, _iterator, _step, _step$value, start, end; + var _a, streamCanceller, segmentBufferStatus, periodEnd, _config$getCurrent, DELTA_POSITION_AFTER_RELOAD, relativePosAfterSwitch, adaptation, representations, readyState, segmentBuffer, playbackInfos, strategy, _iterator3, _step3, _step3$value, start, end; return regenerator_default().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: @@ -45890,7 +45847,16 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { _context.next = 15; break; } - return _context.abrupt("return", askForMediaSourceReload(0, streamCanceller.signal)); + return _context.abrupt("return", createReloadRequest(playbackObserver, function (_ref3) { + var position = _ref3.position, + autoPlay = _ref3.autoPlay; + callbacks.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay + }); + }, 0, period, streamCanceller.signal)); case 15: periodEnd = (_a = period.end) !== null && _a !== void 0 ? _a : Infinity; if (!(period.start > periodEnd)) { @@ -45944,7 +45910,7 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { * delta to the current position so we can re-play back some media in the * new Adaptation to give some context back. * This value contains this relative position, in seconds. - * @see askForMediaSourceReload + * @see createMediaSourceReloadRequester */ _config$getCurrent = config/* default */.Z.getCurrent(), DELTA_POSITION_AFTER_RELOAD = _config$getCurrent.DELTA_POSITION_AFTER_RELOAD; relativePosAfterSwitch = isFirstAdaptationSwitch ? 0 : bufferType === "audio" ? DELTA_POSITION_AFTER_RELOAD.trackSwitch.audio : bufferType === "video" ? DELTA_POSITION_AFTER_RELOAD.trackSwitch.video : DELTA_POSITION_AFTER_RELOAD.trackSwitch.other; @@ -45953,8 +45919,43 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { _context.next = 39; break; } - return _context.abrupt("return", askForMediaSourceReload(relativePosAfterSwitch, streamCanceller.signal)); + return _context.abrupt("return", createReloadRequest(playbackObserver, function (_ref4) { + var position = _ref4.position, + autoPlay = _ref4.autoPlay; + callbacks.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay + }); + }, relativePosAfterSwitch, period, streamCanceller.signal)); case 39: + // Reload if the Adaptation disappears from the manifest + manifest.addEventListener("manifestUpdate", function (updates) { + // If current period has been unexpectedly removed, ask to reload + for (var _iterator = period_stream_createForOfIteratorHelperLoose(updates.updatedPeriods), _step; !(_step = _iterator()).done;) { + var element = _step.value; + if (element.period.id === period.id) { + for (var _iterator2 = period_stream_createForOfIteratorHelperLoose(element.result.removedAdaptations), _step2; !(_step2 = _iterator2()).done;) { + var adap = _step2.value; + if (adap.id === adaptation.id) { + return createReloadRequest(playbackObserver, function (_ref5) { + var position = _ref5.position, + autoPlay = _ref5.autoPlay; + callbacks.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay + }); + }, relativePosAfterSwitch, period, streamCanceller.signal); + } + } + } else if (element.period.start > period.start) { + break; + } + } + }, currentStreamCanceller.signal); adaptation = choice.adaptation, representations = choice.representations; log/* default */.Z.info("Stream: Updating " + bufferType + " adaptation", "A: " + adaptation.id, "P: " + period.start); callbacks.adaptationChange({ @@ -45963,11 +45964,11 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { period: period }); if (!streamCanceller.isUsed()) { - _context.next = 44; + _context.next = 45; break; } return _context.abrupt("return"); - case 44: + case 45: readyState = playbackObserver.getReadyState(); segmentBuffer = createOrReuseSegmentBuffer(segmentBuffersStore, bufferType, adaptation, options); playbackInfos = { @@ -45976,57 +45977,66 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { }; strategy = getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, choice.switchingMode, playbackInfos, options); if (!(strategy.type === "needs-reload")) { - _context.next = 50; + _context.next = 51; break; } - return _context.abrupt("return", askForMediaSourceReload(relativePosAfterSwitch, streamCanceller.signal)); - case 50: - _context.next = 52; + return _context.abrupt("return", createReloadRequest(playbackObserver, function (_ref6) { + var position = _ref6.position, + autoPlay = _ref6.autoPlay; + callbacks.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay + }); + }, relativePosAfterSwitch, period, streamCanceller.signal)); + case 51: + _context.next = 53; return segmentBuffersStore.waitForUsableBuffers(streamCanceller.signal); - case 52: + case 53: if (!streamCanceller.isUsed()) { - _context.next = 54; + _context.next = 55; break; } return _context.abrupt("return"); - case 54: + case 55: if (!(strategy.type === "flush-buffer" || strategy.type === "clean-buffer")) { - _context.next = 68; + _context.next = 69; break; } - _iterator = period_stream_createForOfIteratorHelperLoose(strategy.value); - case 56: - if ((_step = _iterator()).done) { - _context.next = 64; + _iterator3 = period_stream_createForOfIteratorHelperLoose(strategy.value); + case 57: + if ((_step3 = _iterator3()).done) { + _context.next = 65; break; } - _step$value = _step.value, start = _step$value.start, end = _step$value.end; - _context.next = 60; + _step3$value = _step3.value, start = _step3$value.start, end = _step3$value.end; + _context.next = 61; return segmentBuffer.removeBuffer(start, end, streamCanceller.signal); - case 60: + case 61: if (!streamCanceller.isUsed()) { - _context.next = 62; + _context.next = 63; break; } return _context.abrupt("return"); - case 62: - _context.next = 56; + case 63: + _context.next = 57; break; - case 64: + case 65: if (!(strategy.type === "flush-buffer")) { - _context.next = 68; + _context.next = 69; break; } callbacks.needsBufferFlush(); if (!streamCanceller.isUsed()) { - _context.next = 68; + _context.next = 69; break; } return _context.abrupt("return"); - case 68: + case 69: garbageCollectors.get(segmentBuffer)(streamCanceller.signal); createAdaptationStream(adaptation, representations, segmentBuffer, streamCanceller.signal); - case 70: + case 71: case "end": return _context.stop(); } @@ -46091,51 +46101,6 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) { callbacks.error(error); } } - /** - * Regularly ask to reload the MediaSource on each playback observation - * performed by the playback observer. - * - * If and only if the Period currently played corresponds to the concerned - * Period, applies an offset to the reloaded position corresponding to - * `deltaPos`. - * This can be useful for example when switching the audio/video tracks, where - * you might want to give back some context if that was the currently played - * track. - * - * @param {number} deltaPos - If the concerned Period is playing at the time - * this function is called, we will add this value, in seconds, to the current - * position to indicate the position we should reload at. - * This value allows to give back context (by replaying some media data) after - * a switch. - * @param {Object} cancelSignal - */ - function askForMediaSourceReload(deltaPos, cancelSignal) { - // We begin by scheduling a micro-task to reduce the possibility of race - // conditions where `askForMediaSourceReload` would be called synchronously before - // the next observation (which may reflect very different playback conditions) - // is actually received. - // It can happen when `askForMediaSourceReload` is called as a side-effect of - // the same event that triggers the playback observation to be emitted. - next_tick_default()(function () { - playbackObserver.listen(function (observation) { - var _a, _b; - var currentTime = playbackObserver.getCurrentTime(); - var pos = currentTime + deltaPos; - // Bind to Period start and end - var position = Math.min(Math.max(period.start, pos), (_a = period.end) !== null && _a !== void 0 ? _a : Infinity); - var autoPlay = !((_b = observation.paused.pending) !== null && _b !== void 0 ? _b : playbackObserver.getIsPaused()); - callbacks.waitingMediaSourceReload({ - bufferType: bufferType, - period: period, - position: position, - autoPlay: autoPlay - }); - }, { - includeLastObservation: true, - clearSignal: cancelSignal - }); - }); - } } /** * @param {string} bufferType @@ -46362,6 +46327,7 @@ function stream_orchestrator_arrayLikeToArray(arr, len) { if (len == null || len + /** * Create and manage the various "Streams" needed for the content to * play: @@ -46497,7 +46463,13 @@ function StreamOrchestrator(content, playbackObserver, representationEstimator, includeLastObservation: true }); manifest.addEventListener("decipherabilityUpdate", function (evt) { + if (orchestratorCancelSignal.isCancelled()) { + return; + } onDecipherabilityUpdates(evt)["catch"](function (err) { + if (orchestratorCancelSignal.isCancelled()) { + return; + } currentCanceller.cancel(); callbacks.error(err); }); @@ -46510,7 +46482,7 @@ function StreamOrchestrator(content, playbackObserver, representationEstimator, var consecutivePeriodStreamCb = Object.assign(Object.assign({}, callbacks), { waitingMediaSourceReload: function waitingMediaSourceReload(payload) { // Only reload the MediaSource when the more immediately required - // Period is the one asking for it + // Period is the one it is asked for var firstPeriod = periodList.head(); if (firstPeriod === undefined || firstPeriod.id !== payload.period.id) { callbacks.lockedStream({ @@ -46791,6 +46763,7 @@ function StreamOrchestrator(content, playbackObserver, representationEstimator, } }); period(periodStreamArgs, periodStreamCallbacks, currentStreamCanceller.signal); + handleUnexpectedManifestUpdates(currentStreamCanceller.signal); /** * Create `PeriodStream` for the next Period, specified under `nextPeriod`. * @param {Object} nextPeriod @@ -46816,6 +46789,62 @@ function StreamOrchestrator(content, playbackObserver, representationEstimator, }; manageConsecutivePeriodStreams(bufferType, nextPeriod, consecutivePeriodStreamCb, nextStreamInfo.canceller.signal); } + /** + * Check on Manifest updates that the Manifest still appears coherent + * regarding its internal Period structure to what we created for now, + * handling cases where it does not. + * @param {Object} innerCancelSignal - When that cancel signal emits, stop + * performing checks. + */ + function handleUnexpectedManifestUpdates(innerCancelSignal) { + manifest.addEventListener("manifestUpdate", function (updates) { + var _loop = function _loop() { + var period = _step2.value; + if (period.id === basePeriod.id) { + // Check that this was not just one of the earliests Periods that + // was removed, in which case this is a normal cleanup scenario + if (manifest.periods.length > 0 && manifest.periods[0].start <= period.start) { + createReloadRequest(playbackObserver, function (_ref3) { + var position = _ref3.position, + autoPlay = _ref3.autoPlay; + consecutivePeriodStreamCb.waitingMediaSourceReload({ + bufferType: bufferType, + period: period, + position: position, + autoPlay: autoPlay + }); + }, 0, { + start: undefined, + end: undefined + }, innerCancelSignal); + } + } else if (period.start > basePeriod.start) { + return "break"; + } + }; + // If current period has been unexpectedly removed, ask to reload + for (var _iterator2 = stream_orchestrator_createForOfIteratorHelperLoose(updates.removedPeriods), _step2; !(_step2 = _iterator2()).done;) { + var _ret = _loop(); + if (_ret === "break") break; + } + if (updates.addedPeriods.length > 0) { + // If the next period changed, cancel the next created one if one + if (nextStreamInfo !== null) { + var newNextPeriod = manifest.getPeriodAfter(basePeriod); + if (newNextPeriod === null || nextStreamInfo.period.id !== newNextPeriod.id) { + log/* default */.Z.warn("Stream: Destroying next PeriodStream due to new one being added", bufferType, nextStreamInfo.period.start); + consecutivePeriodStreamCb.periodStreamCleared({ + type: bufferType, + manifest: manifest, + period: nextStreamInfo.period + }); + nextStreamInfo.canceller.cancel(); + nextStreamInfo = null; + } + } + } + }, innerCancelSignal); + } } } /** @@ -48602,9 +48631,6 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer) manifest.addEventListener("manifestUpdate", function () { _this5.trigger("manifestUpdate", null); }, initCanceller.signal); - manifest.addEventListener("decipherabilityUpdate", function (args) { - _this5.trigger("decipherabilityUpdate", args); - }, initCanceller.signal); log/* default */.Z.debug("Init: Calculating initial time"); initialTime = getInitialTime(manifest, lowLatencyMode, startAt); log/* default */.Z.debug("Init: Initial time calculated:", initialTime); @@ -48617,11 +48643,11 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer) segmentFetcherCreator = new segment(transport, segmentRequestOptions, initCanceller.signal); this.trigger("manifestReady", manifest); if (!initCanceller.isUsed()) { - _context.next = 25; + _context.next = 24; break; } return _context.abrupt("return"); - case 25: + case 24: bufferOnMediaSource = this._startBufferingOnMediaSource.bind(this); triggerEvent = this.trigger.bind(this); onFatalError = this._onFatalError.bind(this); // handle initial load and reloads @@ -48636,7 +48662,7 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer) * @param {Object} currentCanceller * @param {boolean} shouldPlay */ - case 29: + case 28: case "end": return _context.stop(); } @@ -48707,7 +48733,17 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer) speed: speed, startTime: initialTime }); - var rebufferingController = this._createRebufferingController(playbackObserver, manifest, speed, cancelSignal); + var rebufferingController = this._createRebufferingController(playbackObserver, manifest, segmentBuffersStore, speed, cancelSignal); + rebufferingController.addEventListener("needsReload", function () { + // NOTE couldn't both be always calculated at event destination? + // Maybe there are exceptions? + var position = initialSeekPerformed.getValue() ? playbackObserver.getCurrentTime() : initialTime; + var autoplay = initialPlayPerformed.getValue() ? !playbackObserver.getIsPaused() : autoPlay; + onReloadOrder({ + position: position, + autoPlay: autoplay + }); + }, cancelSignal); var contentTimeBoundariesObserver = this._createContentTimeBoundariesObserver(manifest, mediaSource, streamObserver, segmentBuffersStore, cancelSignal); /** * Emit a "loaded" events once the initial play has been performed and the @@ -48855,8 +48891,8 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer) self.trigger("periodStreamCleared", value); }, - bitrateEstimationChange: function bitrateEstimationChange(value) { - return self.trigger("bitrateEstimationChange", value); + bitrateEstimateChange: function bitrateEstimateChange(value) { + return self.trigger("bitrateEstimateChange", value); }, addedSegment: function addedSegment(value) { return self.trigger("addedSegment", value); @@ -48970,9 +49006,9 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer) * @param {Object} cancelSignal * @returns {Object} */; - _proto._createRebufferingController = function _createRebufferingController(playbackObserver, manifest, speed, cancelSignal) { + _proto._createRebufferingController = function _createRebufferingController(playbackObserver, manifest, segmentBuffersStore, speed, cancelSignal) { var _this8 = this; - var rebufferingController = new rebuffering_controller/* default */.Z(playbackObserver, manifest, speed); + var rebufferingController = new rebuffering_controller/* default */.Z(playbackObserver, manifest, segmentBuffersStore, speed); // Bubble-up events rebufferingController.addEventListener("stalled", function (evt) { return _this8.trigger("stalled", evt); @@ -49020,7 +49056,6 @@ function option_utils_arrayLikeToArray(arr, len) { if (len == null || len > arr. - /** * Parse options given to the API constructor and set default options as found * in the config. @@ -49036,17 +49071,10 @@ function parseConstructorOptions(options) { var wantedBufferAhead; var maxVideoBufferSize; var videoElement; - var initialVideoBitrate; - var initialAudioBitrate; - var minAudioBitrate; - var minVideoBitrate; - var maxAudioBitrate; - var maxVideoBitrate; + var baseBandwidth; var _config$getCurrent = config/* default */.Z.getCurrent(), - DEFAULT_INITIAL_BITRATES = _config$getCurrent.DEFAULT_INITIAL_BITRATES, - DEFAULT_LIMIT_VIDEO_WIDTH = _config$getCurrent.DEFAULT_LIMIT_VIDEO_WIDTH, - DEFAULT_MIN_BITRATES = _config$getCurrent.DEFAULT_MIN_BITRATES, - DEFAULT_MAX_BITRATES = _config$getCurrent.DEFAULT_MAX_BITRATES, + DEFAULT_BASE_BANDWIDTH = _config$getCurrent.DEFAULT_BASE_BANDWIDTH, + DEFAULT_VIDEO_RESOLUTION_LIMIT = _config$getCurrent.DEFAULT_VIDEO_RESOLUTION_LIMIT, DEFAULT_MAX_BUFFER_AHEAD = _config$getCurrent.DEFAULT_MAX_BUFFER_AHEAD, DEFAULT_MAX_BUFFER_BEHIND = _config$getCurrent.DEFAULT_MAX_BUFFER_BEHIND, DEFAULT_MAX_VIDEO_BUFFER_SIZE = _config$getCurrent.DEFAULT_MAX_VIDEO_BUFFER_SIZE, @@ -49090,7 +49118,7 @@ function parseConstructorOptions(options) { } } - var limitVideoWidth = (0,is_null_or_undefined/* default */.Z)(options.limitVideoWidth) ? DEFAULT_LIMIT_VIDEO_WIDTH : !!options.limitVideoWidth; + var videoResolutionLimit = (0,is_null_or_undefined/* default */.Z)(options.videoResolutionLimit) ? DEFAULT_VIDEO_RESOLUTION_LIMIT : options.videoResolutionLimit; var throttleVideoBitrateWhenHidden = (0,is_null_or_undefined/* default */.Z)(options.throttleVideoBitrateWhenHidden) ? DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN : !!options.throttleVideoBitrateWhenHidden; if ((0,is_null_or_undefined/* default */.Z)(options.videoElement)) { videoElement = document.createElement("video"); @@ -49102,78 +49130,26 @@ function parseConstructorOptions(options) { /* eslint-enable max-len */ } - if ((0,is_null_or_undefined/* default */.Z)(options.initialVideoBitrate)) { - initialVideoBitrate = DEFAULT_INITIAL_BITRATES.video; + if ((0,is_null_or_undefined/* default */.Z)(options.baseBandwidth)) { + baseBandwidth = DEFAULT_BASE_BANDWIDTH; } else { - initialVideoBitrate = Number(options.initialVideoBitrate); - if (isNaN(initialVideoBitrate)) { + baseBandwidth = Number(options.baseBandwidth); + if (isNaN(baseBandwidth)) { /* eslint-disable max-len */ - throw new Error("Invalid initialVideoBitrate parameter. Should be a number."); + throw new Error("Invalid baseBandwidth parameter. Should be a number."); /* eslint-enable max-len */ } } - if ((0,is_null_or_undefined/* default */.Z)(options.initialAudioBitrate)) { - initialAudioBitrate = DEFAULT_INITIAL_BITRATES.audio; - } else { - initialAudioBitrate = Number(options.initialAudioBitrate); - if (isNaN(initialAudioBitrate)) { - /* eslint-disable max-len */ - throw new Error("Invalid initialAudioBitrate parameter. Should be a number."); - /* eslint-enable max-len */ - } - } - - if ((0,is_null_or_undefined/* default */.Z)(options.minVideoBitrate)) { - minVideoBitrate = DEFAULT_MIN_BITRATES.video; - } else { - minVideoBitrate = Number(options.minVideoBitrate); - if (isNaN(minVideoBitrate)) { - throw new Error("Invalid maxVideoBitrate parameter. Should be a number."); - } - } - if ((0,is_null_or_undefined/* default */.Z)(options.minAudioBitrate)) { - minAudioBitrate = DEFAULT_MIN_BITRATES.audio; - } else { - minAudioBitrate = Number(options.minAudioBitrate); - if (isNaN(minAudioBitrate)) { - throw new Error("Invalid minAudioBitrate parameter. Should be a number."); - } - } - if ((0,is_null_or_undefined/* default */.Z)(options.maxVideoBitrate)) { - maxVideoBitrate = DEFAULT_MAX_BITRATES.video; - } else { - maxVideoBitrate = Number(options.maxVideoBitrate); - if (isNaN(maxVideoBitrate)) { - throw new Error("Invalid maxVideoBitrate parameter. Should be a number."); - } else if (minVideoBitrate > maxVideoBitrate) { - throw new Error("Invalid maxVideoBitrate parameter. Its value, \"" + (maxVideoBitrate + "\", is inferior to the set minVideoBitrate, \"") + (minVideoBitrate + "\"")); - } - } - if ((0,is_null_or_undefined/* default */.Z)(options.maxAudioBitrate)) { - maxAudioBitrate = DEFAULT_MAX_BITRATES.audio; - } else { - maxAudioBitrate = Number(options.maxAudioBitrate); - if (isNaN(maxAudioBitrate)) { - throw new Error("Invalid maxAudioBitrate parameter. Should be a number."); - } else if (minAudioBitrate > maxAudioBitrate) { - throw new Error("Invalid maxAudioBitrate parameter. Its value, \"" + (maxAudioBitrate + "\", is inferior to the set minAudioBitrate, \"") + (minAudioBitrate + "\"")); - } - } return { maxBufferAhead: maxBufferAhead, maxBufferBehind: maxBufferBehind, - limitVideoWidth: limitVideoWidth, + videoResolutionLimit: videoResolutionLimit, videoElement: videoElement, wantedBufferAhead: wantedBufferAhead, maxVideoBufferSize: maxVideoBufferSize, throttleVideoBitrateWhenHidden: throttleVideoBitrateWhenHidden, - initialAudioBitrate: initialAudioBitrate, - initialVideoBitrate: initialVideoBitrate, - minAudioBitrate: minAudioBitrate, - minVideoBitrate: minVideoBitrate, - maxAudioBitrate: maxAudioBitrate, - maxVideoBitrate: maxVideoBitrate + baseBandwidth: baseBandwidth }; } /** @@ -49205,11 +49181,10 @@ function checkReloadOptions(options) { * * Throws if any mandatory option is not set. * @param {Object|undefined} options - * @param {Object} ctx - The player context, needed for some default values. * @returns {Object} */ function parseLoadVideoOptions(options) { - var _a, _b, _c, _d, _e, _f, _g; + var _a, _b, _c; var url; var transport; var keySystems; @@ -49220,15 +49195,14 @@ function parseLoadVideoOptions(options) { DEFAULT_AUTO_PLAY = _config$getCurrent2.DEFAULT_AUTO_PLAY, DEFAULT_CODEC_SWITCHING_BEHAVIOR = _config$getCurrent2.DEFAULT_CODEC_SWITCHING_BEHAVIOR, DEFAULT_ENABLE_FAST_SWITCHING = _config$getCurrent2.DEFAULT_ENABLE_FAST_SWITCHING, - DEFAULT_MANUAL_BITRATE_SWITCHING_MODE = _config$getCurrent2.DEFAULT_MANUAL_BITRATE_SWITCHING_MODE, DEFAULT_TEXT_TRACK_MODE = _config$getCurrent2.DEFAULT_TEXT_TRACK_MODE; if ((0,is_null_or_undefined/* default */.Z)(options)) { throw new Error("No option set on loadVideo"); } if (!(0,is_null_or_undefined/* default */.Z)(options.url)) { url = String(options.url); - } else if ((0,is_null_or_undefined/* default */.Z)((_a = options.transportOptions) === null || _a === void 0 ? void 0 : _a.initialManifest) && (0,is_null_or_undefined/* default */.Z)((_b = options.transportOptions) === null || _b === void 0 ? void 0 : _b.manifestLoader)) { - throw new Error("Unable to load a content: no url set on loadVideo.\n" + "Please provide at least either an `url` argument, a " + "`transportOptions.initialManifest` option or a " + "`transportOptions.manifestLoader` option so the RxPlayer " + "can load the content."); + } else if ((0,is_null_or_undefined/* default */.Z)(options.initialManifest) && (0,is_null_or_undefined/* default */.Z)(options.manifestLoader)) { + throw new Error("Unable to load a content: no url set on loadVideo.\n" + "Please provide at least either an `url` argument, a " + "`initialManifest` option or a " + "`manifestLoader` option so the RxPlayer " + "can load the content."); } if ((0,is_null_or_undefined/* default */.Z)(options.transport)) { throw new Error("No transport set on loadVideo"); @@ -49245,29 +49219,21 @@ function parseLoadVideoOptions(options) { if (typeof keySystem.type !== "string" || typeof keySystem.getLicense !== "function") { throw new Error("Invalid key system given: Missing type string or " + "getLicense callback"); } - if (!(0,is_null_or_undefined/* default */.Z)(keySystem.onKeyStatusesChange)) { - (0,warn_once/* default */.Z)("`keySystems[].onKeyStatusesChange` is deprecated and won't " + "be present in the next major version. " + "Please open an issue if you still need this."); - } - if (!(0,is_null_or_undefined/* default */.Z)(keySystem.throwOnLicenseExpiration)) { - (0,warn_once/* default */.Z)("`keySystems[].throwOnLicenseExpiration` is deprecated and won't " + "be present in the next major version. " + "Please open an issue if you still need this."); - } } } var lowLatencyMode = options.lowLatencyMode === undefined ? false : !!options.lowLatencyMode; - var transportOptsArg = typeof options.transportOptions === "object" && options.transportOptions !== null ? options.transportOptions : {}; - var initialManifest = (_c = options.transportOptions) === null || _c === void 0 ? void 0 : _c.initialManifest; - var minimumManifestUpdateInterval = (_e = (_d = options.transportOptions) === null || _d === void 0 ? void 0 : _d.minimumManifestUpdateInterval) !== null && _e !== void 0 ? _e : 0; + var initialManifest = options.initialManifest; + var minimumManifestUpdateInterval = (_a = options.minimumManifestUpdateInterval) !== null && _a !== void 0 ? _a : 0; + var defaultAudioTrackSwitchingMode = (_b = options.defaultAudioTrackSwitchingMode) !== null && _b !== void 0 ? _b : undefined; + if (defaultAudioTrackSwitchingMode !== undefined && !(0,array_includes/* default */.Z)(["seamless", "direct", "reload"], defaultAudioTrackSwitchingMode)) { + log/* default */.Z.warn("The `defaultAudioTrackSwitchingMode` loadVideo option must match one of " + "the following strategy name:\n" + "- `seamless`\n" + "- `direct`\n" + "- `reload`"); + defaultAudioTrackSwitchingMode = undefined; + } var onCodecSwitch = (0,is_null_or_undefined/* default */.Z)(options.onCodecSwitch) ? DEFAULT_CODEC_SWITCHING_BEHAVIOR : options.onCodecSwitch; if (!(0,array_includes/* default */.Z)(["continue", "reload"], onCodecSwitch)) { log/* default */.Z.warn("The `onCodecSwitch` loadVideo option must match one of " + "the following string:\n" + "- `continue`\n" + "- `reload`\n" + "If badly set, " + DEFAULT_CODEC_SWITCHING_BEHAVIOR + " will be used as default"); onCodecSwitch = DEFAULT_CODEC_SWITCHING_BEHAVIOR; } - var transportOptions = (0,object_assign/* default */.Z)({}, transportOptsArg, { - lowLatencyMode: lowLatencyMode - }); - // remove already parsed data to simplify the `transportOptions` object - delete transportOptions.initialManifest; - delete transportOptions.minimumManifestUpdateInterval; if ((0,is_null_or_undefined/* default */.Z)(options.textTrackMode)) { textTrackMode = DEFAULT_TEXT_TRACK_MODE; } else { @@ -49276,7 +49242,6 @@ function parseLoadVideoOptions(options) { } textTrackMode = options.textTrackMode; } - var manualBitrateSwitchingMode = (_f = options.manualBitrateSwitchingMode) !== null && _f !== void 0 ? _f : DEFAULT_MANUAL_BITRATE_SWITCHING_MODE; var enableFastSwitching = (0,is_null_or_undefined/* default */.Z)(options.enableFastSwitching) ? DEFAULT_ENABLE_FAST_SWITCHING : options.enableFastSwitching; if (textTrackMode === "html") { // TODO Better way to express that in TypeScript? @@ -49301,30 +49266,41 @@ function parseLoadVideoOptions(options) { startAt = options.startAt; } } - var networkConfig = (_g = options.networkConfig) !== null && _g !== void 0 ? _g : {}; - // TODO without cast - /* eslint-disable @typescript-eslint/consistent-type-assertions */ + var requestConfig = (_c = options.requestConfig) !== null && _c !== void 0 ? _c : {}; + // All those eslint disable are needed because the option is voluntarily + // hidden from the base type to limit discovery of this hidden API. + /* eslint-disable @typescript-eslint/no-explicit-any */ + /* eslint-disable @typescript-eslint/no-unsafe-assignment */ + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ return { + __priv_patchLastSegmentInSidx: options.__priv_patchLastSegmentInSidx, + /* eslint-enable @typescript-eslint/no-explicit-any */ + /* eslint-enable @typescript-eslint/no-unsafe-assignment */ + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + checkMediaSegmentIntegrity: options.checkMediaSegmentIntegrity, autoPlay: autoPlay, + defaultAudioTrackSwitchingMode: defaultAudioTrackSwitchingMode, enableFastSwitching: enableFastSwitching, - keySystems: keySystems, initialManifest: initialManifest, + keySystems: keySystems, lowLatencyMode: lowLatencyMode, - manualBitrateSwitchingMode: manualBitrateSwitchingMode, + manifestLoader: options.manifestLoader, + manifestUpdateUrl: options.manifestUpdateUrl, minimumManifestUpdateInterval: minimumManifestUpdateInterval, - networkConfig: networkConfig, + requestConfig: requestConfig, onCodecSwitch: onCodecSwitch, + referenceDateTime: options.referenceDateTime, + representationFilter: options.representationFilter, + segmentLoader: options.segmentLoader, + serverSyncInfos: options.serverSyncInfos, startAt: startAt, textTrackElement: textTrackElement, textTrackMode: textTrackMode, transport: transport, - transportOptions: transportOptions, url: url }; - /* eslint-enable @typescript-eslint/consistent-type-assertions */ } - ;// CONCATENATED MODULE: ./src/core/api/playback_observer.ts /** * Copyright 2015 CANAL+ Group @@ -49912,8 +49888,6 @@ function generateReadOnlyObserver(src, transform, cancellationSignal) { - - /** * Class handling track changes and quality locking for a single Period and * Adaptation type. @@ -49928,42 +49902,55 @@ var TrackDispatcher = /*#__PURE__*/function (_EventEmitter) { * synchronously. * @param {Object} manifest * @param {Object} adaptationRef - * @param {Object|null} initialTrackInfo */ - function TrackDispatcher(manifest, adaptationRef, initialTrackInfo) { + function TrackDispatcher(manifest, adaptationRef) { var _this; _this = _EventEmitter.call(this) || this; _this._canceller = new task_canceller/* default */.ZP(); _this._manifest = manifest; _this._adaptationRef = adaptationRef; + _this._updateToken = false; + return _this; + } + /** + * @param {Object|null} initialTrackInfo + */ + var _proto = TrackDispatcher.prototype; + _proto.start = function start(initialTrackInfo) { + this._updateToken = true; if (initialTrackInfo === null) { - _this._lastEmitted = initialTrackInfo; - adaptationRef.setValue(null); - return (0,assertThisInitialized/* default */.Z)(_this); + this._lastEmitted = null; + this._updateToken = false; + this._adaptationRef.setValue(null); + return; + } + var reference = this._constructLockedRepresentationsReference(initialTrackInfo); + if (!this._updateToken) { + return; } - var reference = _this._constructLockedRepresentationsReference(initialTrackInfo); - _this._lastEmitted = { + this._lastEmitted = { adaptation: initialTrackInfo.adaptation, switchingMode: initialTrackInfo.switchingMode, lockedRepresentations: null }; - adaptationRef.setValue({ + this._updateToken = false; + this._adaptationRef.setValue({ adaptation: initialTrackInfo.adaptation, switchingMode: initialTrackInfo.switchingMode, representations: reference }); - return _this; } /** * Update the wanted track on the Reference linked to this `TrackDispatcher`. * @param {Object|null} newTrackInfo - */ - var _proto = TrackDispatcher.prototype; + */; _proto.updateTrack = function updateTrack(newTrackInfo) { + this._updateToken = true; if (newTrackInfo === null) { if (this._lastEmitted === null) { return; } + this._updateToken = false; this._canceller.cancel(); // has no point but let's still create one for simplicity sake this._canceller = new task_canceller/* default */.ZP(); @@ -49976,11 +49963,15 @@ var TrackDispatcher = /*#__PURE__*/function (_EventEmitter) { this._canceller.cancel(); this._canceller = new task_canceller/* default */.ZP(); var reference = this._constructLockedRepresentationsReference(newTrackInfo); + if (!this._updateToken) { + return; + } this._lastEmitted = { adaptation: adaptation, switchingMode: switchingMode, lockedRepresentations: null }; + this._updateToken = false; this._adaptationRef.setValue({ adaptation: adaptation, switchingMode: switchingMode, @@ -50034,11 +50025,9 @@ var TrackDispatcher = /*#__PURE__*/function (_EventEmitter) { } } if (playableRepresentations.length <= 0) { - var adaptationType = trackInfo.adaptation.type; - var noRepErr = new media_error/* default */.Z("NO_PLAYABLE_REPRESENTATION", "No Representation in the chosen " + adaptationType + " Adaptation can be played", { - adaptation: trackInfo.adaptation - }); - throw noRepErr; + trackInfo.adaptation.isSupported = false; + self.trigger("noPlayableRepresentation", null); + return; } // Check if Locked Representations have changed var oldRef = reference.getValue(); @@ -50106,6 +50095,8 @@ var TrackDispatcher = /*#__PURE__*/function (_EventEmitter) { + + /** * Class helping with the management of the audio, video and text tracks and * qualities. @@ -50119,11 +50110,13 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { (0,inheritsLoose/* default */.Z)(TracksStore, _EventEmitter); function TracksStore(args) { var _this; + var _a; _this = _EventEmitter.call(this) || this; _this._storedPeriodInfo = []; _this._isDisposed = false; _this._cachedPeriodInfo = new WeakMap(); _this._isTrickModeTrackEnabled = args.preferTrickModeTracks; + _this._defaultAudioTrackSwitchingMode = (_a = args.defaultAudioTrackSwitchingMode) !== null && _a !== void 0 ? _a : config/* default */.Z.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE; return _this; } /** @@ -50148,6 +50141,8 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { _proto.updatePeriodList = function updatePeriodList(manifest) { var _this2 = this; var _a, _b, _c; + var _config$getCurrent = config/* default */.Z.getCurrent(), + DEFAULT_VIDEO_TRACK_SWITCHING_MODE = _config$getCurrent.DEFAULT_VIDEO_TRACK_SWITCHING_MODE; var periods = manifest.periods; // We assume that they are always sorted chronologically // In dev mode, perform a runtime check that this is the case @@ -50175,10 +50170,10 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { return a.id === curWantedTextTrack.adaptation.id; }); if (!stillHere) { - log/* default */.Z.warn("TracksStore: Chosen text Adaptation not available anymore"); + log/* default */.Z.warn("TS: Chosen text Adaptation not available anymore"); var periodInfo = _this2._storedPeriodInfo[_i2]; periodInfo.text.storedSettings = null; - _this2.trigger("autoTrackSwitch", { + _this2.trigger("trackUpdate", { period: toExposedPeriod(newPeriod), trackType: "text", reason: "missing" @@ -50203,7 +50198,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { return a.id === curWantedVideoTrack.adaptation.id; }); if (!_stillHere) { - log/* default */.Z.warn("TracksStore: Chosen video Adaptation not available anymore"); + log/* default */.Z.warn("TS: Chosen video Adaptation not available anymore"); var _periodItem = _this2._storedPeriodInfo[_i2]; var storedSettings; if (videoAdaptations.length === 0) { @@ -50215,12 +50210,12 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { storedSettings = { adaptationBase: adaptationBase, adaptation: adaptation, - switchingMode: "seamless", + switchingMode: DEFAULT_VIDEO_TRACK_SWITCHING_MODE, lockedRepresentations: lockedRepresentations }; } _periodItem.video.storedSettings = storedSettings; - _this2.trigger("autoTrackSwitch", { + _this2.trigger("trackUpdate", { period: toExposedPeriod(newPeriod), trackType: "video", reason: "missing" @@ -50245,15 +50240,15 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { return a.id === curWantedAudioTrack.adaptation.id; }); if (!_stillHere2) { - log/* default */.Z.warn("TracksStore: Chosen audio Adaptation not available anymore"); + log/* default */.Z.warn("TS: Chosen audio Adaptation not available anymore"); var _periodItem2 = _this2._storedPeriodInfo[_i2]; var _storedSettings = audioAdaptations.length === 0 ? null : { adaptation: audioAdaptations[0], - switchingMode: "seamless", + switchingMode: _this2._defaultAudioTrackSwitchingMode, lockedRepresentations: (0,utils_reference/* default */.ZP)(null) }; _periodItem2.audio.storedSettings = _storedSettings; - _this2.trigger("autoTrackSwitch", { + _this2.trigger("trackUpdate", { period: toExposedPeriod(newPeriod), trackType: "audio", reason: "missing" @@ -50280,7 +50275,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { _i2--; } } else { - var newPeriodInfo = generatePeriodInfo(newPeriod, true, _this2._isTrickModeTrackEnabled); + var newPeriodInfo = generatePeriodInfo(newPeriod, true, _this2._isTrickModeTrackEnabled, _this2._defaultAudioTrackSwitchingMode); // oldPeriod.start > newPeriod.start: insert newPeriod before _this2._storedPeriodInfo.splice(_i2, 0, newPeriodInfo); addedPeriods.push(newPeriodInfo); @@ -50298,7 +50293,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { var _this$_storedPeriodIn; // Add further new Period var periodsToAdd = periods.slice(newPListIdx).map(function (p) { - return generatePeriodInfo(p, true, _this2._isTrickModeTrackEnabled); + return generatePeriodInfo(p, true, _this2._isTrickModeTrackEnabled, _this2._defaultAudioTrackSwitchingMode); }); (_this$_storedPeriodIn = this._storedPeriodInfo).push.apply(_this$_storedPeriodIn, periodsToAdd); addedPeriods.push.apply(addedPeriods, periodsToAdd); @@ -50334,7 +50329,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { var periodObj = getPeriodItem(this._storedPeriodInfo, period.id); if (periodObj === undefined) { // The Period has not yet been added. - periodObj = this._manuallyAddPeriod(period); + periodObj = this._addPeriod(period); this.trigger("newAvailablePeriods", [{ id: period.id, start: period.start, @@ -50342,13 +50337,57 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { }]); } if (periodObj[bufferType].dispatcher !== null) { - log/* default */.Z.error("TracksStore: Subject already added for " + bufferType + " " + ("and Period " + period.start)); + log/* default */.Z.error("TS: Subject already added for " + bufferType + " " + ("and Period " + period.start)); return; } var trackSetting = periodObj[bufferType].storedSettings; - var dispatcher = new TrackDispatcher(manifest, adaptationRef, trackSetting); + var dispatcher = new TrackDispatcher(manifest, adaptationRef); periodObj[bufferType].dispatcher = dispatcher; + dispatcher.addEventListener("noPlayableRepresentation", function () { + var _a, _b, _c; + var nextAdaptation = (0,array_find/* default */.Z)(period.getAdaptationsForType(bufferType), function (a) { + var playableRepresentations = a.getPlayableRepresentations(); + return playableRepresentations.length > 0; + }); + if (nextAdaptation === undefined) { + var noRepErr = new media_error/* default */.Z("NO_PLAYABLE_REPRESENTATION", "No " + bufferType + " Representation can be played", { + adaptation: undefined + }); + _this3.trigger("error", noRepErr); + _this3.dispose(); + return; + } + var typeInfo = (_a = getPeriodItem(_this3._storedPeriodInfo, period.id)) === null || _a === void 0 ? void 0 : _a[bufferType]; + if ((0,is_null_or_undefined/* default */.Z)(typeInfo)) { + return; + } + var switchingMode = bufferType === "audio" ? _this3._defaultAudioTrackSwitchingMode : "reload"; + var storedSettings = { + adaptation: nextAdaptation, + switchingMode: switchingMode, + lockedRepresentations: (0,utils_reference/* default */.ZP)(null) + }; + typeInfo.storedSettings = storedSettings; + _this3.trigger("trackUpdate", { + period: toExposedPeriod(period), + trackType: bufferType, + reason: "no-playable-representation" + }); + // The previous event trigger could have had side-effects, so we + // re-check if we're still mostly in the same state + if (_this3._isDisposed) { + return; // Someone disposed the `TracksStore` on the previous side-effect + } + + typeInfo = (_b = getPeriodItem(_this3._storedPeriodInfo, period.id)) === null || _b === void 0 ? void 0 : _b[bufferType]; + if ((0,is_null_or_undefined/* default */.Z)(typeInfo) || typeInfo.storedSettings !== storedSettings) { + return; + } + (_c = typeInfo.dispatcher) === null || _c === void 0 ? void 0 : _c.updateTrack(storedSettings); + }); dispatcher.addEventListener("noPlayableLockedRepresentation", function () { + // TODO check that it doesn't already lead to segment loading or MediaSource + // reloading trackSetting === null || trackSetting === void 0 ? void 0 : trackSetting.lockedRepresentations.setValue(null); _this3.trigger("brokenRepresentationsLock", { period: { @@ -50359,6 +50398,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { trackType: bufferType }); }); + dispatcher.start(trackSetting); } /** * Remove shared reference to choose an "audio", "video" or "text" Adaptation @@ -50369,13 +50409,13 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { _proto.removeTrackReference = function removeTrackReference(bufferType, period) { var periodIndex = findPeriodIndex(this._storedPeriodInfo, period); if (periodIndex === undefined) { - log/* default */.Z.warn("TracksStore: " + bufferType + " not found for period", period.start); + log/* default */.Z.warn("TS: " + bufferType + " not found for period", period.start); return; } var periodObj = this._storedPeriodInfo[periodIndex]; var choiceItem = periodObj[bufferType]; if ((choiceItem === null || choiceItem === void 0 ? void 0 : choiceItem.dispatcher) === null) { - log/* default */.Z.warn("TracksStore: TrackDispatcher already removed for " + bufferType + " " + ("and Period " + period.start)); + log/* default */.Z.warn("TS: TrackDispatcher already removed for " + bufferType + " " + ("and Period " + period.start)); return; } choiceItem.dispatcher.dispose(); @@ -50431,14 +50471,14 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { return; } this._isTrickModeTrackEnabled = false; - this._resetVideoTrackChoices(); + this._resetVideoTrackChoices("trickmode-disabled"); }; _proto.enableVideoTrickModeTracks = function enableVideoTrickModeTracks() { if (this._isTrickModeTrackEnabled) { return; } this._isTrickModeTrackEnabled = true; - this._resetVideoTrackChoices(); + this._resetVideoTrackChoices("trickmode-enabled"); } /** * Reset the TracksStore's Period objects: @@ -50479,9 +50519,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { * `null` if no Audio Representation should be locked. */; _proto.setAudioTrack = function setAudioTrack(periodObj, wantedId, switchingMode, reprsToLock) { - var _config$getCurrent = config/* default */.Z.getCurrent(), - DEFAULT_AUDIO_TRACK_SWITCHING_MODE = _config$getCurrent.DEFAULT_AUDIO_TRACK_SWITCHING_MODE; - return this._setAudioOrTextTrack("audio", periodObj, wantedId, switchingMode !== null && switchingMode !== void 0 ? switchingMode : DEFAULT_AUDIO_TRACK_SWITCHING_MODE, reprsToLock); + return this._setAudioOrTextTrack("audio", periodObj, wantedId, switchingMode !== null && switchingMode !== void 0 ? switchingMode : this._defaultAudioTrackSwitchingMode, reprsToLock); } /** * Set text track based on the ID of its Adaptation for a given added Period. @@ -50502,6 +50540,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { * `null` if no Audio Representation should be locked. */; _proto._setAudioOrTextTrack = function _setAudioOrTextTrack(bufferType, periodObj, wantedId, switchingMode, reprsToLock) { + var _a; var period = periodObj.period; var wantedAdaptation = (0,array_find/* default */.Z)(period.getSupportedAdaptations(bufferType), function (_ref) { var id = _ref.id; @@ -50515,22 +50554,33 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { if (reprsToLock === null) { lockedRepresentations = (0,utils_reference/* default */.ZP)(null); } else { - var _config$getCurrent2 = config/* default */.Z.getCurrent(), - DEFAULT_AUDIO_TRACK_SWITCHING_MODE = _config$getCurrent2.DEFAULT_AUDIO_TRACK_SWITCHING_MODE; var representationsToLock = this._getRepresentationsToLock(wantedAdaptation, reprsToLock); - var repSwitchingMode = bufferType === "audio" ? DEFAULT_AUDIO_TRACK_SWITCHING_MODE : "direct"; + var repSwitchingMode = bufferType === "audio" ? this._defaultAudioTrackSwitchingMode : "direct"; lockedRepresentations = (0,utils_reference/* default */.ZP)({ representations: representationsToLock, switchingMode: repSwitchingMode }); } - typeInfo.storedSettings = { + var storedSettings = { adaptation: wantedAdaptation, switchingMode: switchingMode, lockedRepresentations: lockedRepresentations }; - if (typeInfo.dispatcher !== null) { - typeInfo.dispatcher.updateTrack(typeInfo.storedSettings); + typeInfo.storedSettings = storedSettings; + this.trigger("trackUpdate", { + period: toExposedPeriod(period), + trackType: bufferType, + reason: "manual" + }); + // The previous event trigger could have had side-effects, so we + // re-check if we're still mostly in the same state + if (this._isDisposed) { + return; // Someone disposed the `TracksStore` on the previous side-effect + } + + var newPeriodItem = getPeriodItem(this._storedPeriodInfo, period.id); + if (newPeriodItem !== undefined && newPeriodItem[bufferType].storedSettings === storedSettings) { + (_a = newPeriodItem[bufferType].dispatcher) === null || _a === void 0 ? void 0 : _a.updateTrack(storedSettings); } } /** @@ -50544,6 +50594,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { * `null` if no Video Representation should be locked. */; _proto.setVideoTrack = function setVideoTrack(periodObj, wantedId, switchingMode, reprsToLock) { + var _a; var period = periodObj.period; var wantedAdaptation = (0,array_find/* default */.Z)(period.getSupportedAdaptations("video"), function (_ref2) { var id = _ref2.id; @@ -50552,8 +50603,8 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { if (wantedAdaptation === undefined) { throw new Error("Wanted video track not found."); } - var _config$getCurrent3 = config/* default */.Z.getCurrent(), - DEFAULT_VIDEO_TRACK_SWITCHING_MODE = _config$getCurrent3.DEFAULT_VIDEO_TRACK_SWITCHING_MODE; + var _config$getCurrent2 = config/* default */.Z.getCurrent(), + DEFAULT_VIDEO_TRACK_SWITCHING_MODE = _config$getCurrent2.DEFAULT_VIDEO_TRACK_SWITCHING_MODE; var typeInfo = periodObj.video; var newAdaptation = getRightVideoTrack(wantedAdaptation, this._isTrickModeTrackEnabled); var lockedRepresentations; @@ -50567,14 +50618,27 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { switchingMode: repSwitchingMode }); } - typeInfo.storedSettings = { + var storedSettings = { adaptationBase: wantedAdaptation, switchingMode: switchingMode !== null && switchingMode !== void 0 ? switchingMode : DEFAULT_VIDEO_TRACK_SWITCHING_MODE, adaptation: newAdaptation, lockedRepresentations: lockedRepresentations }; - if (typeInfo.dispatcher !== null) { - typeInfo.dispatcher.updateTrack(typeInfo.storedSettings); + typeInfo.storedSettings = storedSettings; + this.trigger("trackUpdate", { + period: toExposedPeriod(period), + trackType: "video", + reason: "manual" + }); + // The previous event trigger could have had side-effects, so we + // re-check if we're still mostly in the same state + if (this._isDisposed) { + return; // Someone disposed the `TracksStore` on the previous side-effect + } + + var newPeriodItem = getPeriodItem(this._storedPeriodInfo, period.id); + if (newPeriodItem !== undefined && newPeriodItem.video.storedSettings === storedSettings) { + (_a = newPeriodItem.video.dispatcher) === null || _a === void 0 ? void 0 : _a.updateTrack(storedSettings); } } /** @@ -50585,7 +50649,7 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { * @throws Error - Throws if the period given has not been added */; _proto.disableTrack = function disableTrack(periodObj, bufferType) { - var _a; + var _a, _b; var trackInfo = periodObj[bufferType]; if (trackInfo.storedSettings === null) { return; @@ -50595,8 +50659,20 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { (_a = periodObj[bufferType].storedSettings) === null || _a === void 0 ? void 0 : _a.lockedRepresentations.finish(); } trackInfo.storedSettings = null; - if (trackInfo.dispatcher !== null) { - trackInfo.dispatcher.updateTrack(null); + this.trigger("trackUpdate", { + period: toExposedPeriod(periodObj.period), + trackType: bufferType, + reason: "manual" + }); + // The previous event trigger could have had side-effects, so we + // re-check if we're still mostly in the same state + if (this._isDisposed) { + return; // Someone disposed the `TracksStore` on the previous side-effect + } + + var newPeriodItem = getPeriodItem(this._storedPeriodInfo, periodObj.period.id); + if (newPeriodItem !== undefined && newPeriodItem[bufferType].storedSettings === null) { + (_b = newPeriodItem[bufferType].dispatcher) === null || _b === void 0 ? void 0 : _b.updateTrack(null); } } /** @@ -50743,8 +50819,8 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { if (storedSettings === null) { return; } - var _config$getCurrent4 = config/* default */.Z.getCurrent(), - DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE = _config$getCurrent4.DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE; + var _config$getCurrent3 = config/* default */.Z.getCurrent(), + DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE = _config$getCurrent3.DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE; var filtered = this._getRepresentationsToLock(storedSettings.adaptation, lockSettings.representations); var switchingMode = (_a = lockSettings.switchingMode) !== null && _a !== void 0 ? _a : DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE; storedSettings.lockedRepresentations.setValue({ @@ -50758,8 +50834,8 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { if (storedSettings === null) { return; } - var _config$getCurrent5 = config/* default */.Z.getCurrent(), - DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE = _config$getCurrent5.DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE; + var _config$getCurrent4 = config/* default */.Z.getCurrent(), + DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE = _config$getCurrent4.DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE; var filtered = this._getRepresentationsToLock(storedSettings.adaptation, lockSettings.representations); var switchingMode = (_a = lockSettings.switchingMode) !== null && _a !== void 0 ? _a : DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE; storedSettings.lockedRepresentations.setValue({ @@ -50795,8 +50871,8 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { * @param {Period} period * @returns {Object} */; - _proto._manuallyAddPeriod = function _manuallyAddPeriod(period) { - var periodObj = generatePeriodInfo(period, false, this._isTrickModeTrackEnabled); + _proto._addPeriod = function _addPeriod(period) { + var periodObj = generatePeriodInfo(period, false, this._isTrickModeTrackEnabled, this._defaultAudioTrackSwitchingMode); for (var i = 0; i < this._storedPeriodInfo.length; i++) { if (this._storedPeriodInfo[i].period.start > period.start) { this._storedPeriodInfo.splice(i, 0, periodObj); @@ -50806,7 +50882,8 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { this._storedPeriodInfo.push(periodObj); return periodObj; }; - _proto._resetVideoTrackChoices = function _resetVideoTrackChoices() { + _proto._resetVideoTrackChoices = function _resetVideoTrackChoices(reason) { + var _a; for (var i = 0; i < this._storedPeriodInfo.length; i++) { var periodObj = this._storedPeriodInfo[i]; if (periodObj.video.storedSettings !== null) { @@ -50822,9 +50899,23 @@ var TracksStore = /*#__PURE__*/function (_EventEmitter) { // or added while the loop is running. var sliced = this._storedPeriodInfo.slice(); for (var _i3 = 0; _i3 < sliced.length; _i3++) { + var period = sliced[_i3].period; var videoItem = sliced[_i3].video; - if (videoItem.dispatcher !== null) { - videoItem.dispatcher.updateTrack(videoItem.storedSettings); + var storedSettings = videoItem.storedSettings; + this.trigger("trackUpdate", { + period: toExposedPeriod(period), + trackType: "video", + reason: reason + }); + // The previous event trigger could have had side-effects, so we + // re-check if we're still mostly in the same state + if (this._isDisposed) { + return; // Someone disposed the `TracksStore` on the previous side-effect + } + + var newPeriodItem = getPeriodItem(this._storedPeriodInfo, period.id); + if (newPeriodItem !== undefined && newPeriodItem.video.storedSettings === storedSettings) { + (_a = newPeriodItem.video.dispatcher) === null || _a === void 0 ? void 0 : _a.updateTrack(storedSettings); } } }; @@ -50912,17 +51003,16 @@ function getRightVideoTrack(adaptation, isTrickModeEnabled) { * @param {boolean} isTrickModeTrackEnabled * @returns {object} */ -function generatePeriodInfo(period, inManifest, isTrickModeTrackEnabled) { +function generatePeriodInfo(period, inManifest, isTrickModeTrackEnabled, defaultAudioTrackSwitchingMode) { var _a; var audioAdaptation = period.getSupportedAdaptations("audio")[0]; var baseVideoAdaptation = period.getSupportedAdaptations("video")[0]; var videoAdaptation = getRightVideoTrack(baseVideoAdaptation, isTrickModeTrackEnabled); - var _config$getCurrent6 = config/* default */.Z.getCurrent(), - DEFAULT_AUDIO_TRACK_SWITCHING_MODE = _config$getCurrent6.DEFAULT_AUDIO_TRACK_SWITCHING_MODE, - DEFAULT_VIDEO_TRACK_SWITCHING_MODE = _config$getCurrent6.DEFAULT_VIDEO_TRACK_SWITCHING_MODE; + var _config$getCurrent5 = config/* default */.Z.getCurrent(), + DEFAULT_VIDEO_TRACK_SWITCHING_MODE = _config$getCurrent5.DEFAULT_VIDEO_TRACK_SWITCHING_MODE; var audioSettings = audioAdaptation !== undefined ? { adaptation: audioAdaptation, - switchingMode: DEFAULT_AUDIO_TRACK_SWITCHING_MODE, + switchingMode: defaultAudioTrackSwitchingMode, lockedRepresentations: (0,utils_reference/* default */.ZP)(null) } : null; var videoSettings = videoAdaptation !== undefined ? { @@ -51068,8 +51158,10 @@ function constructPlayerStateReference(initializer, mediaElement, playbackObserv playerStateRef.setValue(newState); } } + } else if (playerStateRef.getValue() === "RELOADING" /* PLAYER_STATES.RELOADING */) { + playerStateRef.setValue(getLoadedContentState(mediaElement, null)); } else { - playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, null)); + updateStateIfLoaded(null); } }, cancelSignal); initializer.addEventListener("reloadingMediaSource", function () { @@ -51084,28 +51176,36 @@ function constructPlayerStateReference(initializer, mediaElement, playbackObserv var prevStallReason = null; initializer.addEventListener("stalled", function (s) { if (s !== prevStallReason) { - if (isLoadedState(playerStateRef.getValue())) { - playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, s)); - } + updateStateIfLoaded(s); prevStallReason = s; } }, cancelSignal); initializer.addEventListener("unstalled", function () { if (prevStallReason !== null) { - if (isLoadedState(playerStateRef.getValue())) { - playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, null)); - } + updateStateIfLoaded(null); prevStallReason = null; } }, cancelSignal); playbackObserver.listen(function (observation) { - if (isLoadedState(playerStateRef.getValue()) && (0,array_includes/* default */.Z)(["seeking", "ended", "play", "pause"], observation.event)) { - playerStateRef.setValueIfChanged(getLoadedContentState(mediaElement, prevStallReason)); + if ((0,array_includes/* default */.Z)(["seeking", "ended", "play", "pause"], observation.event)) { + updateStateIfLoaded(prevStallReason); } }, { clearSignal: cancelSignal }); return playerStateRef; + function updateStateIfLoaded(stallRes) { + if (!isLoadedState(playerStateRef.getValue())) { + return; + } + var newState = getLoadedContentState(mediaElement, stallRes); + var prevState = playerStateRef.getValue(); + // Some safety checks to avoid having nonsense state switches + if (prevState === "LOADED" /* PLAYER_STATES.LOADED */ && newState === "PAUSED" /* PLAYER_STATES.PAUSED */) { + return; + } + playerStateRef.setValueIfChanged(newState); + } } /** * Get state string for a _loaded_ content. @@ -51132,7 +51232,7 @@ function getLoadedContentState(mediaElement, stalledStatus) { return "ENDED" /* PLAYER_STATES.ENDED */; } - return stalledStatus === "seeking" ? "SEEKING" /* PLAYER_STATES.SEEKING */ : "BUFFERING" /* PLAYER_STATES.BUFFERING */; + return stalledStatus === "seeking" ? "SEEKING" /* PLAYER_STATES.SEEKING */ : stalledStatus === "freezing" ? "FREEZING" /* PLAYER_STATES.FREEZING */ : "BUFFERING" /* PLAYER_STATES.BUFFERING */; } return mediaElement.paused ? "PAUSED" /* PLAYER_STATES.PAUSED */ : "PLAYING" /* PLAYER_STATES.PLAYING */; @@ -51150,7 +51250,7 @@ function public_api_arrayLikeToArray(arr, len) { if (len == null || len > arr.le /** * Copyright 2015 CANAL+ Group * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License");publicapi * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -51194,7 +51294,8 @@ function public_api_arrayLikeToArray(arr, len) { if (len == null || len > arr.le var generateContentId = (0,id_generator/* default */.Z)(); var getPictureOnPictureStateRef = event_listeners/* getPictureOnPictureStateRef */.w0, getVideoVisibilityRef = event_listeners/* getVideoVisibilityRef */.it, - getVideoWidthRef = event_listeners/* getVideoWidthRef */.O0; + getElementResolutionRef = event_listeners/* getElementResolutionRef */.bD, + getScreenResolutionRef = event_listeners/* getScreenResolutionRef */.c9; /** * @class Player * @extends EventEmitter @@ -51212,15 +51313,10 @@ var Player = /*#__PURE__*/function (_EventEmitter) { } _this = _EventEmitter.call(this) || this; var _parseConstructorOpti = parseConstructorOptions(options), - initialAudioBitrate = _parseConstructorOpti.initialAudioBitrate, - initialVideoBitrate = _parseConstructorOpti.initialVideoBitrate, - limitVideoWidth = _parseConstructorOpti.limitVideoWidth, - minAudioBitrate = _parseConstructorOpti.minAudioBitrate, - minVideoBitrate = _parseConstructorOpti.minVideoBitrate, - maxAudioBitrate = _parseConstructorOpti.maxAudioBitrate, + baseBandwidth = _parseConstructorOpti.baseBandwidth, + videoResolutionLimit = _parseConstructorOpti.videoResolutionLimit, maxBufferAhead = _parseConstructorOpti.maxBufferAhead, maxBufferBehind = _parseConstructorOpti.maxBufferBehind, - maxVideoBitrate = _parseConstructorOpti.maxVideoBitrate, throttleVideoBitrateWhenHidden = _parseConstructorOpti.throttleVideoBitrateWhenHidden, videoElement = _parseConstructorOpti.videoElement, wantedBufferAhead = _parseConstructorOpti.wantedBufferAhead, @@ -51230,7 +51326,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) { // Workaround to support Firefox autoplay on FF 42. // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624 videoElement.preload = "auto"; - _this.version = /* PLAYER_VERSION */"3.31.0"; + _this.version = /* PLAYER_VERSION */"4.0.0-beta.2"; _this.log = log/* default */.Z; _this.state = "STOPPED"; _this.videoElement = videoElement; @@ -51248,24 +51344,12 @@ var Player = /*#__PURE__*/function (_EventEmitter) { }; _this._priv_bitrateInfos = { lastBitrates: { - audio: initialAudioBitrate, - video: initialVideoBitrate - }, - minAutoBitrates: { - audio: (0,utils_reference/* default */.ZP)(minAudioBitrate, _this._destroyCanceller.signal), - video: (0,utils_reference/* default */.ZP)(minVideoBitrate, _this._destroyCanceller.signal) - }, - maxAutoBitrates: { - audio: (0,utils_reference/* default */.ZP)(maxAudioBitrate, _this._destroyCanceller.signal), - video: (0,utils_reference/* default */.ZP)(maxVideoBitrate, _this._destroyCanceller.signal) - }, - manualBitrates: { - audio: (0,utils_reference/* default */.ZP)(-1, _this._destroyCanceller.signal), - video: (0,utils_reference/* default */.ZP)(-1, _this._destroyCanceller.signal) + audio: baseBandwidth, + video: baseBandwidth } }; _this._priv_throttleVideoBitrateWhenHidden = throttleVideoBitrateWhenHidden; - _this._priv_limitVideoWidth = limitVideoWidth; + _this._priv_videoResolutionLimit = videoResolutionLimit; _this._priv_mutedMemory = DEFAULT_UNMUTED_VOLUME; _this._priv_currentError = null; _this._priv_contentInfos = null; @@ -51404,18 +51488,26 @@ var Player = /*#__PURE__*/function (_EventEmitter) { */; _proto._priv_initializeContentPlayback = function _priv_initializeContentPlayback(options) { var _this2 = this; + var _a, _b, _c, _d; var autoPlay = options.autoPlay, + defaultAudioTrackSwitchingMode = options.defaultAudioTrackSwitchingMode, enableFastSwitching = options.enableFastSwitching, initialManifest = options.initialManifest, keySystems = options.keySystems, lowLatencyMode = options.lowLatencyMode, - manualBitrateSwitchingMode = options.manualBitrateSwitchingMode, minimumManifestUpdateInterval = options.minimumManifestUpdateInterval, - networkConfig = options.networkConfig, + requestConfig = options.requestConfig, onCodecSwitch = options.onCodecSwitch, startAt = options.startAt, transport = options.transport, - transportOptions = options.transportOptions, + checkMediaSegmentIntegrity = options.checkMediaSegmentIntegrity, + manifestLoader = options.manifestLoader, + manifestUpdateUrl = options.manifestUpdateUrl, + referenceDateTime = options.referenceDateTime, + representationFilter = options.representationFilter, + segmentLoader = options.segmentLoader, + serverSyncInfos = options.serverSyncInfos, + __priv_patchLastSegmentInSidx = options.__priv_patchLastSegmentInSidx, url = options.url; // Perform multiple checks on the given options if (this.videoElement === null) { @@ -51435,25 +51527,29 @@ var Player = /*#__PURE__*/function (_EventEmitter) { this._priv_currentError = null; throw new Error("transport \"" + transport + "\" not supported"); } - var transportPipelines = transportFn(transportOptions); - var offlineRetry = networkConfig.offlineRetry, - segmentRetry = networkConfig.segmentRetry, - manifestRetry = networkConfig.manifestRetry, - manifestRequestTimeout = networkConfig.manifestRequestTimeout, - segmentRequestTimeout = networkConfig.segmentRequestTimeout; + var transportPipelines = transportFn({ + lowLatencyMode: lowLatencyMode, + checkMediaSegmentIntegrity: checkMediaSegmentIntegrity, + manifestLoader: manifestLoader, + manifestUpdateUrl: manifestUpdateUrl, + referenceDateTime: referenceDateTime, + representationFilter: representationFilter, + segmentLoader: segmentLoader, + serverSyncInfos: serverSyncInfos, + __priv_patchLastSegmentInSidx: __priv_patchLastSegmentInSidx + }); /** Interface used to load and refresh the Manifest. */ var manifestRequestSettings = { lowLatencyMode: lowLatencyMode, - maxRetryRegular: manifestRetry, - maxRetryOffline: offlineRetry, - requestTimeout: manifestRequestTimeout, + maxRetry: (_a = requestConfig.manifest) === null || _a === void 0 ? void 0 : _a.maxRetry, + requestTimeout: (_b = requestConfig.manifest) === null || _b === void 0 ? void 0 : _b.timeout, minimumManifestUpdateInterval: minimumManifestUpdateInterval, initialManifest: initialManifest }; var relyOnVideoVisibilityAndSize = canRelyOnVideoVisibilityAndSize(); var throttlers = { throttleBitrate: {}, - limitWidth: {} + limitResolution: {} }; if (this._priv_throttleVideoBitrateWhenHidden) { if (!relyOnVideoVisibilityAndSize) { @@ -51466,22 +51562,23 @@ var Player = /*#__PURE__*/function (_EventEmitter) { }; } } - if (this._priv_limitVideoWidth) { + if (this._priv_videoResolutionLimit === "videoElement") { if (!relyOnVideoVisibilityAndSize) { - log/* default */.Z.warn("API: Can't apply limitVideoWidth because browser can't be " + "trusted for video size."); + log/* default */.Z.warn("API: Can't apply videoResolutionLimit because browser can't be " + "trusted for video size."); } else { - throttlers.limitWidth = { - video: getVideoWidthRef(videoElement, this._priv_pictureInPictureRef, currentContentCanceller.signal) + throttlers.limitResolution = { + video: getElementResolutionRef(videoElement, this._priv_pictureInPictureRef, currentContentCanceller.signal) }; } + } else if (this._priv_videoResolutionLimit === "screen") { + throttlers.limitResolution = { + video: getScreenResolutionRef(currentContentCanceller.signal) + }; } /** Options used by the adaptive logic. */ var adaptiveOptions = { initialBitrates: this._priv_bitrateInfos.lastBitrates, lowLatencyMode: lowLatencyMode, - manualBitrates: this._priv_bitrateInfos.manualBitrates, - minAutoBitrates: this._priv_bitrateInfos.minAutoBitrates, - maxAutoBitrates: this._priv_bitrateInfos.maxAutoBitrates, throttlers: throttlers }; /** Options used by the TextTrack SegmentBuffer. */ @@ -51493,14 +51590,12 @@ var Player = /*#__PURE__*/function (_EventEmitter) { }; var bufferOptions = (0,object_assign/* default */.Z)({ enableFastSwitching: enableFastSwitching, - manualBitrateSwitchingMode: manualBitrateSwitchingMode, onCodecSwitch: onCodecSwitch }, this._priv_bufferOptions); var segmentRequestOptions = { lowLatencyMode: lowLatencyMode, - maxRetryRegular: segmentRetry, - requestTimeout: segmentRequestTimeout, - maxRetryOffline: offlineRetry + maxRetry: (_c = requestConfig.segment) === null || _c === void 0 ? void 0 : _c.maxRetry, + requestTimeout: (_d = requestConfig.segment) === null || _d === void 0 ? void 0 : _d.timeout }; initializer = new MediaSourceContentInitializer({ adaptiveOptions: adaptiveOptions, @@ -51539,6 +51634,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) { contentId: generateContentId(), originalUrl: url, currentContentCanceller: currentContentCanceller, + defaultAudioTrackSwitchingMode: defaultAudioTrackSwitchingMode, initializer: initializer, isDirectFile: isDirectFile, segmentBuffersStore: null, @@ -51551,23 +51647,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) { }; // Bind events initializer.addEventListener("error", function (error) { - var formattedError = (0,format_error/* default */.Z)(error, { - defaultCode: "NONE", - defaultReason: "An unknown error stopped content playback." - }); - formattedError.fatal = true; - contentInfos.currentContentCanceller.cancel(); - _this2._priv_cleanUpCurrentContentState(); - _this2._priv_currentError = formattedError; - log/* default */.Z.error("API: The player stopped because of an error", error instanceof Error ? error : ""); - _this2._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */); - // TODO This condition is here because the eventual callback called when the - // player state is updated can launch a new content, thus the error will not - // be here anymore, in which case triggering the "error" event is unwanted. - // This is very ugly though, and we should probable have a better solution - if (_this2._priv_currentError === formattedError) { - _this2.trigger("error", formattedError); - } + _this2._priv_onFatalError(error, contentInfos); }); initializer.addEventListener("warning", function (error) { var formattedError = (0,format_error/* default */.Z)(error, { @@ -51593,21 +51673,6 @@ var Player = /*#__PURE__*/function (_EventEmitter) { initializer.addEventListener("streamEventSkip", function (streamEventSkip) { return _this2.trigger("streamEventSkip", streamEventSkip); }); - initializer.addEventListener("decipherabilityUpdate", function (decipherabilityUpdate) { - return _this2.trigger("decipherabilityUpdate", decipherabilityUpdate.map(function (i) { - return { - periodInfo: { - start: i.period.start, - end: i.period.end, - id: i.period.id - }, - trackType: i.adaptation.type, - trackId: i.adaptation.id, - representationId: i.representation.id, - isDecipherable: i.representation.decipherable - }; - })); - }); initializer.addEventListener("activePeriodChanged", function (periodInfo) { return _this2._priv_onActivePeriodChanged(contentInfos, periodInfo); }); @@ -51623,8 +51688,8 @@ var Player = /*#__PURE__*/function (_EventEmitter) { initializer.addEventListener("adaptationChange", function (adaptationInfo) { return _this2._priv_onAdaptationChange(contentInfos, adaptationInfo); }); - initializer.addEventListener("bitrateEstimationChange", function (bitrateEstimationInfo) { - return _this2._priv_onBitrateEstimationChange(bitrateEstimationInfo); + initializer.addEventListener("bitrateEstimateChange", function (bitrateEstimateInfo) { + return _this2._priv_onBitrateEstimateChange(bitrateEstimateInfo); }); initializer.addEventListener("manifestReady", function (manifest) { return _this2._priv_onManifestReady(contentInfos, manifest); @@ -51871,12 +51936,12 @@ var Player = /*#__PURE__*/function (_EventEmitter) { return this._priv_preferTrickModeTracks; } /** - * Returns the url of the currently considered Manifest, or of the content for + * Returns the URL(s) of the currently considered Manifest, or of the content for * directfile content. - * @returns {string|undefined} - Current URL. `undefined` if not known or no - * URL yet. + * @returns {Array.|undefined} - Current URL. `undefined` if not known + * or no URL yet. */; - _proto.getUrl = function getUrl() { + _proto.getContentUrls = function getContentUrls() { if (this._priv_contentInfos === null) { return undefined; } @@ -51885,10 +51950,10 @@ var Player = /*#__PURE__*/function (_EventEmitter) { manifest = _this$_priv_contentIn2.manifest, originalUrl = _this$_priv_contentIn2.originalUrl; if (isDirectFile) { - return originalUrl; + return originalUrl === undefined ? undefined : [originalUrl]; } if (manifest !== null) { - return manifest.getUrl(); + return manifest.getUrls(); } return undefined; } @@ -51929,7 +51994,11 @@ var Player = /*#__PURE__*/function (_EventEmitter) { throw new Error("Disposed player"); } var videoElement = this.videoElement; - return (0,ranges/* getLeftSizeOfRange */.L7)(videoElement.buffered, videoElement.currentTime); + var bufferGap = (0,ranges/* getLeftSizeOfRange */.L7)(videoElement.buffered, videoElement.currentTime); + if (bufferGap === Infinity) { + return 0; + } + return bufferGap; } /** * Get the current position, in s, in wall-clock time. @@ -52074,54 +52143,36 @@ var Player = /*#__PURE__*/function (_EventEmitter) { } } /** - * Returns currently considered bitrate for video segments. - * @returns {Number|undefined} + * Returns video Representation currently considered for the current Period. + * + * Returns `null` if no video track is playing for the current Period. + * + * Returns `undefined` either when are not currently playing any Period or + * when we don't know which Representation is playing. + * @returns {Object|null|undefined} */; - _proto.getVideoBitrate = function getVideoBitrate() { + _proto.getVideoRepresentation = function getVideoRepresentation() { var representations = this.__priv_getCurrentRepresentations(); - if (representations === null || (0,is_null_or_undefined/* default */.Z)(representations.video)) { + if (representations === null) { return undefined; } - return representations.video.bitrate; + return representations.video; } /** - * Returns currently considered bitrate for audio segments. - * @returns {Number|undefined} + * Returns audio Representation currently considered for the current Period. + * + * Returns `null` if no audio track is playing for the current Period. + * + * Returns `undefined` either when are not currently playing any Period or + * when we don't know which Representation is playing. + * @returns {Object|null|undefined} */; - _proto.getAudioBitrate = function getAudioBitrate() { + _proto.getAudioRepresentation = function getAudioRepresentation() { var representations = this.__priv_getCurrentRepresentations(); - if (representations === null || (0,is_null_or_undefined/* default */.Z)(representations.audio)) { + if (representations === null) { return undefined; } - return representations.audio.bitrate; - } - /** - * Returns minimum wanted video bitrate currently set. - * @returns {Number} - */; - _proto.getMinVideoBitrate = function getMinVideoBitrate() { - return this._priv_bitrateInfos.minAutoBitrates.video.getValue(); - } - /** - * Returns minimum wanted audio bitrate currently set. - * @returns {Number} - */; - _proto.getMinAudioBitrate = function getMinAudioBitrate() { - return this._priv_bitrateInfos.minAutoBitrates.audio.getValue(); - } - /** - * Returns maximum wanted video bitrate currently set. - * @returns {Number} - */; - _proto.getMaxVideoBitrate = function getMaxVideoBitrate() { - return this._priv_bitrateInfos.maxAutoBitrates.video.getValue(); - } - /** - * Returns maximum wanted audio bitrate currently set. - * @returns {Number} - */; - _proto.getMaxAudioBitrate = function getMaxAudioBitrate() { - return this._priv_bitrateInfos.maxAutoBitrates.audio.getValue(); + return representations.audio; } /** * Play/Resume the current video. @@ -52258,50 +52309,6 @@ var Player = /*#__PURE__*/function (_EventEmitter) { this.setVolume(this._priv_mutedMemory === 0 ? DEFAULT_UNMUTED_VOLUME : this._priv_mutedMemory); } } - /** - * Update the minimum video bitrate the user can switch to. - * @param {Number} btr - */; - _proto.setMinVideoBitrate = function setMinVideoBitrate(btr) { - var maxVideoBitrate = this._priv_bitrateInfos.maxAutoBitrates.video.getValue(); - if (btr > maxVideoBitrate) { - throw new Error("Invalid minimum video bitrate given. " + ("Its value, \"" + btr + "\" is superior the current maximum ") + ("video birate, \"" + maxVideoBitrate + "\".")); - } - this._priv_bitrateInfos.minAutoBitrates.video.setValue(btr); - } - /** - * Update the minimum audio bitrate the user can switch to. - * @param {Number} btr - */; - _proto.setMinAudioBitrate = function setMinAudioBitrate(btr) { - var maxAudioBitrate = this._priv_bitrateInfos.maxAutoBitrates.audio.getValue(); - if (btr > maxAudioBitrate) { - throw new Error("Invalid minimum audio bitrate given. " + ("Its value, \"" + btr + "\" is superior the current maximum ") + ("audio birate, \"" + maxAudioBitrate + "\".")); - } - this._priv_bitrateInfos.minAutoBitrates.audio.setValue(btr); - } - /** - * Update the maximum video bitrate the user can switch to. - * @param {Number} btr - */; - _proto.setMaxVideoBitrate = function setMaxVideoBitrate(btr) { - var minVideoBitrate = this._priv_bitrateInfos.minAutoBitrates.video.getValue(); - if (btr < minVideoBitrate) { - throw new Error("Invalid maximum video bitrate given. " + ("Its value, \"" + btr + "\" is inferior the current minimum ") + ("video birate, \"" + minVideoBitrate + "\".")); - } - this._priv_bitrateInfos.maxAutoBitrates.video.setValue(btr); - } - /** - * Update the maximum audio bitrate the user can switch to. - * @param {Number} btr - */; - _proto.setMaxAudioBitrate = function setMaxAudioBitrate(btr) { - var minAudioBitrate = this._priv_bitrateInfos.minAutoBitrates.audio.getValue(); - if (btr < minAudioBitrate) { - throw new Error("Invalid maximum audio bitrate given. " + ("Its value, \"" + btr + "\" is inferior the current minimum ") + ("audio birate, \"" + minAudioBitrate + "\".")); - } - this._priv_bitrateInfos.maxAutoBitrates.audio.setValue(btr); - } /** * Set the max buffer size for the buffer behind the current position. * Every buffer data before will be removed. @@ -52361,19 +52368,6 @@ var Player = /*#__PURE__*/function (_EventEmitter) { */; _proto.getMaxVideoBufferSize = function getMaxVideoBufferSize() { return this._priv_bufferOptions.maxVideoBufferSize.getValue(); - } - /** - * Returns type of current keysystem (e.g. playready, widevine) if the content - * is encrypted. null otherwise. - * @deprecated - * @returns {string|null} - */; - _proto.getCurrentKeySystem = function getCurrentKeySystem() { - (0,warn_once/* default */.Z)("`getCurrentKeySystem` is deprecated." + "Please use the `getKeySystemConfiguration` method instead."); - if (this.videoElement === null) { - throw new Error("Disposed player"); - } - return get_key_system_configuration_getCurrentKeySystem(this.videoElement); }; _proto.getCurrentPeriod = function getCurrentPeriod() { var _a; @@ -52962,19 +52956,31 @@ var Player = /*#__PURE__*/function (_EventEmitter) { } contentInfos.manifest = manifest; - var cancelSignal = contentInfos.currentContentCanceller.signal; this._priv_reloadingMetadata.manifest = manifest; - contentInfos.tracksStore = new TracksStore({ - preferTrickModeTracks: this._priv_preferTrickModeTracks + var tracksStore = new TracksStore({ + preferTrickModeTracks: this._priv_preferTrickModeTracks, + defaultAudioTrackSwitchingMode: contentInfos.defaultAudioTrackSwitchingMode }); - contentInfos.tracksStore.addEventListener("newAvailablePeriods", function (p) { + contentInfos.tracksStore = tracksStore; + tracksStore.addEventListener("newAvailablePeriods", function (p) { _this5.trigger("newAvailablePeriods", p); }); - contentInfos.tracksStore.addEventListener("brokenRepresentationsLock", function (e) { + tracksStore.addEventListener("brokenRepresentationsLock", function (e) { _this5.trigger("brokenRepresentationsLock", e); }); - contentInfos.tracksStore.addEventListener("autoTrackSwitch", function (e) { - _this5.trigger("autoTrackSwitch", e); + tracksStore.addEventListener("trackUpdate", function (e) { + var _a, _b; + _this5.trigger("trackUpdate", e); + var currentPeriod = (_b = (_a = _this5._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.currentPeriod) !== null && _b !== void 0 ? _b : undefined; + if (e.reason === "no-playable-representation" && e.period.id === (currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.id)) { + _this5._priv_onAvailableTracksMayHaveChanged(e.trackType); + } + }); + contentInfos.tracksStore.addEventListener("warning", function (err) { + _this5.trigger("warning", err); + }); + contentInfos.tracksStore.addEventListener("error", function (err) { + _this5._priv_onFatalError(err, contentInfos); }); contentInfos.tracksStore.updatePeriodList(manifest); manifest.addEventListener("manifestUpdate", function (updates) { @@ -52984,8 +52990,8 @@ var Player = /*#__PURE__*/function (_EventEmitter) { contentInfos.tracksStore.updatePeriodList(manifest); } var currentPeriod = (_b = (_a = _this5._priv_contentInfos) === null || _a === void 0 ? void 0 : _a.currentPeriod) !== null && _b !== void 0 ? _b : undefined; - var tracksStore = (_c = _this5._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.tracksStore; - if (currentPeriod === undefined || (0,is_null_or_undefined/* default */.Z)(tracksStore)) { + var currTracksStore = (_c = _this5._priv_contentInfos) === null || _c === void 0 ? void 0 : _c.tracksStore; + if (currentPeriod === undefined || (0,is_null_or_undefined/* default */.Z)(currTracksStore)) { return; } for (var _iterator = public_api_createForOfIteratorHelperLoose(updates.updatedPeriods), _step; !(_step = _iterator()).done;) { @@ -52993,21 +52999,68 @@ var Player = /*#__PURE__*/function (_EventEmitter) { if (update.period.id === currentPeriod.id) { if (update.result.addedAdaptations.length > 0 || update.result.removedAdaptations.length > 0) { // We might have new (or less) tracks, send events just to be sure - var periodRef = tracksStore.getPeriodObjectFromPeriod(currentPeriod); + var periodRef = currTracksStore.getPeriodObjectFromPeriod(currentPeriod); if (periodRef === undefined) { return; } - var audioTracks = tracksStore.getAvailableAudioTracks(periodRef); - _this5._priv_triggerEventIfNotStopped("availableAudioTracksChange", audioTracks !== null && audioTracks !== void 0 ? audioTracks : [], cancelSignal); - var textTracks = tracksStore.getAvailableTextTracks(periodRef); - _this5._priv_triggerEventIfNotStopped("availableTextTracksChange", textTracks !== null && textTracks !== void 0 ? textTracks : [], cancelSignal); - var videoTracks = tracksStore.getAvailableVideoTracks(periodRef); - _this5._priv_triggerEventIfNotStopped("availableVideoTracksChange", videoTracks !== null && videoTracks !== void 0 ? videoTracks : [], cancelSignal); + _this5._priv_onAvailableTracksMayHaveChanged("audio"); + _this5._priv_onAvailableTracksMayHaveChanged("text"); + _this5._priv_onAvailableTracksMayHaveChanged("video"); } } return; } }, contentInfos.currentContentCanceller.signal); + manifest.addEventListener("decipherabilityUpdate", function (elts) { + /** + * Array of tuples only including once the Period/Track combination, and + * only when it concerns the currently-selected track. + */ + var periodsAndTrackTypes = elts.reduce(function (acc, elt) { + var _a, _b, _c; + var isFound = (0,array_find/* default */.Z)(acc, function (x) { + return x[0].id === elt.period.id && x[1] === elt.adaptation.type; + }) === undefined; + if (!isFound) { + // Only consider the currently-selected tracks. + // NOTE: Maybe there's room for optimizations? Unclear. + var tStore = contentInfos.tracksStore; + if (tStore === null) { + return acc; + } + var isCurrent = false; + var periodRef = tStore.getPeriodObjectFromPeriod(elt.period); + if (periodRef === undefined) { + return acc; + } + switch (elt.adaptation.type) { + case "audio": + isCurrent = ((_a = tStore.getChosenAudioTrack(periodRef)) === null || _a === void 0 ? void 0 : _a.id) === elt.adaptation.id; + break; + case "video": + isCurrent = ((_b = tStore.getChosenVideoTrack(periodRef)) === null || _b === void 0 ? void 0 : _b.id) === elt.adaptation.id; + break; + case "text": + isCurrent = ((_c = tStore.getChosenTextTrack(periodRef)) === null || _c === void 0 ? void 0 : _c.id) === elt.adaptation.id; + break; + } + if (isCurrent) { + acc.push([elt.period, elt.adaptation.type]); + } + } + return acc; + }, []); + for (var _iterator2 = public_api_createForOfIteratorHelperLoose(periodsAndTrackTypes), _step2; !(_step2 = _iterator2()).done;) { + var _step2$value = _step2.value, + period = _step2$value[0], + trackType = _step2$value[1]; + _this5._priv_triggerEventIfNotStopped("representationListUpdate", { + period: period, + trackType: trackType, + reason: "decipherability-update" + }, contentInfos.currentContentCanceller.signal); + } + }, contentInfos.currentContentCanceller.signal); } /** * Triggered each times the current Period Changed. @@ -53228,13 +53281,15 @@ var Player = /*#__PURE__*/function (_EventEmitter) { * * @param {Object} value */; - _proto._priv_onBitrateEstimationChange = function _priv_onBitrateEstimationChange(_ref4) { + _proto._priv_onBitrateEstimateChange = function _priv_onBitrateEstimateChange(_ref4) { var type = _ref4.type, bitrate = _ref4.bitrate; if (bitrate !== undefined) { this._priv_bitrateInfos.lastBitrates[type] = bitrate; } - this.trigger("bitrateEstimationChange", { + // !!! undocumented API :O !!! + /* eslint-disable-next-line */ + this.trigger("__priv_bitrateEstimateChange", { type: type, bitrate: bitrate }); @@ -53359,6 +53414,76 @@ var Player = /*#__PURE__*/function (_EventEmitter) { return defaultValue; } return cb(tracksStore, periodRef); + } + /** + * Method to call when some event lead to a high for possibility that the + * available tracks for the given type have changed. + * Send the corresponding `available*Tracks` change event with the last + * available tracks. + * + * @param {string} trackType + * @param {Object|undefined} [oPeriodRef] - optional period object used by the + * `tracksStore` API, allows to optimize the method by bypassing this step. + */; + _proto._priv_onAvailableTracksMayHaveChanged = function _priv_onAvailableTracksMayHaveChanged(trackType, oPeriodRef) { + var contentInfos = this._priv_contentInfos; + if (contentInfos === null) { + return; + } + var currentPeriod = contentInfos.currentPeriod, + tracksStore = contentInfos.tracksStore, + currentContentCanceller = contentInfos.currentContentCanceller; + var cancelSignal = currentContentCanceller.signal; + if ((0,is_null_or_undefined/* default */.Z)(currentPeriod) || tracksStore === null) { + return; + } + var periodRef = oPeriodRef !== null && oPeriodRef !== void 0 ? oPeriodRef : tracksStore.getPeriodObjectFromPeriod(currentPeriod); + if (periodRef === undefined) { + return; + } + switch (trackType) { + case "video": + var videoTracks = tracksStore.getAvailableVideoTracks(periodRef); + this._priv_triggerEventIfNotStopped("availableVideoTracksChange", videoTracks !== null && videoTracks !== void 0 ? videoTracks : [], cancelSignal); + break; + case "audio": + var audioTracks = tracksStore.getAvailableAudioTracks(periodRef); + this._priv_triggerEventIfNotStopped("availableAudioTracksChange", audioTracks !== null && audioTracks !== void 0 ? audioTracks : [], cancelSignal); + break; + case "text": + var textTracks = tracksStore.getAvailableTextTracks(periodRef); + this._priv_triggerEventIfNotStopped("availableTextTracksChange", textTracks !== null && textTracks !== void 0 ? textTracks : [], cancelSignal); + break; + default: + (0,assert_unreachable/* default */.Z)(trackType); + } + } + /** + * Method to call when a fatal error lead to the stopping of the current + * content. + * + * @param {*} err - The error encountered. + * @param {Object} contentInfos - The `IPublicApiContentInfos` object linked + * to the content for which the error was received. + */; + _proto._priv_onFatalError = function _priv_onFatalError(err, contentInfos) { + var formattedError = (0,format_error/* default */.Z)(err, { + defaultCode: "NONE", + defaultReason: "An unknown error stopped content playback." + }); + formattedError.fatal = true; + contentInfos.currentContentCanceller.cancel(); + this._priv_cleanUpCurrentContentState(); + this._priv_currentError = formattedError; + log/* default */.Z.error("API: The player stopped because of an error", formattedError); + this._priv_setPlayerState("STOPPED" /* PLAYER_STATES.STOPPED */); + // TODO This condition is here because the eventual callback called when the + // player state is updated can launch a new content, thus the error will not + // be here anymore, in which case triggering the "error" event is unwanted. + // This is very ugly though, and we should probable have a better solution + if (this._priv_currentError === formattedError) { + this.trigger("error", formattedError); + } }; (0,createClass/* default */.Z)(Player, null, [{ key: "ErrorTypes", @@ -53394,7 +53519,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) { }]); return Player; }(event_emitter/* default */.Z); -Player.version = /* PLAYER_VERSION */"3.31.0"; +Player.version = /* PLAYER_VERSION */"4.0.0-beta.2"; /* harmony default export */ var public_api = (Player); ;// CONCATENATED MODULE: ./src/core/api/index.ts /** @@ -53426,7 +53551,7 @@ var features_object = __webpack_require__(7273); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + *j http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -53439,9 +53564,7 @@ var features_object = __webpack_require__(7273); /* eslint-disable @typescript-eslint/no-var-requires */ /** - * Selects the features to include based on environment variables. - * - * @param {Object} features + * Selects the features to include. */ function initializeFeaturesObject() { if (true) { @@ -53517,15 +53640,12 @@ function initializeFeaturesObject() { * limitations under the License. */ /** - * This file exports a Player class with a default feature set (depends on the - * environment variables set at build). - * + * This file exports a Player class with a default feature set. * This is the class used from a regular build. */ -// set initial features according to environment variables initializeFeaturesObject(); if (typeof __RX_PLAYER_DEBUG_MODE__ === "boolean" && __RX_PLAYER_DEBUG_MODE__) { log/* default */.Z.setLevel("DEBUG"); diff --git a/dist/rx-player.min.js b/dist/rx-player.min.js index 900bc05bfa5..4b60f9de89a 100644 --- a/dist/rx-player.min.js +++ b/dist/rx-player.min.js @@ -1,2 +1,2 @@ /*! For license information please see rx-player.min.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RxPlayer=t():e.RxPlayer=t()}(self,(function(){return function(){var e={3774:function(e,t,n){"use strict";n.d(t,{J:function(){return a},c:function(){return o}});var r=n(1946),i=n(2203).Z?void 0:window,a=void 0===i?void 0:(0,r.Z)(i.MediaSource)?(0,r.Z)(i.MozMediaSource)?(0,r.Z)(i.WebKitMediaSource)?i.MSMediaSource:i.WebKitMediaSource:i.MozMediaSource:i.MediaSource,o={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4}},3666:function(e,t,n){"use strict";n.d(t,{$u:function(){return p},SB:function(){return c},YM:function(){return u},fq:function(){return s},kD:function(){return o},lV:function(){return m},l_:function(){return h},op:function(){return f},vS:function(){return d},vU:function(){return l},yS:function(){return v}});var r,i,a=n(2203),o=!1,s=!1,u=!1,l=!1,d=!1,c=!1,f=!1,v=!1,p=!1,h=!1,m=!1;a.Z||(void 0!==window.MSInputMethodContext&&void 0!==document.documentMode?(s=!0,u=!0):"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?u=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?o=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?l=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?c=!0:(Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>=0||"[object SafariRemoteNotification]"===(null===(i=null===(r=window.safari)||void 0===r?void 0:r.pushNotification)||void 0===i?void 0:i.toString()))&&(d=!0),/SamsungBrowser/.test(navigator.userAgent)&&(f=!0),-1!==navigator.userAgent.indexOf("PlayStation 5")?m=!0:/Tizen/.test(navigator.userAgent)?v=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(p=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent))):/[Pp]anasonic/.test(navigator.userAgent)&&(h=!0))},5767:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(3887),i=n(1946);function a(e){var t=e.textTracks;if(!(0,i.Z)(t)){for(var n=0;n=0;o--)if("track"===a[o].nodeName)try{e.removeChild(a[o])}catch(e){r.Z.warn("Compat: Could not remove text track child from element.")}}e.src="",e.removeAttribute("src")}},6139:function(e,t,n){"use strict";n.d(t,{N:function(){return P},Y:function(){return M}});var r,i=n(3714),a=n(811),o=n(3666),s=n(2203),u=n(5059),l=n(1656),d=function(){function e(e,t,n){this._keyType=e,this._mediaKeys=t,this._configuration=n}var t=e.prototype;return t.createMediaKeys=function(){var e=this;return new Promise((function(t){return t(e._mediaKeys)}))},t.getConfiguration=function(){return this._configuration},(0,l.Z)(e,[{key:"keySystem",get:function(){return this._keyType}}]),e}();if(!s.Z){var c=window.MSMediaKeys;void 0!==c&&void 0!==c.prototype&&"function"==typeof c.isTypeSupported&&"function"==typeof c.prototype.createSession&&(r=c)}var f,v=n(4578),p=n(1959),h=n(288),m=n(3038),g=function(e){function t(t){var n;return(n=e.call(this)||this).expiration=NaN,n.keyStatuses=new Map,n._mk=t,n._sessionClosingCanceller=new h.ZP,n.closed=new Promise((function(e){n._sessionClosingCanceller.signal.register((function(){return e()}))})),n.update=function(e){return new Promise((function(t,r){if(void 0===n._ss)return r("MediaKeySession not set.");try{t(n._ss.update(e,""))}catch(e){r(e)}}))},n}(0,v.Z)(t,e);var n=t.prototype;return n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r=t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer);n._ss=n._mk.createSession("video/mp4",r),m.RV(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"message",e)}),n._sessionClosingCanceller.signal),m.kk(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyadded",e)}),n._sessionClosingCanceller.signal),m.Dl(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyerror",e)}),n._sessionClosingCanceller.signal),e()}))},n.close=function(){var e=this;return new Promise((function(t){null!=e._ss&&(e._ss.close(),e._ss=void 0),e._sessionClosingCanceller.cancel(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},(0,l.Z)(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._ss)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(p.Z),y=function(){function e(e){if(void 0===r)throw new Error("No MSMediaKeys API.");this._mediaKeys=new r(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0!==this._videoElement.msSetMediaKeys)return this._videoElement.msSetMediaKeys(this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new g(this._mediaKeys)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();if(!s.Z){var _=window.MozMediaKeys;void 0!==_&&void 0!==_.prototype&&"function"==typeof _.isTypeSupported&&"function"==typeof _.prototype.createSession&&(f=_)}var b=n(9689),S=n(8894),E=n(3635);function T(e){return"function"==typeof e.webkitGenerateKeyRequest}var k=function(e){function t(t,n){var r;(r=e.call(this)||this)._vid=t,r._key=n,r.sessionId="",r._closeSession=S.Z,r.keyStatuses=new Map,r.expiration=NaN;var i=function(e){r.trigger(e.type,e)};return r.closed=new Promise((function(e){r._closeSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.removeEventListener(e,i),t.removeEventListener("webkit"+e,i)})),e()}})),["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.addEventListener(e,i),t.addEventListener("webkit"+e,i)})),r}(0,v.Z)(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){try{if(t._key.indexOf("clearkey")>=0){var i=e instanceof ArrayBuffer?new Uint8Array(e):e,a=JSON.parse((0,E.uR)(i)),o=(0,b.K)(a.keys[0].k),s=(0,b.K)(a.keys[0].kid);n(t._vid.webkitAddKey(t._key,o,s,""))}else n(t._vid.webkitAddKey(t._key,e,null,""))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){n._vid.webkitGenerateKeyRequest(n._key,t),e()}))},n.close=function(){var e=this;return new Promise((function(t){e._closeSession(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},t}(p.Z),w=function(){function e(e){this._keySystem=e}var t=e.prototype;return t._setVideo=function(e){if(!T(e))throw new Error("Video not attached to the MediaKeys");this._videoElement=e},t.createSession=function(){if(null==this._videoElement)throw new Error("Video not attached to the MediaKeys");return new k(this._videoElement,this._keySystem)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();var A=n(6968);var I=n(158);function R(e,t){var n=e;if(void 0===n.webkitSetMediaKeys)throw new Error("No webKitMediaKeys API.");return n.webkitSetMediaKeys(t)}var Z=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._serverCertificate=r,i._videoElement=t,i._keyType=n,i._unbindSession=S.Z,i._closeSession=S.Z,i.closed=new Promise((function(e){i._closeSession=e})),i.keyStatuses=new Map,i.expiration=NaN,i}(0,v.Z)(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){if(void 0===t._nativeSession||void 0===t._nativeSession.update||"function"!=typeof t._nativeSession.update)return r("Unavailable WebKit key session.");try{var i;i=e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e.buffer),n(t._nativeSession.update(i))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r,i,a,o=n._videoElement;if(void 0===(null===(r=o.webkitKeys)||void 0===r?void 0:r.createSession))throw new Error("No WebKitMediaKeys API.");if("com.apple.fps.1_0"===(a=n._keyType)||"com.apple.fps.2_0"===a){if(void 0===n._serverCertificate)throw new Error("A server certificate is needed for creating fairplay session.");i=function(e,t){var n=e instanceof Uint8Array?e:new Uint8Array(e),r=t instanceof Uint8Array?t:new Uint8Array(t);if((0,A.dN)(n,0)+4!==n.length)throw new Error("Unsupported WebKit initData.");var i=(0,E.wV)(n),a=i.indexOf("skd://"),o=a>-1?i.substring(a+6):i,s=(0,E.TZ)(o),u=0,l=new Uint8Array(n.byteLength+4+s.byteLength+4+r.byteLength);return l.set(n),u+=n.length,l.set((0,A.O_)(s.byteLength),u),u+=4,l.set(s,u),u+=s.byteLength,l.set((0,A.O_)(r.byteLength),u),u+=4,l.set(r,u),l}(t,n._serverCertificate)}else i=t;var s=o.webkitKeys.createSession("video/mp4",i);if(null==s)throw new Error("Impossible to get the key sessions");n._listenEvent(s),n._nativeSession=s,e()}))},n.close=function(){var e=this;return new Promise((function(t,n){e._unbindSession(),e._closeSession(),void 0!==e._nativeSession?(e._nativeSession.close(),t()):n("No session to close.")}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},n._listenEvent=function(e){var t=this;this._unbindSession();var n=function(e){t.trigger(e.type,e)};["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.addEventListener(t,n),e.addEventListener("webkit"+t,n)})),this._unbindSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.removeEventListener(t,n),e.removeEventListener("webkit"+t,n)}))}},(0,l.Z)(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._nativeSession)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(p.Z),x=function(){function e(e){if(void 0===I.t)throw new Error("No WebKitMediaKeys API.");this._keyType=e,this._mediaKeys=new I.t(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0===this._videoElement)throw new Error("Video not attached to the MediaKeys");return R(this._videoElement,this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new Z(this._videoElement,this._keyType,this._serverCertificate)},t.setServerCertificate=function(e){return this._serverCertificate=e,Promise.resolve()},e}();var P=null,M=function(e,t){var n=e;return"function"==typeof n.setMediaKeys?n.setMediaKeys(t):"function"==typeof n.webkitSetMediaKeys?n.webkitSetMediaKeys(t):"function"==typeof n.mozSetMediaKeys?n.mozSetMediaKeys(t):"function"==typeof n.msSetMediaKeys&&null!==t?n.msSetMediaKeys(t):void 0};if(s.Z||null!=navigator.requestMediaKeySystemAccess&&!(0,u.Z)())P=function(){var e;return(e=navigator).requestMediaKeySystemAccess.apply(e,arguments)};else{var C,D;if(T(HTMLVideoElement.prototype)){var N={isTypeSupported:function(e){var t=document.querySelector("video");return null==t&&(t=document.createElement("video")),null!=t&&"function"==typeof t.canPlayType&&!!t.canPlayType("video/mp4",e)},createCustomMediaKeys:function(e){return new w(e)},setMediaKeys:function(e,t){if(null!==t){if(!(t instanceof w))throw new Error("Custom setMediaKeys is supposed to be called with old webkit custom MediaKeys.");return t._setVideo(e)}}};C=N.isTypeSupported,D=N.createCustomMediaKeys,M=N.setMediaKeys}else if(void 0!==I.t){var O=function(){if(void 0===I.t)throw new Error("No WebKitMediaKeys API.");return{isTypeSupported:I.t.isTypeSupported,createCustomMediaKeys:function(e){return new x(e)},setMediaKeys:function(e,t){if(null===t)return R(e,t);if(!(t instanceof x))throw new Error("Custom setMediaKeys is supposed to be called with webkit custom MediaKeys.");return t._setVideo(e)}}}();C=O.isTypeSupported,D=O.createCustomMediaKeys,M=O.setMediaKeys}else if(o.fq&&void 0!==r){var L={isTypeSupported:function(e,t){if(void 0===r)throw new Error("No MSMediaKeys API.");return void 0!==t?r.isTypeSupported(e,t):r.isTypeSupported(e)},createCustomMediaKeys:function(e){return new y(e)},setMediaKeys:function(e,t){if(null!==t){if(!(t instanceof y))throw new Error("Custom setMediaKeys is supposed to be called with IE11 custom MediaKeys.");return t._setVideo(e)}}};C=L.isTypeSupported,D=L.createCustomMediaKeys,M=L.setMediaKeys}else if(void 0!==f){var U={isTypeSupported:function(e,t){if(void 0===f)throw new Error("No MozMediaKeys API.");return void 0!==t?f.isTypeSupported(e,t):f.isTypeSupported(e)},createCustomMediaKeys:function(e){if(void 0===f)throw new Error("No MozMediaKeys API.");return new f(e)},setMediaKeys:function(e,t){var n=e;if(void 0===n.mozSetMediaKeys||"function"!=typeof n.mozSetMediaKeys)throw new Error("Can't set video on MozMediaKeys.");return n.mozSetMediaKeys(t)}};C=U.isTypeSupported,D=U.createCustomMediaKeys,M=U.setMediaKeys}else{var B=window.MediaKeys,F=function(){if(void 0===B)throw new i.Z("MEDIA_KEYS_NOT_SUPPORTED","No `MediaKeys` implementation found in the current browser.");if(void 0===B.isTypeSupported){throw new Error("This browser seems to be unable to play encrypted contents currently. Note: Some browsers do not allow decryption in some situations, like when not using HTTPS.")}};C=function(e){return F(),(0,a.Z)("function"==typeof B.isTypeSupported),B.isTypeSupported(e)},D=function(e){return F(),new B(e)}}P=function(e,t){if(!C(e))return Promise.reject(new Error("Unsupported key type"));for(var n=0;n=t)return r.Z.warn("Compat: Invalid cue times: "+e+" - "+t),null;if((0,i.Z)(window.VTTCue)){if((0,i.Z)(window.TextTrackCue))throw new Error("VTT cues not supported in your target");return new TextTrackCue(e,t,n)}return new VTTCue(e,t,n)}},5059:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(3666),i=n(158);function a(){return(r.vS||r.SB)&&void 0!==i.t}},1669:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(3666);function i(){return r.op}},6872:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r={DEFAULT_UNMUTED_VOLUME:.1,DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_TEXT_TRACK_MODE:"native",DEFAULT_MANUAL_BITRATE_SWITCHING_MODE:"seamless",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:-.7,video:-.1,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:"continue",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_INITIAL_BITRATES:{audio:0,video:0,other:0},DEFAULT_MIN_BITRATES:{audio:0,video:0,other:0},DEFAULT_MAX_BITRATES:{audio:1/0,video:1/0,other:1/0},INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_LIMIT_VIDEO_WIDTH:!1,DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,FORCE_DISCONTINUITY_SEEK_DELAY:5e3,BITRATE_REBUFFERING_RATIO:1.5,BUFFER_GC_GAPS:{CALM:240,BEEFY:30},DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE:1/0,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:250,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs="avc1.4d401e"','video/mp4;codecs="avc1.42e01e"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"',"audio/webm;codecs=opus"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:["HW_SECURE_ALL","HW_SECURE_DECODE","HW_SECURE_CRYPTO","SW_SECURE_DECODE","SW_SECURE_CRYPTO"],EME_DEFAULT_PLAYREADY_ROBUSTNESSES:["3000","2000"],EME_KEY_SYSTEMS:{clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.microsoft.playready.recommendation","com.microsoft.playready","com.chromecast.playready","com.youtube.playready"],fairplay:["com.apple.fps.1_0"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:"reload",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:"seamless"},i=n(8026);function a(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function o(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r=e.length||(e[t].enabled=!0)}(this._audioTracks.map((function(e){return e.nativeTrack})),e)},t}(a.Z);function v(e){for(var t=0;te.length)return u.Z.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var i=e.subarray(n,n+r),a={systemId:(0,l.Y)(i,8),data:i};p(t,a)?u.Z.warn("Compat: Duplicated PSSH found in initialization data, removing it."):t.push(a),n+=r}return n!==e.length?(u.Z.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}]):t}(new Uint8Array(t));return{type:n,values:r}}var m=n(6872),g=n(5157),y=n(5389),_=n(3274),b=n(7714),S=n(1959),E=n(1946),T=n(288),k=n(6139),w=n(770);function A(e){w.Z.setState(e,null),(0,k.Y)(e,null)}function I(){return(I=(0,r.Z)(o().mark((function e(t,n,r){var i,a,s,l,d,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.keySystemOptions,a=n.loadedSessionsStore,s=n.mediaKeySystemAccess,l=n.mediaKeys,d=w.Z.getState(t),c=null!==d&&d.loadedSessionsStore!==a?d.loadedSessionsStore.closeAllSessions():Promise.resolve(),e.next=5,c;case 5:if(!r.isCancelled()){e.next=7;break}throw r.cancellationError;case 7:if(w.Z.setState(t,{keySystemOptions:i,mediaKeySystemAccess:s,mediaKeys:l,loadedSessionsStore:a}),t.mediaKeys!==l){e.next=10;break}return e.abrupt("return");case 10:u.Z.info("DRM: Attaching MediaKeys to the media element"),(0,k.Y)(t,l),u.Z.info("DRM: MediaKeys attached with success");case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function R(e){if(""===e.sessionId)return!1;var t=e.keyStatuses,n=[];return t.forEach((function(e){n.push(e)})),n.length<=0?(u.Z.debug("DRM: isSessionUsable: MediaKeySession given has an empty keyStatuses",e.sessionId),!1):(0,b.Z)(n,"expired")?(u.Z.debug("DRM: isSessionUsable: MediaKeySession given has an expired key",e.sessionId),!1):(0,b.Z)(n,"internal-error")?(u.Z.debug("DRM: isSessionUsable: MediaKeySession given has a key with an internal-error",e.sessionId),!1):(u.Z.debug("DRM: isSessionUsable: MediaKeySession is usable",e.sessionId),!0)}function Z(e,t,n,r){var i=e.loadedSessionsStore,a=e.persistentSessionsStore;return"temporary"===n?x(i,t):null===a?(u.Z.warn("DRM: Cannot create persistent MediaKeySession, PersistentSessionsStore not created."),x(i,t)):function(e,t,n,r){return P.apply(this,arguments)}(i,a,t,r)}function x(e,t){u.Z.info("DRM: Creating a new temporary session");var n=e.createSession(t,"temporary");return Promise.resolve({type:"created-session",value:n})}function P(){return P=(0,r.Z)(o().mark((function e(t,n,i,a){var s,l,d,c,f,v;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(v=function(){return v=(0,r.Z)(o().mark((function e(){var r,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===a.cancellationError){e.next=2;break}throw a.cancellationError;case 2:return u.Z.info("DRM: Removing previous persistent session."),null!==(r=n.get(i))&&n.delete(r.sessionId),e.prev=5,e.next=8,t.closeSession(s.mediaKeySession);case 8:e.next=15;break;case 10:if(e.prev=10,e.t0=e.catch(5),""===s.mediaKeySession.sessionId){e.next=14;break}throw e.t0;case 14:t.removeSessionWithoutClosingIt(s.mediaKeySession);case 15:if(null===a.cancellationError){e.next=17;break}throw a.cancellationError;case 17:return l=t.createSession(i,"persistent-license"),e.abrupt("return",{type:"created-session",value:l});case 19:case"end":return e.stop()}}),e,null,[[5,10]])}))),v.apply(this,arguments)},f=function(){return v.apply(this,arguments)},null===a.cancellationError){e.next=4;break}throw a.cancellationError;case 4:if(u.Z.info("DRM: Creating persistent MediaKeySession"),s=t.createSession(i,"persistent-license"),null!==(l=n.getAndReuse(i))){e.next=9;break}return e.abrupt("return",{type:"created-session",value:s});case 9:return e.prev=9,e.next=12,t.loadPersistentSession(s.mediaKeySession,l.sessionId);case 12:if(d=e.sent){e.next=19;break}return u.Z.warn("DRM: No data stored for the loaded session"),n.delete(l.sessionId),t.removeSessionWithoutClosingIt(s.mediaKeySession),c=t.createSession(i,"persistent-license"),e.abrupt("return",{type:"created-session",value:c});case 19:if(!d||!R(s.mediaKeySession)){e.next=23;break}return n.add(i,i.keyIds,s.mediaKeySession),u.Z.info("DRM: Succeeded to load persistent session."),e.abrupt("return",{type:"loaded-persistent-session",value:s});case 23:return u.Z.warn("DRM: Previous persistent session not usable anymore."),e.abrupt("return",f());case 27:return e.prev=27,e.t0=e.catch(9),u.Z.warn("DRM: Unable to load persistent session: "+(e.t0 instanceof Error?e.t0.toString():"Unknown Error")),e.abrupt("return",f());case 31:case"end":return e.stop()}}),e,null,[[9,27]])}))),P.apply(this,arguments)}function M(e,t){return C.apply(this,arguments)}function C(){return(C=(0,r.Z)(o().mark((function e(t,n){var r,i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n<0||n>=t.getLength())){e.next=2;break}return e.abrupt("return");case 2:for(u.Z.info("DRM: LSS cache limit exceeded",n,t.getLength()),r=[],i=t.getAll().slice(),a=i.length-n,s=0;s=s.length)){e.next=2;break}throw new g.Z("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");case 2:if(null!=k.N){e.next=4;break}throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");case 4:return r=s[t],i=r.keyName,a=r.keyType,d=r.keySystemOptions,c=B(i,a,d),u.Z.debug("DRM: Request keysystem access "+a+","+(t+1)+" of "+s.length),e.prev=7,e.next=10,(0,k.N)(a,c);case 10:return f=e.sent,u.Z.info("DRM: Found compatible keysystem",a,t+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:d,mediaKeySystemAccess:f}});case 15:if(e.prev=15,e.t0=e.catch(7),u.Z.debug("DRM: Rejected access to keysystem",a,t+1),null===n.cancellationError){e.next=20;break}throw n.cancellationError;case 20:return e.abrupt("return",l(t+1));case 21:case"end":return e.stop()}}),e,null,[[7,15]])})))).apply(this,arguments)}}var V=n(2297);function z(e,t,n){var r;u.Z.debug("Compat: Calling generateRequest on the MediaKeySession");try{r=function(e){u.Z.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,n=new Uint8Array,r=new Uint8Array,i=0;ie.length)throw u.Z.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var o=e.subarray(i,i+a);if(16===e[i+12]&&119===e[i+13]&&239===e[i+14]&&236===e[i+15]&&192===e[i+16]&&178===e[i+17]&&77===e[i+18]&&2===e[i+19]&&172===e[i+20]&&227===e[i+21]&&60===e[i+22]&&30===e[i+23]&&82===e[i+24]&&226===e[i+25]&&251===e[i+26]&&75===e[i+27]){var s=(0,V.Xj)(o),l=null===s?void 0:o[s[1]];u.Z.info("Compat: CENC PSSH found with version",l),void 0===l?u.Z.warn("Compat: could not read version of CENC PSSH"):t===(1===l)?n=(0,c.zo)(n,o):1===l?(u.Z.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),n=o,t=!0):u.Z.warn("Compat: filtering out cenc pssh box with wrong version",l)}else r=(0,c.zo)(r,o);i+=a}if(i!==e.length)throw u.Z.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return(0,c.zo)(r,n)}(n)}catch(e){r=n}var i=null!=t?t:"";return e.generateRequest(i,r).catch((function(t){if(""!==i||!(t instanceof TypeError))throw t;return u.Z.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',t),e.generateRequest("cenc",r)}))}var K=100;function G(e,t){return W.apply(this,arguments)}function W(){return(W=(0,r.Z)(o().mark((function e(t,n){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u.Z.info("DRM: Load persisted session",n),e.next=3,t.load(n);case 3:if((r=e.sent)&&!(t.keyStatuses.size>0)){e.next=6;break}return e.abrupt("return",r);case 6:return e.abrupt("return",new Promise((function(e){t.addEventListener("keystatuseschange",i);var n=setTimeout(i,K);function i(){clearTimeout(n),t.removeEventListener("keystatuseschange",i),e(r)}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var j=n(7864);function H(e){var t=new T.ZP;return Promise.race([e.close().then((function(){t.cancel()})),e.closed.then((function(){t.cancel()})),function(){return n.apply(this,arguments)}()]);function n(){return(n=(0,r.Z)(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,j.Z)(1e3,t.signal);case 3:return e.next=5,i();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),!(e.t0 instanceof T.FU)){e.next=11;break}return e.abrupt("return");case 11:n=e.t0 instanceof Error?e.t0.message:"Unknown error made it impossible to close the session",u.Z.error("DRM: "+n);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function i(){return a.apply(this,arguments)}function a(){return(a=(0,r.Z)(o().mark((function n(){return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.update(new Uint8Array(1));case 3:n.next=13;break;case 5:if(n.prev=5,n.t0=n.catch(0),!t.isUsed()){n.next=9;break}return n.abrupt("return");case 9:if(!(n.t0 instanceof Error&&"The session is already closed."===n.t0.message)){n.next=11;break}return n.abrupt("return");case 11:return n.next=13,(0,j.Z)(1e3,t.signal);case 13:if(!t.isUsed()){n.next=15;break}return n.abrupt("return");case 15:throw new Error("Compat: Couldn't know if session is closed");case 16:case"end":return n.stop()}}),n,null,[[0,5]])})))).apply(this,arguments)}}var q=n(811);function Y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return X(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return X(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){if(null!==this._keyIds&&J(t,this._keyIds))return!0;if(void 0!==this._initializationData.keyIds)return J(t,this._initializationData.keyIds)}return this._checkInitializationDataCompatibility(e)},t._checkInitializationDataCompatibility=function(e){return void 0!==e.keyIds&&e.keyIds.length>0&&void 0!==this._initializationData.keyIds?J(e.keyIds,this._initializationData.keyIds):this._initializationData.type===e.type&&this._initializationData.values.isCompatibleWith(e.values)},e}();function re(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ie(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&n._storage[e].mediaKeySession===i&&n._storage.splice(e,1)})).catch((function(e){u.Z.warn("DRM-LSS: MediaKeySession.closed rejected: "+e)})),this._storage.push(Object.assign({},a)),u.Z.debug("DRM-LSS: MediaKeySession added",a.sessionType,this._storage.length),a},t.reuse=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.keySessionRecord.isCompatibleWith(e))return this._storage.splice(t,1),this._storage.push(n),u.Z.debug("DRM-LSS: Reusing session:",n.mediaKeySession.sessionId,n.sessionType),Object.assign({},n)}return null},t.getEntryForSession=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.mediaKeySession===e)return Object.assign({},n)}return null},t.generateLicenseRequest=function(){var e=(0,r.Z)(o().mark((function e(t,n,r){var i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=re(this._storage);case 1:if((s=a()).done){e.next=8;break}if((l=s.value).mediaKeySession!==t){e.next=6;break}return i=l,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==i){e.next=11;break}return u.Z.error("DRM-LSS: generateRequest error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",z(t,n,r));case 11:if(i.isGeneratingRequest=!0,"none"===i.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,z(t,n,r);case 17:e.next=26;break;case 19:if(e.prev=19,e.t0=e.catch(14),void 0!==i){e.next=23;break}throw e.t0;case 23:throw i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start(),e.t0;case 26:if(void 0!==i){e.next=28;break}return e.abrupt("return",void 0);case 28:i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start();case 30:case"end":return e.stop()}}),e,this,[[14,19]])})));return function(t,n,r){return e.apply(this,arguments)}}(),t.loadPersistentSession=function(){var e=(0,r.Z)(o().mark((function e(t,n){var r,i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=re(this._storage);case 1:if((a=i()).done){e.next=8;break}if((s=a.value).mediaKeySession!==t){e.next=6;break}return r=s,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==r){e.next=11;break}return u.Z.error("DRM-LSS: loadPersistentSession error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",G(t,n));case 11:if(r.isLoadingPersistentSession=!0,"none"===r.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,G(t,n);case 17:l=e.sent,e.next=27;break;case 20:if(e.prev=20,e.t0=e.catch(14),void 0!==r){e.next=24;break}throw e.t0;case 24:throw r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.t0;case 27:if(void 0!==r){e.next=29;break}return e.abrupt("return",l);case 29:return r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.abrupt("return",l);case 32:case"end":return e.stop()}}),e,this,[[14,20]])})));return function(t,n){return e.apply(this,arguments)}}(),t.closeSession=function(){var e=(0,r.Z)(o().mark((function e(t){var n,r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=re(this._storage);case 1:if((i=r()).done){e.next=8;break}if((a=i.value).mediaKeySession!==t){e.next=6;break}return n=a,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==n){e.next=11;break}return u.Z.warn("DRM-LSS: No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Promise.resolve(!1));case 11:return e.abrupt("return",this._closeEntry(n));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getLength=function(){return this._storage.length},t.getAll=function(){return this._storage},t.closeAllSessions=function(){var e=(0,r.Z)(o().mark((function e(){var t,n,r=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._storage,u.Z.debug("DRM-LSS: Closing all current MediaKeySessions",t.length),this._storage=[],n=t.map((function(e){return r._closeEntry(e)})),e.next=6,Promise.all(n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.removeSessionWithoutClosingIt=function(e){(0,q.Z)(""===e.sessionId,"Initialized `MediaKeySession`s should always be properly closed");for(var t=this._storage.length-1;t>=0;t--){if(this._storage[t].mediaKeySession===e)return u.Z.debug("DRM-LSS: Removing session without closing it",e.sessionId),this._storage.splice(t,1),!0}return!1},t.getIndex=function(e){for(var t=0;t=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0){var o=void 0===t?3:4,s=this._entries[a];if((null!==(r=s.version)&&void 0!==r?r:-1)>=o&&i===s.sessionId)return;u.Z.info("DRM-PSS: Updating session info.",i),this._entries.splice(a,1)}else u.Z.info("DRM-PSS: Add new session",i);var l=e.values.getFormattedValues().map((function(e){var t=e.systemId,n=e.data;return{systemId:t,hash:e.hash,data:new ce(n)}}));void 0===t?this._entries.push({version:3,sessionId:i,values:l,initDataType:e.type}):this._entries.push({version:4,sessionId:i,keyIds:t.map((function(e){return new ce(e)})),values:l,initDataType:e.type}),this._save()}else u.Z.warn("DRM-PSS: Invalid Persisten Session given.")},t.delete=function(e){for(var t=-1,n=0;n0&&(r=new g.Z("KEY_STATUS_CHANGE_ERROR","One or several problematic key statuses have been encountered",{keyStatuses:c})),{warning:r,blacklistedKeyIds:l,whitelistedKeyIds:d}}var Ce=s.Dl,De=s.RV,Ne=s.qo;function Oe(e,t,n,i,a){u.Z.info("DRM: Binding session events",e.sessionId);var s=t.getLicenseConfig,l=void 0===s?{}:s,d=new T.ZP;return d.linkToSignal(a),(0,E.Z)(e.closed)||e.closed.then((function(){return d.cancel()})).catch((function(e){a.isCancelled()||(d.cancel(),i.onError(e))})),Ce(e,(function(e){d.cancel(),i.onError(new g.Z("KEY_ERROR",e.type))}),d.signal),Ne(e,(function(e){(function(e){return c.apply(this,arguments)})(e).catch((function(e){a.isCancelled()||d.isUsed()&&e instanceof T.XG||(d.cancel(),i.onError(e))}))}),d.signal),De(e,(function(n){var a,s=n,c=new Uint8Array(s.message),f=(0,de.Z)(s.messageType)?s.messageType:"license-request";u.Z.info("DRM: Received message event, type "+f,e.sessionId),function(e,t,n){var i=t.baseDelay,a=t.maxDelay,s=t.totalRetry,u=t.shouldRetry,l=t.onRetry,d=0;return c();function c(){return f.apply(this,arguments)}function f(){return(f=(0,r.Z)(o().mark((function t(){var r,f,v,p;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===n.cancellationError){t.next=2;break}throw n.cancellationError;case 2:return t.prev=2,t.next=5,e();case 5:return r=t.sent,t.abrupt("return",r);case 9:if(t.prev=9,t.t0=t.catch(2),null===n.cancellationError){t.next=13;break}throw n.cancellationError;case 13:if(!(!(0,E.Z)(u)&&!u(t.t0)||d++>=s)){t.next=15;break}throw t.t0;case 15:return"function"==typeof l&&l(t.t0,d),f=Math.min(i*Math.pow(2,d-1),a),v=(0,Ie.Z)(f),t.next=20,Re(v);case 20:return p=c(),t.abrupt("return",p);case 22:case"end":return t.stop()}}),t,null,[[2,9]])})))).apply(this,arguments)}}((function(){return function(e,n){var r;return new Promise((function(i,a){try{u.Z.debug("DRM: Calling `getLicense`",n);var o=t.getLicense(e,n),s=(0,E.Z)(l.timeout)?1e4:l.timeout;s>=0&&(r=setTimeout((function(){a(new Ve('"getLicense" timeout exceeded ('+s+" ms)"))}),s)),Promise.resolve(o).then(d,c)}catch(e){c(e)}function d(e){void 0!==r&&clearTimeout(r),i(e)}function c(e){void 0!==r&&clearTimeout(r),a(e)}}))}(c,f)}),{totalRetry:null!=(a=l.retry)?a:2,baseDelay:200,maxDelay:3e3,shouldRetry:function(e){return e instanceof Ve||(0,E.Z)(e)||!0!==e.noRetry},onRetry:function(e){return i.onWarning(Le(e))}},d.signal).then((function(t){if(d.isUsed())return Promise.resolve();if((0,E.Z)(t))u.Z.info("DRM: No license given, skipping session.update");else try{return Ue(e,t)}catch(e){d.cancel(),i.onError(e)}})).catch((function(e){if(!d.isUsed()){d.cancel();var t=Le(e);if(!(0,E.Z)(e))if(!0===e.fallbackOnLastTry)return u.Z.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void i.onError(new Fe(t));i.onError(t)}}))}),d.signal),void f();function c(){return c=(0,r.Z)(o().mark((function n(i){var s,l;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=function(){return(l=(0,r.Z)(o().mark((function n(){var r,s;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!d.isUsed()){n.next=2;break}return n.abrupt("return");case 2:if("function"!=typeof t.onKeyStatusesChange){n.next=24;break}return n.prev=3,n.next=6,t.onKeyStatusesChange(i,e);case 6:if(r=n.sent,!d.isUsed()){n.next=9;break}return n.abrupt("return");case 9:n.next=18;break;case 11:if(n.prev=11,n.t0=n.catch(3),!a.isCancelled()){n.next=15;break}return n.abrupt("return");case 15:throw s=new g.Z("KEY_STATUS_CHANGE_ERROR","Unknown `onKeyStatusesChange` error"),!(0,E.Z)(n.t0)&&(0,de.Z)(n.t0.message)&&(s.message=n.t0.message),s;case 18:if(!(0,E.Z)(r)){n.next=22;break}u.Z.info("DRM: No license given, skipping session.update"),n.next=24;break;case 22:return n.next=24,Ue(e,r);case 24:case"end":return n.stop()}}),n,null,[[3,11]])})))).apply(this,arguments)},s=function(){return l.apply(this,arguments)},u.Z.info("DRM: keystatuseschange event received",e.sessionId),n.next=5,Promise.all([s(),Promise.resolve(f())]);case 5:case"end":return n.stop()}}),n)}))),c.apply(this,arguments)}function f(){if(!d.isUsed()&&0!==e.keyStatuses.size){var r=Me(e,t,n),a=r.warning,o=r.blacklistedKeyIds,s=r.whitelistedKeyIds;void 0!==a&&(i.onWarning(a),d.isUsed())||i.onKeyUpdate({whitelistedKeyIds:s,blacklistedKeyIds:o})}}}function Le(e){if(e instanceof Ve)return new g.Z("KEY_LOAD_TIMEOUT","The license server took too much time to respond.");var t=new g.Z("KEY_LOAD_ERROR","An error occured when calling `getLicense`.");return!(0,E.Z)(e)&&(0,de.Z)(e.message)&&(t.message=e.message),t}function Ue(e,t){return Be.apply(this,arguments)}function Be(){return(Be=(0,r.Z)(o().mark((function e(t,n){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u.Z.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(n);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new g.Z("KEY_UPDATE_ERROR",r);case 10:u.Z.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}}),e,null,[[1,6]])})))).apply(this,arguments)}var Fe=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf((0,we.Z)(r),t.prototype),r.sessionError=n,r}return(0,i.Z)(t,e),t}((0,Ae.Z)(Error)),Ve=function(e){function t(t){var n;return n=e.call(this)||this,Object.setPrototypeOf((0,we.Z)(n),Fe.prototype),n.message=t,n}return(0,i.Z)(t,e),t}((0,Ae.Z)(Error)),ze=n(9822);function Ke(e,t){return Ge.apply(this,arguments)}function Ge(){return(Ge=(0,r.Z)(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(n);case 3:return r=e.sent,e.abrupt("return",r);case 7:throw e.prev=7,e.t0=e.catch(0),u.Z.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),i=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new g.Z("LICENSE_SERVER_CERTIFICATE_ERROR",i);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function We(e,t){return je.apply(this,arguments)}function je(){return(je=(0,r.Z)(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==ye.hasOne(t)){e.next=3;break}return u.Z.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});case 3:if("function"==typeof t.setServerCertificate){e.next=6;break}return u.Z.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});case 6:return u.Z.info("DRM: Setting server certificate on the MediaKeys"),ye.prepare(t),e.prev=8,e.next=11,Ke(t,n);case 11:return r=e.sent,ye.set(t,n),e.abrupt("return",{type:"success",value:r});case 16:return e.prev=16,e.t0=e.catch(8),i=(0,ze.Z)(e.t0)?e.t0:new g.Z("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:i});case 20:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}function He(e,t){if(!(isNaN(t)||t<0||t>=e.getLength())){var n=e.getLength(),r=n-t;u.Z.info("DRM: Too many stored persistent sessions, removing some.",n,r),e.deleteOldSessions(r)}}var qe=n(9252);var Ye=function(){function e(e){this._innerValues=e,this._lazyFormattedValues=null}var t=e.prototype;return t.constructRequestData=function(){return c.zo.apply(void 0,this._innerValues.map((function(e){return e.data})))},t.isCompatibleWith=function(t){var n=t instanceof e?t.getFormattedValues():t;return fe(this.getFormattedValues(),n)},t.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort((function(e,t){return e.systemId===t.systemId?0:void 0===e.systemId?1:void 0===t.systemId||e.systemId=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Qe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&K._currentSessions.splice(r),void 0!==t.content&&nt(t.content.manifest,[],[],N.record.getAssociatedKeyIds()),null===(n=i.persistentSessionsStore)||void 0===n||n.delete(L.sessionId),i.loadedSessionsStore.closeSession(L).catch((function(e){var t=e instanceof Error?e:"unknown error";u.Z.warn("DRM: failed to close expired session",t)})).then((function(){return K._unlockInitDataQueue()})).catch((function(e){return K._onFatalError(e)})),void(K._isStopped()||K.trigger("warning",e.reason))}if(e instanceof Fe){if(N.blacklistedSessionError=e,void 0!==t.content){var a=t.content.manifest;u.Z.info("DRM: blacklisting Representations based on protection data."),rt(a,t)}K._unlockInitDataQueue()}else K._onFatalError(e)}},this._canceller.signal),void 0!==a.singleLicensePer&&"init-data"!==a.singleLicensePer||this._unlockInitDataQueue(),"created-session"!==C.type){e.next=67;break}return F=t.values.constructRequestData(),e.prev=54,e.next=57,i.loadedSessionsStore.generateLicenseRequest(L,t.type,F);case 57:e.next=67;break;case 59:if(e.prev=59,e.t0=e.catch(54),null!==(V=i.loadedSessionsStore.getEntryForSession(L))&&"none"===V.closingStatus.type){e.next=66;break}return(z=this._currentSessions.indexOf(N))>=0&&this._currentSessions.splice(z,1),e.abrupt("return",Promise.resolve());case 66:throw new g.Z("KEY_GENERATE_REQUEST_ERROR",e.t0 instanceof Error?e.t0.toString():"Unknown error");case 67:return e.abrupt("return",Promise.resolve());case 68:case"end":return e.stop()}}),e,this,[[54,59]])})));return function(t,n){return e.apply(this,arguments)}}(),n._tryToUseAlreadyCreatedSession=function(e,t){var n=t.stores,r=t.options,i=(0,_.Z)(this._currentSessions,(function(t){return t.record.isCompatibleWith(e)}));if(void 0===i)return!1;var a=i.blacklistedSessionError;if(!(0,E.Z)(a))return void 0===e.type||void 0===e.content?(u.Z.error("DRM: This initialization data has already been blacklisted but the current content is not known."),!0):(u.Z.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),rt(e.content.manifest,e),!0);if(void 0!==e.keyIds){var o;if(void 0===r.singleLicensePer||"init-data"===r.singleLicensePer){var s=i.keyStatuses.blacklisted;o=function(e,t){for(var n,r=function(){var e=n.value;if(t.some((function(t){return Q(t,e)})))return{v:!0}},i=Y(e);!(n=i()).done;){var a=r();if("object"==typeof a)return a.v}return!1}(e.keyIds,s)}else{var l=i.keyStatuses.whitelisted;o=!J(e.keyIds,l)}if(o)return void 0===e.content?(u.Z.error("DRM: Cannot forbid key id, the content is unknown."),!0):(u.Z.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),nt(e.content.manifest,[],e.keyIds,[]),!0)}if(null!==n.loadedSessionsStore.reuse(e))return u.Z.debug("DRM: Init data already processed. Skipping it."),!0;var d=this._currentSessions.indexOf(i);return-1===d?u.Z.error("DRM: Unable to remove processed init data: not found."):(u.Z.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(d,1)),!1},n._onFatalError=function(e){if(!this._canceller.isUsed()){var t=e instanceof Error?e:new y.Z("NONE","Unknown decryption error");this.error=t,this._initDataQueue.length=0,this._stateData={state:$e.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",t),this._stateData.state===$e.Error&&this.trigger("stateChange",this._stateData.state)}},n._isStopped=function(){return this._stateData.state===$e.Disposed||this._stateData.state===$e.Error},n._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},n._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},n._unlockInitDataQueue=function(){!0===this._stateData.isMediaKeysAttached?(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue()):u.Z.error("DRM: Trying to unlock in the wrong state")},t}(S.Z);function tt(e){var t=e.getConfiguration().sessionTypes;return void 0!==t&&(0,b.Z)(t,"persistent-license")}function nt(e,t,n,r){e.updateRepresentationsDeciperability((function(e){if(void 0===e.contentProtections)return e.decipherable;var i=e.contentProtections.keyIds;if(void 0!==i)for(var a,o=Xe(i);!(a=o()).done;){for(var s,u=a.value,l=Xe(n);!(s=l()).done;){if(Q(s.value,u.keyId))return!1}for(var d,c=Xe(t);!(d=c()).done;){if(Q(d.value,u.keyId))return!0}for(var f,v=Xe(r);!(f=v()).done;){if(Q(f.value,u.keyId))return}}return e.decipherable}))}function rt(e,t){e.updateRepresentationsDeciperability((function(e){var n,r;if(!1===e.decipherable)return!1;for(var i,a=function(){var e=i.value;if((void 0===t.type||e.type===t.type)&&t.values.getFormattedValues().every((function(t){return e.values.some((function(e){return(void 0===t.systemId||e.systemId===t.systemId)&&(0,d.Z)(e.data,t.data)}))})))return{v:!1}},o=Xe(null!==(r=null===(n=e.contentProtections)||void 0===n?void 0:n.initData)&&void 0!==r?r:[]);!(i=o()).done;){var s=a();if("object"==typeof s)return s.v}return e.decipherable}))}function it(e,t,n,r,i,a){for(var o,s,l=[].concat(i,a),d=function(){var e=s.value;l.some((function(t){return Q(t,e)}))||(u.Z.hasLevel("DEBUG")&&u.Z.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it",(0,f.ci)(e)),l.push(e))},c=Xe(t.getAssociatedKeyIds());!(s=c()).done;)d();if(void 0!==n&&"init-data"!==n){var v=e.keyIds,p=e.content;if(void 0!==v){var h=v.filter((function(e){return!l.some((function(t){return Q(t,e)}))}));h.length>0&&(u.Z.hasLevel("DEBUG")&&u.Z.debug("DRM: init data keys missing in the license, blacklisting them",h.map((function(e){return(0,f.ci)(e)})).join(", ")),l.push.apply(l,h))}if(r&&void 0!==p)if("content"===n){for(var m,g=new Set,y=Xe(p.manifest.periods);!(m=y()).done;){ot(g,m.value)}at(g,l)}else if("periods"===n)for(var _,b=Xe(p.manifest.periods);!(_=b()).done;){var S=_.value,E=new Set;if(ot(E,S),(null===(o=e.content)||void 0===o?void 0:o.period.id)===S.id)at(E,l);else for(var T=Array.from(E),k=function(){var e=A[w];if(l.some((function(t){return Q(t,e)})))return at(E,l),"break"},w=0,A=T;w=100?n:r<=0?0:n*(+r/100)}return 0}(e,s);return a.Z.debug("Init: Initial time calculated:",t),t}),o,(function(e){return n.trigger("warning",e)}),r).autoPlayResult.then((function(){return(0,l.Z)(t,e,!0,r).onUpdate((function(e,t){e&&(t(),n.trigger("loaded",{segmentBuffersStore:null}))}),{emitCurrentValue:!0,clearSignal:r})})).catch((function(e){r.isCancelled()||n._onFatalError(e)}))},t}(u.K)},379:function(e,t,n){"use strict";n.d(t,{K:function(){return i}});var r=n(4578),i=function(e){function t(){return e.apply(this,arguments)||this}return(0,r.Z)(t,e),t}(n(1959).Z)},1757:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var r=n(3666);var i=n(1669),a=n(5095),o=n(288);function s(e,t,n,s){var u=new o.ZP;u.linkToSignal(s);var l=(0,a.ZP)(!1,u.signal);return e.listen((function(e){if(null===e.rebuffering&&null===e.freezing&&0!==e.readyState)return!function(e,t){return!e||!r.SB||t}(n,t.hasAttribute("playsinline"))&&t.duration>0||e.readyState>=3&&null!==e.currentRange&&(!(0,i.Z)()||t.duration>0)?(l.setValue(!0),void u.cancel()):void 0}),{includeLastObservation:!0,clearSignal:u.signal}),l}},8833:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(1669),i=n(3774),a=n(3714),o=n(3887),s=n(5095);function u(e,t,n,u,l,d){var c,f,v=new Promise((function(e,t){c=e,f=t})),p=(0,s.$l)(!1,d),h=(0,s.$l)(!1,d);e.addEventListener("loadedmetadata",g),e.readyState>=i.c.HAVE_METADATA&&g();var m=d.register((function(t){e.removeEventListener("loadedmetadata",g),f(t)}));return{autoPlayResult:v,initialPlayPerformed:h,initialSeekPerformed:p};function g(){e.removeEventListener("loadedmetadata",g);var i="function"==typeof n?n():n;if(o.Z.info("Init: Set initial time",i),t.setCurrentTime(i),p.setValue(!0),p.finish(),(0,r.Z)()&&0===e.duration){var s=new a.Z("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content.");l(s)}d.isCancelled()||t.listen((function(t,n){!t.seeking&&null===t.rebuffering&&t.readyState>=1&&(n(),function(){var t,n;if(o.Z.info("Init: Can begin to play content"),!u)return e.autoplay&&o.Z.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),h.setValue(!0),h.finish(),m(),c({type:"skipped"});try{n=null!==(t=e.play())&&void 0!==t?t:Promise.resolve()}catch(e){return m(),f(e)}n.then((function(){if(!d.isCancelled())return h.setValue(!0),h.finish(),m(),c({type:"autoplay"})})).catch((function(e){if(m(),!d.isCancelled()){if(e instanceof Error&&"NotAllowedError"===e.name){o.Z.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var t=new a.Z("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(l(t),d.isCancelled())return;return c({type:"autoplay-blocked"})}f(e)}}))}())}),{includeLastObservation:!0,clearSignal:d})}}},8799:function(e,t,n){"use strict";n.d(t,{Z:function(){return d}});var r=n(6139);var i=n(5157),a=n(3887),o=n(5095),s=n(288),u=n(1266),l=n(1960);function d(e,t,n,d,c){if(0===t.length){n.onUpdate((function(e,t){if(null!==e){t(),a.Z.error("Init: Encrypted event but EME feature not activated");var n=new i.Z("MEDIA_IS_ENCRYPTED_ERROR","EME feature not activated.");d.onError(n)}}),{clearSignal:c});var f=(0,o.ZP)({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return f.finish(),f}if("function"!=typeof r.N){n.onUpdate((function(e,t){if(null!==e){t(),a.Z.error("Init: Encrypted event but no EME API available");var n=new i.Z("MEDIA_IS_ENCRYPTED_ERROR","Encryption APIs not found.");d.onError(n)}}),{clearSignal:c});var v=(0,o.ZP)({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return v.finish(),v}var p=new s.ZP;p.linkToSignal(c);var h=(0,o.ZP)({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},c);a.Z.debug("Init: Creating ContentDecryptor");var m=new u.ZP(e,t);return m.addEventListener("stateChange",(function(e){if(e===l.u.WaitingForAttachment){var t=(0,o.ZP)(!1);t.onUpdate((function(t,n){t&&(n(),e===l.u.WaitingForAttachment&&m.attach())}),{clearSignal:p.signal}),h.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:t}},drmSystemId:m.systemId})}else e===l.u.ReadyForContent&&(h.setValue({initializationState:{type:"initialized",value:null},drmSystemId:m.systemId}),m.removeEventListener("stateChange"))})),m.addEventListener("error",(function(e){p.cancel(),d.onError(e)})),m.addEventListener("warning",(function(e){d.onWarning(e)})),n.onUpdate((function(e){null!==e&&m.onInitializationData(e)}),{clearSignal:p.signal}),p.signal.register((function(){m.dispose()})),h}},6199:function(e,t,n){"use strict";n.d(t,{Z:function(){return f}});var r=n(4578),i=n(3666).yS,a=n(6872),o=n(3714),s=n(3887),u=n(1959),l=n(2829),d=n(288),c=1/60,f=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._playbackObserver=t,i._manifest=n,i._speed=r,i._discontinuitiesStore=[],i._isStarted=!1,i._canceller=new d.ZP,i}(0,r.Z)(t,e);var n=t.prototype;return n.start=function(){var e=this;if(!this._isStarted){var t;this._isStarted=!0;var n=null,r=new h(this._playbackObserver,this._speed);this._canceller.signal.register((function(){r.dispose()}));var o=null;this._playbackObserver.listen((function(u){var d,f,v=e._discontinuitiesStore,h=u.buffered,m=u.position,g=u.readyState,y=u.rebuffering,_=u.freezing,b=a.Z.getCurrent(),S=b.BUFFER_DISCONTINUITY_THRESHOLD,E=b.FORCE_DISCONTINUITY_SEEK_DELAY,T=b.FREEZING_STALLED_DELAY,k=b.UNFREEZING_SEEK_DELAY,w=b.UNFREEZING_DELTA_POSITION;if(!u.seeking&&i&&null===n&&null!==t&&u.positionk&&(s.Z.warn("Init: trying to seek to un-freeze player"),e._playbackObserver.setCurrentTime(e._playbackObserver.getCurrentTime()+w),o={attemptTimestamp:I}),I-_.timestamp>T)return null===y||null!==n?r.stopRebuffering():r.startRebuffering(),void e.trigger("stalled","freezing")}else o=null;if(null===y)return r.stopRebuffering(),1===g?(f=u.seeking?null!==u.pendingInternalSeek?"internal-seek":"seeking":"not-ready",void e.trigger("stalled",f)):void e.trigger("unstalled",null);var R="seeking"===y.reason&&null!==u.pendingInternalSeek?"internal-seek":y.reason;if(null!==n){var Z=performance.now();if(Z-n0){var P=function(e,t,n){if(0===e.length)return null;for(var r=null,i=0;in)return r;var o=void 0;if(void 0===a.end||a.end>n){var u=e[i],l=u.discontinuity,d=u.position,f=l.start,v=l.end;if(n>=(null!=f?f:d)-c)if(null===v){var p=t.getPeriodAfter(a);null!==p?o=p.start+c:s.Z.warn("Init: discontinuity at Period's end but no next Period")}else no?r:o)}}return r}(v,e._manifest,x);if(null!==P){var M=P+.001;if(!(M<=e._playbackObserver.getCurrentTime()))return s.Z.warn("SA: skippable discontinuity found in the stream",m,M),e._playbackObserver.setCurrentTime(M),void e.trigger("warning",p(x,M));s.Z.info("Init: position to seek already reached, no seeking",e._playbackObserver.getCurrentTime(),M)}}var C=null!=x?x:m,D=(0,l.XS)(h,C);if(e._speed.getValue()>0&&D=0;O--){var L=e._manifest.periods[O];if(void 0!==L.end&&L.end<=C){if(e._manifest.periods[O+1].start>C&&e._manifest.periods[O+1].start>e._playbackObserver.getCurrentTime()){var U=e._manifest.periods[O+1];return e._playbackObserver.setCurrentTime(U.start),void e.trigger("warning",p(C,U.start))}break}}e.trigger("stalled",R)}else e.trigger("stalled",R)}),{includeLastObservation:!0,clearSignal:this._canceller.signal})}},n.updateDiscontinuityInfo=function(e){this._isStarted||this.start();var t=this._playbackObserver.getReference().getValue();!function(e,t,n){for(;e.length>0&&void 0!==e[0].period.end&&e[0].period.end+10r.start)return void(v(t)&&e.splice(a,0,t));v(t)&&e.push(t)}(this._discontinuitiesStore,e,t)},n.onLockedStream=function(e,t){var n;this._isStarted||this.start();var r=this._playbackObserver.getReference().getValue();if(!(!r.rebuffering||r.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e)){var i=r.position,a=null!==(n=r.rebuffering.position)&&void 0!==n?n:i,o=t.start;i=0;n--){if(e[n].startt)return e.slice(n,e.length)}return[]}function m(e,t,n){var r=Math.max(e.start,t),i=p(e.cues,t),a={start:e.start,end:r,cues:i},o=Math.min(n,e.end),s=h(e.cues,n);return[a,{start:o,end:e.end,cues:s}]}var g=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.get=function(e){for(var t=this._cuesBuffer,n=[],r=t.length-1;r>=0;r--){var i=t[r];if(e=i.start){for(var a=i.cues,o=0;o=a[o].start&&ee){var a=r[i];if(a.start>=n)return;if(a.end>=n){if(e<=a.start)a.cues=h(a.cues,n),a.start=n;else{var o=m(a,e,n),s=o[0],u=o[1];this._cuesBuffer[i]=s,r.splice(i+1,0,u)}return}a.start>=e?(r.splice(i,1),i--):(a.cues=p(a.cues,e),a.end=Math.max(e,a.start))}},t.insert=function(e,t,n){var r=this._cuesBuffer,i={start:t,end:n,cues:e};function a(e){var t=r[e];void 0===t||v(i.end,t.end)?r[e]=i:(t.start>=i.end||(t.cues=h(t.cues,i.end),t.start=i.end),r.splice(e,0,i))}for(var o=0;os.end);return void a(o)}if(ts.end);return void a(o)}if(v(s.end,n))return s.cues=p(s.cues,t),s.end=t,void r.splice(o+1,0,i);if(s.end>n){var u=m(s,t,n),l=u[0],d=u[1];return this._cuesBuffer[o]=l,r.splice(o+1,0,i),void r.splice(o+2,0,d)}s.cues=p(s.cues,t),s.end=t;var c=o+1;for(s=r[c];void 0!==s&&n>s.end;)r.splice(c,1),s=r[c];return void a(c)}}r.push(i)},e}();function y(e,t,n,r){for(var i=[t/n.columns,e/n.rows],a=r.getElementsByClassName("proportional-style"),o=0;o0}var _=i.M4,b=i.bQ,S=i.Q$;function E(e,t){try{e.removeChild(t)}catch(e){a.Z.warn("HTSB: Can't remove text track: not in the element.")}}function T(e){var t=e.getAttribute("data-resolution-rows"),n=e.getAttribute("data-resolution-columns");if(null===t||null===n)return null;var r=parseInt(t,10),i=parseInt(n,10);return null===r||null===i?null:{rows:r,columns:i}}var k=function(e){function t(t,n){var r;return a.Z.debug("HTSB: Creating HTMLTextSegmentBuffer"),(r=e.call(this)||this).bufferType="text",r._buffered=new c.Z,r._videoElement=t,r._textTrackElement=n,r._sizeUpdateCanceller=new l.ZP,r._canceller=new l.ZP,r._buffer=new g,r._currentCues=[],r.autoRefreshSubtitles(r._canceller.signal),r}(0,r.Z)(t,e);var n=t.prototype;return n.pushChunk=function(e){try{this.pushChunkSync(e)}catch(e){return Promise.reject(e)}return Promise.resolve()},n.removeBuffer=function(e,t){return this.removeBufferSync(e,t),Promise.resolve()},n.endOfSegment=function(e){return this._segmentInventory.completeSegment(e,this._buffered),Promise.resolve()},n.getBufferedRanges=function(){return this._buffered},n.dispose=function(){a.Z.debug("HTSB: Disposing HTMLTextSegmentBuffer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._canceller.cancel()},n.pushChunkSync=function(e){var t,n;a.Z.debug("HTSB: Appending new html text tracks");var r=e.data,i=r.timestampOffset,o=r.appendWindow,s=r.chunk;if(null!==s){var u,l,d=s.start,c=s.end,v=s.data,p=s.type,h=s.language,m=null!==(t=o[0])&&void 0!==t?t:0,g=null!==(n=o[1])&&void 0!==n?n:1/0,y=function(e,t,n,r){a.Z.debug("HTSB: Finding parser for html text tracks:",e);var i=f.Z.htmlTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");a.Z.debug("HTSB: Parser found, parsing...");var o=i(t,n,r);return a.Z.debug("HTTB: Parsed successfully!",o.length),o}(p,v,i,h);if(0!==m&&g!==1/0){for(var _=0;_=0&&y[_].start>=g;)_--;for(y.splice(_,y.length),_=y.length-1;_>=0&&y[_].end>g;)y[_].end=g,_--}if(void 0!==d)u=Math.max(m,d);else{if(y.length<=0)return void a.Z.warn("HTSB: Current text tracks have no cues nor start time. Aborting");a.Z.warn("HTSB: No start time given. Guessing from cues."),u=y[0].start}if(void 0!==c)l=Math.min(g,c);else{if(y.length<=0)return void a.Z.warn("HTSB: Current text tracks have no cues nor end time. Aborting");a.Z.warn("HTSB: No end time given. Guessing from cues."),l=y[y.length-1].end}l<=u?a.Z.warn("HTSB: Invalid text track appended: ","the start time is inferior or equal to the end time."):(null!==e.inventoryInfos&&this._segmentInventory.insertChunk(e.inventoryInfos),this._buffer.insert(y,u,l),this._buffered.insert(u,l))}},n.removeBufferSync=function(e,t){a.Z.debug("HTSB: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t)},n._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),this._currentCues.length>0){for(var e=0;e0){this._sizeUpdateCanceller=new l.ZP,this._sizeUpdateCanceller.linkToSignal(this._canceller.signal);var c=u.Z.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL,f=function(e,t,n){var r=e.getBoundingClientRect(),i=r.height,u=r.width,l=(0,o.ZP)({height:i,width:u},n),d=i,c=u;if(void 0!==s){var f=new s((function(e){if(0!==e.length){var t=e[0].contentRect,n=t.height,r=t.width;n===d&&r===c||(d=n,c=r,l.setValue({height:n,width:r}))}else a.Z.error("Compat: Resized but no observed element.")}));f.observe(e),n.register((function(){f.disconnect()}))}else{var v=setInterval((function(){var t=e.getBoundingClientRect(),n=t.height,r=t.width;n===d&&r===c||(d=n,c=r,l.setValue({height:n,width:r}))}),t);n.register((function(){clearInterval(v)}))}return l}(this._textTrackElement,c,this._sizeUpdateCanceller.signal);f.onUpdate((function(e){for(var t=e.height,n=e.width,r=0;r0?e.textTracks[o-1]:e.addTextTrack(a)).mode=null!==(t=n.SHOWING)&&void 0!==t?t:"showing"}else r=document.createElement("track"),e.appendChild(r),n=r.track,r.kind=a,n.mode="showing";return{track:n,trackElement:r}}(t),o=r.track,s=r.trackElement;return n.bufferType="text",n._buffered=new u.Z,n._videoElement=t,n._track=o,n._trackElement=s,n}(0,r.Z)(t,e);var n=t.prototype;return n.pushChunk=function(e){var t,n;if(a.Z.debug("NTSB: Appending new native text tracks"),null===e.data.chunk)return Promise.resolve();var r=e.data,i=r.timestampOffset,o=r.appendWindow,s=r.chunk,u=s.start,d=s.end,c=s.data,f=s.type,v=s.language,p=null!==(t=o[0])&&void 0!==t?t:0,h=null!==(n=o[1])&&void 0!==n?n:1/0;try{var m,g,y=function(e,t,n,r){a.Z.debug("NTSB: Finding parser for native text tracks:",e);var i=l.Z.nativeTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");a.Z.debug("NTSB: Parser found, parsing...");var o=i(t,n,r);return a.Z.debug("NTSB: Parsed successfully!",o.length),o}(f,c,i,v);if(0!==p&&h!==1/0){for(var _=0;_=0&&y[_].startTime>=h;)_--;for(y.splice(_,y.length),_=y.length-1;_>=0&&y[_].endTime>h;)y[_].endTime=h,_--}if(void 0!==u)m=Math.max(p,u);else{if(y.length<=0)return a.Z.warn("NTSB: Current text tracks have no cues nor start time. Aborting"),Promise.resolve();a.Z.warn("NTSB: No start time given. Guessing from cues."),m=y[0].startTime}if(void 0!==d)g=Math.min(h,d);else{if(y.length<=0)return a.Z.warn("NTSB: Current text tracks have no cues nor end time. Aborting"),Promise.resolve();a.Z.warn("NTSB: No end time given. Guessing from cues."),g=y[y.length-1].endTime}if(g<=m)return a.Z.warn("NTSB: Invalid text track appended: ","the start time is inferior or equal to the end time."),Promise.resolve();if(y.length>0){var b=y[0],S=this._track.cues;null!==S&&S.length>0&&b.startTime=0;i--){var s=r[i],u=s.startTime,l=s.endTime;u>=e&&u<=t&&l<=t&&o(n,s)}this._buffered.remove(e,t)},t}(s.C)},9612:function(e,t,n){"use strict";n.d(t,{C:function(){return _},f:function(){return g}});var r=n(6872),i=n(3887),a=n(520),o=n(5278);function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate 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 n=0,r=new Array(t);n0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){var a=this._history.length-this._maxHistoryLength;this._history=this._history.splice(a)}},e}();function d(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){var _=t[p+y-1];g={end:(0,o.Z)(_.bufferedEnd,_.end),precizeEnd:_.precizeEnd},i.Z.debug("SI: "+y+" segments GCed.",u);for(var b,S=d(t.splice(p,y));!(b=S()).done;){var E=b.value;void 0===E.bufferedStart&&void 0===E.bufferedEnd&&this._bufferedHistory.addBufferedSegment(E.infos,null)}n=p}if(void 0===a)return;if(v-(0,o.Z)(a.bufferedStart,a.start)>=s){if(h(a,f,g,u),n===t.length-1)return void m(a,v,u);a=t[++n];for(var T=(0,o.Z)(a.bufferedStart,a.start),k=(0,o.Z)(a.bufferedEnd,a.end),w=c=s&&(void 0===w||v-T>=k-w);){var A=t[n-1];void 0===A.bufferedEnd&&(A.bufferedEnd=a.precizeStart?a.start:A.end,i.Z.debug("SI: calculating buffered end of contiguous segment",u,A.bufferedEnd,A.end)),a.bufferedStart=A.bufferedEnd,void 0!==(a=t[++n])&&(T=(0,o.Z)(a.bufferedStart,a.start),k=(0,o.Z)(a.bufferedEnd,a.end))}}var I=t[n-1];void 0!==I&&m(I,v,u)}}if(null!=a){i.Z.debug("SI: last segments have been GCed",u,n,t.length);for(var R,Z=d(t.splice(n,t.length-n));!(R=Z()).done;){var x=R.value;void 0===x.bufferedStart&&void 0===x.bufferedEnd&&this._bufferedHistory.addBufferedSegment(x.infos,null)}}void 0!==u&&i.Z.hasLevel("DEBUG")&&i.Z.debug("SI: current "+u+" inventory timeline:\n"+function(e){var t=1/60,n={},r=[],i=null,a=null;function o(e){var t=String.fromCharCode(r.length+65);return r.push({letter:t,periodId:e.period.id,representationId:e.representation.id,bitrate:e.representation.bitrate}),t}for(var s="",u=0;u=u)i.Z.warn("SI: Invalid chunked inserted: starts before it ends",l,s,u);else{for(var d=this._inventory,c={partiallyPushed:!0,chunkSize:o,splitted:!1,start:s,end:u,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:a,period:t,adaptation:n,representation:r}},f=d.length-1;f>=0;f--){var v=d[f];if(v.start<=s){if(v.end<=s){for(i.Z.debug("SI: Pushing segment strictly after previous one.",l,s,v.end),this._inventory.splice(f+1,0,c),f+=2;fc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[f].start),d[f].start=c.end,d[f].bufferedStart=void 0,void(d[f].precizeStart=d[f].precizeStart&&c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[f].start,d[f].end),d.splice(f,1)}return}if(v.start===s){if(v.end<=u){for(i.Z.debug("SI: Segment pushed replace another one",l,s,u,v.end),this._inventory.splice(f,1,c),f+=1;fc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[f].start),d[f].start=c.end,d[f].bufferedStart=void 0,void(d[f].precizeStart=d[f].precizeStart&&c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[f].start,d[f].end),d.splice(f,1)}return}return i.Z.debug("SI: Segment pushed ends before another with the same start",l,s,u,v.end),d.splice(f,0,c),v.start=c.end,v.bufferedStart=void 0,void(v.precizeStart=v.precizeStart&&c.precizeEnd)}if(v.end<=c.end){for(i.Z.debug("SI: Segment pushed updates end of previous one",l,s,u,v.start,v.end),this._inventory.splice(f+1,0,c),v.end=c.start,v.bufferedEnd=void 0,v.precizeEnd=v.precizeEnd&&c.precizeStart,f+=2;fc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[f].start),d[f].start=c.end,d[f].bufferedStart=void 0,void(d[f].precizeStart=d[f].precizeStart&&c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[f].start,d[f].end),d.splice(f,1)}return}i.Z.warn("SI: Segment pushed is contained in a previous one",l,s,u,v.start,v.end);var p={partiallyPushed:v.partiallyPushed,chunkSize:v.chunkSize,splitted:!0,start:c.end,end:v.end,precizeStart:v.precizeStart&&v.precizeEnd&&c.precizeEnd,precizeEnd:v.precizeEnd,bufferedStart:void 0,bufferedEnd:v.end,infos:v.infos};return v.end=c.start,v.splitted=!0,v.bufferedEnd=void 0,v.precizeEnd=v.precizeEnd&&c.precizeStart,d.splice(f+1,0,c),void d.splice(f+2,0,p)}}var h=this._inventory[0];if(void 0===h)return i.Z.debug("SI: first segment pushed",l,s,u),void this._inventory.push(c);if(!(h.start>=u)){if(h.end<=u){for(i.Z.debug("SI: Segment pushed starts before and completely recovers the previous first one",l,s,u,h.start,h.end),this._inventory.splice(0,1,c);d.length>1&&d[1].startc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[1].start),d[1].start=c.end,d[1].bufferedStart=void 0,void(d[1].precizeStart=c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[1].start,d[1].end),d.splice(1,1)}return}return i.Z.debug("SI: Segment pushed start of the next one",l,s,u,h.start,h.end),h.start=u,h.bufferedStart=void 0,h.precizeStart=c.precizeEnd,void this._inventory.splice(0,0,c)}i.Z.debug("SI: Segment pushed comes before all previous ones",l,s,u,h.start),this._inventory.splice(0,0,c)}}},t.completeSegment=function(e,t){if(!e.segment.isInit){for(var n=this._inventory,r=[],o=0;o0&&(s=!0,1===r.length&&(i.Z.warn("SI: Completed Segment is splitted.",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));var u=o,l=n[o].chunkSize;for(o+=1;o0&&(this._inventory.splice(u+1,v),o-=v),this._inventory[u].partiallyPushed=!1,this._inventory[u].chunkSize=l,this._inventory[u].end=p,this._inventory[u].bufferedEnd=h,this._inventory[u].splitted=s,r.push(this._inventory[u])}if(0===r.length)i.Z.warn("SI: Completed Segment not found",e.segment.id,e.segment.time);else{this.synchronizeBuffered(t);for(var m,g=d(r);!(m=g()).done;){var y=m.value;void 0!==y.bufferedStart&&void 0!==y.bufferedEnd?this._bufferedHistory.addBufferedSegment(y.infos,{start:y.bufferedStart,end:y.bufferedEnd}):i.Z.debug("SI: buffered range not known after sync. Skipping history.",y.start,y.end)}}}},t.getInventory=function(){return this._inventory},t.getHistoryFor=function(e){return this._bufferedHistory.getHistoryFor(e)},e}();function v(e){if(void 0===e.bufferedStart||e.partiallyPushed)return!1;var t=e.start,n=e.end-t,i=r.Z.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(t-e.bufferedStart)<=a&&(void 0===e.bufferedEnd||e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-n)<=Math.min(o,n/3))}function p(e){if(void 0===e.bufferedEnd||e.partiallyPushed)return!1;var t=e.start,n=e.end,i=n-t,a=r.Z.getCurrent(),o=a.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,s=a.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(n-e.bufferedEnd)<=o&&null!=e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-i)<=Math.min(s,i/3)}function h(e,t,n,a){var o=r.Z.getCurrent().MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE;void 0!==e.bufferedStart?(e.bufferedStartt&&(n.precizeEnd||e.start-n.end<=o)?(i.Z.debug("SI: buffered start is end of previous segment",a,t,e.start,n.end),e.bufferedStart=n.end,v(e)&&(e.start=n.end,e.precizeStart=!0)):e.start-t<=o?(i.Z.debug("SI: found true buffered start",a,t,e.start),e.bufferedStart=t,v(e)&&(e.start=t,e.precizeStart=!0)):tt&&(i.Z.debug("SI: Segment partially GCed at the end",n,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=a&&p(e)&&(e.precizeEnd=!0,e.end=t)):e.precizeEnd?(i.Z.debug("SI: buffered end is precize end",n,e.end),e.bufferedEnd=e.end):t-e.end<=a?(i.Z.debug("SI: found true buffered end",n,t,e.end),e.bufferedEnd=t,p(e)&&(e.end=t,e.precizeEnd=!0)):t>e.end?(i.Z.debug("SI: range end too far from expected end",n,t,e.end),e.bufferedEnd=e.end):(i.Z.debug("SI: Segment appears immediately garbage collected at the end",n,e.bufferedEnd,t),e.bufferedEnd=t)}var g,y=f,_=function(){function e(){this._segmentInventory=new y}var t=e.prototype;return t.synchronizeInventory=function(){this._segmentInventory.synchronizeBuffered(this.getBufferedRanges())},t.getInventory=function(){return this._segmentInventory.getInventory()},t.getPendingOperations=function(){return[]},t.getSegmentHistory=function(e){return this._segmentInventory.getHistoryFor(e)},e}();!function(e){e[e.Push=0]="Push",e[e.Remove=1]="Remove",e[e.EndOfSegment=2]="EndOfSegment"}(g||(g={}))},4309:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(2829),i=function(){function e(){this._ranges=[],this.length=0}var t=e.prototype;return t.insert=function(e,t){(0,r.kR)(this._ranges,{start:e,end:t}),this.length=this._ranges.length},t.remove=function(e,t){var n=[];e>0&&n.push({start:0,end:e}),t<1/0&&n.push({start:t,end:1/0}),this._ranges=(0,r.tn)(this._ranges,n),this.length=this._ranges.length},t.start=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}()},7839:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(7326),i=n(4578),a=function(e){function t(n,i,a,o){var s;return s=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(s),t.prototype),s.name="CustomLoaderError",s.message=n,s.canRetry=i,s.isOfflineError=a,s.xhr=o,s}return(0,i.Z)(t,e),t}((0,n(2146).Z)(Error))},5157:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i,a){var u;return u=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(u),t.prototype),u.name="EncryptedMediaError",u.type=o.ZB.ENCRYPTED_MEDIA_ERROR,u.code=n,u.message=(0,s.Z)(u.name,u.code,i),u.fatal=!1,"string"==typeof(null==a?void 0:a.keyStatuses)&&(u.keyStatuses=a.keyStatuses),u}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},5992:function(e,t,n){"use strict";n.d(t,{SM:function(){return a},ZB:function(){return r},br:function(){return i}});var r={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},i={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},a={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"}},7367:function(e,t,n){"use strict";function r(e,t,n){return e+" ("+t+") "+n}n.d(t,{Z:function(){return r}})},8750:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(9822),i=n(5389);function a(e,t){var n=t.defaultCode,a=t.defaultReason;if((0,r.Z)(e))return e;var o=e instanceof Error?e.toString():a;return new i.Z(n,o)}},9822:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(5157),i=n(5992),a=n(3714),o=n(9362),s=n(5389);function u(e){return(e instanceof r.Z||e instanceof a.Z||e instanceof s.Z||e instanceof o.Z)&&Object.keys(i.ZB).indexOf(e.type)>=0}},3714:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i,a){var u;u=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(u),t.prototype),u.name="MediaError",u.type=o.ZB.MEDIA_ERROR,u.code=n,u.message=(0,s.Z)(u.name,u.code,i),u.fatal=!1;var l=null==a?void 0:a.adaptation;if(void 0!==l)switch(l.type){case"audio":u.trackInfo={type:"audio",track:l.toAudioTrack(!1)};break;case"video":u.trackInfo={type:"video",track:l.toVideoTrack(!1)};break;case"text":u.trackInfo={type:"text",track:l.toTextTrack()}}return u}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},9362:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i){var a;return a=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(a),t.prototype),a.name="NetworkError",a.type=o.ZB.NETWORK_ERROR,a.url=i.url,a.status=i.status,a.errorType=i.type,a.code=n,a.message=(0,s.Z)(a.name,a.code,i.message),a.fatal=!1,a}return(0,i.Z)(t,e),t.prototype.isHttpError=function(e){return this.errorType===o.br.ERROR_HTTP_CODE&&this.status===e},t}((0,a.Z)(Error))},5389:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i){var a;return a=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(a),t.prototype),a.name="OtherError",a.type=o.ZB.OTHER_ERROR,a.code=n,a.message=(0,s.Z)(a.name,a.code,i),a.fatal=!1,a}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},9105:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(7326),i=n(4578),a=function(e){function t(n,i,a){var o;return o=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(o),t.prototype),o.name="RequestError",o.url=n,o.status=i,o.type=a,o.message=a,o}return(0,i.Z)(t,e),t}((0,n(2146).Z)(Error))},7273:function(e,t){"use strict";t.Z={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,ContentDecryptor:null,htmlTextTracksBuffer:null,htmlTextTracksParsers:{},nativeTextTracksBuffer:null,nativeTextTracksParsers:{},transports:{}}},7874:function(e,t,n){"use strict";var r=n(7273);t.Z=r.Z},3887:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(8894),i=new(function(){function e(){this.error=r.Z,this.warn=r.Z,this.info=r.Z,this.debug=r.Z,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentLevel="NONE"}var t=e.prototype;return t.setLevel=function(e){var t,n=this._levels[e];"number"==typeof n?(t=n,this._currentLevel=e):(t=0,this._currentLevel="NONE"),this.error=t>=this._levels.ERROR?console.error.bind(console):r.Z,this.warn=t>=this._levels.WARNING?console.warn.bind(console):r.Z,this.info=t>=this._levels.INFO?console.info.bind(console):r.Z,this.debug=t>=this._levels.DEBUG?console.log.bind(console):r.Z},t.getLevel=function(){return this._currentLevel},t.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},e}())},9665:function(e,t,n){"use strict";n.d(t,{r:function(){return f},Z:function(){return v}});var r=n(3887),i=n(3274),a=n(1946),o=n(5288),s=n(3774);var u=n(4791);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(this.trickModeTracks=i.map((function(t){return new e(t)})));for(var d=t.representations,f=[],v=!1,p=0;p0&&!r.isSupported){var i=new d.Z("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{adaptation:r});n.contentWarnings.push(i)}return r})).filter((function(e){return e.representations.length>0}));if(o.every((function(e){return!e.isSupported}))&&a.length>0&&("video"===i||"audio"===i))throw new d.Z("MANIFEST_PARSE_ERROR","No supported "+i+" adaptations");return o.length>0&&(r[i]=o),r}),{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new d.Z("MANIFEST_PARSE_ERROR","No supported audio and video tracks.");this.duration=e.duration,this.start=e.start,null!=this.duration&&null!=this.start&&(this.end=this.start+this.duration),this.streamEvents=void 0===e.streamEvents?[]:e.streamEvents}var t=e.prototype;return t.getAdaptations=function(){var e=this.adaptations;return(0,c.Z)(e).reduce((function(e,t){return null!=t?e.concat(t):e}),[])},t.getAdaptationsForType=function(e){var t=this.adaptations[e];return null==t?[]:t},t.getAdaptation=function(e){return(0,o.Z)(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},t.getSupportedAdaptations=function(e){if(void 0===e)return this.getAdaptations().filter((function(e){return e.isSupported}));var t=this.adaptations[e];return void 0===t?[]:t.filter((function(e){return e.isSupported}))},t.containsTime=function(e){return e>=this.start&&(void 0===this.end||e=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0)a.Z.warn("Manifest: "+y.length+" new Representations found when merging."),(m=t.representations).push.apply(m,y),v.push.apply(v,y)}l=e},l=0;l0){a.Z.warn("Manifest: "+s.length+" new Adaptations found when merging.");for(var d,c=h(s);!(d=c()).done;){var f=d.value,v=e.adaptations[f.type];void 0===v?e.adaptations[f.type]=[f]:v.push(f),i.addedAdaptations.push(f)}}return i}function y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=t.start&&(void 0===t.end||t.end>e)}))},n.getNextPeriod=function(e){return(0,o.Z)(this.periods,(function(t){return t.start>e}))},n.getPeriodAfter=function(e){var t=e.end;if(void 0===t)return null;var n=(0,o.Z)(this.periods,(function(e){return void 0===e.end||t0&&this.trigger("decipherabilityUpdate",t)},n.getAdaptations=function(){(0,l.Z)("manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead");var e=this.periods[0];if(void 0===e)return[];var t=e.adaptations,n=[];for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];n.push.apply(n,i)}return n},n.getAdaptationsForType=function(e){(0,l.Z)("manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead");var t=this.periods[0];if(void 0===t)return[];var n=t.adaptations[e];return void 0===n?[]:n},n.getAdaptation=function(e){return(0,l.Z)("manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead"),(0,o.Z)(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n._performUpdate=function(e,t){var n;if(this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.contentWarnings=e.contentWarnings,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime,t===r.Full)this._timeBounds=e._timeBounds,this.uris=e.uris,n=function(e,t){for(var n={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},i=0,o=0;oe.length)return a.Z.error("Manifest: error when updating Periods"),n;if(i0&&(e.push.apply(e,b),(_=n.addedPeriods).push.apply(_,b)),n}(this.periods,e.periods);else{this._timeBounds.maximumTimeData=e._timeBounds.maximumTimeData,this.updateUrl=e.uris[0],n=function(e,t){var n,i={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(0===e.length)return e.splice.apply(e,[0,0].concat(t)),(n=i.addedPeriods).push.apply(n,t),i;if(0===t.length)return i;var o=e[e.length-1];if(o.startc){var T;a.Z.warn("Manifest: old Periods not found in new when updating, removing");var k=e.splice(c,h-c);(T=i.removedPeriods).push.apply(T,k),h=c}var w=g(e[h],v,r.Full);i.updatedPeriods.push({period:e[h],result:w})}c++}if(c0;){var o=this.periods[0];if(void 0===o.end||o.end>i)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",n)},t}(s.Z);var E=S},520:function(e,t,n){"use strict";n.d(t,{K:function(){return a},z:function(){return i}});var r=n(1946);function i(e,t){return e.segment.id===t.segment.id&&e.representation.id===t.representation.id&&e.adaptation.id===t.adaptation.id&&e.period.id===t.period.id}function a(e){if((0,r.Z)(e))return"";var t=e.period,n=e.adaptation,i=e.representation,a=e.segment;return n.type+" P: "+t.id+" A: "+n.id+" R: "+i.id+" S: "+(a.isInit?"init":a.complete?a.time+"-"+a.duration:""+a.time)}},2689:function(e,t,n){"use strict";n.d(t,{s:function(){return r}});var r=Math.pow(2,32)-1},2297:function(e,t,n){"use strict";n.d(t,{Qy:function(){return f},Xj:function(){return p},iz:function(){return c},lp:function(){return d},nR:function(){return v},t_:function(){return l},vA:function(){return u}});var r=n(3887),i=n(811),a=n(6968);function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ni)return null;s=(0,a.pV)(e,r),r+=8}if(s<0)throw new Error("ISOBMFF: Size out of range");if(n===t)return 1970628964===t&&(r+=16),[o,r,o+s];o+=s}return null}function v(e,t,n,r,i){for(var o,s=e.length,u=0;us)return;o=(0,a.pV)(e,l),l+=8}if(1970628964===d&&l+16<=s&&(0,a.pX)(e,l)===t&&(0,a.pX)(e,l+4)===n&&(0,a.pX)(e,l+8)===r&&(0,a.pX)(e,l+12)===i)return l+=16,e.subarray(l,u+o)}}function p(e){var t=e.length;if(t<8)return r.Z.warn("ISOBMFF: box inferior to 8 bytes, cannot find offsets"),null;var n=0,i=(0,a.pX)(e,n);n+=4;var o=(0,a.pX)(e,n);if(n+=4,0===i)i=t;else if(1===i){if(n+8>t)return r.Z.warn("ISOBMFF: box too short, cannot find offsets"),null;i=(0,a.pV)(e,n),n+=8}if(i<0)throw new Error("ISOBMFF: Size out of range");return 1970628964===o&&(n+=16),[0,n,i]}},6807:function(e,t,n){"use strict";n.d(t,{E3:function(){return u},Le:function(){return o},XA:function(){return i},fs:function(){return s},uq:function(){return a}});var r=n(2297);function i(e){var t=(0,r.t_)(e,1836019558);return null===t?null:(0,r.t_)(t,1953653094)}function a(e){return(0,r.lp)(e,1836019558).reduce((function(e,t){var n=(0,r.t_)(t,1953653094);return null!==n&&e.push(n),e}),[])}function o(e){return(0,r.t_)(e,1835295092)}function s(e){var t=(0,r.t_)(e,1836019574);if(null===t)return null;var n=(0,r.t_)(t,1953653099);return null===n?null:(0,r.t_)(n,1835297121)}function u(e,t){return void 0===t&&(t=0),(0,r.t_)(e.subarray(t),1701671783)}},6490:function(e,t,n){"use strict";n.d(t,{Z:function(){return s},Y:function(){return u}});var r=n(3887);var i="function"==typeof Uint8Array.prototype.slice?function(e,t,n){return e.slice(t,n)}:function(e,t,n){return new Uint8Array(Array.prototype.slice.call(e,t,n))},a=n(3635),o=n(2297);function s(e){var t=0,n=(0,o.t_)(e,1836019574);if(null===n)return[];for(var a=[];t1)r.Z.warn("ISOBMFF: un-handled PSSH version");else{var n=t+4;if(!(n+16>e.length)){var o=i(e,n,n+16);return(0,a.ci)(o)}}}},4644:function(e,t,n){"use strict";n.d(t,{J6:function(){return m},LD:function(){return h},MM:function(){return p},Qx:function(){return f},R0:function(){return y},Wf:function(){return c},s9:function(){return g}});var r=n(3887),i=n(6968),a=n(3635),o=n(2689),s=n(2297),u=n(6807);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0;){var v=(0,i.pX)(e,o);o+=4;var p=2147483647&v;if(1===(2147483648&v)>>>31)throw new Error("sidx with reference_type `1` not yet implemented");var h=(0,i.pX)(e,o);o+=4,o+=4,c.push({time:l,duration:h,timescale:d,range:[r,r+p-1]}),l+=h,r+=p}return c}function f(e){var t=(0,u.XA)(e);if(null!==t){var n=(0,s.t_)(t,1952867444);if(null!==n){var r=n[0];return 1===r?(0,i.pV)(n,4):0===r?(0,i.pX)(n,4):void 0}}}function v(e){var t=(0,s.t_)(e,1952868452);if(null!==t){var n=1,r=(0,i.QI)(t,n);if(n+=3,(8&r)>0)return n+=4,(1&r)>0&&(n+=8),(2&r)>0&&(n+=4),(0,i.pX)(t,n)}}function p(e){var t=(0,u.uq)(e);if(0!==t.length){for(var n,r=0,a=l(t);!(n=a()).done;){var o=n.value,d=(0,s.t_)(o,1953658222);if(null===d)return;var c=0,f=d[c];if(c+=1,f>1)return;var p=(0,i.QI)(d,c);c+=3;var h=(256&p)>0,m=0;if(!h&&void 0===(m=v(o)))return;var g=(1&p)>0,y=(4&p)>0,_=(512&p)>0,b=(1024&p)>0,S=(2048&p)>0,E=(0,i.pX)(d,c);c+=4,g&&(c+=4),y&&(c+=4);for(var T=E,k=0;T-- >0;)h?(k+=(0,i.pX)(d,c),c+=4):k+=m,_&&(c+=4),b&&(c+=4),S&&(c+=4);r+=k}return r}}function h(e){var t=(0,u.fs)(e);if(null!==t){var n=(0,s.t_)(t,1835296868);if(null!==n){var r=0,a=n[r];return r+=4,1===a?(0,i.pX)(n,r+16):0===a?(0,i.pX)(n,r+8):void 0}}}function m(e){var t=e.length;if(t<4)throw new Error("Cannot update box length: box too short");var n=(0,i.pX)(e,0);if(0===n){if(t>o.s){var r=new Uint8Array(t+8);return r.set((0,i.kh)(1),0),r.set(e.subarray(4,8),4),r.set((0,i.el)(t+8),8),r.set(e.subarray(8,t),16),r}return e.set((0,i.kh)(t),0),e}if(1===n){if(t<16)throw new Error("Cannot update box length: box too short");return e.set((0,i.el)(t),8),e}if(t<=o.s)return e.set((0,i.kh)(t),0),e;var a=new Uint8Array(t+8);return a.set((0,i.kh)(1),0),a.set(e.subarray(4,8),4),a.set((0,i.el)(t+8),8),a.set(e.subarray(8,t),16),a}function g(e){for(var t=[],n=0;n=0;t--){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,s=null;if(void 0!==r){var u=d(r);if(void 0===u)return{safe:void 0,unsafe:void 0};a=u}if(void 0!==i){var l=d(i);if(void 0===l)return{safe:void 0,unsafe:void 0};s=l}if(void 0!==r&&null===a||void 0!==i&&null===s)return o.Z.info("Parser utils: found Period with no segment. ","Going to previous one to calculate last position"),{safe:void 0,unsafe:void 0};if(null!==s)return null!==a?{safe:Math.min(a,s),unsafe:Math.max(a,s)}:{safe:s,unsafe:s};if(null!==a)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}(e);return{minimumSafePosition:t,maximumSafePosition:n.safe,maximumUnsafePosition:n.unsafe}}var v=n(9592),p=n(908),h=n(1679),m=n(3635);var g=function(){function e(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=e.isDynamic&&void 0!==e.timeShiftBufferDepth?e.timeShiftBufferDepth:null}var t=e.prototype;return t.setLastPosition=function(e,t){this._lastPosition=e,this._positionTime=t},t.lastPositionIsKnown=function(){return this._isDynamic?null!=this._positionTime&&null!=this._lastPosition:null!=this._lastPosition},t.estimateMinimumBound=function(){if(!this._isDynamic||null===this._timeShiftBufferDepth)return 0;var e=this.estimateMaximumBound();return void 0!==e?e-this._timeShiftBufferDepth:void 0},t.estimateMaximumBound=function(){return this._isDynamic&&null!=this._positionTime&&null!=this._lastPosition?Math.max(this._lastPosition-this._positionTime+performance.now()/1e3,0):this._lastPosition},e}(),y=n(9665),_=n(5138),b=n(7714),S=n(6923);function E(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=a?o:(new Array(a+1).join("0")+o).slice(-a)}}function P(e,t,n){return function(e,t,n){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,x(void 0===n?0:n))}(e,t,n)}function M(e,t){return function(n){return-1===n.indexOf("$")?n:n.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,(function(e,n,r){if(void 0===t)throw new Error("Segment number not defined in a $Number$ scheme");return x(t)(e,n,r)})).replace(/\$Time(\%0(\d+)d)?\$/g,(function(t,n,r){if(void 0===e)throw new Error("Segment time not defined in a $Time$ scheme");return x(e)(t,n,r)}))}}function C(e,t,n,r,i){for(var a,o,s=(0,R.gT)(t,e),u=(0,R.gT)(t+n,e),l=e.timeline,d=e.timescale,c=e.segmentUrlTemplate,f=e.startNumber,v=e.endNumber,p=null!=f?f:1,h=[],m=l.length,g=0;g0?Math.floor(o/a):0),w=b+k*_;wv)break;var I=null===c?null:M(w,A)(c),Z=w-e.indexTimeOffset,x=_;Z<0&&(x=_+Z,Z=0);var P={id:String(w),time:Z/d,end:(Z+x)/d,duration:x/d,isInit:!1,range:S,timescale:1,url:I,number:A,timestampOffset:-e.indexTimeOffset/d,complete:T,privateInfos:{isEMSGWhitelisted:r}};h.push(P),w=b+ ++k*_}if(w>=u)return h;if(p+=E+1,void 0!==v&&p>v)return h}return h}function D(e,t){if(t.timescale!==e.timescale){var n=e.timescale;e.timeline.push({start:t.time/t.timescale*n,duration:t.duration/t.timescale*n,repeatCount:void 0===t.count?0:t.count,range:t.range})}else e.timeline.push({start:t.time,duration:t.duration,repeatCount:void 0===t.count?0:t.count,range:t.range});return!0}var N=function(){function e(e,t){var n,r,i,a=t.periodStart,o=t.periodEnd,s=t.representationId,u=t.representationBitrate,l=t.isEMSGWhitelisted,d=null!==(n=e.timescale)&&void 0!==n?n:1,c=(null!=e.presentationTimeOffset?e.presentationTimeOffset:0)-a*d,f=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:P(e.initialization.media,s,u),v=void 0===e.media?null:P(e.media,s,u),p=void 0!==e.initialization?e.initialization.range:void 0!==e.indexRange?[0,e.indexRange[0]-1]:void 0;this._index={indexRange:e.indexRange,indexTimeOffset:c,initialization:{url:f,range:p},segmentUrlTemplate:v,startNumber:e.startNumber,endNumber:e.endNumber,timeline:null!==(i=e.timeline)&&void 0!==i?i:[],timescale:d},this._scaledPeriodStart=(0,R.gT)(a,this._index),this._scaledPeriodEnd=null==o?void 0:(0,R.gT)(o,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=l}var t=e.prototype;return t.getInitSegment=function(){return Z(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){return C(this._index,e,t,this._isEMSGWhitelisted,this._scaledPeriodEnd)},t.shouldRefresh=function(){return!1},t.getFirstAvailablePosition=function(){var e=this._index;return 0===e.timeline.length?null:(0,R.zG)(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)},t.getLastAvailablePosition=function(){var e,t=this._index.timeline;if(0===t.length)return null;var n=t[t.length-1],r=Math.min((0,R.jH)(n,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0);return(0,R.zG)(r,this._index)},t.getEnd=function(){return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(){return!1},t.isSegmentStillAvailable=function(){return!0},t.checkDiscontinuity=function(){return null},t.canBeOutOfSyncError=function(){return!1},t.isFinished=function(){return!0},t.isInitialized=function(){return this._isInitialized},t.initialize=function(e){if(!this._isInitialized){for(var t=0;t0){var s=i-a.start;if(s%a.duration==0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(++o>=e.length)return null;if((a=e[o]).start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}else for(var u=0,l=t[0],d=i;;){var c=l.getAttribute("d"),f=null===c?null:parseInt(c,10);if(null===f||Number.isNaN(f))return null;var v=l.getAttribute("r"),p=null===v?null:parseInt(v,10);if(null!==p){if(Number.isNaN(p)||p<0)return null;if(p>0){var h=n-d;if(h%f==0&&h/f<=p)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:u}}d+=f*(p+1)}else d+=f;if(++u>=t.length)return null;var m=(l=t[u]).getAttribute("t"),g=null===m?null:parseInt(m,10);if(null!==g){if(Number.isNaN(g))return null;d=g}if(d===n)return{newElementsIdx:u,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(d>i)return null}}(t,e);if(null===r)return o.Z.warn('DASH: Cannot perform "based" update. Common segment not found.'),W(e);var i=r.prevSegmentsIdx,a=r.newElementsIdx,s=r.repeatNumberInPrevSegments,u=r.repeatNumberInNewElements,l=t.length-i+a-1;if(l>=e.length)return o.Z.info('DASH: Cannot perform "based" update. New timeline too short'),W(e);var d=t.slice(i);if(s>0){var c=d[0];c.start+=c.duration*s,d[0].repeatCount-=s}if(u>0&&0!==a)return o.Z.info('DASH: Cannot perform "based" update. The new timeline has a different form.'),W(e);var f=d[d.length-1],v=G(e[l]),p=(null!==(n=v.repeatCount)&&void 0!==n?n:0)-u;if(v.duration!==f.duration||f.repeatCount>p)return o.Z.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),W(e);void 0!==v.repeatCount&&v.repeatCount>f.repeatCount&&(f.repeatCount=v.repeatCount);for(var h=[],m=[],g=l+1;g0){var s=i[i.length-1];if((0,R.jH)(s,null,this._scaledPeriodEnd)+a>=Math.min(o,null!==(n=this._scaledPeriodEnd)&&void 0!==n?n:1/0))return!1}return void 0===this._scaledPeriodEnd?o+a>this._scaledPeriodStart&&void 0:(0,R.gT)(e,this._index)-athis._scaledPeriodStart},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index,n=t.timeline,r=t.timescale,i=t.indexTimeOffset;return(0,F.Z)(e,n,r,i)},t.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),(0,R._j)({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},t.canBeOutOfSyncError=function(e){return!!this._isDynamic&&(e instanceof L.Z&&e.isHttpError(404))},t._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},t._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),(0,V.Z)(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},t.isFinished=function(){if(!this._isDynamic||!this._isLastPeriod)return!0;null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;if(void 0===this._scaledPeriodEnd||0===e.length)return!1;var t=e[e.length-1];return(0,R.jH)(t,null,this._scaledPeriodEnd)+z(this._index.timescale)>=this._scaledPeriodEnd},t.isInitialized=function(){return!0},t.initialize=function(){o.Z.error("A `TimelineRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){o.Z.warn("Cannot add predicted segments to a `TimelineRepresentationIndex`")},e.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},t._refreshTimeline=function(){if(null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic){var e=this._manifestBoundsCalculator.estimateMinimumBound();if(null!=e){var t=(0,R.gT)(e,this._index),n=(0,B.Z)(this._index.timeline,t);void 0!==this._index.startNumber?this._index.startNumber+=n:void 0!==this._index.endNumber&&(this._index.startNumber=n+1)}}},e.getIndexEnd=function(e,t){return e.length<=0?null:Math.min((0,R.jH)(e[e.length-1],null,t),null!=t?t:1/0)},t._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(o.Z.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,n=a.Z.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.lengthn){if(r===n+1)return e.slice(0,i+1);var o=e.slice(0,i),s=Object.assign({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,n-u),o.push(s),o}}return e}var Y=H,X=function(){function e(e,t){var n,r,i=t.availabilityTimeOffset,a=t.manifestBoundsCalculator,o=t.isDynamic,s=t.periodEnd,u=t.periodStart,l=t.representationId,d=t.representationBitrate,c=t.isEMSGWhitelisted,f=null!==(n=e.timescale)&&void 0!==n?n:1;this._availabilityTimeOffset=i,this._manifestBoundsCalculator=a;var v=null!=e.presentationTimeOffset?e.presentationTimeOffset:0,p=v-u*f;if(void 0===e.duration)throw new Error("Invalid SegmentTemplate: no duration");var h=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:P(e.initialization.media,l,d),m=void 0===e.media?null:P(e.media,l,d);this._index={duration:e.duration,timescale:f,indexRange:e.indexRange,indexTimeOffset:p,initialization:null==e.initialization?void 0:{url:h,range:e.initialization.range},url:m,presentationTimeOffset:v,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=o,this._periodStart=u,this._scaledRelativePeriodEnd=void 0===s?void 0:(s-u)*f,this._isEMSGWhitelisted=c}var t=e.prototype;return t.getInitSegment=function(){return Z(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){var n=this._index,r=n.duration,i=n.startNumber,a=n.endNumber,o=n.timescale,s=n.url,u=this._periodStart*o,l=this._scaledRelativePeriodEnd,d=e*o-u,c=(e+t)*o-u,f=this._getFirstSegmentStart(),v=this._getLastSegmentStart();if(null==f||null==v)return[];var p=Math.max(f,d),h=Math.min(v,c);if(h+r<=p)return[];for(var m=[],g=null!=i?i:1,y=Math.floor(p/r),_=y*r;_<=h;_+=r){var b=y+g;if(void 0!==a&&b>a)return m;var S=null!=l&&_+r>l?l-_:r,E=_+u,T=_+this._index.presentationTimeOffset,k=null===s?null:M(T,b)(s),w={id:String(b),number:b,time:E/o,end:(E+S)/o,duration:S/o,timescale:1,isInit:!1,scaledDuration:S/o,url:k,timestampOffset:-n.indexTimeOffset/o,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(w),y++}return m},t.getFirstAvailablePosition=function(){var e=this._getFirstSegmentStart();return null==e?e:e/this._index.timescale+this._periodStart},t.getLastAvailablePosition=function(){var e=this._getLastSegmentStart();if((0,i.Z)(e))return e;var t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,null!=t?t:1/0)/this._index.timescale+this._periodStart},t.getEnd=function(){if(!this._isDynamic)return this.getLastAvailablePosition();var e=this._estimateRelativeScaledEnd();if(void 0!==e){var t=this._index.timescale;return(e+this._periodStart*t)/t}},t.awaitSegmentBetween=function(e,t){if((0,U.Z)(e<=t),!this._isDynamic)return!1;var n=this._index.timescale,r=z(n),i=this._periodStart*n,a=t*n-i,o=this._estimateRelativeScaledEnd();return void 0===o?a+r>=0:e*n-i-r=e},t.isInitialized=function(){return!0},t.initialize=function(){o.Z.error("A `TemplateRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){o.Z.warn("Cannot add predicted segments to a `TemplateRepresentationIndex`")},t._replace=function(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator},t._update=function(e){this._replace(e)},t._getFirstSegmentStart=function(){if(!this._isDynamic)return 0;if(0===this._scaledRelativePeriodEnd||void 0===this._scaledRelativePeriodEnd){var e=this._manifestBoundsCalculator.estimateMaximumBound();if(void 0!==e&&ethis._periodStart?(i-this._periodStart)*r:0;return Math.floor(a/n)*n}},t._getLastSegmentStart=function(){var e,t=this._index,n=t.duration,r=t.timescale,i=t.endNumber,o=t.startNumber,s=void 0===o?1:o;if(this._isDynamic){var u=this._manifestBoundsCalculator.estimateMaximumBound();if(void 0===u)return;if(void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<(u-this._periodStart)*this._index.timescale){var l=Math.ceil(this._scaledRelativePeriodEnd/n);return void 0!==i&&i-s+1m||p<2?h:(p-2)*n},t._estimateRelativeScaledEnd=function(){var e,t;if(void 0!==this._index.endNumber){var n=this._index.endNumber-(null!==(e=this._index.startNumber)&&void 0!==e?e:1)+1;return Math.max(Math.min(n*this._index.duration,null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:1/0),0)}if(void 0!==this._scaledRelativePeriodEnd)return Math.max(this._scaledRelativePeriodEnd,0)},e}();function Q(e,t){var n;if(0===t.length)return e;var r=t.map((function(e){return{url:e.value}}));if(0===e.length)return r;for(var i=[],a=0;a=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){var g=t.parentSegmentTemplates.slice(),y=e.children.segmentTemplate;void 0!==y&&g.push(y);var _=I.Z.apply(void 0,[{}].concat(g));p.availabilityTimeComplete=null!==(n=_.availabilityTimeComplete)&&void 0!==n?n:t.availabilityTimeComplete,p.availabilityTimeOffset=(null!==(r=_.availabilityTimeOffset)&&void 0!==r?r:0)+t.availabilityTimeOffset,i=Y.isTimelineIndexArgument(_)?new Y(_,p):new X(_,p)}else{var b=t.adaptation.children;if(void 0!==b.segmentBase){var S=b.segmentBase;i=new N(S,p)}else if(void 0!==b.segmentList){var E=b.segmentList;i=new O(E,p)}else i=new X({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:""},p)}return i}(e,(0,I.Z)({},n,{availabilityTimeOffset:m,availabilityTimeComplete:h,unsafelyBaseOnPreviousRepresentation:v,adaptation:t,inbandEventStreams:p}));null==e.attributes.bitrate?(o.Z.warn("DASH: No usable bitrate found in the Representation."),f=0):f=e.attributes.bitrate;var y,_=Q(n.baseURLs,e.children.baseURLs),b={bitrate:f,cdnMetadata:0===_.length?[{baseUrl:"",id:void 0}]:_.map((function(e){return{baseUrl:e.url,id:e.serviceLocation}})),index:g,id:c};null!=e.attributes.codecs?y=e.attributes.codecs:null!=t.attributes.codecs&&(y=t.attributes.codecs),null!=y&&(y="mp4a.40.02"===y?"mp4a.40.2":y,b.codecs=y),null!=e.attributes.frameRate?b.frameRate=e.attributes.frameRate:null!=t.attributes.frameRate&&(b.frameRate=t.attributes.frameRate),null!=e.attributes.height?b.height=e.attributes.height:null!=t.attributes.height&&(b.height=t.attributes.height),null!=e.attributes.mimeType?b.mimeType=e.attributes.mimeType:null!=t.attributes.mimeType&&(b.mimeType=t.attributes.mimeType),null!=e.attributes.width?b.width=e.attributes.width:null!=t.attributes.width&&(b.width=t.attributes.width);var S=void 0!==t.children.contentProtections?t.children.contentProtections:[];if(void 0!==e.children.contentProtections&&S.push.apply(S,e.children.contentProtections),S.length>0){var E=S.reduce((function(e,t){var n;if(void 0!==t.attributes.schemeIdUri&&"urn:uuid:"===t.attributes.schemeIdUri.substring(0,9)&&(n=t.attributes.schemeIdUri.substring(9).replace(/-/g,"").toLowerCase()),void 0!==t.attributes.keyId&&t.attributes.keyId.length>0){var r={keyId:t.attributes.keyId,systemId:n};void 0===e.keyIds?e.keyIds=[r]:e.keyIds.push(r)}if(void 0!==n){for(var i,a=[],o=$(t.children.cencPssh);!(i=o()).done;){var u=i.value;a.push({systemId:n,data:u})}if(a.length>0){var l,d=(0,s.Z)(e.initData,(function(e){return"cenc"===e.type}));if(void 0===d)e.initData.push({type:"cenc",values:a});else(l=d.values).push.apply(l,a)}}return e}),{keyIds:void 0,initData:[]});(Object.keys(E.initData).length>0||void 0!==E.keyIds&&E.keyIds.length>0)&&(b.contentProtections=E)}b.hdrInfo=ee({adaptationProfiles:t.attributes.profiles,supplementalProperties:t.children.supplementalProperties,essentialProperties:t.children.essentialProperties,manifestProfiles:n.manifestProfiles,codecs:y}),d.push(b)},f=$(e);!(l=f()).done;)c();return d}function ne(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return re(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return re(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function re(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(n.sort(le),e[t]=n.map((function(e){return e[0]}))),e}),{});return d.video.sort(le),k(re,c),re}(I.children.adaptations,F),z=(null!==(u=t.xmlNamespaces)&&void 0!==u?u:[]).concat(null!==(l=I.attributes.namespaces)&&void 0!==l?l:[]),K=function(e,t,n){for(var r,i,a,o=[],s=de(e);!(a=s()).done;)for(var u,l=a.value,d=l.attributes,c=d.schemeIdUri,f=void 0===c?"":c,v=d.timescale,p=void 0===v?1:v,h=n.concat(null!==(r=l.attributes.namespaces)&&void 0!==r?r:[]),g=de(l.children.events);!(u=g()).done;){var y=u.value;if(void 0!==y.eventStreamData){var _=(null!==(i=y.presentationTime)&&void 0!==i?i:0)/p+t,b=void 0===y.duration?void 0:_+y.duration/p,S=void 0;if(y.eventStreamData instanceof Element)S=y.eventStreamData;else{var E=h.reduce((function(e,t){return e+"xmlns:"+t.key+'="'+t.value+'" '}),"","application/xml").documentElement.childNodes[0]}o.push({start:_,end:b,id:y.id,data:{type:"dash-event-stream",value:{schemeIdUri:f,timescale:p,element:S}}})}}return o}(I.children.eventStreams,P,z),G={id:g,start:P,end:C,duration:M,adaptations:V,streamEvents:K};if(d.unshift(G),!E.lastPositionIsKnown()){var W=function(e){for(var t,n=null,r=!0,i=(0,h.Z)(e).filter((function(e){return null!=e})),a=de((0,v.Z)(i,(function(e){return e})));!(t=a()).done;)for(var o,s=de(t.value.representations);!(o=s()).done;){var u=o.value.index.getLastAvailablePosition();null!==u&&(r=!1,"number"==typeof u&&(n=null==n?u:Math.max(n,u)))}if(null!=n)return n;if(r)return null;return}(V);if(f)if("number"==typeof W){var j=performance.now()/1e3;E.setLastPosition(W,j)}else{var H=pe(t,P);if(void 0!==H){var q=H[0],Y=H[1];E.setLastPosition(q,Y)}}else"number"==typeof W&&E.setLastPosition(W)}},w=e.length-1;w>=0;w--)T();if(t.isDynamic&&!E.lastPositionIsKnown()){var I=pe(t,0);if(void 0!==I){var R=I[0],Z=I[1];E.setLastPosition(R,Z)}}return function(e){if(0===e.length)return[];for(var t=[e[0]],n=1;nr.start)&&(o.Z.warn("DASH: Updating overlapping Periods.",null==i?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));)t.pop(),i=t[t.length-1];t.push(r)}return t}(d)}function pe(e,t){if(null!=e.clockOffset){var n=e.clockOffset/1e3-e.availabilityStartTime,r=performance.now()/1e3,i=r+n;if(i>=t)return[i,r]}else{var a=Date.now()/1e3;if(a>=t)return o.Z.warn("DASH Parser: no clock synchronization mechanism found. Using the system clock instead."),[a-e.availabilityStartTime,performance.now()/1e3]}}function he(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return me(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?t[0].value:void 0}(t);if(null!=y&&y.length>0)return{type:"needs-clock",value:{url:y,continue:function(i){return i.success?(n.externalClockOffset=l(i.data),e(t,n,r,!0)):(r.push(i.error),o.Z.warn("DASH Parser: Error on fetching the clock ressource",i.error),e(t,n,r,!0))}}}}}for(var _=[],b=0;b=0&&(d=0===h.minimumUpdatePeriod?a.Z.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:h.minimumUpdatePeriod);var I=f(k),R=I.minimumSafePosition,Z=I.maximumSafePosition,x=I.maximumUnsafePosition,P=performance.now();if(m){var M,C;if(c=R,A=null!=b?b:null,void 0!==x&&(C=x),void 0!==Z)M=Z;else{var D=null!=_?_:0,N=t.externalClockOffset;if(void 0===N)o.Z.warn("DASH Parser: use system clock to define maximum position"),M=Date.now()/1e3-D;else M=(performance.now()+N)/1e3-D}void 0===C&&(C=M),v={isLinear:!0,maximumSafePosition:M,livePosition:C,time:P},null!==A&&void 0!==c&&M-c>A&&(A=M-c)}else{c=void 0!==R?R:void 0!==(null===(i=k[0])||void 0===i?void 0:i.start)?k[0].start:0;var O=null!=w?w:1/0;if(void 0!==k[k.length-1]){var L=k[k.length-1],U=null!==(s=L.end)&&void 0!==s?s:void 0!==L.duration?L.start+L.duration:void 0;void 0!==U&&U=0;o--){var s,u=_[o].index,l=a[o],f=l.parsed,v=l.warnings,p=l.receivedTime,h=l.sendingTime,m=l.url;v.length>0&&r.push.apply(r,v);for(var g,y=he(f);!(g=y()).done;){var b=g.value;d.set(b,{receivedTime:p,sendingTime:h,url:m})}(s=c.periods).splice.apply(s,[u,1].concat(f))}return e(t,n,r,i,d)}}}};function ye(e){var t=e.textContent,n=[];return null===t||0===t.length?[void 0,n]:[{value:t},n]}function _e(e){for(var t={},n=0;n0){var s=Ce(a,"cenc:pssh"),u=s[0],l=s[1];null!==l&&(o.Z.warn(l.message),t.push(l)),null!==u&&n.push(u)}}}return[{cencPssh:n},t]}(e.childNodes),n=t[0],r=t[1];return[{children:n,attributes:function(e){for(var t={},n=0;n0&&(r=r.concat(c));break;case"SegmentList":var f=ze(a),v=f[0],p=f[1];r=r.concat(p),t.segmentList=v;break;case"SegmentTemplate":var h=Ge(a),m=h[0],g=h[1];r=r.concat(g),t.segmentTemplate=m;break;case"ContentProtection":var y=Ue(a),_=y[0],b=y[1];b.length>0&&(r=r.concat(b)),void 0!==_&&n.push(_)}}return n.length>0&&(t.contentProtections=n),[t,r]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Oe(t,n),i=0;i0&&(r=r.concat(u));break;case"ContentComponent":t.contentComponent=_e(a);break;case"EssentialProperty":null==t.essentialProperties?t.essentialProperties=[Ne(a)]:t.essentialProperties.push(Ne(a));break;case"InbandEventStream":void 0===t.inbandEventStreams&&(t.inbandEventStreams=[]),t.inbandEventStreams.push(Ne(a));break;case"Label":var l=a.textContent;null!=l&&(t.label=l);break;case"Representation":var d=We(a),c=d[0],f=d[1];t.representations.push(c),f.length>0&&(r=r.concat(f));break;case"Role":null==t.roles?t.roles=[Ne(a)]:t.roles.push(Ne(a));break;case"SupplementalProperty":null==t.supplementalProperties?t.supplementalProperties=[Ne(a)]:t.supplementalProperties.push(Ne(a));break;case"SegmentBase":var v=Fe(a),p=v[0],h=v[1];t.segmentBase=p,h.length>0&&(r=r.concat(h));break;case"SegmentList":var m=ze(a),g=m[0],y=m[1];t.segmentList=g,y.length>0&&(r=r.concat(y));break;case"SegmentTemplate":var _=Ge(a),b=_[0],S=_[1];t.segmentTemplate=b,S.length>0&&(r=r.concat(S));break;case"ContentProtection":var E=Ue(a),T=E[0],k=E[1];k.length>0&&(r=r.concat(k)),void 0!==T&&n.push(T)}}return n.length>0&&(t.contentProtections=n),[t,r]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Oe(t,n),i=0;i0&&(n=n.concat(d))}}return[t,n]}function qe(e){for(var t={eventStreamData:e},n=[],r=Oe(t,n),i=0;i0&&(i=i.concat(_))}}return[{baseURLs:n,adaptations:r,eventStreams:a,segmentTemplate:t},i]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Oe(t,n),i=0;i",c=(new DOMParser).parseFromString(d,"text/xml");if(null==c||0===c.children.length)throw new Error("DASH parser: Invalid external ressources");for(var f=c.children[0].children,v=[],p=[],h=0;h0;){var r=e[0];if(r.start>=t)return n;if(-1===r.repeatCount)return n;if(0===r.repeatCount)e.shift(),n+=1;else{var i=e[1];if(void 0!==i&&i.start<=t)e.shift(),n+=1;else{if(r.duration<=0)return n;for(var a=r.start+r.duration,o=1;ar.repeatCount)){var s=r.repeatCount-o;return r.start=a,r.repeatCount=s,n+=o}e.shift(),n=r.repeatCount+1}}}return n}n.d(t,{Z:function(){return r}})},3911:function(e,t,n){"use strict";n.d(t,{KF:function(){return i},PZ:function(){return u},_j:function(){return l},gT:function(){return o},jH:function(){return a},zG:function(){return s}});var r=n(1946);function i(e,t,n){var i,a=e.repeatCount;return a>=0?a:(i=(0,r.Z)(t)?void 0!==n?n:Number.MAX_VALUE:t.start,Math.ceil((i-e.start)/e.duration)-1)}function a(e,t,n){var r=e.start,a=e.duration;return a<=0?r:r+(i(e,t,n)+1)*a}function o(e,t){var n;return e*t.timescale+(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0)}function s(e,t){var n;return(e-(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0))/t.timescale}function u(e,t,n){return[e*n,(e+t)*n]}function l(e,t,n){var r=e.timeline,i=o(t,e);if(i<0)return null;var u=function(e,t){for(var n=0,r=e.length;n>>1;e[i].start<=t?n=i+1:r=i}return n-1}(r,i);if(u<0||u>=r.length-1)return null;var l=r[u];if(l.duration<=0)return null;var d=r[u+1];if(void 0===d)return null;var c=d.start;return i>=a(l,d,n)&&ie.time)return!1;if(o===e.time)return void 0===a.range?void 0===e.range:null!=e.range&&a.range[0]===e.range[0]&&a.range[1]===e.range[1];if(a.repeatCount>=0&&void 0!==a.duration){var s=(o-a.start)/a.duration-1;return s%1==0&&s<=a.repeatCount}}return!1}n.d(t,{Z:function(){return r}})},5505:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(3714),i=n(3887),a=n(3911);function o(e,t){if(0===e.length)return e.push.apply(e,t),!0;if(0===t.length)return!1;var n=e.length,o=t[0].start,s=e[n-1];if((0,a.jH)(s,t[0])=0;u--){var l=e[u].start;if(l===o){var d=n-u;return e.splice.apply(e,[u,d].concat(t)),!1}if(lo)return i.Z.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,n].concat(t)),!0;if(void 0===c.repeatCount||c.repeatCount<=0)return c.repeatCount<0&&(c.repeatCount=Math.floor((o-c.start)/c.duration)-1),e.splice.apply(e,[u+1,n-(u+1)].concat(t)),!1;if(c.start+c.duration*(c.repeatCount+1)<=o)return e.splice.apply(e,[u+1,n-(u+1)].concat(t)),!1;var f=(o-c.start)/c.duration-1;if(f%1==0&&c.duration===t[0].duration){var v=t[0].repeatCount<0?-1:t[0].repeatCount+f+1;return e.splice.apply(e,[u,n-u].concat(t)),e[u].start=c.start,e[u].repeatCount=v,!1}return i.Z.warn("RepresentationIndex: Manifest update removed previous segments"),e[u].repeatCount=Math.floor(f),e.splice.apply(e,[u+1,n-(u+1)].concat(t)),!1}}var p=e[e.length-1],h=t[t.length-1];return void 0!==p.repeatCount&&p.repeatCount<0?p.start>h.start?(i.Z.warn("RepresentationIndex: The new index is older than the previous one"),!1):(i.Z.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0):p.start+p.duration*(p.repeatCount+1)>=h.start+h.duration*(h.repeatCount+1)?(i.Z.warn("RepresentationIndex: The new index is older than the previous one"),!1):(i.Z.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0)}},5734:function(e,t,n){"use strict";var r=n(6923),i=/&#([0-9]+);/g,a=/
/gi,o=/]*>([\s\S]*?)<\/style[^>]*>/i,s=/\s*

]+))?>(.*)/i,u=/]+?start="?([0-9]*)"?[^0-9]/i;function l(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}t.Z=function(e,t,n){var d,c,f=/]/gi,v=/]|<\/body>/gi,p=[],h=o.exec(e),m=Array.isArray(h)?h[1]:"";v.exec(e);var g,y=function(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,n={},r=t.exec(e);null!==r;){var i=r[1],a=l(r[2],"lang");null!=i&&null!=a&&(n[a]=i),r=t.exec(e)}return n}(m),_=function(e){var t=/p\s*{([^}]*)}/gi.exec(e);return null===t?"":t[1]}(m);if((0,r.Z)(n)&&void 0===(g=y[n]))throw new Error("sami: could not find lang "+n+" in CSS");for(;d=f.exec(e),c=v.exec(e),null!==d||null!==c;){if(null===d||null===c||d.index>=c.index)throw new Error("parse error");var b=e.slice(d.index,c.index),S=u.exec(b);if(!Array.isArray(S))throw new Error("parse error (sync time attribute)");var E=+S[1];if(isNaN(E))throw new Error("parse error (sync time attribute NaN)");T(b.split("\n"),E/1e3)}return p;function T(e,n){for(var o=e.length;--o>=0;){var u=s.exec(e[o]);if(Array.isArray(u)){var l=u[1],d=u[2];if(g===l)if(" "===d)p[p.length-1].end=n;else{var c=document.createElement("DIV");c.className="rxp-texttrack-region";var f=document.createElement("DIV");f.className="rxp-texttrack-div",f.style.position="absolute",f.style.bottom="0",f.style.width="100%",f.style.color="#fff",f.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000";var v=document.createElement("div");v.className="rxp-texttrack-p",(0,r.Z)(_)&&(v.style.cssText=_);for(var h=d.split(a),m=0;m/gi,s=/]*>([\s\S]*?)<\/style[^>]*>/i,u=/\s*

]+))?>(.*)/i,l=/]+?start="?([0-9]*)"?[^0-9]/i;function d(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}t.Z=function(e,t,n){var c,f,v=/]/gi,p=/]|<\/body>/gi,h=[],m=s.exec(e),g=null!==m?m[1]:"";p.exec(e);var y,_=function(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,n={},r=t.exec(e);Array.isArray(r);){var i=r[1],a=d(r[2],"lang");null!=i&&null!=a&&(n[a]=i),r=t.exec(e)}return n}(g);if((0,i.Z)(n)&&void 0===(y=_[n]))throw new Error("sami: could not find lang "+n+" in CSS");for(;c=v.exec(e),f=p.exec(e),null!==c||null!==f;){if(null===c||null===f||c.index>=f.index)throw new Error("parse error");var b=e.slice(c.index,f.index),S=l.exec(b);if(null===S)throw new Error("parse error (sync time attribute)");var E=+S[1];if(isNaN(E))throw new Error("parse error (sync time attribute NaN)");T(b.split("\n"),E/1e3)}return function(e){for(var t=[],n=0;n=0;)if(null!==(r=u.exec(e[s]))){var l=r,d=l[1],c=l[2];y===d&&(" "===c?h[h.length-1].end=n:h.push({text:(i=c,i.replace(o,"\n").replace(a,(function(e,t){return String.fromCharCode(Number(t))}))),start:n+t}))}}}},2061:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(6923);function i(e,t){for(var n=t+1;(0,r.Z)(e[n]);)n++;return n}function a(e){for(var t=[],n=0;n0&&(1===o.length?o[0].indexOf("--\x3e")>=0&&t.push(o):(o[1].indexOf("--\x3e")>=0||o[0].indexOf("--\x3e")>=0)&&t.push(o)),n=a}return t}},8675:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(2061),i=n(788);function a(e,t){for(var n=e.split(/\r\n|\n|\r/),a=(0,r.Z)(n),s=[],u=0;u0){var l=document.createTextNode(o[s]);r.appendChild(l)}}else if("B"===a.nodeName){var d=e(a);d.style.fontWeight="bold",r.appendChild(d)}else if("I"===a.nodeName){var c=e(a);c.style.fontStyle="italic",r.appendChild(c)}else if("U"===a.nodeName){var f=e(a);f.style.textDecoration="underline",r.appendChild(f)}else if(u(a)&&"string"==typeof a.color){var v=e(a);v.style.color=a.color,r.appendChild(v)}else{var p=e(a);r.appendChild(p)}}return r}(t)}function u(e){return"FONT"===e.nodeName&&"color"in e}},8057:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(7253),i=n(2061),a=n(788);function o(e,t){for(var n,o,s,u,l,d=e.split(/\r\n|\n|\r/),c=(0,i.Z)(d),f=[],v=0;v0){var _=p.getAttribute("xml:space"),b=(0,l.Z)(_)?"default"===_:o,E=(0,d.Z)({},i,(0,c.U)(g,[p],n,t));u.push.apply(u,e(p,E,[p].concat(a),b))}}return u}(e,(0,d.Z)({},r),[],i)}(e,n,r,i,s),E=0;E|\u2265/g,">").replace(/\u200E/g,"‎").replace(/\u200F/g,"‏").replace(/\u00A0/g," ")}else if((0,l.OE)(s))i+="\n";else if((0,l.jg)(s)&&s.nodeType===Node.ELEMENT_NODE&&s.childNodes.length>0){var c=s.getAttribute("xml:space");i+=n(s,(0,o.Z)(c)?"default"===c:t)}}return i}return n(e,t)}(t,v),y=(0,i.Z)(h+n,m+n,g);return null===y?null:((0,a.Z)(y)&&function(e,t){var n=t.extent;if((0,o.Z)(n)){var r=u._0.exec(n);null!=r&&(e.size=Number(r[1]))}switch(t.writingMode){case"tb":case"tblr":e.vertical="lr";break;case"tbrl":e.vertical="rl"}var i=t.origin;if((0,o.Z)(i))u._0.exec(i);var a=t.align;if((0,o.Z)(a)){e.align=a,"center"===a&&("center"!==e.align&&(e.align="middle"),e.position="auto");var s=c[a];e.positionAlign=void 0===s?"":s;var l=d[a];e.lineAlign=void 0===l?"":l}}(y,r),y)}var v=function(e,t){for(var n=(0,r.Z)(e,t),i=[],a=0;a0&&(t=n)}return t}function a(e){var t=e.getElementsByTagName("body");if(t.length>0)return t[0];var n=e.getElementsByTagName("tt:body");return n.length>0?n[0]:null}function o(e){var t=e.getElementsByTagName("style");if(t.length>0)return t;var n=e.getElementsByTagName("tt:style");return n.length>0?n:t}function s(e){var t=e.getElementsByTagName("region");if(t.length>0)return t;var n=e.getElementsByTagName("tt:region");return n.length>0?n:t}function u(e){var t=e.getElementsByTagName("p");if(t.length>0)return t;var n=e.getElementsByTagName("tt:p");return n.length>0?n:t}function l(e){return"br"===e.nodeName||"tt:br"===e.nodeName}function d(e){return"span"===e.nodeName||"tt:span"===e.nodeName}n.d(t,{DM:function(){return s},H:function(){return a},OE:function(){return l},jF:function(){return i},jg:function(){return d},kd:function(){return u},vU:function(){return o}})},1138:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(6923),i=n(360);function a(e,t){for(var n=[],a=t;a=2)for(var r=function(r){var o=e[r];if(Array.isArray(/::cue {/.exec(o)))for(o=e[++r];(0,i.Z)(o)&&!Array.isArray(/}/.exec(o))&&0!==o.length;)n+=o,o=e[++r];else{for(var s=[],u=/::cue\(\.?(.*?)\)(?:,| {)/.exec(o);(0,i.Z)(o)&&Array.isArray(u);)s.push(u[1]),o=e[++r],u=/::cue\(\.?(.*?)\)(?:,| {)/.exec(o);for(var l="";(0,i.Z)(o)&&!Array.isArray(/}/.exec(o))&&0!==o.length;)l+=o,o=e[++r];s.forEach((function(e){void 0===t[e]?t[e]=l:t[e]+=l}))}a=r},a=1;a0&&n.appendChild(document.createElement("br")),o[s].length>0){var u=document.createTextNode(o[s]);n.appendChild(u)}}else{var c=e.nodeName.toLowerCase().split("."),f=[];if(c.forEach((function(e){(0,i.Z)(t[e])&&f.push(t[e])})),0!==f.length){var v=document.createAttribute("style");f.forEach((function(e){v.value+=e}));var p=(0,l.Z)(r,a)?a:"span";(n=document.createElement(p)).setAttributeNode(v)}else{var h=(0,l.Z)(r,a)?a:"span";n=document.createElement(h)}for(var m=0;m/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3"),r=(new DOMParser).parseFromString(n,"text/html").body.childNodes,i=[],a=0;a=2){var a=parseInt(i[1],10);isNaN(a)||(t.position=a,void 0!==i[2]&&(t.positionAlign=i[2]))}}(0,u.Z)(e.size)&&(t.size=e.size),"string"==typeof e.align&&(0,s.Z)(["start","center","end","left"],e.align)&&(t.align=e.align)}var d=n(7253);var c=function(e,t){var n=e.split(/\r\n|\n|\r/);if(!/^WEBVTT($| |\t)/.test(n[0]))throw new Error("Can't parse WebVTT: Invalid file.");for(var s,u,c,f,v=(0,o.yE)(n),p=(0,i.Z)(n,v),h=[],m=0;m/;if(o.test(e[0]))n=e[0],r=e.slice(1,e.length);else{if(!o.test(e[1]))return null;a=e[0],n=e[1],r=e.slice(2,e.length)}var s=function(e){var t=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(e);if(null===t)return null;var n=i(t[1]),r=i(t[2]);return null==n||null==r?null:{start:n,end:r,settings:t[3].split(/ |\t/).reduce((function(e,t){var n=t.split(":");return 2===n.length&&(e[n[0]]=n[1]),e}),{})}}(n);return null===s?null:{start:s.start+t,end:s.end+t,settings:s.settings,payload:r,header:a}}},360:function(e,t,n){"use strict";n.d(t,{$4:function(){return s},JF:function(){return a},tq:function(){return o},yE:function(){return i}});var r=n(6923);function i(e){for(var t=0;t=0)return!0;var r=e[t+1];return void 0!==r&&r.indexOf("--\x3e")>=0}function s(e,t){for(var n=t+1;(0,r.Z)(e[n]);)n++;return n}},2047:function(e,t,n){"use strict";n.d(t,{Z:function(){return ue}});var r=n(7874),i=n(8791),a=n(6872),o=n(8750),s=n(3887),u=n(8619),l=n(8026),d=n(4597),c=n(3635);function f(e){var t=e.referenceDateTime,n=void 0!==e.serverSyncInfos?e.serverSyncInfos.serverTimestamp-e.serverSyncInfos.clientTime:void 0;return function(i,f,v,p,h){var m,g=i.responseData,y=f.externalClockOffset,_=null!==(m=i.url)&&void 0!==m?m:f.originalUrl,b=null!=n?n:y,S={unsafelyBaseOnPreviousManifest:f.unsafeMode?f.previousManifest:null,url:_,referenceDateTime:t,externalClockOffset:b},E=r.Z.dashParsers;if(null===E.wasm||"uninitialized"===E.wasm.status||"failure"===E.wasm.status)return s.Z.debug("DASH: WASM MPD Parser not initialized. Running JS one."),k();var T=function(e){if(e instanceof ArrayBuffer)return e;if("string"==typeof e)return(0,c.tG)(e).buffer;if(e instanceof Document)return(0,c.tG)(e.documentElement.innerHTML).buffer;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(g);return function(e){var t=new DataView(e);if(61371===t.getUint16(0)&&191===t.getUint8(2))return!0;if(65279===t.getUint16(0)||65534===t.getUint16(0))return!1;return!0}(T)?"initialized"===E.wasm.status?(s.Z.debug("DASH: Running WASM MPD Parser."),w(E.wasm.runWasmParser(T,S))):(s.Z.debug("DASH: Awaiting WASM initialization before parsing the MPD."),E.wasm.waitForInitialization().catch((function(){})).then((function(){return null===E.wasm||"initialized"!==E.wasm.status?(s.Z.warn("DASH: WASM MPD parser initialization failed. Running JS parser instead"),k()):(s.Z.debug("DASH: Running WASM MPD Parser."),w(E.wasm.runWasmParser(T,S)))}))):(s.Z.info("DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one."),k());function k(){if(null===E.js)throw new Error("No MPD parser is imported");var e=function(e){if(e instanceof ArrayBuffer)return(new DOMParser).parseFromString((0,c.uR)(new Uint8Array(e)),"text/xml");if("string"==typeof e)return(new DOMParser).parseFromString(e,"text/xml");if(e instanceof Document)return e;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(g);return w(E.js(e,S))}function w(t){if("done"===t.type)return t.value.warnings.length>0&&v(t.value.warnings),p.isCancelled()?Promise.reject(p.cancellationError):{manifest:new u.ZP(t.value.parsed,e),url:_};var n=t.value,r=n.urls.map((function(e){return h((function(){var t=a.Z.getCurrent().DEFAULT_REQUEST_TIMEOUT;return"string"===n.format?(0,d.ZP)({url:e,responseType:"text",timeout:t,cancelSignal:p}):(0,d.ZP)({url:e,responseType:"arraybuffer",timeout:t,cancelSignal:p})})).then((function(e){if("string"===n.format){if("string"!=typeof e.responseData)throw new Error("External DASH resources should have been a string");return(0,l.Z)(e,{responseData:{success:!0,data:e.responseData}})}if(!(e.responseData instanceof ArrayBuffer))throw new Error("External DASH resources should have been ArrayBuffers");return(0,l.Z)(e,{responseData:{success:!0,data:e.responseData}})}),(function(e){var t=(0,o.Z)(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"An unknown error occured when parsing ressources."});return(0,l.Z)({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:t}})}))}));return Promise.all(r).then((function(e){return n.format,w(n.continue(e))}))}}}var v=n(7839),p=n(5861),h=n(4687),m=n.n(h),g=n(9105),y=n(5992),_=n(1946),b="function"==typeof Headers?Headers:null,S="function"==typeof AbortController?AbortController:null;function E(){return"function"==typeof window.fetch&&!(0,_.Z)(S)&&!(0,_.Z)(b)}var T=n(8806),k=n(281);function w(e,t){return"audio"===e||"video"===e?"video/mp4"===t||"audio/mp4"===t?"mp4":"video/webm"===t||"audio/webm"===t?"webm":void 0:"text"===e&&"application/mp4"===t?"mp4":void 0}var A=n(288),I=n(4460);function R(e){return function(t,n,r,i,a){return new Promise((function(s,u){var l=new A.ZP,d=l.linkToSignal(i);function c(){l.signal.deregister(u),d()}l.signal.register(u),e(t,n,r,l.signal,Object.assign(Object.assign({},a),{onNewChunk:function(e){try{o(e),a.onNewChunk(e)}catch(e){c(),l.cancel(),u(e)}}})).then((function(e){if(c(),!l.isUsed()){if("segment-loaded"===e.resultType)try{o(e.resultData.responseData)}catch(e){return void u(e)}s(e)}}),(function(e){c(),u(e)}))}));function o(e){(e instanceof ArrayBuffer||e instanceof Uint8Array)&&"mp4"===w(n.type,n.mimeType)&&(0,I.Z)(new Uint8Array(e),n.segment.isInit)}}}var Z=n(9829);function x(e,t){return null===e?null:null===t.url?e.baseUrl:(0,Z.Z)(e.baseUrl,t.url)}var P=n(6968);function M(e,t,n,r,i){if(void 0===t.range)return(0,d.ZP)({url:e,responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(void 0===t.indexRange)return(0,d.ZP)({url:e,headers:{Range:(0,k.Z)(t.range)},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(t.range[1]+1===t.indexRange[0])return(0,d.ZP)({url:e,headers:{Range:(0,k.Z)([t.range[0],t.indexRange[1]])},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));var a=(0,d.ZP)({url:e,headers:{Range:(0,k.Z)(t.range)},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}),o=(0,d.ZP)({url:e,headers:{Range:(0,k.Z)(t.indexRange)},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then((function(t){var n=t[0],r=t[1],i=(0,P.zo)(new Uint8Array(n.responseData),new Uint8Array(r.responseData)),a=Math.min(n.sendingTime,r.sendingTime),o=Math.max(n.receivedTime,r.receivedTime);return{resultType:"segment-loaded",resultData:{url:e,responseData:i,size:n.size+r.size,requestDuration:o-a,sendingTime:a,receivedTime:o}}}))}var C=n(8766);function D(e,t,n,r,i){var a=t.segment,o=void 0!==a.range?{Range:(0,k.Z)(a.range)}:void 0,u=null;return function(e){var t;if(!(0,_.Z)(e.headers))if((0,_.Z)(b))t=e.headers;else{t=new b;for(var n=Object.keys(e.headers),r=0;r=300)throw s.Z.warn("Fetch: Request HTTP Error",t.status,t.url),new g.Z(t.url,t.status,y.br.ERROR_HTTP_CODE);if((0,_.Z)(t.body))throw new g.Z(t.url,t.status,y.br.PARSE_ERROR);var n=t.headers.get("Content-Length"),r=(0,_.Z)(n)||isNaN(+n)?void 0:+n,i=t.body.getReader(),o=0;return u();function u(){return d.apply(this,arguments)}function d(){return(d=(0,p.Z)(m().mark((function n(){var a,s,d,c,v;return m().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,i.read();case 2:if((a=n.sent).done||(0,_.Z)(a.value)){n.next=11;break}return o+=a.value.byteLength,s=performance.now(),d={url:t.url,currentTime:s,duration:s-l,sendingTime:l,chunkSize:a.value.byteLength,chunk:a.value.buffer,size:o,totalSize:r},e.onData(d),n.abrupt("return",u());case 11:if(!a.done){n.next=16;break}return f(),c=performance.now(),v=c-l,n.abrupt("return",{requestDuration:v,receivedTime:c,sendingTime:l,size:o,status:t.status,url:t.url});case 16:return n.abrupt("return",u());case 17:case"end":return n.stop()}}),n)})))).apply(this,arguments)}})).catch((function(t){if(null!==o)throw o;if(f(),u)throw s.Z.warn("Fetch: Request timeouted."),new g.Z(e.url,0,y.br.TIMEOUT);if(t instanceof g.Z)throw t;throw s.Z.warn("Fetch: Request Error",t instanceof Error?t.toString():""),new g.Z(e.url,0,y.br.ERROR_EVENT)}))}({url:e,headers:o,onData:function(e){var t=new Uint8Array(e.chunk),n=function(e){for(var t=0,n=[];te.length)return[n,r];var o=(0,C.Z)(r,1835295092);if(o<0)return[n,r];var s=t+o+(0,P.pX)(e,o+t);if(s>e.length)return[n,r];var u=Math.max(a,s),l=e.subarray(t,u);n.push(l),t=u}return[n,null]}(null!==u?(0,P.zo)(u,t):t),a=n[0];u=n[1];for(var o=0;o0)for(var v=0;v=Math.pow(2,8-n))return n}function Q(e,t){var n=X(e,t);if(null==n)return s.Z.warn("webm: unrepresentable length"),null;if(t+n>e.length)return s.Z.warn("webm: impossible length"),null;for(var r=0,i=0;ie.length)return s.Z.warn("webm: impossible length"),null;for(var r=(e[t]&(1<<8-n)-1)*Math.pow(2,8*(n-1)),i=1;i=i)return!0}return!1}(r,t);return{inbandEvents:a,needsManifestRefresh:o}}}function re(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.segment,o=n.periodStart,s=n.periodEnd,u=e.data,l=e.isChunked,d=[o,s];if(null===u)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:d};var c=u instanceof Uint8Array?u:new Uint8Array(u),f=w(n.type,n.mimeType),v="mp4"===f||void 0===f,p=[];if(v){var h,m=(0,O.Z)(c);a.isInit&&(h=null!==(i=(0,L.R0)(c))&&void 0!==i?i:void 0),(m.length>0||void 0!==h)&&p.push({initDataType:"cenc",keyId:h,initData:m})}if(!a.isInit){var g=v?te(c,l,a,r):null,y=(0,ee.Z)(a.timestampOffset,0);if(v){var b=(0,L.s9)(c);if(void 0!==b){var S=ne(b.filter((function(e){return void 0!==a.privateInfos&&void 0!==a.privateInfos.isEMSGWhitelisted&&a.privateInfos.isEMSGWhitelisted(e)})),n.manifestPublishTime);if(void 0!==S){var E=S.needsManifestRefresh,T=S.inbandEvents;return{segmentType:"media",chunkData:c,chunkSize:c.length,chunkInfos:g,chunkOffset:y,appendWindow:d,inbandEvents:T,protectionData:p,needsManifestRefresh:E}}}}return{segmentType:"media",chunkData:c,chunkSize:c.length,chunkInfos:g,chunkOffset:y,protectionData:p,appendWindow:d}}var k,A=a.indexRange;if("webm"===f)k=function(e,t){var n=H(U,[],e,[t,e.length]);if(null==n)return null;var r=n[0],i=n[1],a=q(e,r);if(null==a)return null;var o=Y(e,r);if(null==o)return null;var s=H(z,[],e,[r,i]);if(null==s)return null;for(var u=[],l=s[0];l0)){var I=k[k.length-1];Array.isArray(I.range)&&(I.range[1]=1/0)}var R=v?(0,L.LD)(c):"webm"===f?q(c,0):void 0,Z=(0,_.Z)(R)?void 0:R;return{segmentType:"init",initializationData:c,initializationDataSize:c.length,protectionData:p,initTimescale:Z,segmentList:null!=k?k:void 0}}}var ie=n(6807);function ae(e,t,n,r){var i,a,o=e.segment,u=e.language,l=e.codecs;if(o.isInit)return null;null===n?r?(i=o.time,a=o.end):s.Z.warn("Transport: Unavailable time data for current text track."):(i=n.time,void 0!==n.duration?a=i+n.duration:!r&&o.complete&&(a=i+o.duration));var d=function(e){if(void 0===e)throw new Error("Cannot parse subtitles: unknown format");switch(e.toLowerCase()){case"stpp":case"stpp.ttml.im1t":return"ttml";case"wvtt":return"vtt"}throw new Error('The codec used for the subtitles "'+e+'" is not managed yet.')}(l),f=function(e){var t=(0,ie.Le)(e);return null===t?"":(0,c.uR)(t)}(t);return{data:f,type:d,language:u,start:i,end:a}}function oe(e,t,n){var r,i,a=e.segment;return a.isInit?null:(n?s.Z.warn("Transport: Unavailable time data for current text track."):(r=a.time,a.complete&&(i=a.time+a.duration)),{data:t,type:function(e,t){switch(t){case"application/ttml+xml":return"ttml";case"application/x-sami":case"application/smil":return"sami";case"text/vtt":return"vtt"}if(void 0!==e&&"srt"===e.toLowerCase())return"srt";throw new Error("could not find a text-track parser for the type "+(null!=t?t:""))}(e.codecs,e.mimeType),language:e.language,start:r,end:i})}function se(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=e.data,l=e.isChunked;if(null===u)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:null!==(i=s.timestampOffset)&&void 0!==i?i:0,protectionData:[],appendWindow:[a,o]};var d=w(n.type,n.mimeType);if("webm"===d)throw new Error("Text tracks with a WEBM container are not yet handled.");return"mp4"===d?function(e,t,n,r,i){var a=n.segment,o=a.isInit,s=a.indexRange,u="string"==typeof e?(0,c.tG)(e):e instanceof Uint8Array?e:new Uint8Array(e);if(o){var l=(0,L.Wf)(u,Array.isArray(s)?s[0]:0);if(!0===i&&null!==l&&l.length>0){var d=l[l.length-1];Array.isArray(d.range)&&(d.range[1]=1/0)}return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:(0,L.LD)(u),segmentList:null!=l?l:void 0}}var f=te(u,t,a,r),v=ae(n,u,f,t),p=(0,ee.Z)(a.timestampOffset,0);return{segmentType:"media",chunkData:v,chunkSize:u.length,chunkInfos:f,chunkOffset:p,protectionData:[],appendWindow:[n.periodStart,n.periodEnd]}}(u,l,n,r,t):function(e,t,n){var r,i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=s.timestampOffset,l=void 0===u?0:u;if(s.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if("string"!=typeof e){var d=e instanceof Uint8Array?e:new Uint8Array(e);r=(0,c.uR)(d),i=d.length}else r=e;return{segmentType:"media",chunkData:oe(n,r,t),chunkSize:i,chunkInfos:null,chunkOffset:l,protectionData:[],appendWindow:[a,o]}}(u,l,n)}}var ue=function(e){var t=(0,i.Z)({customManifestLoader:e.manifestLoader},null===r.Z.dashParsers.wasm||"initialized"!==r.Z.dashParsers.wasm.status&&"initializing"!==r.Z.dashParsers.wasm.status?"arraybuffer":"text"),n=f(e),a=function(e){var t=e.lowLatencyMode,n=e.segmentLoader;return!0!==e.checkMediaSegmentIntegrity?r:R(r);function r(e,r,i,a,o){var s=x(e,r.segment);return null==s?Promise.resolve({resultType:"segment-created",resultData:null}):t||void 0===n?N(s,r,t,i,o,a):new Promise((function(e,u){var l=!1,d={reject:function(e){var t,n,r;if(!l&&!a.isCancelled()){l=!0,a.deregister(p);var i=e,o=null!==(t=null==i?void 0:i.message)&&void 0!==t?t:"Unknown error when fetching a DASH segment through a custom segmentLoader.",s=new v.Z(o,null!==(n=null==i?void 0:i.canRetry)&&void 0!==n&&n,null!==(r=null==i?void 0:i.isOfflineError)&&void 0!==r&&r,null==i?void 0:i.xhr);u(s)}},resolve:function(t){l||a.isCancelled()||(l=!0,a.deregister(p),e({resultType:"segment-loaded",resultData:{responseData:t.data,size:t.size,requestDuration:t.duration}}))},progress:function(e){l||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})},fallback:function(){l||a.isCancelled()||(l=!0,a.deregister(p),N(s,r,t,i,o,a).then(e,u))}},c={isInit:r.segment.isInit,timeout:i.timeout,range:r.segment.range,indexRange:r.segment.indexRange,type:r.type,url:s},f=n(c,d);function p(e){l||(l=!0,"function"==typeof f&&f(),u(e))}a.register(p)}))}}(e),o=re(e),s=function(e){var t=e.lowLatencyMode;return!0!==e.checkMediaSegmentIntegrity?n:R(n);function n(e,n,r,i,a){var o=n.segment,s=o.range,u=x(e,o);if(null===u)return Promise.resolve({resultType:"segment-created",resultData:null});if(o.isInit)return M(u,o,r,i,a);var l=w(n.type,n.mimeType),c="mp4"===l||void 0===l;if(t&&c){if(E())return D(u,n,r,a,i);(0,T.Z)("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}return c?(0,d.ZP)({url:u,responseType:"arraybuffer",headers:Array.isArray(s)?{Range:(0,k.Z)(s)}:null,timeout:r.timeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}})):(0,d.ZP)({url:u,responseType:"text",headers:Array.isArray(s)?{Range:(0,k.Z)(s)}:null,timeout:r.timeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}}(e);return{manifest:{loadManifest:t,parseManifest:n},audio:{loadSegment:a,parseSegment:o},video:{loadSegment:a,parseSegment:o},text:{loadSegment:s,parseSegment:se(e)}}}},5418:function(e,t,n){"use strict";n.d(t,{Z:function(){return le}});var r=n(3887),i=n(8619),a=n(6807),o=n(9665),s=n(7714),u=n(811),l=n(6968),d=n(6923),c=n(8026),f=n(9829),v=n(3635),p=n(5278),h=n(2689),m={};function g(e){if(null!=m[e])return m[e];var t=(0,v.tG)(e);return m[e]=t,t}function y(e,t){var n=t.length+8;return n<=h.s?(0,l.zo)((0,l.kh)(n),g(e),t):(0,l.zo)((0,l.kh)(1),g(e),(0,l.el)(n+8),t)}function _(e,t){return y(e,l.zo.apply(void 0,t))}function b(e){var t=[];e.periods.forEach((function(n){var i=n.id;if((0,s.Z)(t,i)){r.Z.warn("Two periods with the same ID found. Updating.");var a=i+"-dup";n.id=a,b(e),t.push(a)}else t.push(i);var o=n.adaptations,u=[];Object.keys(o).forEach((function(t){var n=o[t];void 0!==n&&n.forEach((function(t){var n=t.id;if((0,s.Z)(u,n)){r.Z.warn("Two adaptations with the same ID found. Updating.",n);var i=n+"-dup";t.id=i,b(e),u.push(i)}else u.push(n);var a=[];t.representations.forEach((function(t){var n=t.id;if((0,s.Z)(a,n)){r.Z.warn("Two representations with the same ID found. Updating.",n);var i=n+"-dup";t.id=i,b(e),a.push(i)}else a.push(n)}))}))}))}))}var S=n(9689);function E(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:(0,l.zo)([8,1,18,16],e)}]}function T(e,t){if(void 0===t&&(t=E),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var n=e.firstElementChild,r=(0,S.K)(null===n.textContent?"":n.textContent),i=function(e){var t=(0,l.qb)(e,8),n=(0,v.wV)(e.subarray(10,t+10)),r=(new DOMParser).parseFromString(n,"application/xml").querySelector("KID");if(null===r)throw new Error("Cannot parse PlayReady private data: invalid XML");var i=null===r.textContent?"":r.textContent,a=(0,v.wO)((0,S.K)(i));return(0,v.ci)(a).toLowerCase()}(r),a=(0,v.nr)(i),o=n.getAttribute("SystemID");return{keyId:a,keySystems:[{systemId:(null!==o?o:"").toLowerCase().replace(/\{|\}/g,""),privateData:r}].concat(t(a))}}var k=n(9362),w=n(3911),A=n(1091);function I(e,t){return e.replace(/\{start time\}/g,String(t))}function R(e,t,n){var r=t-e;return r>0?Math.floor(r/n):0}function Z(e,t){var n=e.repeatCount;if(void 0!==e.duration&&n<0){var r=void 0!==t?t.start:1/0;n=Math.ceil((r-e.start)/e.duration)-1}return n}var x=function(){function e(e){var t=e.isLive,n=e.segmentPrivateInfos,r=e.media,i=e.sharedSmoothTimeline;if(this._sharedSmoothTimeline=i,this._initSegmentInfos={bitsPerSample:n.bitsPerSample,channels:n.channels,codecPrivateData:n.codecPrivateData,packetSize:n.packetSize,samplingRate:n.samplingRate,timescale:i.timescale,height:n.height,width:n.width,protection:n.protection},this._isLive=t,this._media=r,0!==i.timeline.length&&t){var a=i.timeline,o=i.validityTime,s=a[a.length-1],u=(0,w.jH)(s,null),l=o/1e3*i.timescale;this._scaledLiveGap=l-u}}var t=e.prototype;return t.getInitSegment=function(){return{id:"init",isInit:!0,privateInfos:{smoothInitSegment:this._initSegmentInfos},url:null,time:0,end:0,duration:0,timescale:1,complete:!0}},t.getSegments=function(e,t){this._refreshTimeline();for(var n,r=this._sharedSmoothTimeline,i=r.timescale,a=r.timeline,o=function(e,t,n){var r=void 0===e||0===e?1:e;return{up:t*r,to:(t+n)*r}}(i,e,t),s=o.up,u=o.to,l=this._media,d=[],c=a.length,f=void 0===this._scaledLiveGap?void 0:performance.now()/1e3*i-this._scaledLiveGap,v=0;v=u)return d;void 0!==n&&(n+=g+1)}return d},t.shouldRefresh=function(e,t){if(this._refreshTimeline(),!this._isLive)return!1;var n=this._sharedSmoothTimeline,r=n.timeline,i=n.timescale,a=r[r.length-1];if(void 0===a)return!1;var o=a.repeatCount,s=a.start+(o+1)*a.duration;return!(t*i=s||e*i>a.start+o*a.duration)},t.getFirstAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;return 0===t.length?null:t[0].start/n},t.getLastAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;if(void 0===this._scaledLiveGap){var r=t[t.length-1];return(0,w.jH)(r,null)/n}for(var i=t.length-1;i>=0;i--)for(var a=t[i],o=performance.now()/1e3*n,s=a.start,u=a.duration,l=a.repeatCount;l>=0;l--){var d=s+u*(l+1);if(d<=o-this._scaledLiveGap)return d/n}},t.getEnd=function(){if(!this._isLive)return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(e,t){var n;if((0,u.Z)(e<=t),this.isFinished())return!1;var r=this.getLastAvailablePosition();return!(void 0!==r&&t(null!==(n=this.getFirstAvailablePosition())&&void 0!==n?n:0)&&void 0)},t.checkDiscontinuity=function(e){return this._refreshTimeline(),(0,w._j)(this._sharedSmoothTimeline,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();var t=this._sharedSmoothTimeline,n=t.timeline,r=t.timescale;return(0,A.Z)(e,n,r,0)},t.canBeOutOfSyncError=function(e){return!!this._isLive&&(e instanceof k.Z&&(e.isHttpError(404)||e.isHttpError(412)))},t._replace=function(e){this._initialScaledLastPosition=e._initialScaledLastPosition,this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.replace(e._sharedSmoothTimeline)},t._update=function(e){this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.update(e._sharedSmoothTimeline)},t.isFinished=function(){return!this._isLive},t.isInitialized=function(){return!0},t.initialize=function(){r.Z.error("A `SmoothRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(e,t){this._sharedSmoothTimeline.addPredictedSegments(e,t)},t._refreshTimeline=function(){this._sharedSmoothTimeline.refresh()},e}(),P=n(8232),M=n(5505);function C(e,t,n,r){var i=e[e.length-1],a=n.timescale===t?{time:n.time,duration:n.duration}:{time:n.time/n.timescale*t,duration:n.duration/n.timescale*t};return!(r.time===a.time)&&(a.time>=(0,w.jH)(i,null)&&(i.duration===a.duration?i.repeatCount++:e.push({duration:a.duration,start:a.time,repeatCount:0}),!0))}var D=function(){function e(e){var t=e.timeline,n=e.timescale,r=e.timeShiftBufferDepth,i=e.manifestReceivedTime;this.timeline=t,this.timescale=n;var a=null!=i?i:performance.now();if(this.validityTime=a,this._timeShiftBufferDepth=r,0!==t.length){var o=t[t.length-1],s=(0,w.jH)(o,null);this._initialScaledLastPosition=s}}var t=e.prototype;return t.refresh=function(){if(void 0!==this._initialScaledLastPosition){var e=this._timeShiftBufferDepth,t=(performance.now()-this.validityTime)/1e3+this._initialScaledLastPosition/this.timescale;if(void 0!==e){var n=(t-e)*this.timescale;(0,P.Z)(this.timeline,n)}}},t.replace=function(e){var t=this.timeline,n=e.timeline,i=this.timescale,a=e.timescale;if(this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime,0!==t.length&&0!==n.length&&i===a){var o=t[t.length-1],s=n[n.length-1],u=(0,w.jH)(s,null);if(!((0,w.jH)(o,null)<=u))for(var l=0;lu){if(d.duration!==s.duration)return;var f=u-d.start;if(0===f)return r.Z.warn("Smooth Parser: a discontinuity detected in the previous manifest has been resolved."),void(this.timeline=this.timeline.concat(t.slice(l)));if(f<0||f%d.duration!=0)return;var v=f/d.duration-1,p=d.repeatCount-v;if(p<0)return;s.repeatCount+=p;var h=t.slice(l+1);return void(this.timeline=this.timeline.concat(h))}}}},t.update=function(e){(0,M.Z)(this.timeline,e.timeline),this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime},t.addPredictedSegments=function(e,t){var n;if(void 0!==(null===(n=t.privateInfos)||void 0===n?void 0:n.smoothMediaSegment)){this.refresh();for(var i=0;i>3:2)?"mp4a.40.2":"mp4a.40."+n}(u,l);return{audiotag:void 0!==a?parseInt(a,10):a,bitrate:h,bitsPerSample:void 0!==o?parseInt(o,10):o,channels:void 0!==s?parseInt(s,10):s,codecPrivateData:u,codecs:m,customAttributes:n,mimeType:void 0!==l?L[l]:l,packetSize:void 0!==c?parseInt(c,10):c,samplingRate:void 0!==f?parseInt(f,10):f};case"video":var g=i("CodecPrivateData"),y=i("FourCC"),_=i("MaxWidth"),b=i("MaxHeight"),S=i("Bitrate"),E=void 0===S||isNaN(parseInt(S,10))?0:parseInt(S,10);if(void 0!==y&&void 0===L[y]||void 0===g)return r.Z.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null;var T=function(e){var t=/00000001\d7([0-9a-fA-F]{6})/.exec(e);return null!==t&&(0,d.Z)(t[1])?"avc1."+t[1]:"avc1.4D401E"}(g);return{bitrate:E,customAttributes:n,mimeType:void 0!==y?L[y]:y,codecPrivateData:g,codecs:T,width:void 0!==_?parseInt(_,10):void 0,height:void 0!==b?parseInt(b,10):void 0};case"text":var k=i("CodecPrivateData"),w=i("FourCC"),A=i("Bitrate");return{bitrate:void 0===A||isNaN(parseInt(A,10))?0:parseInt(A,10),customAttributes:n,mimeType:void 0!==w?L[w]:w,codecPrivateData:(0,p.Z)(k,"")};default:return r.Z.error("Smooth Parser: Unrecognized StreamIndex type: "+t),null}}function m(e){var t=e.root,i=e.timescale,a=e.baseUrl,f=e.protections,p=e.timeShiftBufferDepth,m=e.manifestReceivedTime,g=e.isLive,_=t.getAttribute("Timescale"),b=null===_||isNaN(+_)?i:+_,S=t.getAttribute("Type");if(null===S)throw new Error("StreamIndex without type.");(0,s.Z)(o.r,S)||r.Z.warn("Smooth Parser: Unrecognized adaptation type:",S);var E=S,T=t.getAttribute("Subtype"),k=t.getAttribute("Language"),w=t.getAttribute("Url"),A=null===w?"":w;var I,R=N(t,(function(e,t,r){switch(t){case"QualityLevel":var i=h(r,E);if(null===i)return e;("video"!==E||i.bitrate>n)&&e.qualityLevels.push(i);break;case"c":e.cNodes.push(r)}return e}),{qualityLevels:[],cNodes:[]}),Z=R.qualityLevels,P=R.cNodes,M=new D({timeline:(I=P,I.reduce((function(e,t,n){var r=t.getAttribute("d"),i=t.getAttribute("t"),a=t.getAttribute("r"),o=null!==a?+a-1:0,s=null!==i?+i:void 0,u=null!==r?+r:void 0;if(0===n)s=void 0===s||isNaN(s)?0:s;else{var l=e[n-1];if(null==s||isNaN(s)){if(null==l.duration||isNaN(l.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");s=l.start+l.duration*(l.repeatCount+1)}}if(null==u||isNaN(u)){var c=I[n+1];if(void 0===c)return e;var f=c.getAttribute("t"),v=(0,d.Z)(f)?+f:null;if(null===v)throw new Error("Can't build index timeline from Smooth Manifest.");u=v-s}return e.push({duration:u,start:s,repeatCount:o}),e}),[])),timescale:b,timeShiftBufferDepth:p,manifestReceivedTime:m});(0,u.Z)(0!==Z.length,"Adaptation should have at least one playable representation.");var C=E+((0,d.Z)(k)?"_"+k:""),L=Z.map((function(e){var t,n,r,i,o=(t=A,n=e.bitrate,r=e.customAttributes,t.replace(/\{bitrate\}/g,String(n)).replace(/{CustomAttributes}/g,r.length>0?r[0]:"")),s=(0,d.Z)(e.mimeType)?e.mimeType:O[E],u=e.codecs,p=C+"_"+(null!=E?E+"-":"")+(null!=s?s+"-":"")+(null!=u?u+"-":"")+String(e.bitrate),h=[];f.length>0&&(i=f[0],f.forEach((function(e){var t=e.keyId;e.keySystems.forEach((function(e){h.push({keyId:t,systemId:e.systemId})}))})));var m={bitsPerSample:e.bitsPerSample,channels:e.channels,codecPrivateData:e.codecPrivateData,packetSize:e.packetSize,samplingRate:e.samplingRate,height:e.height,width:e.width,protection:null!=i?{keyId:i.keyId}:void 0},_=new x({isLive:g,sharedSmoothTimeline:M,media:o,segmentPrivateInfos:m}),b=(0,c.Z)({},e,{index:_,cdnMetadata:[{baseUrl:a}],mimeType:s,codecs:u,id:p});if(h.length>0||void 0!==i){var S=void 0===i?[]:i.keySystems.map((function(e){var t=e.systemId,n=e.privateData,r=t.replace(/-/g,""),i=function(e,t){if(32!==e.length)throw new Error("HSS: wrong system id length");var n=0;return y("pssh",(0,l.zo)([n,0,0,0],(0,v.nr)(e),(0,l.kh)(t.length),t))}(r,n);return{systemId:r,data:i}}));if(S.length>0){var T=[{type:"cenc",values:S}];b.contentProtections={keyIds:h,initData:T}}else b.contentProtections={keyIds:h,initData:[]}}return b}));if("ADVT"===T)return null;var U={id:C,type:E,representations:L,language:null==k?void 0:k};return"text"===E&&"DESC"===T&&(U.closedCaption=!0),U}return function(n,r,i){var o="";if(void 0!==r){var s=(0,f.$)(r);o=r.substring(0,s)}var u=n.documentElement;if(null==u||"SmoothStreamingMedia"!==u.nodeName)throw new Error("document root should be SmoothStreamingMedia");var l=u.getAttribute("MajorVersion"),c=u.getAttribute("MinorVersion");if(null===l||null===c||!/^[2]-[0-2]$/.test(l+"-"+c))throw new Error("Version should be 2.0, 2.1 or 2.2");var v,p,h=u.getAttribute("Timescale"),g=(0,d.Z)(h)?isNaN(+h)?1e7:+h:1e7,y=N(u,(function(t,n,r){switch(n){case"Protection":t.protections.push(T(r,e.keySystems));break;case"StreamIndex":t.adaptationNodes.push(r)}return t}),{adaptationNodes:[],protections:[]}),_=y.protections,S=y.adaptationNodes,E="boolean"==typeof(v=u.getAttribute("IsLive"))?v:"string"==typeof v&&"TRUE"===v.toUpperCase();if(E){var k=u.getAttribute("DVRWindowLength");null==k||isNaN(+k)||0==+k||(p=+k/g)}var w,A,I,R,Z,x,P,M=S.reduce((function(e,t){var n=m({root:t,baseUrl:o,timescale:g,protections:_,isLive:E,timeShiftBufferDepth:p,manifestReceivedTime:i});if(null===n)return e;var r=n.type,a=e[r];return void 0===a?e[r]=[n]:a.push(n),e}),{}),C=null,D=void 0!==M.video?M.video[0]:void 0,O=void 0!==M.audio?M.audio[0]:void 0;if(void 0!==D||void 0!==O){var L=[],U=[];if(void 0!==D){var B=D.representations[0];if(void 0!==B){var F=B.index.getFirstAvailablePosition(),V=B.index.getLastAvailablePosition();null!=F&&L.push(F),null!=V&&U.push(V)}}if(void 0!==O){var z=O.representations[0];if(void 0!==z){var K=z.index.getFirstAvailablePosition(),G=z.index.getLastAvailablePosition();null!=K&&L.push(K),null!=G&&U.push(G)}}L.length>0&&(Z=Math.max.apply(Math,L)),U.length>0&&(x=Math.min.apply(Math,U),P=Math.max.apply(Math,U))}var W=u.getAttribute("Duration"),j=null!==W&&0!=+W?+W/g:void 0;if(E){w=e.suggestedPresentationDelay,A=t,I=null!=Z?Z:A;var H=P;void 0===H&&(H=Date.now()/1e3-A);var q=x;void 0===q&&(q=H),R={isLinear:!0,maximumSafePosition:q,livePosition:H,time:performance.now()},C=null!=p?p:null}else{I=null!=Z?Z:0,R={isLinear:!1,maximumSafePosition:void 0!==x?x:void 0!==j?I+j:1/0,livePosition:void 0,time:performance.now()}}var Y=E?0:I,X=E?void 0:R.maximumSafePosition,Q={availabilityStartTime:void 0===A?0:A,clockOffset:a,isLive:E,isDynamic:E,isLastPeriodKnown:!0,timeBounds:{minimumSafePosition:I,timeshiftDepth:C,maximumTimeData:R},periods:[{adaptations:M,duration:void 0!==X?X-Y:j,end:X,id:"gen-smooth-period-0",start:Y}],suggestedPresentationDelay:w,transportType:"smooth",uris:null==r?[]:[r]};return b(Q),Q}},B=U,F=n(4597),V=n(4460),z=n(8791),K=n(4644),G=n(2297);function W(e,t,n,i,o){var s,u,d,c=[];if(o){var f=(0,a.XA)(e);null!==f?(d=function(e){var t=(0,G.nR)(e,3565190898,3392751253,2387879627,2655430559);if(void 0===t)return[];for(var n=[],r=t[0],i=t[4],a=0;a=0}var H=n(3666);function q(e,t){return y("schm",(0,l.zo)(4,(0,v.tG)(e),(0,l.kh)(t)))}function Y(e){return y("frma",(0,v.tG)(e))}function X(e){var t=[7,[e.length]];return y("stsd",l.zo.apply(void 0,t.concat(e)))}function Q(e,t,n){return y("tenc",(0,l.zo)(6,[e,t],n))}function $(e,t,n,r,i){var a=[e,t,n];return void 0!==i&&a.push(y("senc",i),function(e){if(0===e.length)return y("saiz",new Uint8Array(0));var t=(0,l.pX)(e,0),n=(0,l.pX)(e,4),r=new Uint8Array(n+9);r.set((0,l.kh)(n),5);for(var i,a,o=9,s=8;s0;if(n)return e;var r=new Uint8Array(e.length+4);return r.set(e.subarray(0,t+8),0),r[t+3]=1|r[t+3],r.set([0,0,0,0],t+8),r.set(e.subarray(t+8,e.length),t+12),(0,K.J6)(r)}(d,s[1]-s[0]),v=$(u,c,f,i,(0,G.nR)(a,2721664850,1520127764,2722393154,2086964724)),p=_("moof",[i,v]),h=(0,G.Qy)(p,1836019558),m=(0,G.Qy)(v,1953653094),g=(0,G.Qy)(f,1953658222);if(null===h||null===m||null===g)throw new Error("Smooth: Invalid moof, trun or traf generation");var b=h[1]-h[0]+i.length+(m[1]-m[0])+u.length+c.length+(g[1]-g[0])+8,S=n[2]-n[0],E=p.length-S,T=(0,G.Qy)(e,1835295092);if(null===T)throw new Error("Smooth: Invalid ISOBMFF given");if(!H.YM&&(0===E||E<=-8)){var k=T[1];return p.set((0,l.kh)(k),b),e.set(p,n[0]),E<=-8&&e.set(y("free",new Uint8Array(-E-8)),p.length),e}var w=T[1]+E;p.set((0,l.kh)(w),b);var A=new Uint8Array(e.length+E),I=e.subarray(0,n[0]),R=e.subarray(n[2],e.length);return A.set(I,0),A.set(p,I.length),A.set(R,I.length+p.length),A}var ee=n(7839),te=n(281);function ne(e,t,n,r,i,a){var o,s,u,d=_("stbl",[n,y("stts",new Uint8Array(8)),y("stsc",new Uint8Array(8)),y("stsz",new Uint8Array(12)),y("stco",new Uint8Array(8))]),c=function(e){return y("dref",(0,l.zo)(7,[1],e))}(y("url ",new Uint8Array([0,0,0,1]))),f=_("dinf",[c]),p=_("minf",[r,f,d]),h=function(e){var t,n;switch(e){case"video":t="vide",n="VideoHandler";break;case"audio":t="soun",n="SoundHandler";break;default:t="hint",n=""}return y("hdlr",(0,l.zo)(8,(0,v.tG)(t),12,(0,v.tG)(n),1))}(t),m=function(e){return y("mdhd",(0,l.zo)(12,(0,l.kh)(e),8))}(e),g=_("mdia",[m,h,p]),b=function(e,t,n){return y("tkhd",(0,l.zo)((0,l.kh)(7),8,(0,l.kh)(n),20,[1,0,0,0],[0,1,0,0],12,[0,1,0,0],12,[64,0,0,0],(0,l.XT)(e),2,(0,l.XT)(t),2))}(i,a,1),S=_("trak",[b,g]),E=_("mvex",[(o=1,y("trex",(0,l.zo)(4,(0,l.kh)(o),[0,0,0,1],12)))]),T=function(e,t){return y("mvhd",(0,l.zo)(12,(0,l.kh)(e),4,[0,1],2,[1,0],10,[0,1],14,[0,1],14,[64,0,0,0],26,(0,l.XT)(t+1)))}(e,1),k=function(e,t,n){return _("moov",[e,t,n])}(T,E,S),w=(s="isom",u=["isom","iso2","iso6","avc1","dash"],y("ftyp",l.zo.apply(void 0,[(0,v.tG)(s),[0,0,0,1]].concat(u.map(v.tG)))));return(0,l.zo)(w,k)}function re(e,t,n,r,i,a,o,s){var u=o.split("00000001"),d=u[1],c=u[2];if(void 0===d||void 0===c)throw new Error("Smooth: unsupported codec private data.");var f,p,h=function(e,t,n){var r=2===n?1:4===n?3:0,i=e[1],a=e[2],o=e[3];return y("avcC",(0,l.zo)([1,i,a,o,252|r,225],(0,l.XT)(e.length),e,[1],(0,l.XT)(t.length),t))}((0,v.nr)(d),(0,v.nr)(c),a);if(void 0===s){var m=function(e,t,n,r,i,a,o){return y("avc1",(0,l.zo)(6,(0,l.XT)(1),16,(0,l.XT)(e),(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),6,[0,1,i.length],(0,v.tG)(i),31-i.length,(0,l.XT)(a),[255,255],o))}(t,n,r,i,"AVC Coding",24,h);f=X([m])}else{var g=_("schi",[Q(1,8,s)]),b=q("cenc",65536),S=function(e,t,n,r,i,a,o,s){return y("encv",(0,l.zo)(6,(0,l.XT)(1),16,(0,l.XT)(e),(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),6,[0,1,i.length],(0,v.tG)(i),31-i.length,(0,l.XT)(a),[255,255],o,s))}(t,n,r,i,"AVC Coding",24,h,_("sinf",[Y("avc1"),b,g]));f=X([S])}return ne(e,"video",f,((p=new Uint8Array(12))[3]=1,y("vmhd",p)),t,n)}var ie=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function ae(e,t,n,r,i,a,o){var s,u,d,c=function(e,t){return y("esds",(0,l.zo)(4,[3,25],(0,l.XT)(e),[0,4,17,64,21],11,[5,2],(0,v.nr)(t),[6,1,2]))}(1,0===a.length?(s=i,u=t,d=((d=((d=(63&2)<<4)|31&ie.indexOf(s))<<4)|31&u)<<3,(0,v.ci)((0,l.XT)(d))):a),f=function(){if(void 0===o){var e=function(e,t,n,r,i,a){return y("mp4a",(0,l.zo)(6,(0,l.XT)(e),8,(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),(0,l.XT)(i),2,a))}(1,t,n,r,i,c);return X([e])}var a=_("schi",[Q(1,8,o)]),s=q("cenc",65536),u=_("sinf",[Y("mp4a"),s,a]),d=function(e,t,n,r,i,a,o){return y("enca",(0,l.zo)(6,(0,l.XT)(e),8,(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),(0,l.XT)(i),2,a,o))}(1,t,n,r,i,c,u);return X([d])}();return ne(e,"audio",f,y("smhd",new Uint8Array(8)),0,0)}function oe(e,t,n,r,i,a){var o,s=t.segment.range;return Array.isArray(s)&&(o={Range:(0,te.Z)(s)}),(0,F.ZP)({url:e,responseType:"arraybuffer",headers:o,timeout:r.timeout,cancelSignal:i,onProgress:n.onProgress}).then((function(e){if(!j(t.mimeType)||!0!==a)return{resultType:"segment-loaded",resultData:e};var n=new Uint8Array(e.responseData);return(0,V.Z)(n,t.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},e),{responseData:n})}}))}var se=function(e){var t=e.checkMediaSegmentIntegrity,n=e.customSegmentLoader;return function(e,r,i,a,o){var s=r.segment;if(s.isInit){if(void 0===s.privateInfos||void 0===s.privateInfos.smoothInitSegment)throw new Error("Smooth: Invalid segment format");var u,l=s.privateInfos.smoothInitSegment,d=l.codecPrivateData,c=l.timescale,f=l.height,v=l.width,p=l.protection,h=void 0===p?{keyId:void 0,keySystems:void 0}:p;if(void 0===d)throw new Error("Smooth: no codec private data.");switch(r.type){case"video":u=re(c,null!=v?v:0,null!=f?f:0,72,72,4,d,h.keyId);break;case"audio":var m=l.channels,g=void 0===m?0:m,y=l.bitsPerSample,_=void 0===y?0:y,b=l.packetSize,S=void 0===b?0:b,E=l.samplingRate;u=ae(c,g,_,S,void 0===E?0:E,d,h.keyId);break;default:0,u=new Uint8Array(0)}return Promise.resolve({resultType:"segment-created",resultData:u})}return null===e?Promise.resolve({resultType:"segment-created",resultData:null}):"function"!=typeof n?oe(e,r,o,i,a,t):new Promise((function(s,u){var l=!1,d={reject:function(e){var t,n,r;if(!l&&!a.isCancelled()){l=!0,a.deregister(v);var i=e,o=null!==(t=null==i?void 0:i.message)&&void 0!==t?t:"Unknown error when fetching a Smooth segment through a custom segmentLoader.",s=new ee.Z(o,null!==(n=null==i?void 0:i.canRetry)&&void 0!==n&&n,null!==(r=null==i?void 0:i.isOfflineError)&&void 0!==r&&r,null==i?void 0:i.xhr);u(s)}},resolve:function(e){if(!l&&!a.isCancelled()){l=!0,a.deregister(v),j(r.mimeType)&&!0===t||s({resultType:"segment-loaded",resultData:{responseData:e.data,size:e.size,requestDuration:e.duration}});var n=e.data instanceof Uint8Array?e.data:new Uint8Array(e.data);(0,V.Z)(n,r.segment.isInit),s({resultType:"segment-loaded",resultData:{responseData:n,size:e.size,requestDuration:e.duration}})}},fallback:function(){l||a.isCancelled()||(l=!0,a.deregister(v),oe(e,r,o,i,a,t).then(s,u))},progress:function(e){l||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})}},c={isInit:r.segment.isInit,timeout:i.timeout,range:r.segment.range,indexRange:r.segment.indexRange,type:r.type,url:e},f=n(c,d);function v(e){l||((l=!0)||"function"!=typeof f||f(),u(e))}a.register(v)}))}};function ue(e,t){return null===e?null:null===t.url?e.baseUrl:(0,f.Z)(e.baseUrl,t.url)}var le=function(e){var t=B(e),n=se(e),o={customManifestLoader:e.manifestLoader},s={loadSegment:function(e,t,r,i,a){var o=ue(e,t.segment);return n(o,t,r,i,a)},parseSegment:function(e,t,n){var r,i,a=t.segment,o=e.data,s=e.isChunked;if(null===o)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var u=o instanceof Uint8Array?o:new Uint8Array(o);if(a.isInit){var l=null===(i=null===(r=a.privateInfos)||void 0===r?void 0:r.smoothInitSegment)||void 0===i?void 0:i.timescale;return{segmentType:"init",initializationData:o,initializationDataSize:o.byteLength,initTimescale:l,protectionData:[]}}var d=void 0!==n?W(u,s,n,a,t.isLive):null;if(null===d||null===d.chunkInfos||void 0===d.scaledSegmentTime)throw new Error("Smooth Segment without time information");var c=d.nextSegments,f=d.chunkInfos,v=J(u,d.scaledSegmentTime),p=c.length>0?c:void 0;return{segmentType:"media",chunkData:v,chunkInfos:f,chunkOffset:0,chunkSize:v.length,protectionData:[],predictedSegments:p,appendWindow:[void 0,void 0]}}};return{manifest:{loadManifest:(0,z.Z)(o,"text"),parseManifest:function(n,r){var a,o=null!==(a=n.url)&&void 0!==a?a:r.originalUrl,s=n.receivedTime,u=n.responseData,l="string"==typeof u?(new DOMParser).parseFromString(u,"text/xml"):u,d=t(l,o,s);return{manifest:new i.ZP(d,{representationFilter:e.representationFilter}),url:o}}},audio:s,video:s,text:{loadSegment:function(t,n,r,i,a){var o=n.segment,s=ue(t,o);return o.isInit||null===s?Promise.resolve({resultType:"segment-created",resultData:null}):j(n.mimeType)?(0,F.ZP)({url:s,responseType:"arraybuffer",timeout:r.timeout,cancelSignal:i,onProgress:a.onProgress}).then((function(t){if(!0!==e.checkMediaSegmentIntegrity)return{resultType:"segment-loaded",resultData:t};var r=new Uint8Array(t.responseData);return(0,V.Z)(r,n.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},t),{responseData:r})}})):(0,F.ZP)({url:s,responseType:"text",timeout:r.timeout,cancelSignal:i,onProgress:a.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))},parseSegment:function(e,t,n){var i,o,s,u=t.segment,l=t.language,d=t.mimeType,c=void 0===d?"":d,f=t.codecs,p=void 0===f?"":f,h=j(t.mimeType),m=e.data,g=e.isChunked;if(u.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if(null===m)return{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var y,_,b,S,E=null;if(h){var T;o=(T="string"==typeof m?(0,v.tG)(m):m instanceof Uint8Array?m:new Uint8Array(m)).length;var k=void 0!==n?W(T,g,n,u,t.isLive):null;s=null==k?void 0:k.nextSegments,null===(E=null!==(i=null==k?void 0:k.chunkInfos)&&void 0!==i?i:null)?g?r.Z.warn("Smooth: Unavailable time data for current text track."):(y=u.time,_=u.end):(y=E.time,_=void 0!==E.duration?E.time+E.duration:u.end);var w=p.toLowerCase();if("application/ttml+xml+mp4"===c||"stpp"===w||"stpp.ttml.im1t"===w)S="ttml";else{if("wvtt"!==w)throw new Error("could not find a text-track parser for the type "+c);S="vtt"}var A=(0,a.Le)(T);b=null===A?"":(0,v.uR)(A)}else{var I;if(y=u.time,_=u.end,"string"!=typeof m){var R=m instanceof Uint8Array?m:new Uint8Array(m);o=R.length,I=(0,v.uR)(R)}else I=m;switch(c){case"application/x-sami":case"application/smil":S="sami";break;case"application/ttml+xml":S="ttml";break;case"text/vtt":S="vtt"}if(void 0===S){if("srt"!==p.toLowerCase())throw new Error("could not find a text-track parser for the type "+c);S="srt"}b=I}return{segmentType:"media",chunkData:{type:S,data:b,start:y,end:_,language:l},chunkSize:o,chunkInfos:E,chunkOffset:null!=y?y:0,protectionData:[],predictedSegments:Array.isArray(s)&&s.length>0?s:void 0,appendWindow:[void 0,void 0]}}}}}},281:function(e,t,n){"use strict";function r(e){var t=e[0],n=e[1];return n===1/0?"bytes="+t+"-":"bytes="+t+"-"+n}n.d(t,{Z:function(){return r}})},4460:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(5389),i=n(8766);function a(e,t){if(t){if((0,i.Z)(e,1718909296)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `ftyp` box");if((0,i.Z)(e,1836019574)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `moov` box")}else{if((0,i.Z)(e,1836019558)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `moof` box");if((0,i.Z)(e,1835295092)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `mdat` box")}}},8766:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(6968);function i(e,t){for(var n=e.length,i=0;i+8<=n;){var a=(0,r.pX)(e,i);if(0===a)a=n-i;else if(1===a){if(i+16>n)return-1;a=(0,r.pV)(e,i+8)}if(isNaN(a)||a<=0)return-1;if((0,r.pX)(e,i+4)===t)return i+a<=n?i:-1;i+=a}return-1}},8791:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(7904),i=n(4597),a=n(7839);function o(e,t){var n=e.customManifestLoader,o=function(e){return function(t,n,a){if(void 0===t)throw new Error("Cannot perform HTTP(s) request. URL not known");switch(e){case"arraybuffer":return(0,i.ZP)({url:t,responseType:"arraybuffer",timeout:n.timeout,cancelSignal:a});case"text":return(0,i.ZP)({url:t,responseType:"text",timeout:n.timeout,cancelSignal:a});case"document":return(0,i.ZP)({url:t,responseType:"document",timeout:n.timeout,cancelSignal:a});default:(0,r.Z)(e)}}}(t);return"function"!=typeof n?o:function(e,t){return function(n,r,i){return new Promise((function(o,s){var u=Date.now()-performance.now(),l=!1,d={reject:function(e){var t,n,r;if(!l&&!i.isCancelled()){l=!0,i.deregister(f);var o=e,u=null!==(t=null==o?void 0:o.message)&&void 0!==t?t:"Unknown error when fetching the Manifest through a custom manifestLoader.",d=new a.Z(u,null!==(n=null==o?void 0:o.canRetry)&&void 0!==n&&n,null!==(r=null==o?void 0:o.isOfflineError)&&void 0!==r&&r,null==o?void 0:o.xhr);s(d)}},resolve:function(e){if(!l&&!i.isCancelled()){l=!0,i.deregister(f);var t=void 0!==e.receivingTime?e.receivingTime-u:void 0,n=void 0!==e.sendingTime?e.sendingTime-u:void 0;o({responseData:e.data,size:e.size,requestDuration:e.duration,url:e.url,receivedTime:t,sendingTime:n})}},fallback:function(){l||i.isCancelled()||(l=!0,i.deregister(f),t(n,r,i).then(o,s))}},c=e({url:n,timeout:r.timeout},d);function f(e){l||(l=!0,"function"==typeof c&&c(),s(e))}i.register(f)}))}}(n,o)}},4791:function(e,t,n){"use strict";function r(e,t){if(e.length!==t.length)return!1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return!1;return!0}n.d(t,{Z:function(){return r}})},3274:function(e,t,n){"use strict";function r(e,t,n){if("function"==typeof Array.prototype.find)return e.find(t,n);for(var r=e.length>>>0,i=0;i>>0,i=0;i>>0;if(0===r)return!1;for(var i,a,o=0|n,s=o>=0?Math.min(o,r-1):Math.max(r+o,0);s=a.length)throw new Error("Unable to parse base64 string.");var t=a[e];if(255===t)throw new Error("Unable to parse base64 string.");return t}function s(e){var t,n="",r=e.length;for(t=2;t>2],n+=i[(3&e[t-2])<<4|e[t-1]>>4],n+=i[(15&e[t-1])<<2|e[t]>>6],n+=i[63&e[t]];return t===r+1&&(n+=i[e[t-2]>>2],n+=i[(3&e[t-2])<<4],n+="=="),t===r&&(n+=i[e[t-2]>>2],n+=i[(3&e[t-2])<<4|e[t-1]>>4],n+=i[(15&e[t-1])<<2],n+="="),n}function u(e){var t=e.length%4,n=e;0!==t&&(r.Z.warn("base64ToBytes: base64 given miss padding"),n+=3===t?"=":2===t?"==":"===");var i=n.indexOf("=");if(-1!==i&&i>16,l[c+1]=a>>8&255,l[c+2]=255&a;return l.subarray(0,l.length-s)}},6968:function(e,t,n){"use strict";function r(){for(var e,t=arguments.length,n=-1,r=0;++n0&&(i.set(e,a),a+=e.length);return i}function i(e,t){return(e[t+0]<<8)+(e[t+1]<<0)}function a(e,t){return 65536*e[t+0]+256*e[t+1]+e[t+2]}function o(e,t){return 16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3]}function s(e,t){return 4294967296*(16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3])+16777216*e[t+4]+65536*e[t+5]+256*e[t+6]+e[t+7]}function u(e){return new Uint8Array([e>>>8&255,255&e])}function l(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function d(e){var t=e%4294967296,n=(e-t)/4294967296;return new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function c(e,t){return(e[t+0]<<0)+(e[t+1]<<8)}function f(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}function v(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}function p(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer)}n.d(t,{O_:function(){return v},QI:function(){return a},XT:function(){return u},_f:function(){return p},dN:function(){return f},el:function(){return d},kh:function(){return l},pV:function(){return s},pX:function(){return o},qb:function(){return c},zK:function(){return i},zo:function(){return r}})},7864:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(7733);function i(e,t){return(0,r.Z)(t,(function(t){var n=setTimeout((function(){return t()}),e);return function(){return clearTimeout(n)}}))}},7733:function(e,t,n){"use strict";function r(e,t){var n;return new Promise((function(r,i){if(null!==e.cancellationError)return i(e.cancellationError);var a=!1;function o(e){void 0!==n&&n(),i(e)}n=t((function(t){e.deregister(o),a=!0,r(t)}),(function(t){e.deregister(o),a=!0,i(t)})),a||e.register(o)}))}n.d(t,{Z:function(){return r}})},1959:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(3887),i=n(1946),a=function(){function e(){this._listeners={}}var t=e.prototype;return t.addEventListener=function(e,t,n){var r=this,i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],void 0!==n&&n.register((function(){r.removeEventListener(e,t)}))},t.removeEventListener=function(e,t){if((0,i.Z)(e))this._listeners={};else{var n=this._listeners[e];if(Array.isArray(n))if((0,i.Z)(t))delete this._listeners[e];else{var r=n.indexOf(t);-1!==r&&n.splice(r,1),0===n.length&&delete this._listeners[e]}}},t.trigger=function(e,t){var n=this._listeners[e];Array.isArray(n)&&n.slice().forEach((function(e){try{e(t)}catch(e){r.Z.error("EventEmitter: listener error",e instanceof Error?e:null)}}))},e}()},9592:function(e,t,n){"use strict";function r(e,t){return"function"==typeof Array.prototype.flatMap?e.flatMap(t):e.reduce((function(e,n){var r=t(n);return Array.isArray(r)?(e.push.apply(e,r),e):(e.push(r),e)}),[])}n.d(t,{Z:function(){return r}})},2572:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=.3;function i(e){return e*((2*Math.random()-1)*r+1)}},2870:function(e,t,n){"use strict";function r(e){for(var t=0,n=0;n=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}n.d(t,{Z:function(){return r}})},6923:function(e,t,n){"use strict";function r(e){return"string"==typeof e&&e.length>0}n.d(t,{Z:function(){return r}})},1946:function(e,t,n){"use strict";function r(e){return null==e}n.d(t,{Z:function(){return r}})},5288:function(e,t,n){"use strict";n.d(t,{ZP:function(){return u}});var r=n(6923),i=n(1946),a={aa:"aar",ab:"abk",ae:"ave",af:"afr",ak:"aka",am:"amh",an:"arg",ar:"ara",as:"asm",av:"ava",ay:"aym",az:"aze",ba:"bak",be:"bel",bg:"bul",bi:"bis",bm:"bam",bn:"ben",bo:"bod",br:"bre",bs:"bos",ca:"cat",ce:"che",ch:"cha",co:"cos",cr:"cre",cs:"ces",cu:"chu",cv:"chv",cy:"cym",da:"dan",de:"deu",dv:"div",dz:"dzo",ee:"ewe",el:"ell",en:"eng",eo:"epo",es:"spa",et:"est",eu:"eus",fa:"fas",ff:"ful",fi:"fin",fj:"fij",fo:"fao",fr:"fra",fy:"fry",ga:"gle",gd:"gla",gl:"glg",gn:"grn",gu:"guj",gv:"glv",ha:"hau",he:"heb",hi:"hin",ho:"hmo",hr:"hrv",ht:"hat",hu:"hun",hy:"hye",hz:"her",ia:"ina",id:"ind",ie:"ile",ig:"ibo",ii:"iii",ik:"ipk",io:"ido",is:"isl",it:"ita",iu:"iku",ja:"jpn",jv:"jav",ka:"kat",kg:"kon",ki:"kik",kj:"kua",kk:"kaz",kl:"kal",km:"khm",kn:"kan",ko:"kor",kr:"kau",ks:"kas",ku:"kur",kv:"kom",kw:"cor",ky:"kir",la:"lat",lb:"ltz",lg:"lug",li:"lim",ln:"lin",lo:"lao",lt:"lit",lu:"lub",lv:"lav",mg:"mlg",mh:"mah",mi:"mri",mk:"mkd",ml:"mal",mn:"mon",mr:"mar",ms:"msa",mt:"mlt",my:"mya",na:"nau",nb:"nob",nd:"nde",ne:"nep",ng:"ndo",nl:"nld",nn:"nno",no:"nor",nr:"nbl",nv:"nav",ny:"nya",oc:"oci",oj:"oji",om:"orm",or:"ori",os:"oss",pa:"pan",pi:"pli",pl:"pol",ps:"pus",pt:"por",qu:"que",rm:"roh",rn:"run",ro:"ron",ru:"rus",rw:"kin",sa:"san",sc:"srd",sd:"snd",se:"sme",sg:"sag",si:"sin",sk:"slk",sl:"slv",sm:"smo",sn:"sna",so:"som",sq:"sqi",sr:"srp",ss:"ssw",st:"sot",su:"sun",sv:"swe",sw:"swa",ta:"tam",te:"tel",tg:"tgk",th:"tha",ti:"tir",tk:"tuk",tl:"tgl",tn:"tsn",to:"ton",tr:"tur",ts:"tso",tt:"tat",tw:"twi",ty:"tah",ug:"uig",uk:"ukr",ur:"urd",uz:"uzb",ve:"ven",vi:"vie",vo:"vol",wa:"wln",wo:"wol",xh:"xho",yi:"yid",yo:"yor",za:"zha",zh:"zho",zu:"zul"},o={alb:"sqi",arm:"hye",baq:"eus",bur:"mya",chi:"zho",cze:"ces",dut:"nld",fre:"fra",geo:"kat",ger:"deu",gre:"ell",ice:"isl",mac:"mkd",mao:"mri",may:"msa",per:"fas",slo:"slk",rum:"ron",tib:"bod",wel:"cym"};function s(e){if((0,i.Z)(e)||""===e)return"";var t=function(e){var t;switch(e.length){case 2:t=a[e];break;case 3:t=o[e]}return t}((""+e).toLowerCase().split("-")[0]);return(0,r.Z)(t)?t:e}var u=s},8894:function(e,t,n){"use strict";function r(){}n.d(t,{Z:function(){return r}})},8026:function(e,t){"use strict";t.Z="function"==typeof Object.assign?Object.assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=0;n<(arguments.length<=1?0:arguments.length-1);n++){var r=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}},1679:function(e,t,n){"use strict";t.Z="function"==typeof Object.values?Object.values:function(e){return Object.keys(e).map((function(t){return e[t]}))}},2829:function(e,t,n){"use strict";n.d(t,{A1:function(){return s},F_:function(){return p},JN:function(){return c},L7:function(){return h},Ti:function(){return u},XS:function(){return v},kR:function(){return m},rx:function(){return f},tn:function(){return y},uH:function(){return _}});var r=1/60;function i(e,t){return Math.abs(e-t)=0;n--){var r=e.start(n);if(t>=r){var i=e.end(n);if(t=o?r.push({start:a,end:o}):n={start:a,end:o}}return{outerRanges:r,innerRange:n}}function h(e,t){var n=f(e,t);return null!==n?n.end-t:1/0}function m(e,t){if(t.start===t.end)return e;for(var n=t,r=0;r0)for(var o=0;o0)for(var s=0;sl&&n.push({start:l,end:a[d].start}),l=a[d].end;l=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&i.splice(e,1)}}i.push(r),!0===(null==t?void 0:t.emitCurrentValue)&&e(n,o),a||r.hasBeenCleared?o():void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.register(o)},waitUntilDefined:function(e,t){this.onUpdate((function(t,r){void 0!==t&&(r(),e(n))}),{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:!0})},finish:o};function o(){void 0!==t&&t.deregister(o),a=!0;for(var e,n=r(i.slice());!(e=n()).done;){var s=e.value;try{s.hasBeenCleared||(s.complete(),s.hasBeenCleared=!0)}catch(e){}}i.length=0}}function o(e,t,n){var r=a(t(e.getValue()),n);return e.onUpdate((function(e){r.setValue(t(e))}),{clearSignal:n}),r}n.d(t,{$l:function(){return a},ZP:function(){return a},lR:function(){return o}})},4597:function(e,t,n){"use strict";n.d(t,{ZP:function(){return o}});var r=n(9105),i=n(6923),a=n(1946);var o=function(e){var t={url:e.url,headers:e.headers,responseType:(0,a.Z)(e.responseType)?"json":e.responseType,timeout:e.timeout};return new Promise((function(n,o){var s,u=e.onProgress,l=e.cancelSignal,d=t.url,c=t.headers,f=t.responseType,v=t.timeout,p=new XMLHttpRequest;if(p.open("GET",d,!0),void 0!==v&&(p.timeout=v,s=window.setTimeout((function(){_(),o(new r.Z(d,p.status,"TIMEOUT"))}),v+3e3)),p.responseType=f,"document"===p.responseType&&p.overrideMimeType("text/xml"),!(0,a.Z)(c)){var h=c;for(var m in h)h.hasOwnProperty(m)&&p.setRequestHeader(m,h[m])}var g=performance.now(),y=null;function _(){void 0!==s&&clearTimeout(s),null!==y&&y()}void 0!==l&&(y=l.register((function(e){_(),(0,a.Z)(p)||4===p.readyState||p.abort(),o(e)})),l.isCancelled())||(p.onerror=function(){_(),o(new r.Z(d,p.status,"ERROR_EVENT"))},p.ontimeout=function(){_(),o(new r.Z(d,p.status,"TIMEOUT"))},void 0!==u&&(p.onprogress=function(e){var t=performance.now();u({url:d,duration:t-g,sendingTime:g,currentTime:t,size:e.loaded,totalSize:e.total})}),p.onload=function(e){if(4===p.readyState)if(_(),p.status>=200&&p.status<300){var t,s=performance.now(),u=p.response instanceof ArrayBuffer?p.response.byteLength:e.total,l=p.status,c=p.responseType,f=(0,i.Z)(p.responseURL)?p.responseURL:d;if(t="json"===c?"object"==typeof p.response?p.response:function(e){try{return JSON.parse(e)}catch(e){return null}}(p.responseText):p.response,(0,a.Z)(t))return void o(new r.Z(d,p.status,"PARSE_ERROR"));n({status:l,url:f,responseType:c,sendingTime:g,receivedTime:s,requestDuration:s-g,size:u,responseData:t})}else o(new r.Z(d,p.status,"ERROR_HTTP_CODE"))},p.send())}))}},9829:function(e,t,n){"use strict";n.d(t,{$:function(){return o},Z:function(){return a}});var r=/^(?:[a-z]+:)?\/\//i,i=/\/\.{1,2}\//;function a(){var e=arguments.length;if(0===e)return"";for(var t="",n=0;n=0&&t===n+1)return e.length}var i=e.indexOf("?");return i>=0&&i>8&255}return n}function u(e){if(a)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";r.Z.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var n="",i=0;i=t?n:new Array(t-n.length+1).join("0")+n}function c(e){if(a)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";r.Z.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var n=e;239===n[0]&&187===n[1]&&191===n[2]&&(n=n.subarray(3));var i,o=function(e){for(var t="",n=0;n=256?"%u"+d(l,4):"%"+d(l,2)}}return decodeURIComponent(i)}function f(e){for(var t=e.length,n=new Uint8Array(t/2),r=0,i=0;r>>4).toString(16),n+=(15&e[r]).toString(16),t.length>0&&r0;)try{var n=t._listeners.pop();null==n||n(e)}catch(e){o.Z.error("Error while calling clean up listener",e instanceof Error?e.toString():"Unknown error")}}))}var t=e.prototype;return t.isCancelled=function(){return this._isCancelled},t.register=function(e){var t=this;return this._isCancelled?((0,s.Z)(null!==this.cancellationError),e(this.cancellationError),u.Z):(this._listeners.push(e),function(){return t.deregister(e)})},t.deregister=function(e){for(var t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)},e}(),c=function(e){function t(){var n;return n=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(n),t.prototype),n.name="CancellationError",n.message="This task was cancelled.",n}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},8806:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(7714),i=[];function a(e){(0,r.Z)(i,e)||(console.warn(e),i.push(e))}},7473:function(e){"use strict";var t=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e},n=function(e){var n,r,i=document.createTextNode(""),a=0;return new e((function(){var e;if(n)r&&(n=r.concat(n));else{if(!r)return;n=r}if(r=n,n=null,"function"==typeof r)return e=r,r=null,void e();for(i.data=a=++a%2;r;)e=r.shift(),r.length||(r=null),e()})).observe(i,{characterData:!0}),function(e){t(e),n?"function"==typeof n?n=[n,e]:n.push(e):(n=e,i.data=a=++a%2)}};e.exports=function(){if("object"==typeof process&&process&&"function"==typeof process.nextTick)return process.nextTick;if("function"==typeof queueMicrotask)return function(e){queueMicrotask(t(e))};if("object"==typeof document&&document){if("function"==typeof MutationObserver)return n(MutationObserver);if("function"==typeof WebKitMutationObserver)return n(WebKitMutationObserver)}return"function"==typeof setImmediate?function(e){setImmediate(t(e))}:"function"==typeof setTimeout||"object"==typeof setTimeout?function(e){setTimeout(t(e),0)}:null}()},7061:function(e,t,n){var r=n(8698).default;function i(){"use strict";e.exports=i=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,a=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",d=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof h?t:h,a=Object.create(i.prototype),s=new R(r||[]);return o(a,"_invoke",{value:k(e,n,s)}),a}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p={};function h(){}function m(){}function g(){}var y={};c(y,u,(function(){return this}));var _=Object.getPrototypeOf,b=_&&_(_(Z([])));b&&b!==n&&a.call(b,u)&&(y=b);var S=g.prototype=h.prototype=Object.create(y);function E(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(i,o,s,u){var l=v(e[i],e,o);if("throw"!==l.type){var d=l.arg,c=d.value;return c&&"object"==r(c)&&a.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){d.value=e,s(d)}),(function(e){return n("throw",e,s,u)}))}u(l.arg)}var i;o(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}})}function k(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return x()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=w(o,n);if(s){if(s===p)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=v(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var i=v(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,p;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function Z(e){if(e){var t=e[u];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(s&&u){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;I(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:Z(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},8698:function(e){function t(n){return e.exports=t="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},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},4687:function(e,t,n){var r=n(7061)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},7326:function(e,t,n){"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,{Z:function(){return r}})},5861:function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var o=e.apply(t,n);function s(e){r(o,i,a,s,u,"next",e)}function u(e){r(o,i,a,s,u,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return i}})},1656:function(e,t,n){"use strict";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)}function i(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===r(t)?t:String(t)}function a(e,t){for(var n=0;ni)break}if(l<0||n.length!==t.length)return s.Z.error("ABR: Current Bitrate not found in the calculated levels"),n[0];void 0!==a&&(u=0===o?a.score:a.score/o);var f=isFinite(r)?r:0,v=performance.now();if(f=0;m--)if(f>=t[m])return n[m];return n[0]}if(void 0!==this._lastUnsuitableQualityTimestamp&&v-this._lastUnsuitableQualityTimestampg)return e}();if(void 0!==y&&r>=t[y])return s.Z.debug("ABR: Raising quality in BufferBasedChooser",n[y]),n[y];return i},e}(),F=n(3274),V=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var n=Math.pow(this._alpha,e),r=t*(1-n)+n*this._lastEstimate;isNaN(r)||(this._lastEstimate=r,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function z(e){if(!(e.progress.length<5)){for(var t=new V(2),n=e.progress,r=1;r=u.outOfStarvationGap&&(s.Z.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(s.Z.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&(o=function(e,t,n,r,i){if(!r){var a=t.bufferGap,o=t.speed,s=t.position,u=isFinite(a)?a:0,l=function(e,t){for(var n=-1,r=0;r-1.2){n=r;break}if(a>t&&t-i.time>-1.2){n=r;break}}}if(n<0)return[];for(var o=e[n],s=o.content.segment.time,u=[o],l=n+1;l0?d.progress[d.progress.length-1]:void 0,p=z(d);if(void 0!==v&&void 0!==p){var h=K(v,p);if((c-v.timestamp)/1e3<=h&&h-u/o>2500)return p}if(d.content.segment.complete){var m=d.content.segment.duration,g=(c-d.requestTimestamp)/1e3;if(null!=n&&!(g<=(1.5*m+2)/o)){var y=m/g,_=n.bitrate*Math.min(.7,y);return void 0===i||_1&&(a/=e.speed),{bandwidthEstimate:o,bitrateChosen:a}},t.isUrgent=function(e,t,n,r){return null===t||!(e>=t.bitrate)&&function(e,t,n){if(n)return!0;var r=isFinite(e.bufferGap)?e.bufferGap:0,i=e.position.last+r,a=(0,F.Z)(t,(function(e){var t=e.content;return t.segment.duration>0&&t.segment.time+t.segment.duration>i}));if(void 0===a)return!0;var o=performance.now(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=z(a);if(void 0===s||void 0===u)return!0;var l=K(s,u);return(o-s.timestamp)/1e3>1.2*l||l-r/e.speed>-1.5}(r,n,this._lowLatencyMode)},e}();function W(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nu.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var l=this._scoreCalculator.getEstimate(n);if(2!==this._lastAbrEstimate.algorithmType){if(void 0===l)return null;if(this._canGuessHigher(a,o,l)){var d=q(e,n);if(null!==d)return d}return null}if(this._isLastGuessValidated(u,r,l)&&(s.Z.debug("ABR: Guessed Representation validated",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),n.id!==u.id)return u;if(this._shouldStopGuess(n,l,a,i))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=performance.now()+Math.min(15e3*this._consecutiveWrongGuesses,12e4),function(e,t){var n=(0,L.Z)(e,(function(e){return e.id===t.id}));if(n<0)return s.Z.error("ABR: Current Representation not found."),null;for(;--n>=0;)if(e[n].bitrate=2.5&&performance.now()>this._blockGuessesUntil&&1===i&&r/t>1.01},t._shouldStopGuess=function(e,t,n,r){if(void 0!==t&&t.score<1.01)return!0;if((void 0===t||t.score<1.2)&&n<.6)return!0;for(var i,a=r.filter((function(t){return t.content.representation.id===e.id})),o=performance.now(),s=W(a);!(i=s()).done;){var u=i.value,l=o-u.requestTimestamp;if(u.content.segment.isInit){if(l>1e3)return!0}else{if(l>1e3*u.content.segment.duration+200)return!0;var d=z(u);if(void 0!==d&&d<.8*e.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,n){return void 0!==n&&1===n.confidenceLevel&&n.score>1.5||t>=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitratet.bitrate)return e[r];return null}var Y=function(){function e(){var e=l.Z.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new V(t),this._slowEWMA=new V(n),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){if(!(t1&&this._lastRepresentationWithGoodScore!==e&&(s.Z.debug("ABR: New last stable representation",e.bitrate),this._lastRepresentationWithGoodScore=e)},t.getEstimate=function(e){if(null!==this._currentRepresentationData&&this._currentRepresentationData.representation.id===e.id){var t=this._currentRepresentationData,n=t.ewma,r=t.loadedSegments,i=t.loadedDuration;return{score:n.getEstimate(),confidenceLevel:r>=5&&i>=10?1:0}}},t.getLastStableRepresentation=function(){return this._lastRepresentationWithGoodScore},e}();function ee(e,t,n,r){var i=t<=n?n:t>=r?r:t,a=(0,L.Z)(e,(function(e){return e.bitrate>i}));return-1===a?e[e.length-1]:0===a?e[0]:e[a-1]}var te=(0,E.ZP)(-1);te.finish();var ne=(0,E.ZP)(0);ne.finish();var re=(0,E.ZP)(1/0);re.finish();var ie=(0,E.ZP)(void 0);ie.finish();var ae=(0,E.ZP)(1/0);ae.finish();var oe=function(e){var t={},n=e.manualBitrates,r=e.minAutoBitrates,i=e.maxAutoBitrates,a=e.initialBitrates,o=e.throttlers,u=e.lowLatencyMode;return function(e,d,c,f,v){var p=e.adaptation.type,h=function(e){var n=t[e];if(null==n){s.Z.debug("ABR: Creating new BandwidthEstimator for ",e);var r=new Y;return t[e]=r,r}return n}(p),m=(0,O.Z)(n[p],te),g=(0,O.Z)(r[p],ne),y=(0,O.Z)(i[p],re),_=(0,O.Z)(a[p],0);return function(e,t){var n=e.bandwidthEstimator,r=e.context,i=e.currentRepresentation,a=e.filters,o=e.initialBitrate,u=e.lowLatencyMode,d=e.manualBitrate,c=e.maxAutoBitrate,f=e.minAutoBitrate,v=e.playbackObserver,p=e.representations,h=new J,m=new G(null!=o?o:0,u),g=new $,y=N.Z,_={metrics:I,requestBegin:R,requestProgress:Z,requestEnd:x,addedSegment:function(e){y(e)}},b=new T.ZP;b.linkToSignal(t);var k=w(d.getValue(),p.getValue(),b.signal);return d.onUpdate(A,{clearSignal:t}),p.onUpdate(A,{clearSignal:t}),{estimates:k,callbacks:_};function w(e,t,o){if(0===t.length)return(0,E.ZP)({representation:null,bitrate:void 0,knownStableBitrate:void 0,manual:!1,urgent:!0});if(e>=0){var d=ee(t,e,0,1/0);return(0,E.ZP)({representation:d,bitrate:void 0,knownStableBitrate:void 0,manual:!0,urgent:!0})}if(1===t.length)return(0,E.ZP)({bitrate:void 0,representation:t[0],manual:!1,urgent:!0,knownStableBitrate:void 0});var p,_=!1,b=t.map((function(e){return e.bitrate})),T=new B(b),k=new X,w=new H(h,k),A=v.getReference().getValue(),I=(0,E.ZP)(Z());return v.listen((function(e){A=e,R()}),{includeLastObservation:!1,clearSignal:o}),y=function(e){if(null!==A){var t=A,n=t.position,r=t.speed,i=e.buffered,a=(0,S.L7)(i,n.last),o=e.content.representation,s=h.getEstimate(o),u={bufferGap:a,currentBitrate:o.bitrate,currentScore:s,speed:r};p=T.getEstimate(u),R()}},o.register((function(){y=N.Z})),f.onUpdate(R,{clearSignal:o}),c.onUpdate(R,{clearSignal:o}),a.limitWidth.onUpdate(R,{clearSignal:o}),a.limitWidth.onUpdate(R,{clearSignal:o}),I;function R(){I.setValue(Z())}function Z(){var e=A,o=e.bufferGap,d=e.position,v=e.maximumPosition,y=a.limitWidth.getValue(),b=a.throttleBitrate.getValue(),S=i.getValue(),E=f.getValue(),T=c.getValue(),I=function(e,t,n){var r=e;n<1/0&&(r=function(e,t){if(0===e.length)return[];e.sort((function(e,t){return e.bitrate-t.bitrate}));var n=e[0].bitrate,r=Math.max(t,n),i=(0,L.Z)(e,(function(e){return e.bitrate>r}));return-1===i?e:e.slice(0,i)}(r,n));void 0!==t&&(r=function(e,t){var n=e.slice().sort((function(e,t){return(0,O.Z)(e.width,0)-(0,O.Z)(t.width,0)})),r=(0,F.Z)(n,(function(e){return"number"==typeof e.width&&e.width>=t}));if(void 0===r)return e;var i="number"==typeof r.width?r.width:0;return e.filter((function(e){return"number"!=typeof e.width||e.width<=i}))}(r,t));return r}(t,y,b),R=g.getRequests(),Z=m.getBandwidthEstimate(A,n,S,R,k.bandwidth),x=Z.bandwidthEstimate,P=Z.bitrateChosen,M=h.getLastStableRepresentation(),C=null===M?void 0:M.bitrate/(A.speed>0?A.speed:1),D=l.Z.getCurrent(),N=D.ABR_ENTER_BUFFER_BASED_ALGO,U=D.ABR_EXIT_BUFFER_BASED_ALGO;_&&o<=U?_=!1:!_&&isFinite(o)&&o>=N&&(_=!0);var B=ee(I,P,E,T),V=B.bitrate,z=null;_&&void 0!==p&&p>V&&(V=(z=ee(I,p,E,T)).bitrate);var K=null;return u&&null!==S&&r.manifest.isDynamic&&v-d.last<40&&(K=w.getGuess(t,A,S,V,R)),null!==K&&K.bitrate>V?(s.Z.debug("ABR: Choosing representation with guess-based estimation.",K.bitrate,K.id),k.update(K,x,2),{bitrate:x,representation:K,urgent:null===S||K.bitrate=500||404===e.status||415===e.status||412===e.status:e.type===f.br.TIMEOUT||e.type===f.br.ERROR_EVENT:e instanceof ce.Z?"boolean"==typeof e.canRetry?e.canRetry:void 0!==e.xhr&&(e.xhr.status>=500||404===e.xhr.status||415===e.xhr.status||412===e.xhr.status):(0,fe.Z)(e)&&"INTEGRITY_ERROR"===e.code}function me(e){return e instanceof ue.Z?e.type===f.br.ERROR_EVENT&&!1===navigator.onLine:e instanceof ce.Z&&e.isOfflineError}function ge(e,t,n,r,i){return ye.apply(this,arguments)}function ye(){return ye=(0,w.Z)(I().mark((function e(t,n,r,i,a){var o,u,l,d,c,f,v,p,h,m,g,y,_,b;return I().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(b=function(e){var t;if(0===f.size)return e[0];var n=performance.now();return null===(t=e.filter((function(e){var t;return!0!==(null===(t=f.get(e))||void 0===t?void 0:t.isBlacklisted)})).reduce((function(e,t){var r,i=null===(r=f.get(t))||void 0===r?void 0:r.blockedUntil;return void 0!==i&&i<=n&&(i=void 0),void 0===e?[t,i]:void 0===i?void 0===e[1]?e:[t,void 0]:void 0===e[1]?e:iv?(c.blockedUntil=void 0,c.isBlacklisted=!0):(p=c.errorCounter,h=Math.min(o*Math.pow(2,p-1),u),m=(0,pe.Z)(h),c.blockedUntil=performance.now()+m),e.abrupt("return",g(e.t0));case 22:case"end":return e.stop()}var y}),e,null,[[0,7]])})))).apply(this,arguments)},h=function(e){return m.apply(this,arguments)},p=function(){if(null===t){var e=f.get(null);if(void 0!==e&&e.isBlacklisted)return;return null}if(null===n)return b(t);var r=n.getCdnPreferenceForResource(t);return b(r)},null===a.cancellationError){e.next=9;break}return e.abrupt("return",Promise.reject(a.cancellationError));case 9:if(o=i.baseDelay,u=i.maxDelay,l=i.maxRetryRegular,d=i.maxRetryOffline,c=i.onRetry,null!==t&&0===t.length&&s.Z.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),f=new Map,void 0!==(v=p())){e.next=15;break}throw new Error("No CDN to request");case 15:return e.abrupt("return",h(v));case 16:case"end":return e.stop()}}),e)}))),ye.apply(this,arguments)}function _e(e,t,n){return ge(null,null,e,t,n)}function be(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Se(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Se(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Se(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?this._consecutiveUnsafeMode=d,v=void 0===r?0:performance.now()-r,p=Math.max(this._settings.minimumManifestUpdateInterval-v,0),h=new T.ZP;if(h.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=function(t){var i=t.enablePartialRefresh,a=t.delay,o=t.canUseUnsafeMode&&f,s=void 0===r?0:performance.now()-r,u=Math.max(n._settings.minimumManifestUpdateInterval-s,0),l=setTimeout((function(){h.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:i,unsafeMode:o})}),Math.max((null!=a?a:0)-s,u));h.signal.register((function(){clearTimeout(l)}))},null!==e.expired){var m=setTimeout((function(){var t;null===(t=e.expired)||void 0===t||t.then((function(){h.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:f})}),N.Z)}),p);h.signal.register((function(){clearTimeout(m)}))}if(void 0!==e.lifetime&&e.lifetime>=0){var g,y=1e3*e.lifetime-v;void 0===c?g=y:e.lifetime<3&&c>=100?(g=Math.min(Math.max(3e3-v,Math.max(y,0)+c),6*y),s.Z.info("MUS: Manifest update rythm is too frequent. Postponing next request.",y,g)):c>=1e3*e.lifetime/10?(g=Math.min(Math.max(y,0)+c,6*y),s.Z.info("MUS: Manifest took too long to parse. Postponing next request",g,g)):g=y;var _=setTimeout((function(){h.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:f})}),Math.max(g,p));h.signal.register((function(){clearTimeout(_)}))}},r._triggerNextManifestRefresh=function(e,t){var n,r,i=this,a=t.enablePartialRefresh,o=t.unsafeMode,u=e.updateUrl;null!==this._prioritizedContentUrl?(n=!0,r=this._prioritizedContentUrl,this._prioritizedContentUrl=null):r=(n=!a||void 0===u)?e.getUrl():u;var d=e.clockOffset;o?(this._consecutiveUnsafeMode+=1,s.Z.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):this._consecutiveUnsafeMode>0&&(s.Z.info('Init: Not parsing the Manifest in "unsafeMode" anymore after '+String(this._consecutiveUnsafeMode)+" consecutive times."),this._consecutiveUnsafeMode=0),this._isRefreshPending||(this._isRefreshPending=!0,this._fetchManifest(r).then((function(t){return t.parse({externalClockOffset:d,previousManifest:e,unsafeMode:o})})).then((function(t){i._isRefreshPending=!1;var r=t.manifest,a=t.sendingTime,o=t.parsingTime,u=performance.now();if(n)e.replace(r);else try{e.update(r)}catch(t){var d=t instanceof Error?t.message:"unknown error";s.Z.warn("MUS: Attempt to update Manifest failed: "+d,"Re-downloading the Manifest fully");var c=l.Z.getCurrent().FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY,f=void 0===a?0:performance.now()-a,v=Math.max(i._settings.minimumManifestUpdateInterval-f,0),p=N.Z,h=setTimeout((function(){p(),i._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})}),Math.max(c-f,v));return void(p=i._canceller.signal.register((function(){clearTimeout(h)})))}var m=performance.now()-u;i._recursivelyRefreshManifest(e,{sendingTime:a,parsingTime:o,updatingTime:m})})).catch((function(e){i._isRefreshPending=!1,i._onFatalError(e)})))},r._onFatalError=function(e){this._canceller.isUsed()||(this.trigger("error",e),this.dispose())},n}(g.Z);var Te=Ee;function ke(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return we(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return we(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function we(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&this._removeIndexFromDowngradeList(n);var r=l.Z.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;this._downgradedCdnList.metadata.push(e);var i=window.setTimeout((function(){var n=Ie(t._downgradedCdnList.metadata,e);n>=0&&t._removeIndexFromDowngradeList(n),t.trigger("priorityChange",null)}),r);this._downgradedCdnList.timeouts.push(i),this.trigger("priorityChange",null)},r._innerGetCdnPreferenceForResource=function(e){var t=this,n=e.reduce((function(e,n){return t._downgradedCdnList.metadata.some((function(e){return e.id===n.id&&e.baseUrl===n.baseUrl}))?e[1].push(n):e[0].push(n),e}),[[],[]]),r=n[0],i=n[1];return r.concat(i)},r._removeIndexFromDowngradeList=function(e){this._downgradedCdnList.metadata.splice(e,1);var t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])},n}(g.Z);function Ie(e,t){return 0===e.length?-1:void 0!==t.id?(0,L.Z)(e,(function(e){return e.id===t.id})):(0,L.Z)(e,(function(e){return e.baseUrl===t.baseUrl}))}var Re=n(520),Ze=function(){function e(){this._cache=new WeakMap}var t=e.prototype;return t.add=function(e,t){var n=e.representation;e.segment.isInit&&this._cache.set(n,t)},t.get=function(e){var t=e.representation;if(e.segment.isInit){var n=this._cache.get(t);if(void 0!==n)return n}return null},e}(),xe=(0,y.Z)();var Pe=function(){function e(e){var t=e.prioritySteps;if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=t,this._prioritySteps.high>=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,n,r){var i,a=this;return(0,D.Z)(r,(function(o,s){return i={hasEnded:!1,priority:t,trigger:function(){if(!i.hasEnded){var e=function(){u(),a._endTask(i)},t=new T.ZP,u=t.linkToSignal(r);i.interrupter=t,t.signal.register((function(){i.interrupter=null,r.isCancelled()||n.beforeInterrupted()})),a._minPendingPriority=null===a._minPendingPriority?i.priority:Math.min(a._minPendingPriority,i.priority),a._pendingTasks.push(i),i.taskFn(t.signal).then((function(t){n.beforeEnded(),e(),o(t)})).catch((function(n){!r.isCancelled()&&t.isUsed()&&n instanceof T.FU||function(t){e(),s(t)}(n)}))}},taskFn:e,interrupter:null},a._canBeStartedNow(i)?(i.trigger(),a._isRunningHighPriorityTasks()&&a._interruptCancellableTasks()):a._waitingQueue.push(i),function(){return a._endTask(i)}}))},t._endTask=function(e){e.hasEnded=!0;var t=Me(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{var n=Me(e.taskFn,this._pendingTasks);if(n<0)return;this._pendingTasks.splice(n,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}},t.updatePriority=function(e,t){var n=Me(e,this._waitingQueue);if(n>=0){var r=this._waitingQueue[n];if(r.priority===t)return;if(r.priority=t,!this._canBeStartedNow(r))return;return this._findAndRunWaitingQueueTask(n),void(this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks())}var i=Me(e,this._pendingTasks);if(i<0)s.Z.warn("TP: request to update the priority of a non-existent task");else{var a=this._pendingTasks[i];if(a.priority!==t){var o=a.priority;a.priority=t,null===this._minPendingPriority||tt.priority?t.priority:e}),null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(s.Z.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t,n=Me(e.taskFn,this._pendingTasks);n<0?s.Z.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(n,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))),null===(t=e.interrupter)||void 0===t||t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function Me(e,t){return(0,L.Z)(t,(function(t){return t.taskFn===e}))}var Ce=function(){function e(e,t,n){var r=new Ae(n),i=l.Z.getCurrent(),a=i.MIN_CANCELABLE_PRIORITY,o=i.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new Pe({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=r,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,t){var n,r,i,a,o,u,c,f,v,h,m,g,y,S,E=(n=this._backoffOptions,r=n.maxRetryRegular,i=n.maxRetryOffline,a=n.lowLatencyMode,o=n.requestTimeout,u=l.Z.getCurrent(),c=u.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,f=u.DEFAULT_REQUEST_TIMEOUT,v=u.DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE,h=u.INITIAL_BACKOFF_DELAY_BASE,m=u.MAX_BACKOFF_DELAY_BASE,{maxRetryRegular:null!=r?r:c,maxRetryOffline:null!=i?i:v,baseDelay:a?h.LOW_LATENCY:h.REGULAR,maxDelay:a?m.LOW_LATENCY:m.REGULAR,requestTimeout:(0,_.Z)(o)?f:o}),k=function(e,t,n,r,i){var a={timeout:i.requestTimeout<0?void 0:i.requestTimeout},o=(0,p.Z)(["audio","video"],e)?new Ze:void 0,u=t.loadSegment,l=t.parseSegment;return function(){var e=(0,w.Z)(I().mark((function e(t,c,f){var v,p,h,m,g,y,S,E,k,w,A,R,Z,x,P,M,C,D,N,O,L,U,B,F;return I().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(F=function(){var e;x||!(0,_.Z)(A)&&void 0!==A.size&&void 0!==A.requestDuration&&R.length>0&&R.every((function(e){return e}))&&(x=!0,null===(e=r.onMetrics)||void 0===e||e.call(r,{size:A.size,requestDuration:A.requestDuration,content:t,segmentDuration:Z}))},B=function(e){c.onRetry(de(e))},U=function(e,t){R.push(!1);var n=R.length-1;return function(r){var i={data:e,isChunked:t};try{var a=l(i,P,r);return R[n]||(Z=void 0!==Z&&"media"===a.segmentType&&null!==a.chunkInfos&&void 0!==a.chunkInfos.duration?Z+a.chunkInfos.duration:void 0,R[n]=!0,F()),a}catch(e){throw(0,d.Z)(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown parsing error"})}}},L=function(e){return u(e,P,a,f,M)},O=function(){var e;void 0===A&&(s.Z.debug("SF: Segment request cancelled",k),A=null,null===(e=r.onRequestEnd)||void 0===e||e.call(r,{id:w}))},m=t.segment,g=t.adaptation,y=t.representation,S=t.manifest,E=t.period,k=(0,Re.K)(t),w=xe(),R=[],Z=0,x=!1,P={segment:m,type:g.type,language:g.language,isLive:S.isLive,periodStart:E.start,periodEnd:E.end,mimeType:y.mimeType,codecs:y.codec,manifestPublishTime:S.publishTime},M={onProgress:function(e){var t;void 0===A&&void 0!==e.totalSize&&e.size0;){var e=this._queue.shift();void 0!==e&&e.reject(new T.FU)}if("open"===this._mediaSource.readyState)try{this._sourceBuffer.abort()}catch(e){s.Z.warn("AVSB: Failed to abort a "+this.bufferType+" SourceBuffer:",e instanceof Error?e:"")}},r._onPendingTaskError=function(e){if(this._lastInitSegment=null,null!==this._pendingTask){var t=e instanceof Error?e:new Error("An unknown error occured when doing operations on the SourceBuffer");this._pendingTask.reject(t)}},r._addToQueue=function(e,t){var n=this;return(0,D.Z)(t,(function(t,r){var i=0===n._queue.length&&null===n._pendingTask,a=(0,b.Z)({resolve:t,reject:r},e);return n._queue.push(a),i&&n._flush(),function(){var e=n._queue.indexOf(a);e>=0&&n._queue.splice(e,1),a.resolve=N.Z,a.reject=N.Z}}))},r._flush=function(){if(!this._sourceBuffer.updating){if(null!==this._pendingTask){var e=this._pendingTask;if(e.type!==Be.f.Push||0===e.data.length){switch(e.type){case Be.f.Push:null!==e.inventoryData&&this._segmentInventory.insertChunk(e.inventoryData);break;case Be.f.EndOfSegment:this._segmentInventory.completeSegment(e.value,this.getBufferedRanges());break;case Be.f.Remove:this.synchronizeInventory();break;default:(0,m.Z)(e)}var t=e.resolve;return this._pendingTask=null,t(),void this._flush()}}else{var n=this._queue.shift();if(void 0===n)return;if(n.type!==Be.f.Push)this._pendingTask=n;else{var r,i=n.value;try{r=this._preparePushOperation(i.data)}catch(e){this._pendingTask=(0,b.Z)({data:[],inventoryData:i.inventoryInfos},n);var a=e instanceof Error?e:new Error("An unknown error occured when preparing a push operation");return this._lastInitSegment=null,void n.reject(a)}this._pendingTask=(0,b.Z)({data:r,inventoryData:i.inventoryInfos},n)}}try{switch(this._pendingTask.type){case Be.f.EndOfSegment:return s.Z.debug("AVSB: Acknowledging complete segment",(0,Re.K)(this._pendingTask.value)),void this._flush();case Be.f.Push:var o=this._pendingTask.data.shift();if(void 0===o)return void this._flush();s.Z.debug("AVSB: pushing segment",this.bufferType,(0,Re.K)(this._pendingTask.inventoryData)),this._sourceBuffer.appendBuffer(o);break;case Be.f.Remove:var u=this._pendingTask.value,l=u.start,d=u.end;s.Z.debug("AVSB: removing data from SourceBuffer",this.bufferType,l,d),this._sourceBuffer.remove(l,d);break;default:(0,m.Z)(this._pendingTask)}}catch(e){this._onPendingTaskError(e)}}},r._preparePushOperation=function(e){var t=[],n=e.codec,r=e.timestampOffset,i=e.appendWindow,a=!1;if(void 0!==n&&n!==this.codec&&(s.Z.debug("AVSB: updating codec",n),a=function(e,t){if("function"==typeof e.changeType){try{e.changeType(t)}catch(e){return s.Z.warn("Could not call 'changeType' on the given SourceBuffer:",e instanceof Error?e:""),!1}return!0}return!1}(this._sourceBuffer,n),a?this.codec=n:s.Z.debug("AVSB: could not update codec",n,this.codec)),this._sourceBuffer.timestampOffset!==r){var o=r;s.Z.debug("AVSB: updating timestampOffset",this.bufferType,this._sourceBuffer.timestampOffset,o),this._sourceBuffer.timestampOffset=o}if(void 0===i[0]?this._sourceBuffer.appendWindowStart>0&&(this._sourceBuffer.appendWindowStart=0):i[0]!==this._sourceBuffer.appendWindowStart&&(i[0]>=this._sourceBuffer.appendWindowEnd&&(this._sourceBuffer.appendWindowEnd=i[0]+1),this._sourceBuffer.appendWindowStart=i[0]),void 0===i[1]?this._sourceBuffer.appendWindowEnd!==1/0&&(this._sourceBuffer.appendWindowEnd=1/0):i[1]!==this._sourceBuffer.appendWindowEnd&&(this._sourceBuffer.appendWindowEnd=i[1]),null!==e.initSegment&&(a||!this._isLastInitSegment(e.initSegment))){var u=e.initSegment;t.push(u);var l=(0,Le._f)(u);this._lastInitSegment={data:l,hash:(0,Ue.Z)(l)}}return null!==e.chunk&&t.push(e.chunk),t},r._isLastInitSegment=function(e){if(null===this._lastInitSegment)return!1;if(this._lastInitSegment.data===e)return!0;var t=this._lastInitSegment.data;if(t.byteLength===e.byteLength){var n=(0,Le._f)(e);if((0,Ue.Z)(n)===this._lastInitSegment.hash&&(0,Oe.Z)(t,n))return!0}return!1},n}(Be.C),Ve=["audio","video","text"];function ze(e){return"audio"===e||"video"===e}var Ke=function(){function e(e,t){this._mediaElement=e,this._mediaSource=t,this._initializedSegmentBuffers={},this._onNativeBufferAddedOrDisabled=[]}e.isNative=function(e){return ze(e)};var t=e.prototype;return t.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null==v.Z.nativeTextTracksBuffer&&null==v.Z.htmlTextTracksBuffer||e.push("text"),e},t.getNativeBufferTypes=function(){return"AUDIO"===this._mediaElement.nodeName?["audio"]:["video","audio"]},t.getStatus=function(e){var t=this._initializedSegmentBuffers[e];return void 0===t?{type:"uninitialized"}:null===t?{type:"disabled"}:{type:"initialized",value:t}},t.waitForUsableBuffers=function(e){var t=this;return this._areNativeBuffersUsable()?Promise.resolve():(0,D.Z)(e,(function(e){var n,r=function(){var e=t._onNativeBufferAddedOrDisabled.indexOf(n);e>=0&&t._onNativeBufferAddedOrDisabled.splice(e,1)};return n=function(){t._areNativeBuffersUsable()&&(r(),e())},t._onNativeBufferAddedOrDisabled.push(n),r}))},t.disableSegmentBuffer=function(t){var n=this._initializedSegmentBuffers[t];if(null!==n){if(void 0!==n)throw new Error("Cannot disable an active SegmentBuffer.");this._initializedSegmentBuffers[t]=null,e.isNative(t)&&this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()}))}else s.Z.warn("SBS: The "+t+" SegmentBuffer was already disabled.")},t.createSegmentBuffer=function(e,t,n){void 0===n&&(n={});var r,i=this._initializedSegmentBuffers[e];if(ze(e)){if(null!=i)return i instanceof Fe&&i.codec!==t?s.Z.warn("SB: Reusing native SegmentBuffer with codec",i.codec,"for codec",t):s.Z.info("SB: Reusing native SegmentBuffer with codec",t),i;s.Z.info("SB: Adding native SegmentBuffer with codec",t);var a=new Fe(e,t,this._mediaSource);return this._initializedSegmentBuffers[e]=a,this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()})),a}if(null!=i)return s.Z.info("SB: Reusing a previous custom SegmentBuffer for the type",e),i;if("text"===e){if(s.Z.info("SB: Creating a new text SegmentBuffer"),"html"===n.textTrackMode){if(null==v.Z.htmlTextTracksBuffer)throw new Error("HTML Text track feature not activated");r=new v.Z.htmlTextTracksBuffer(this._mediaElement,n.textTrackElement)}else{if(null==v.Z.nativeTextTracksBuffer)throw new Error("Native Text track feature not activated");r=new v.Z.nativeTextTracksBuffer(this._mediaElement)}return this._initializedSegmentBuffers.text=r,r}throw s.Z.error("SB: Unknown buffer type:",e),new c.Z("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentBuffer of an unknown type.")},t.disposeSegmentBuffer=function(e){var t=this._initializedSegmentBuffers[e];null!=t?(s.Z.info("SB: Aborting SegmentBuffer",e),t.dispose(),delete this._initializedSegmentBuffers[e]):s.Z.warn("SB: Trying to dispose a SegmentBuffer that does not exist")},t.disposeAll=function(){var e=this;Ve.forEach((function(t){"initialized"===e.getStatus(t).type&&e.disposeSegmentBuffer(t)}))},t._areNativeBuffersUsable=function(){var e=this,t=this.getNativeBufferTypes();return!t.some((function(t){return void 0===e._initializedSegmentBuffers[t]}))&&!t.every((function(t){return null===e._initializedSegmentBuffers[t]}))},e}(),Ge=n(7473),We=n.n(Ge),je=function(){function e(e){this._array=[],this._sortingFn=e}var t=e.prototype;return t.add=function(){for(var e=arguments.length,t=new Array(e),n=0;n=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return(0,F.Z)(this._array,e)},t.has=function(e){return(0,p.Z)(this._array,e)},t.removeElement=function(e){var t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}(),He=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t=this._weakMap.get(e);if(void 0===t){var n=this._fn(e);return this._weakMap.set(e,n),n}return t},t.destroy=function(e){this._weakMap.delete(e)},e}();function qe(e,t){var n,r=e.segmentBuffer,i=e.playbackObserver,a=e.maxBufferBehind,o=e.maxBufferAhead;function u(){(function(e,t,n,r,i){return Ye.apply(this,arguments)})(r,n,a.getValue(),o.getValue(),t).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";s.Z.error("Could not run BufferGarbageCollector:",t)}))}i.listen((function(e){var t;n=null!==(t=e.position.pending)&&void 0!==t?t:e.position.last,u()}),{includeLastObservation:!0,clearSignal:t}),a.onUpdate(u,{clearSignal:t}),o.onUpdate(u,{clearSignal:t}),u()}function Ye(){return(Ye=(0,w.Z)(I().mark((function e(t,n,r,i,a){var o,u,l,d,c,f,v,p;return I().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(r)||isFinite(i)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:o=[],u=(0,S.F_)(t.getBufferedRanges(),n),l=u.innerRange,d=u.outerRanges,c=function(){if(isFinite(i)){for(var e=0;et.start&&o.push({start:n+i,end:t.end})}null!=l&&n+i=t.end?o.push(t):n>=t.end&&n-r>t.start&&n-rl.start&&o.push({start:l.start,end:n-r})}}(),c(),f=0,v=o;case 9:if(!(f0&&n[0].segment.id===e._mediaSegmentAwaitingInitMetadata)){var r=e._mediaSegmentRequest;if(0===n.length){if(null===r)return;return s.Z.debug("Stream: no more media segment to request. Cancelling queue.",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()}if(null===r)return s.Z.debug("Stream: Media segments now need to be requested. Starting queue.",e._content.adaptation.type,n.length),void e._restartMediaSegmentDownloadingQueue();var i=n[0];return r.segment.id!==i.segment.id?(s.Z.debug("Stream: Next media segment changed, cancelling previous",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()):void(r.priority!==i.priority&&(s.Z.debug("Stream: Priority of next media segment changed, updating",e._content.adaptation.type,r.priority,i.priority),e._segmentFetcher.updatePriority(r.request,i.priority)))}}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate((function(t){var n,r=e._initSegmentRequest;null===t.initSegment||null===r?(null===(n=t.initSegment)||void 0===n?void 0:n.segment.id)!==(null==r?void 0:r.segment.id)&&(null===t.initSegment&&s.Z.debug("Stream: no more init segment to request. Cancelling queue.",e._content.adaptation.type),e._restartInitSegmentDownloadingQueue(t.initSegment)):t.initSegment.priority!==r.priority&&e._segmentFetcher.updatePriority(r.request,t.initSegment.priority)}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))},r.stop=function(){var e;null===(e=this._currentCanceller)||void 0===e||e.cancel(),this._currentCanceller=null},r._restartMediaSegmentDownloadingQueue=function(){var e=this;null!==this._mediaSegmentRequest&&this._mediaSegmentRequest.canceller.cancel();!function t(n){if(null!==e._currentCanceller&&e._currentCanceller.isUsed())e._mediaSegmentRequest=null;else{if(void 0===n)return e._mediaSegmentRequest=null,void e.trigger("emptyQueue",null);var r=new T.ZP,i=null===e._currentCanceller?N.Z:r.linkToSignal(e._currentCanceller.signal),a=n.segment,o=n.priority,u=(0,b.Z)({segment:a},e._content),l=!1,d=!1;r.signal.register((function(){e._mediaSegmentRequest=null,l||(e._mediaSegmentAwaitingInitMetadata===a.id&&(e._mediaSegmentAwaitingInitMetadata=null),l=!0,d=!1)}));var c=function(t){(0,h.Z)("media"===t.segmentType,"Should have loaded a media segment."),e.trigger("parsedMediaSegment",(0,b.Z)({},t,{segment:a}))},f=function(){var n=e._downloadQueue.getValue().segmentQueue;if(0===n.length)return l=!0,void e.trigger("emptyQueue",null);n[0].segment.id===a.id&&n.shift(),l=!0,t(n[0])},v=e._segmentFetcher.createRequest(u,o,{onRetry:function(t){e.trigger("requestRetry",{segment:a,error:t})},beforeInterrupted:function(){s.Z.info("Stream: segment request interrupted temporarly.",a.id,a.time)},onChunk:function(t){var n=e._initSegmentInfoRef.getValue();void 0!==n?c(t(null!=n?n:void 0)):(d=!0,e._initSegmentInfoRef.waitUntilDefined((function(e){c(t(null!=e?e:void 0))}),{clearSignal:r.signal}))},onAllChunksReceived:function(){d?(e._mediaSegmentAwaitingInitMetadata=a.id,e._initSegmentInfoRef.waitUntilDefined((function(){e._mediaSegmentAwaitingInitMetadata=null,d=!1,e.trigger("fullyLoadedSegment",a)}),{clearSignal:r.signal})):e.trigger("fullyLoadedSegment",a)},beforeEnded:function(){i(),e._mediaSegmentRequest=null,d?e._initSegmentInfoRef.waitUntilDefined(f,{clearSignal:r.signal}):f()}},r.signal);v.catch((function(t){i(),l||(l=!0,e.stop(),e.trigger("error",t))})),e._mediaSegmentRequest={segment:a,priority:o,request:v,canceller:r}}}(this._downloadQueue.getValue().segmentQueue[0])},r._restartInitSegmentDownloadingQueue=function(e){var t=this;if((null===this._currentCanceller||!this._currentCanceller.isUsed())&&(null!==this._initSegmentRequest&&this._initSegmentRequest.canceller.cancel(),null!==e)){var n=new T.ZP,r=null===this._currentCanceller?N.Z:n.linkToSignal(this._currentCanceller.signal),i=e.segment,a=e.priority,o=(0,b.Z)({segment:i},this._content),u=!1,l=this._segmentFetcher.createRequest(o,a,{onRetry:function(e){t.trigger("requestRetry",{segment:i,error:e})},beforeInterrupted:function(){s.Z.info("Stream: init segment request interrupted temporarly.",i.id)},beforeEnded:function(){r(),t._initSegmentRequest=null,u=!0},onChunk:function(e){var n,r=e(void 0);(0,h.Z)("init"===r.segmentType,"Should have loaded an init segment."),t.trigger("parsedInitSegment",(0,b.Z)({},r,{segment:i})),"init"===r.segmentType&&t._initSegmentInfoRef.setValue(null!==(n=r.initTimescale)&&void 0!==n?n:null)},onAllChunksReceived:function(){t.trigger("fullyLoadedSegment",i)}},n.signal);l.catch((function(e){r(),u||(u=!0,t.stop(),t.trigger("error",e))})),n.signal.register((function(){t._initSegmentRequest=null,u||(u=!0)})),this._initSegmentRequest={segment:i,priority:a,request:l,canceller:n}}},n}(g.Z);function Qe(e,t,n,r,i){var a=e.period,o=e.adaptation,u=e.representation,l=function(e,t){for(var n=0;n=t.end)return null;if(r.bufferedEnd>t.start)return n}return null}(i,t);if(null===l){if(null===n){if(r&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var d=u.index.checkDiscontinuity(t.start);if(null!==d)return{start:void 0,end:d}}return null}var c=i[l];if(void 0!==c.bufferedStart&&c.bufferedStart>t.start&&(null===n||c.infos.segment.end<=n)){var f=c.bufferedStart;return r||!1===u.index.awaitSegmentBetween(t.start,f)?(s.Z.debug("RS: current discontinuity encountered",o.type,c.bufferedStart),{start:void 0,end:f}):null}var v=function(e,t,n){if(n<=0)return s.Z.error("RS: Asked to check a discontinuity before the first chunk."),null;for(var r=n;r=t.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}(i,t,l+1);if(null!==v){var p=i[v-1],h=i[v];if(null===n||h.infos.segment.end<=n){if(!r&&!1!==u.index.awaitSegmentBetween(p.infos.segment.end,h.infos.segment.time))return null;var m=p.bufferedEnd,g=h.bufferedStart;return s.Z.debug("RS: future discontinuity encountered",o.type,m,g),{start:m,end:g}}}if(null===n){if(r&&void 0!==a.end){if(t.end=0;n--){var r=e[n];if(void 0===r.bufferedStart)return null;if(r.bufferedStart=a.end)return null;for(var b=i.length-1;b>=0;b--){var S=i[b];if(void 0===S.bufferedStart)break;if(S.bufferedStart=n.length-1?null:n[t+1],u=null;if(function(e,t,n){var r=l.Z.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedStart)return s.Z.warn("Stream: Start of a segment unknown. Assuming it is garbage collected by default.",e.start),!0;if(null!==t&&void 0!==t.bufferedEnd&&e.bufferedStart-t.bufferedEnd<.1)return!1;if(nr)return s.Z.info("Stream: The start of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,r,o.start)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.start;if(void 0!==t&&void 0!==a&&t-a>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.start;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(u=a(e.infos),e.bufferedStart))return!1;s.Z.debug("Stream: skipping segment gc-ed at the start",e.start,e.bufferedStart)}if(function(e,t,n){var r=l.Z.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedEnd)return s.Z.warn("Stream: End of a segment unknown. Assuming it is garbage collected by default.",e.end),!0;if(null!==t&&void 0!==t.bufferedStart&&t.bufferedStart-e.bufferedEnd<.1)return!1;if(n>e.bufferedEnd&&e.end-e.bufferedEnd>r)return s.Z.info("Stream: The end of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,i,o.end)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.end;if(void 0!==t&&void 0!==a&&a-t>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.end;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(u=null!=u?u:a(e.infos),e.bufferedEnd))return!1;s.Z.debug("Stream: skipping segment gc-ed at the end",e.end,e.bufferedEnd)}return!0})),m=l.Z.getCurrent(),g=m.MINIMUM_SEGMENT_SIZE,y=m.MIN_BUFFER_AHEAD,_=!1,S=Math.min(1/60,g),E=!1,T=[],k=p.filter((function(e){var t=(0,b.Z)({segment:e},n);if(u.length>0&&u.some((function(e){return(0,Re.z)(t,e)})))return!1;var l=e.duration,d=e.time,p=e.end;if(e.isInit)return!0;if(_)return T.push(e),!1;if(e.complete&&l0&&u.some((function(e){if(e.period.id!==n.period.id||e.adaptation.id!==n.adaptation.id)return!1;var a=e.segment;return!(a.time-S>d)&&(!(a.end+S-S&&w.end-p>-S)return!1}}var A=l*n.representation.bitrate;if(v-A<0&&(E=!0,d>o.start+y))return _=!0,T.push(e),!1;var I=a(t);if(I.length>1){var R=I[I.length-1],Z=I[I.length-2];if(null===R.buffered&&null===Z.buffered)return s.Z.warn("Stream: Segment GCed multiple times in a row, ignoring it.","If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering."+c.type,f.id,e.time),!1}for(var x=0;xd){var M=P.start>d+S||Je(h,x).ende[n].start;)n++;return e[--n]}function et(e,t,n,r){var i=l.Z.getCurrent().CONTENT_REPLACEMENT_PADDING;return e.period.id===t.period.id&&(!(e.segment.timea}return rr}(e.representation,t.representation,r)))}function tt(e,t){for(var n=e-t,r=l.Z.getCurrent().SEGMENT_PRIORITIES_STEPS,i=0;i=u&&l.isInitialized()&&l.isFinished()&&function(e,t,n){var r;return t.containsTime(n)&&e.isLastPeriodKnown&&t.id===(null===(r=e.periods[e.periods.length-1])||void 0===r?void 0:r.id)}(a,o,t)?u-1:t-.1;var d,c=i+n;d=!(!s.index.isInitialized()||!s.index.isFinished()||void 0===o.end)&&(void 0===u?c>=o.end:null===u||c>=u);return{start:Math.max(i,o.start),end:Math.min(c,null!==(r=o.end)&&void 0!==r?r:1/0),hasReachedPeriodEnd:d}}(e,u,i),c=s.index.shouldRefresh(d.start,d.end),f=o.getPendingOperations().filter((function(e){return e.type===Be.f.EndOfSegment})).map((function(e){return e.value})),v=function(e,t){for(var n=l.Z.getCurrent().MINIMUM_SEGMENT_SIZE,r=Math.max(1/60,n),i=e.start+r,a=e.end-r,o=[],s=t.length-1;s>=0;s--){var u=t[s],d=u.infos.representation;if(!u.partiallyPushed&&!1!==d.decipherable&&d.isSupported){var c=u.infos.segment,f=c.time/c.timescale;((c.complete?f+c.duration/c.timescale:u.end)>i&&fi&&u.start0&&(S=Math.min.apply(Math,f.map((function(e){return e.segment.time})))),m.length>0&&(S=null!==S?Math.min(S,m[0].time):m[0].time),y.length>0&&(S=null!==S?Math.min(S,y[0].segment.time):y[0].segment.time),{imminentDiscontinuity:Qe(e,d,S,b,v),hasFinishedLoading:b,neededSegments:y,isBufferFull:g,shouldRefreshManifest:c}}function rt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return it(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return it(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function it(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nl.end||e+ni.start&&o.push({start:i.start,end:e-n}),e+n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&R.every((function(e){return void 0!==e.keyIds}))&&(I=!0,t.encryptionDataEncountered(R.map((function(e){return(0,b.Z)({content:r},e)}))),_.isUsed()))return}var Z=new Xe(r,w,u,A);return Z.addEventListener("error",(function(e){S.signal.isCancelled()||(_.cancel(),t.error(e))})),Z.addEventListener("parsedInitSegment",P),Z.addEventListener("parsedMediaSegment",P),Z.addEventListener("emptyQueue",x),Z.addEventListener("requestRetry",(function(e){if(t.warning(e.error),!S.signal.isCancelled()){var n=e.segment,r=v.index;!1===r.isSegmentStillAvailable(n)?x():r.canBeOutOfSyncError(e.error,n)&&t.manifestMightBeOufOfSync()}})),Z.addEventListener("fullyLoadedSegment",(function(e){o.endOfSegment((0,b.Z)({segment:e},r),_.signal).catch(M)})),Z.start(),S.signal.register((function(){Z.removeEventListener(),Z.stop()})),a.listen(x,{includeLastObservation:!1,clearSignal:S.signal}),p.onUpdate(x,{emitCurrentValue:!1,clearSignal:S.signal}),h.onUpdate(x,{emitCurrentValue:!1,clearSignal:S.signal}),d.onUpdate(x,{emitCurrentValue:!1,clearSignal:S.signal}),void x();function x(){var e,n;if(!S.isUsed()){var i=a.getReference().getValue(),u=null!==(e=i.position.pending)&&void 0!==e?e:i.position.last,f=nt(r,u,a,g.getValue(),p.getValue(),h.getValue(),o),m=f.neededSegments,b=null;if(v.index.isInitialized()){if(m.length>0&&!k.isLoaded&&null!==k.segment){var E=m[0].priority;b={segment:k.segment,priority:E}}}else if(null===k.segment)s.Z.warn("Stream: Uninitialized index without an initialization segment");else if(k.isLoaded)s.Z.warn("Stream: Uninitialized index with an already loaded initialization segment");else{var T=null!==(n=i.position.pending)&&void 0!==n?n:i.position.last;b={segment:k.segment,priority:tt(c.start,T)}}var A=d.getValue();if(null===A)w.setValue({initSegment:b,segmentQueue:m});else{if(A.urgent)return s.Z.debug("Stream: Urgent switch, terminate now.",y),w.setValue({initSegment:null,segmentQueue:[]}),w.finish(),S.cancel(),void t.terminating();var I=m[0],R=Z.getRequestedInitSegment(),x=Z.getRequestedMediaSegment(),P=null===x||void 0===I||x.id!==I.segment.id?[]:[I],C=null===R?null:b;if(w.setValue({initSegment:C,segmentQueue:P}),0===P.length&&null===C)return s.Z.debug("Stream: No request left, terminate",y),w.finish(),S.cancel(),void t.terminating()}if(t.streamStatusUpdate({period:c,position:i.position.last,bufferType:y,imminentDiscontinuity:f.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:f.hasFinishedLoading,neededSegments:f.neededSegments}),!S.signal.isCancelled()){var D=l.Z.getCurrent().UPTO_CURRENT_POSITION_CLEANUP;if(f.isBufferFull){var N=Math.max(0,u-D);N>0&&o.removeBuffer(0,N,_.signal).catch(M)}f.shouldRefreshManifest&&t.needsManifestRefresh()}}}function P(e){if(!_.isUsed()){for(var n,i=ft(e.protectionData);!(n=i()).done;){var s=n.value;v.addProtectionData(s.initDataType,s.keyId,s.initData)}if(!I){var u=v.getAllEncryptionData();if(u.length>0&&(t.encryptionDataEncountered(u.map((function(e){return(0,b.Z)({content:r},e)}))),I=!0,_.isUsed()))return}if("init"===e.segmentType)return v.index.isInitialized()||void 0===e.segmentList||v.index.initialize(e.segmentList),k.segmentData=e.initializationData,k.isLoaded=!0,function(e,t){return dt.apply(this,arguments)}({playbackObserver:a,content:r,segment:e.segment,segmentData:e.initializationData,segmentBuffer:o},_.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(M),void x();var l=e.inbandEvents,d=e.predictedSegments,c=e.needsManifestRefresh;if(!(void 0!==d&&v.index.addPredictedSegments(d,e.segment),!0===c&&(t.needsManifestRefresh(),_.isUsed())||void 0!==l&&l.length>0&&(t.inbandEvent(l),_.isUsed()))){var f=k.segmentData;(function(e,t){return ct.apply(this,arguments)})({playbackObserver:a,content:r,initSegmentData:f,parsedSegment:e,segment:e.segment,segmentBuffer:o},_.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(M)}}}function M(e){_.isUsed()&&e instanceof T.FU||(_.cancel(),t.error(e))}};function ht(e,t){for(var n=0;n=t.start)return n>0?e[n-1]:null;return e.length>0?e[e.length-1]:null}function mt(e,t){for(var n=0;nt.start)return e[n];return null}function gt(e,t,n,r,i){if("lazy"===n.switchingMode)return{type:"continue",value:void 0};var a=r.getBufferedRanges();if(0===a.length)return{type:"continue",value:void 0};var o=(0,S.JN)(a),s=e.start,u=null==e.end?1/0:e.end,d=(0,S.tn)(o,[{start:s,end:u}]);if(0===d.length)return{type:"continue",value:void 0};r.synchronizeInventory();var c=r.getInventory(),f=function(e,t,n,r){return e.reduce((function(e,i){if(i.infos.period.id!==t.id||i.infos.adaptation.id!==n.id||!r.some((function(e){return e.id===i.infos.representation.id})))return e;var a=i.bufferedStart,o=i.bufferedEnd;return void 0===a||void 0===o||e.push({start:a,end:o}),e}),[])}(c,e,t,n.representations),v=(0,S.uH)(d,f);if(0===v.length)return{type:"continue",value:void 0};var p=i.getCurrentTime(),h=i.getReadyState();if("reload"===n.switchingMode&&(0,S.Ti)({start:s,end:u},p)&&h>1&&!(0,S.A1)(f,p))return{type:"needs-reload",value:void 0};var m="direct"===n.switchingMode,g=[],y=ht(c,e);if(null!==y&&(void 0===y.bufferedEnd||e.start-y.bufferedEnd<1)&&g.push({start:0,end:e.start+1}),!m){var _=l.Z.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,b=t.type,E=_[b].before;null==E&&(E=0);var T=_[b].after;null==T&&(T=0),g.push({start:p-E,end:p+T})}if(void 0!==e.end){var k=mt(c,e);null!==k&&(void 0===k.bufferedStart||k.bufferedStart-e.end<1)&&g.push({start:e.end-1,end:Number.MAX_VALUE})}var w=(0,S.uH)(v,g);return 0===w.length?{type:"continue",value:void 0}:m?{type:"flush-buffer",value:w}:{type:"clean-buffer",value:w}}function yt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _t(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _t(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1||!n.getPlayableRepresentations().some((function(t){var n;return Et(t.getMimeTypeString(),null!==(n=e.codec)&&void 0!==n?n:"")})))&&!(0,S.A1)(v,h))return{type:"needs-reload",value:void 0};var m="direct"===r,g=[],y=ht(f,t);null!==y&&(void 0===y.bufferedEnd||t.start-y.bufferedEnd<1)&&g.push({start:0,end:t.start+1});var _=n.type,b=l.Z.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,E=b[_].before;null==E&&(E=0);var T=b[_].after;if(null==T&&(T=0),m||g.push({start:h-E,end:h+T}),void 0!==t.end){var k=mt(f,t);null!==k&&(void 0===k.bufferedStart||k.bufferedStart-t.end<1)&&g.push({start:t.end-1,end:Number.MAX_VALUE})}var w=(0,S.uH)(p,g);return 0===w.length?{type:"continue",value:void 0}:m&&"text"!==n.type?{type:"flush-buffer",value:w}:{type:"clean-buffer",value:w}}function kt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function wt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=o.end&&(s.Z.debug('Stream: full "empty" AdaptationStream',n),u=!0),i.streamStatusUpdate({period:o,bufferType:n,position:l,imminentDiscontinuity:null,isEmptyStream:!0,hasFinishedLoading:u,neededSegments:[]})}t.onUpdate(l,{emitCurrentValue:!1,clearSignal:a}),e.listen(l,{includeLastObservation:!1,clearSignal:a}),l()}var Rt=function(e,t,n){var r=e.bufferType,i=e.content,a=e.garbageCollectors,o=e.playbackObserver,u=e.representationEstimator,c=e.segmentFetcherCreator,f=e.segmentBuffersStore,v=e.options,p=e.wantedBufferAhead,h=e.maxVideoBufferSize,m=i.manifest,g=i.period,y=(0,E.ZP)(void 0,n);if(t.periodStreamReady({type:r,manifest:m,period:g,adaptationRef:y}),!n.isCancelled()){var _,k=!0;y.onUpdate((function(e){(0,w.Z)(I().mark((function i(){var u,d,c,h,m,y,b,S,E,w,Z,x,P,M,C,D,N,O;return I().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==e){i.next=2;break}return i.abrupt("return");case 2:if((d=new T.ZP).linkToSignal(n),null==_||_.cancel(),_=d,null!==e){i.next=34;break}if(s.Z.info("Stream: Set no "+r+" Adaptation. P:",g.start),"initialized"!==(c=f.getStatus(r)).type){i.next=26;break}if(s.Z.info("Stream: Clearing previous "+r+" SegmentBuffer"),!Ke.isNative(r)){i.next=15;break}return i.abrupt("return",R(0,d.signal));case 15:if(h=null!==(u=g.end)&&void 0!==u?u:1/0,!(g.start>h)){i.next=20;break}s.Z.warn("Stream: Can't free buffer: period's start is after its end"),i.next=24;break;case 20:return i.next=22,c.value.removeBuffer(g.start,h,d.signal);case 22:if(!d.isUsed()){i.next=24;break}return i.abrupt("return");case 24:i.next=30;break;case 26:if("uninitialized"!==c.type){i.next=30;break}if(f.disableSegmentBuffer(r),!d.isUsed()){i.next=30;break}return i.abrupt("return");case 30:if(t.adaptationChange({type:r,adaptation:null,period:g}),!d.isUsed()){i.next=33;break}return i.abrupt("return");case 33:return i.abrupt("return",It(o,p,r,{period:g},t,d.signal));case 34:if(m=l.Z.getCurrent(),y=m.DELTA_POSITION_AFTER_RELOAD,b=k?0:"audio"===r?y.trackSwitch.audio:"video"===r?y.trackSwitch.video:y.trackSwitch.other,k=!1,!Ke.isNative(r)||"disabled"!==f.getStatus(r).type){i.next=39;break}return i.abrupt("return",R(b,d.signal));case 39:if(S=e.adaptation,E=e.representations,s.Z.info("Stream: Updating "+r+" adaptation","A: "+S.id,"P: "+g.start),t.adaptationChange({type:r,adaptation:S,period:g}),!d.isUsed()){i.next=44;break}return i.abrupt("return");case 44:if(w=o.getReadyState(),Z=At(f,r,S,v),x={currentTime:o.getCurrentTime(),readyState:w},"needs-reload"!==(P=Tt(Z,g,S,e.switchingMode,x,v)).type){i.next=50;break}return i.abrupt("return",R(b,d.signal));case 50:return i.next=52,f.waitForUsableBuffers(d.signal);case 52:if(!d.isUsed()){i.next=54;break}return i.abrupt("return");case 54:if("flush-buffer"!==P.type&&"clean-buffer"!==P.type){i.next=68;break}M=kt(P.value);case 56:if((C=M()).done){i.next=64;break}return D=C.value,N=D.start,O=D.end,i.next=60,Z.removeBuffer(N,O,d.signal);case 60:if(!d.isUsed()){i.next=62;break}return i.abrupt("return");case 62:i.next=56;break;case 64:if("flush-buffer"!==P.type){i.next=68;break}if(t.needsBufferFlush(),!d.isUsed()){i.next=68;break}return i.abrupt("return");case 68:a.get(Z)(d.signal),A(S,E,Z,d.signal);case 70:case"end":return i.stop()}}),i)})))().catch((function(e){e instanceof T.FU||(null==_||_.cancel(),t.error(e))}))}),{clearSignal:n,emitCurrentValue:!0})}function A(e,n,i,a){var l=function(e,t){return e.deriveReadOnlyObserver((function(e,n){var r=(0,E.ZP)(i(),n);return e.onUpdate(a,{clearSignal:n,emitCurrentValue:!1}),r;function i(){var n=e.getValue(),r=t.getBufferedRanges(),i=(0,S.L7)(r,n.position.last);return(0,b.Z)({},n,{bufferGap:i})}function a(){r.setValue(i())}}))}(o,i);bt({content:{manifest:m,period:g,adaptation:e,representations:n},options:v,playbackObserver:l,representationEstimator:u,segmentBuffer:i,segmentFetcherCreator:c,wantedBufferAhead:p,maxVideoBufferSize:h},Object.assign(Object.assign({},t),{error:function(e){if(!Ke.isNative(r)){s.Z.error("Stream: "+r+" Stream crashed. Aborting it.",e instanceof Error?e:""),f.disposeSegmentBuffer(r);var n=(0,d.Z)(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"});if(t.warning(n),a.isCancelled())return;return It(o,p,r,{period:g},t,a)}s.Z.error("Stream: "+r+" Stream crashed. Stopping playback.",e instanceof Error?e:""),t.error(e)}}),a)}function R(e,n){We()((function(){o.listen((function(n){var i,a,s=o.getCurrentTime()+e,u=Math.min(Math.max(g.start,s),null!==(i=g.end)&&void 0!==i?i:1/0),l=!(null!==(a=n.paused.pending)&&void 0!==a?a:o.getIsPaused());t.waitingMediaSourceReload({bufferType:r,period:g,position:u,autoPlay:l})}),{includeLastObservation:!0,clearSignal:n})}))}};function Zt(e,t){if(0===t.length)return[];e.synchronizeInventory();for(var n=[],r=e.getInventory(),i=function(){var i=r[a];if(t.some((function(e){return i.infos.period.id===e.period.id&&i.infos.adaptation.id===e.adaptation.id&&i.infos.representation.id===e.representation.id}))){var o=i.bufferedStart,u=i.bufferedEnd;if(void 0===o||void 0===u){s.Z.warn("SO: No buffered start or end found from a segment.");var l=e.getBufferedRanges(),d=l.length;return 0===d?{v:[]}:{v:[{start:l.start(0),end:l.end(d-1)}]}}var c=n[n.length-1];void 0!==c&&c.end===o?c.end=u:n.push({start:o,end:u})}},a=0;a=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0?t[t.length-1].end>=n-5:t[0].start<=n+5}var Ct=function(e,t,n,r,i,a,o,u){for(var d,f=e.manifest,v=e.initialPeriod,p=a.maxBufferAhead,h=a.maxBufferBehind,m=a.wantedBufferAhead,g=a.maxVideoBufferSize,y=l.Z.getCurrent(),_=y.MAXIMUM_MAX_BUFFER_AHEAD,b=y.MAXIMUM_MAX_BUFFER_BEHIND,S=new He((function(e){var n=e.bufferType,r=null!=b[n]?b[n]:1/0,i=null!=_[n]?_[n]:1/0;return function(n){qe({segmentBuffer:e,playbackObserver:t,maxBufferBehind:(0,E.lR)(h,(function(e){return Math.min(e,r)}),n),maxBufferAhead:(0,E.lR)(p,(function(e){return Math.min(e,i)}),n)},n)}})),k=xt(r.getBufferTypes());!(d=k()).done;){A(d.value,v)}function A(e,n){var i=new je((function(e,t){return e.start-t.start})),a=!1,l=new T.ZP;return l.linkToSignal(u),t.listen((function(t){var n,r,c=t.position,v=null!==(n=c.pending)&&void 0!==n?n:c.last;if(a&&function(e){var t=i.head(),n=i.last();if(null==t||null==n)return!0;return t.start>e||(null==n.end?1/0:n.end)0;){var p=i.get(i.length()-1);i.removeElement(p),o.periodStreamCleared({type:e,manifest:f,period:p})}l.cancel(),(l=new T.ZP).linkToSignal(u);var h=null!==(r=f.getPeriodForTime(v))&&void 0!==r?r:f.getNextPeriod(v);void 0!==h?d(h):s.Z.warn("Stream: The wanted position is not found in the Manifest.")}}),{clearSignal:u,includeLastObservation:!0}),f.addEventListener("decipherabilityUpdate",(function(e){(function(e){return v.apply(this,arguments)})(e).catch((function(e){l.cancel(),o.error(e)}))}),u),d(n);function d(t){var n=Object.assign(Object.assign({},o),{waitingMediaSourceReload:function(e){var t=i.head();if(void 0===t||t.id!==e.period.id)o.lockedStream({bufferType:e.bufferType,period:e.period});else{var n=e.position,r=e.autoPlay;o.needsMediaSourceReload({position:n,autoPlay:r})}},periodStreamReady:function(e){a=!0,i.add(e.period),o.periodStreamReady(e)},periodStreamCleared:function(e){i.removeElement(e.period),o.periodStreamCleared(e)},error:function(e){l.cancel(),o.error(e)}});R(e,t,n,l.signal)}function v(){return v=(0,w.Z)(I().mark((function n(v){var p,h,m,g,y,_,b,S,E,k,w,A,R;return I().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(p=r.getStatus(e),0!==(h=v.filter((function(t){return t.adaptation.type===e}))).length&&"initialized"===p.type&&!h.every((function(e){return!0===e.representation.decipherable}))){n.next=4;break}return n.abrupt("return");case 4:for(m=p.value,g=h.filter((function(e){return void 0===e.representation.decipherable})),y=h.filter((function(e){return!1===e.representation.decipherable})),_=Zt(m,y),b=Zt(m,g),a=!1,s.Z.info("Stream: Destroying all PeriodStreams for decipherability matters",e);i.length()>0;)S=i.get(i.length()-1),i.removeElement(S),o.periodStreamCleared({type:e,manifest:f,period:S});l.cancel(),(l=new T.ZP).linkToSignal(u),E=0,k=[].concat(_,b);case 16:if(!(E=o.end&&(s.Z.info("Stream: Destroying PeriodStream as the current playhead moved above it",e,o.start,null!==(i=a.pending)&&void 0!==i?i:a.last,o.end),n(),u.periodStreamCleared({type:e,manifest:f,period:o}),c.cancel())}),{clearSignal:l,includeLastObservation:!0});var v={bufferType:e,content:{manifest:f,period:o},garbageCollectors:S,maxVideoBufferSize:g,segmentFetcherCreator:i,segmentBuffersStore:r,options:a,playbackObserver:t,representationEstimator:n,wantedBufferAhead:m},p=Object.assign(Object.assign({},u),{streamStatusUpdate:function(t){if(t.hasFinishedLoading){var n=f.getPeriodAfter(o);null!==n&&function(t){if(null!==d){if(d.period.id===t.id)return;s.Z.warn("Stream: Creating next `PeriodStream` while one was already created.",e,t.id,d.period.id),u.periodStreamCleared({type:e,manifest:f,period:d.period}),d.canceller.cancel()}var n=new T.ZP;n.linkToSignal(l),d={canceller:n,period:t},R(e,t,u,d.canceller.signal)}(n)}else null!==d&&(s.Z.info("Stream: Destroying next PeriodStream due to current one being active",e,d.period.start),u.periodStreamCleared({type:e,manifest:f,period:d.period}),d.canceller.cancel(),d=null);u.streamStatusUpdate(t)},error:function(e){null!==d&&(d.canceller.cancel(),d=null),c.cancel(),u.error(e)}});Rt(v,p,c.signal)}},Dt=Ct,Nt=n(379);function Ot(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Lt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);na.getMaximumAvailablePosition()){var u=new c.Z("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest.");i.trigger("warning",u)}}),{includeLastObservation:!0,clearSignal:o}),t.addEventListener("manifestUpdate",(function(){i.trigger("durationUpdate",i._getManifestDuration()),o.isCancelled()||i._checkEndOfStream()}),o),i}(0,t.Z)(n,e);var r=n.prototype;return r.getCurrentDuration=function(){return this._getManifestDuration()},r.onAdaptationChange=function(e,t,n){if(this._manifest.isLastPeriodKnown){var r=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(null==r?void 0:r.id)&&("audio"===e||"video"===e)){"audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(n):this._maximumPositionCalculator.updateLastVideoAdaptation(n);var i=this._maximumPositionCalculator.getEndingPosition(),a=void 0!==i?{isEnd:!0,duration:i}:{isEnd:!1,duration:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger("durationUpdate",a)}}this._canceller.isUsed()||null===n&&this._addActivelyLoadedPeriod(t,e)},r.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},r.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},r.onLastSegmentFinishedLoading=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},r.onLastSegmentLoadingResume=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},r.dispose=function(){this.removeEventListener(),this._canceller.cancel()},r._addActivelyLoadedPeriod=function(e,t){var n=this._lazilyCreateActiveStreamInfo(t);n.activePeriods.has(e)||(n.activePeriods.add(e),this._checkCurrentPeriod())},r._removeActivelyLoadedPeriod=function(e,t){var n=this._activeStreams.get(t);void 0!==n&&n.activePeriods.has(e)&&(n.activePeriods.removeElement(e),this._checkCurrentPeriod())},r._checkCurrentPeriod=function(){var e=this;if(0!==this._allBufferTypes.length){var t=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==t)for(var n,r=function(){for(var t=n.value,r=!0,i=1;i=0;a--){var o=i[a];try{"open"===r&&(s.Z.info("Init: Removing SourceBuffer from mediaSource"),o.abort()),t.removeSourceBuffer(o)}catch(e){s.Z.warn("Init: Error while disposing SourceBuffer",e instanceof Error?e:"")}}i.length>0&&s.Z.warn("Init: Not all SourceBuffers could have been removed.")}if((0,zt.Z)(e),null!==n)try{s.Z.debug("Init: Revoking previous URL"),URL.revokeObjectURL(n)}catch(e){s.Z.warn("Init: Error while revoking the media source URL",e instanceof Error?e:"")}}function jt(e,t){return(0,D.Z)(t,(function(n){var r=function(e,t){if(null==Kt.J)throw new c.Z("MEDIA_SOURCE_NOT_SUPPORTED","No MediaSource Object was found in the current browser.");var n=(0,Gt.Z)(e.src)?e.src:null;Wt(e,null,n),s.Z.info("Init: Creating MediaSource");var r=new Kt.J,i=URL.createObjectURL(r);return s.Z.info("Init: Attaching MediaSource URL to the media element",i),e.src=i,t.register((function(){Wt(e,r,i)})),r}(e,t);i.u_(r,(function(){n(r)}),t)}))}function Ht(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return qt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function qt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0?r:Math.max(i,r+d)}if(!(0,_.Z)(n.percentage)){s.Z.debug("Init: using startAt.percentage");var c=n.percentage;return c>100?r:c<0?i:i+(r-i)*(+c/100)}}var f=e.getMinimumSafePosition();if(e.isLive){var v,p=e.suggestedPresentationDelay,h=e.clockOffset,m=e.getMaximumSafePosition(),g=l.Z.getCurrent().DEFAULT_LIVE_GAP;if(void 0===h)s.Z.info("Init: no clock offset found for a live content, starting close to maximum available position"),v=m;else{s.Z.info("Init: clock offset found for a live content, checking if we can start close to it");var y=void 0===e.availabilityStartTime?0:e.availabilityStartTime,b=(performance.now()+h)/1e3-y;v=Math.min(m,b)}var S=void 0!==p?p:t?g.LOW_LATENCY:g.DEFAULT;return s.Z.debug("Init: "+v+" defined as the live time, applying a live gap of "+S),Math.max(v-S,f)}return s.Z.info("Init: starting at the minimum available position:",f),f}var en=n(1757),tn=n(8833),nn=n(8799);var rn=31536e3,an=function(){function e(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}var t=e.prototype;return t.updateDuration=function(e,t){null!==this._currentMediaSourceDurationUpdateCanceller&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new T.ZP;var n=this._mediaSource,r=this._currentMediaSourceDurationUpdateCanceller.signal,a=function(e,t){var n=(0,E.ZP)("open"===e.readyState,t);return(0,i.u_)(e,(function(){n.setValueIfChanged(!0)}),t),(0,i.N8)(e,(function(){n.setValueIfChanged(!1)}),t),(0,i.k6)(e,(function(){n.setValueIfChanged(!1)}),t),n}(n,r),o=new T.ZP;o.linkToSignal(r),a.onUpdate((function(){if(o.cancel(),!a.getValue())return;(o=new T.ZP).linkToSignal(r);var i=function(e,t){if(0===e.length){var n=(0,E.ZP)(!1);return n.finish(),n}var r=(0,E.ZP)(!1,t);o();for(var i=function(){var n=e[a];n.addEventListener("updatestart",o),n.addEventListener("update",o),t.register((function(){n.removeEventListener("updatestart",o),n.removeEventListener("update",o)}))},a=0;a0&&(i=Math.max(u.buffered.end(l-1)))}if(r===e.duration)return"success";if(i>r){if(i=.1?c=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nl||void 0!==h&&l>=h)&&(pn(v)&&c.push(v.publicEvent),o.delete(v)):p<=l&&void 0!==h&&l=(null!=h?h:p)&&(u?d.push({type:"stream-event-skip",value:v.publicEvent}):(d.push({type:"stream-event",value:v.publicEvent}),pn(v)&&c.push(v.publicEvent)))}if(d.length>0)for(var m,g=fn(d);!(m=g()).done;){var y=m.value;if("stream-event"===y.type?r(y.value):i(y.value),a.isCancelled())return}if(c.length>0)for(var _,b=fn(c);!(_=b()).done;){var S=_.value;if("function"==typeof S.onExit&&S.onExit(),a.isCancelled())return}}(s.getValue(),c,e,d.signal),c=e}function h(){var e=n.getReference().getValue().seeking;return{currentTime:t.currentTime,isSeeking:e}}}),{emitCurrentValue:!0,clearSignal:a})},mn=n(4576);function gn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nd.end&&(n=d.end-1)}}else n=s;return{maximumPosition:e.getMaximumSafePosition(),position:{last:u.position,pending:n},duration:u.duration,paused:{last:u.paused,pending:i.getValue()||!r===u.paused?void 0:!r},readyState:u.readyState,speed:l}}function d(){u.setValue(l())}}))}(u,v,{autoPlay:a,initialPlayPerformed:k,initialSeekPerformed:w,speed:g,startTime:s}),I=this._createRebufferingController(v,u,g,n),R=this._createContentTimeBoundariesObserver(u,f,A,b,n);T.then((function(){(0,en.Z)(v,d,!1,n).onUpdate((function(e,t){e&&(t(),i.trigger("loaded",{segmentBuffersStore:b}))}),{emitCurrentValue:!0,clearSignal:n})})).catch((function(e){n.isCancelled()||i._onFatalError(e)}));var Z=this;Dt({manifest:u,initialPeriod:y},A,h,b,m,o,{needsBufferFlush:function(){var e=d.currentTime+.001;v.setCurrentTime(e),v.listen((function(t,n){(null!==t.currentRange||t.position>e+.1)&&(n(),v.setCurrentTime(t.position+.001))}),{includeLastObservation:!1,clearSignal:n})},streamStatusUpdate:function(e){var t=e.period,r=e.bufferType,i=e.imminentDiscontinuity,a=e.position;I.updateDiscontinuityInfo({period:t,bufferType:r,discontinuity:i,position:a}),n.isCancelled()||u.isLastPeriodKnown&&e.period.id===u.periods[u.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?R.onLastSegmentFinishedLoading(e.bufferType):R.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return Z._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=l.Z.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;Z._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return I.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){Z.trigger("adaptationChange",e),n.isCancelled()||R.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){Z.trigger("representationChange",e),n.isCancelled()||R.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return Z.trigger("inbandEvents",e)},warning:function(e){return Z.trigger("warning",e)},periodStreamReady:function(e){return Z.trigger("periodStreamReady",e)},periodStreamCleared:function(e){R.onPeriodCleared(e.type,e.period),n.isCancelled()||Z.trigger("periodStreamCleared",e)},bitrateEstimationChange:function(e){return Z.trigger("bitrateEstimationChange",e)},addedSegment:function(e){return Z.trigger("addedSegment",e)},needsMediaSourceReload:function(e){return t(e)},needsDecipherabilityFlush:function(e){var n,r=M(d);void 0===(n=null==r?void 0:r[0])||n.indexOf("widevine")<0?t(e):e.position+.001=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Sn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(i="internal-seeking",r=t._internalSeeksIncoming.shift());var a=null!=e?e:t._generateInitialObservation(),o=wn(t._mediaElement,i,t._withMediaSource),u=null;o.seeking&&("number"==typeof r?u=r:null!==a.pendingInternalSeek&&"seeking"!==n&&(u=a.pendingInternalSeek));var d=function(e,t,n){var r,i,a=n.withMediaSource,o=n.lowLatencyMode,s=l.Z.getCurrent().REBUFFERING_GAP,u=t.event,d=t.position,c=t.bufferGap,f=t.currentRange,v=t.duration,p=t.paused,h=t.readyState,m=t.ended,g=e.rebuffering,y=e.event,_=e.position,b=function(e,t,n,r,i){var a=l.Z.getCurrent().REBUFFERING_GAP,o=i?"LOW_LATENCY":"DEFAULT";if(void 0===t)return n&&Math.abs(r-e)<=a[o];return null!==t&&r-t.end<=a[o]}(d,f,m,v,o),S=h>=1&&"loadedmetadata"!==u&&null===g&&!(b||m),E=null,T=o?s.LOW_LATENCY:s.DEFAULT;if(a){if(S)c===1/0?(r=!0,E=d):void 0===c?h<3&&(r=!0,E=void 0):c<=T&&(r=!0,E=d+c);else if(null!==g){var k=kn(g,o);!0!==r&&null!==g&&h>1&&(b||m||void 0!==c&&isFinite(c)&&c>k)||void 0===c&&h>=3?i=!0:void 0===c?E=void 0:c===1/0?E=d:c<=k&&(E=d+c)}}else S&&(!p&&"timeupdate"===u&&"timeupdate"===y&&d===_||"seeking"===u&&(c===1/0||void 0===c&&h<3))?r=!0:null!==g&&("seeking"!==u&&d!==_||"canplay"===u||void 0===c&&h>=3||void 0!==c&&c<1/0&&(c>kn(g,o)||b||m))&&(i=!0);if(!0===i)return null;var w;if(!0===r||null!==g)return w="seeking"===u||null!==g&&"seeking"===g.reason||t.seeking?"seeking":1===h?"not-ready":"buffering",null!==g&&g.reason===w?{reason:g.reason,timestamp:g.timestamp,position:E}:{reason:w,timestamp:performance.now(),position:E};return null}(a,o,{lowLatencyMode:t._lowLatencyMode,withMediaSource:t._withMediaSource}),c=function(e,t){var n=l.Z.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position!==t.position?null:e.freezing;return"timeupdate"===t.event&&void 0!==t.bufferGap&&t.bufferGap>n&&!t.ended&&!t.paused&&t.readyState>=1&&0!==t.playbackRate&&t.position===e.position?{timestamp:performance.now()}:null}(a,o),f=(0,b.Z)({},{rebuffering:d,freezing:c,pendingInternalSeek:u},o);return s.Z.hasLevel("DEBUG")&&s.Z.debug("API: current media element state tick","event",f.event,"position",f.position,"seeking",f.seeking,"internalSeek",f.pendingInternalSeek,"rebuffering",null!==f.rebuffering,"freezing",null!==f.freezing,"ended",f.ended,"paused",f.paused,"playbackRate",f.playbackRate,"readyState",f.readyState),f},u=(0,E.ZP)(o("init"),this._canceller.signal),d=function(t){var n=o(t);s.Z.hasLevel("DEBUG")&&s.Z.debug("API: current playback timeline:\n"+function(e,t){for(var n="",r="",i=0;it){var d=n.length-Math.floor(l.length/2);r=" ".repeat(d)+"^"+t}if(i=3?(r=void 0,i=void 0):i=null!==(r=(0,S.rx)(a,o))?r.end-o:1/0,{bufferGap:i,buffered:a,currentRange:r,position:o,duration:s,ended:u,paused:l,playbackRate:d,readyState:c,seeking:f,event:t}}function An(e,t,n){var r=t(e.getReference(),n);return{getCurrentTime:function(){return e.getCurrentTime()},getReadyState:function(){return e.getReadyState()},getPlaybackRate:function(){return e.getPlaybackRate()},getIsPaused:function(){return e.getIsPaused()},getReference:function(){return r},listen:function(e,t){var i;n.isCancelled()||!0===(null===(i=null==t?void 0:t.clearSignal)||void 0===i?void 0:i.isCancelled())||r.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},deriveReadOnlyObserver:function(e){return An(this,e,n)}}}var In=function(e){function n(t,n,r){var i;if((i=e.call(this)||this)._canceller=new T.ZP,i._manifest=t,i._adaptationRef=n,null===r)return i._lastEmitted=r,n.setValue(null),(0,Ne.Z)(i);var a=i._constructLockedRepresentationsReference(r);return i._lastEmitted={adaptation:r.adaptation,switchingMode:r.switchingMode,lockedRepresentations:null},n.setValue({adaptation:r.adaptation,switchingMode:r.switchingMode,representations:a}),i}(0,t.Z)(n,e);var r=n.prototype;return r.updateTrack=function(e){if(null===e){if(null===this._lastEmitted)return;return this._canceller.cancel(),this._canceller=new T.ZP,this._lastEmitted=null,void this._adaptationRef.setValue(null)}var t=e.adaptation,n=e.switchingMode;this._canceller.cancel(),this._canceller=new T.ZP;var r=this._constructLockedRepresentationsReference(e);this._lastEmitted={adaptation:t,switchingMode:n,lockedRepresentations:null},this._adaptationRef.setValue({adaptation:t,switchingMode:n,representations:r})},r._constructLockedRepresentationsReference=function(e){var t=this._manifest,n=(0,E.ZP)({representations:[],switchingMode:"lazy"}),r=this;return t.addEventListener("decipherabilityUpdate",i),t.addEventListener("manifestUpdate",i),this._canceller.signal.register((function(){t.removeEventListener("decipherabilityUpdate",i),t.removeEventListener("manifestUpdate",i)})),e.lockedRepresentations.onUpdate(i,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),i(),n;function i(){var t,i,a=e.lockedRepresentations.getValue();if(null===a)i=e.adaptation.getPlayableRepresentations(),t="lazy";else{var o=a.representations;if(t=a.switchingMode,0===(i=o.filter((function(e){return e.isPlayable()}))).length)return void r.trigger("noPlayableLockedRepresentation",null)}if(i.length<=0){var s=e.adaptation.type;throw new c.Z("NO_PLAYABLE_REPRESENTATION","No Representation in the chosen "+s+" Adaptation can be played",{adaptation:e.adaptation})}var u=n.getValue(),l=i.slice().sort();if(l.length===u.representations.length){for(var d=0;d=e;f--)i._storedPeriodInfo[f].inManifest=!1,xn(i._storedPeriodInfo[f])&&i._removePeriodObject(f);else if(l===c){u++;var v=i._storedPeriodInfo[e].text.storedSettings;if(null!==v)if(!c.getSupportedAdaptations("text").some((function(e){return e.id===v.adaptation.id}))){s.Z.warn("TracksStore: Chosen text Adaptation not available anymore");var p=i._storedPeriodInfo[e];if(p.text.storedSettings=null,i.trigger("autoTrackSwitch",{period:Cn(c),trackType:"text",reason:"missing"}),i._isDisposed)return{v:void 0};var h=Zn(i._storedPeriodInfo,p.period.id);void 0!==h&&null===h.text.storedSettings&&(null===(t=h.text.dispatcher)||void 0===t||t.updateTrack(null))}var m=i._storedPeriodInfo[e].video.storedSettings;if(null!==m){var g=c.getSupportedAdaptations("video");if(!g.some((function(e){return e.id===m.adaptation.id}))){s.Z.warn("TracksStore: Chosen video Adaptation not available anymore");var y,_=i._storedPeriodInfo[e];if(0===g.length)y=null;else{var b=g[0];y={adaptationBase:b,adaptation:Pn(b,i._isTrickModeTrackEnabled),switchingMode:"seamless",lockedRepresentations:(0,E.ZP)(null)}}if(_.video.storedSettings=y,i.trigger("autoTrackSwitch",{period:Cn(c),trackType:"video",reason:"missing"}),i._isDisposed)return{v:void 0};var S=Zn(i._storedPeriodInfo,_.period.id);void 0!==S&&S.video.storedSettings===y&&(null===(n=S.video.dispatcher)||void 0===n||n.updateTrack(y))}}var T=i._storedPeriodInfo[e].audio.storedSettings;if(null!==T){var k=c.getSupportedAdaptations("audio");if(!k.some((function(e){return e.id===T.adaptation.id}))){s.Z.warn("TracksStore: Chosen audio Adaptation not available anymore");var w=i._storedPeriodInfo[e],A=0===k.length?null:{adaptation:k[0],switchingMode:"seamless",lockedRepresentations:(0,E.ZP)(null)};if(w.audio.storedSettings=A,i.trigger("autoTrackSwitch",{period:Cn(c),trackType:"audio",reason:"missing"}),i._isDisposed)return{v:void 0};var I=Zn(i._storedPeriodInfo,w.period.id);void 0!==I&&I.audio.storedSettings===A&&(null===(r=I.audio.dispatcher)||void 0===r||r.updateTrack(A))}}}else if(l.start<=c.start)i._storedPeriodInfo[e].inManifest=!1,xn(i._storedPeriodInfo[e])&&(i._removePeriodObject(e),e--);else{var R=Mn(c,!0,i._isTrickModeTrackEnabled);i._storedPeriodInfo.splice(e,0,R),o.push(R),u++}d=e},d=0;d0&&this.trigger("newAvailablePeriods",p)},r.addTrackReference=function(e,t,n,r){var i=this,a=Zn(this._storedPeriodInfo,n.id);if(void 0===a&&(a=this._manuallyAddPeriod(n),this.trigger("newAvailablePeriods",[{id:n.id,start:n.start,end:n.end}])),null===a[e].dispatcher){var o=a[e].storedSettings,u=new In(t,r,o);a[e].dispatcher=u,u.addEventListener("noPlayableLockedRepresentation",(function(){null==o||o.lockedRepresentations.setValue(null),i.trigger("brokenRepresentationsLock",{period:{id:n.id,start:n.start,end:n.end},trackType:e})}))}else s.Z.error("TracksStore: Subject already added for "+e+" and Period "+n.start)},r.removeTrackReference=function(e,t){var n=function(e,t){for(var n=0;n=0;r--){var i=this._storedPeriodInfo[r];null===(e=i.audio.dispatcher)||void 0===e||e.dispose(),i.audio.dispatcher=null,null===(t=i.video.dispatcher)||void 0===t||t.dispose(),i.video.dispatcher=null,null===(n=i.text.dispatcher)||void 0===n||n.dispose(),i.text.dispatcher=null,i.inManifest||this._removePeriodObject(r)}},r.isTrickModeEnabled=function(){return this._isTrickModeTrackEnabled},r.setAudioTrack=function(e,t,n,r){var i=l.Z.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE;return this._setAudioOrTextTrack("audio",e,t,null!=n?n:i,r)},r.setTextTrack=function(e,t){return this._setAudioOrTextTrack("text",e,t,"direct",null)},r._setAudioOrTextTrack=function(e,t,n,r,i){var a=t.period,o=(0,F.Z)(a.getSupportedAdaptations(e),(function(e){return e.id===n}));if(void 0===o)throw new Error("Wanted "+e+" track not found.");var s,u=t[e];if(null===i)s=(0,E.ZP)(null);else{var d=l.Z.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE,c=this._getRepresentationsToLock(o,i),f="audio"===e?d:"direct";s=(0,E.ZP)({representations:c,switchingMode:f})}u.storedSettings={adaptation:o,switchingMode:r,lockedRepresentations:s},null!==u.dispatcher&&u.dispatcher.updateTrack(u.storedSettings)},r.setVideoTrack=function(e,t,n,r){var i=e.period,a=(0,F.Z)(i.getSupportedAdaptations("video"),(function(e){return e.id===t}));if(void 0===a)throw new Error("Wanted video track not found.");var o,s=l.Z.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,u=e.video,d=Pn(a,this._isTrickModeTrackEnabled);if(null===r)o=(0,E.ZP)(null);else{var c=this._getRepresentationsToLock(a,r),f=s;o=(0,E.ZP)({representations:c,switchingMode:f})}u.storedSettings={adaptationBase:a,switchingMode:null!=n?n:s,adaptation:d,lockedRepresentations:o},null!==u.dispatcher&&u.dispatcher.updateTrack(u.storedSettings)},r.disableTrack=function(e,t){var n,r=e[t];null!==r.storedSettings&&("text"!==t&&(null===(n=e[t].storedSettings)||void 0===n||n.lockedRepresentations.finish()),r.storedSettings=null,null!==r.dispatcher&&r.dispatcher.updateTrack(null))},r.getChosenAudioTrack=function(e){return null===e.audio.storedSettings?null:e.audio.storedSettings.adaptation.toAudioTrack(!0)},r.getChosenTextTrack=function(e){return null===e.text.storedSettings?null:e.text.storedSettings.adaptation.toTextTrack()},r.getChosenVideoTrack=function(e){return null===e.video.storedSettings?null:e.video.storedSettings.adaptation.toVideoTrack(!0)},r.getAvailableAudioTracks=function(e){var t=e.audio.storedSettings,n=null!==t?t.adaptation.id:null;return e.period.getSupportedAdaptations("audio").map((function(e){var t=null!==n&&n===e.id;return(0,b.Z)(e.toAudioTrack(!0),{active:t})}))},r.getAvailableTextTracks=function(e){var t=e.text.storedSettings,n=null!==t?t.adaptation.id:null;return e.period.getSupportedAdaptations("text").map((function(e){var t=null!==n&&n===e.id;return(0,b.Z)(e.toTextTrack(),{active:t})}))},r.getAvailableVideoTracks=function(e){var t=e.video.storedSettings,n=null===t?void 0:t.adaptation.id;return e.period.getSupportedAdaptations("video").map((function(e){var t=null!==n&&n===e.id,r=e.toVideoTrack(!0),i=void 0!==r.trickModeTracks?r.trickModeTracks.map((function(e){var t=null!==n&&n===e.id;return(0,b.Z)(e,{active:t})})):[],a=(0,b.Z)(r,{active:t});return void 0!==i&&(a.trickModeTracks=i),a}))},r.getLockedAudioRepresentations=function(e){var t=e.audio.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representations.map((function(e){return e.id}))},r.getLockedVideoRepresentations=function(e){var t=e.video.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representations.map((function(e){return e.id}))},r.lockAudioRepresentations=function(e,t){var n,r=e.audio.storedSettings;if(null!==r){var i=l.Z.getCurrent().DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representations:a,switchingMode:o})}},r.lockVideoRepresentations=function(e,t){var n,r=e.video.storedSettings;if(null!==r){var i=l.Z.getCurrent().DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representations:a,switchingMode:o})}},r.unlockAudioRepresentations=function(e){var t=e.audio.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.unlockVideoRepresentations=function(e){var t=e.video.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.dispose=function(){for(this._isDisposed=!0;;){var e=this._storedPeriodInfo.pop();if(void 0===e)return;e.isRemoved=!0}},r._manuallyAddPeriod=function(e){for(var t=Mn(e,!1,this._isTrickModeTrackEnabled),n=0;ne.start)return this._storedPeriodInfo.splice(n,0,t),t;return this._storedPeriodInfo.push(t),t},r._resetVideoTrackChoices=function(){for(var e=0;e0){if(null!=i){var h=(0,F.Z)(p,(function(e){return e.normalizedLanguage===i.normalizedLanguage}));void 0!==h&&(v=h)}null===v&&(v=null!==(r=(0,F.Z)(p,(function(e){return void 0===e.normalizedLanguage})))&&void 0!==r?r:null)}var m=null;return null!==v&&(m={adaptation:v,switchingMode:"direct",lockedRepresentations:(0,E.ZP)(null)}),{period:e,inManifest:t,isRemoved:!1,audio:{storedSettings:c,dispatcher:null},video:{storedSettings:f,dispatcher:null},text:{storedSettings:m,dispatcher:null}}}function Cn(e){return{start:e.start,end:e.end,id:e.id}}function Dn(e,t){var n=l.Z.getCurrent().FORCED_ENDED_THRESHOLD;if(e.ended)return"ENDED";if(null!==t){var r=Math.abs(e.duration-e.currentTime);return null!=n&&r=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ln(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nf)throw new Error('Invalid maxVideoBitrate parameter. Its value, "'+f+'", is inferior to the set minVideoBitrate, "'+d+'"')}if((0,_.Z)(e.maxAudioBitrate))c=g.audio;else{if(c=Number(e.maxAudioBitrate),isNaN(c))throw new Error("Invalid maxAudioBitrate parameter. Should be a number.");if(u>c)throw new Error('Invalid maxAudioBitrate parameter. Its value, "'+c+'", is inferior to the set minAudioBitrate, "'+u+'"')}return{maxBufferAhead:t,maxBufferBehind:n,limitVideoWidth:k,videoElement:a,wantedBufferAhead:r,maxVideoBufferSize:i,throttleVideoBitrateWhenHidden:w,initialAudioBitrate:s,initialVideoBitrate:o,minAudioBitrate:u,minVideoBitrate:d,maxAudioBitrate:c,maxVideoBitrate:f}}(e),i=r.initialAudioBitrate,a=r.initialVideoBitrate,o=r.limitVideoWidth,u=r.minAudioBitrate,d=r.minVideoBitrate,c=r.maxAudioBitrate,f=r.maxBufferAhead,v=r.maxBufferBehind,p=r.maxVideoBitrate,h=r.throttleVideoBitrateWhenHidden,m=r.videoElement,g=r.wantedBufferAhead,y=r.maxVideoBufferSize,b=l.Z.getCurrent().DEFAULT_UNMUTED_VOLUME;m.preload="auto",t.version="3.31.0",t.log=s.Z,t.state="STOPPED",t.videoElement=m;var S=new T.ZP;return t._destroyCanceller=S,t._priv_pictureInPictureRef=Bn(m,S.signal),t._priv_speed=(0,E.ZP)(m.playbackRate,t._destroyCanceller.signal),t._priv_preferTrickModeTracks=!1,t._priv_contentLock=(0,E.ZP)(!1,t._destroyCanceller.signal),t._priv_bufferOptions={wantedBufferAhead:(0,E.ZP)(g,t._destroyCanceller.signal),maxBufferAhead:(0,E.ZP)(f,t._destroyCanceller.signal),maxBufferBehind:(0,E.ZP)(v,t._destroyCanceller.signal),maxVideoBufferSize:(0,E.ZP)(y,t._destroyCanceller.signal)},t._priv_bitrateInfos={lastBitrates:{audio:i,video:a},minAutoBitrates:{audio:(0,E.ZP)(u,t._destroyCanceller.signal),video:(0,E.ZP)(d,t._destroyCanceller.signal)},maxAutoBitrates:{audio:(0,E.ZP)(c,t._destroyCanceller.signal),video:(0,E.ZP)(p,t._destroyCanceller.signal)},manualBitrates:{audio:(0,E.ZP)(-1,t._destroyCanceller.signal),video:(0,E.ZP)(-1,t._destroyCanceller.signal)}},t._priv_throttleVideoBitrateWhenHidden=h,t._priv_limitVideoWidth=o,t._priv_mutedMemory=b,t._priv_currentError=null,t._priv_contentInfos=null,t._priv_contentEventsMemory={},t._priv_setPlayerState("STOPPED"),t._priv_reloadingMetadata={},t._priv_lastAutoPlay=!1,t}(0,t.Z)(r,n);var i=r.prototype;return i.addEventListener=function(e,t){return n.prototype.addEventListener.call(this,e,t)},i.stop=function(){null!==this._priv_contentInfos&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),"STOPPED"!==this.state&&this._priv_setPlayerState("STOPPED")},i.dispose=function(){this.stop(),null!==this.videoElement&&x(this.videoElement).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";s.Z.error("API: Could not dispose decryption resources: "+t)})),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null},i.loadVideo=function(e){var t=function(e){var t,n,r,i,a,o,u,d,c,f,v,h,m,g=l.Z.getCurrent(),y=g.DEFAULT_AUTO_PLAY,S=g.DEFAULT_CODEC_SWITCHING_BEHAVIOR,E=g.DEFAULT_ENABLE_FAST_SWITCHING,T=g.DEFAULT_MANUAL_BITRATE_SWITCHING_MODE,w=g.DEFAULT_TEXT_TRACK_MODE;if((0,_.Z)(e))throw new Error("No option set on loadVideo");if((0,_.Z)(e.url)){if((0,_.Z)(null===(t=e.transportOptions)||void 0===t?void 0:t.initialManifest)&&(0,_.Z)(null===(n=e.transportOptions)||void 0===n?void 0:n.manifestLoader))throw new Error("Unable to load a content: no url set on loadVideo.\nPlease provide at least either an `url` argument, a `transportOptions.initialManifest` option or a `transportOptions.manifestLoader` option so the RxPlayer can load the content.")}else d=String(e.url);if((0,_.Z)(e.transport))throw new Error("No transport set on loadVideo");c=String(e.transport);var A=(0,_.Z)(e.autoPlay)?y:!!e.autoPlay;if((0,_.Z)(e.keySystems))f=[];else for(var I,R=bn(f=Array.isArray(e.keySystems)?e.keySystems:[e.keySystems]);!(I=R()).done;){var Z=I.value;if("string"!=typeof Z.type||"function"!=typeof Z.getLicense)throw new Error("Invalid key system given: Missing type string or getLicense callback");(0,_.Z)(Z.onKeyStatusesChange)||(0,k.Z)("`keySystems[].onKeyStatusesChange` is deprecated and won't be present in the next major version. Please open an issue if you still need this."),(0,_.Z)(Z.throwOnLicenseExpiration)||(0,k.Z)("`keySystems[].throwOnLicenseExpiration` is deprecated and won't be present in the next major version. Please open an issue if you still need this.")}var x=void 0!==e.lowLatencyMode&&!!e.lowLatencyMode,P="object"==typeof e.transportOptions&&null!==e.transportOptions?e.transportOptions:{},M=null===(r=e.transportOptions)||void 0===r?void 0:r.initialManifest,C=null!==(a=null===(i=e.transportOptions)||void 0===i?void 0:i.minimumManifestUpdateInterval)&&void 0!==a?a:0,D=(0,_.Z)(e.onCodecSwitch)?S:e.onCodecSwitch;(0,p.Z)(["continue","reload"],D)||(s.Z.warn("The `onCodecSwitch` loadVideo option must match one of the following string:\n- `continue`\n- `reload`\nIf badly set, "+S+" will be used as default"),D=S);var N=(0,b.Z)({},P,{lowLatencyMode:x});if(delete N.initialManifest,delete N.minimumManifestUpdateInterval,(0,_.Z)(e.textTrackMode))v=w;else{if("native"!==e.textTrackMode&&"html"!==e.textTrackMode)throw new Error("Invalid textTrackMode.");v=e.textTrackMode}var O=null!==(o=e.manualBitrateSwitchingMode)&&void 0!==o?o:T,L=(0,_.Z)(e.enableFastSwitching)?E:e.enableFastSwitching;if("html"===v){if((0,_.Z)(e.textTrackElement))throw new Error('You have to provide a textTrackElement in "html" textTrackMode.');if(!(e.textTrackElement instanceof HTMLElement))throw new Error("textTrackElement should be an HTMLElement.");h=e.textTrackElement}else(0,_.Z)(e.textTrackElement)||s.Z.warn('API: You have set a textTrackElement without being in an "html" textTrackMode. It will be ignored.');if(!(0,_.Z)(e.startAt))if(e.startAt.wallClockTime instanceof Date){var U=e.startAt.wallClockTime.getTime()/1e3;m=(0,b.Z)({},e.startAt,{wallClockTime:U})}else m=e.startAt;return{autoPlay:A,enableFastSwitching:L,keySystems:f,initialManifest:M,lowLatencyMode:x,manualBitrateSwitchingMode:O,minimumManifestUpdateInterval:C,networkConfig:null!==(u=e.networkConfig)&&void 0!==u?u:{},onCodecSwitch:D,startAt:m,textTrackElement:h,textTrackMode:v,transport:c,transportOptions:N,url:d}}(e);s.Z.info("API: Calling loadvideo",t.url,t.transport),this._priv_reloadingMetadata={options:t},this._priv_initializeContentPlayback(t),this._priv_lastAutoPlay=t.autoPlay},i.reload=function(e){var t,n,r,i,a=this._priv_reloadingMetadata,o=a.options,s=a.manifest,u=a.reloadPosition,l=a.reloadInPause;if(void 0===o)throw new Error("API: Can't reload without having previously loaded a content.");if(function(e){var t,n,r,i;if(null===e||"object"!=typeof e&&void 0!==e)throw new Error("API: reload - Invalid options format.");if(null===(null==e?void 0:e.reloadAt)||"object"!=typeof(null==e?void 0:e.reloadAt)&&void 0!==(null==e?void 0:e.reloadAt))throw new Error("API: reload - Invalid 'reloadAt' option format.");if("number"!=typeof(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position)&&void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.position))throw new Error("API: reload - Invalid 'reloadAt.position' option format.");if("number"!=typeof(null===(r=null==e?void 0:e.reloadAt)||void 0===r?void 0:r.relative)&&void 0!==(null===(i=null==e?void 0:e.reloadAt)||void 0===i?void 0:i.relative))throw new Error("API: reload - Invalid 'reloadAt.relative' option format.")}(e),void 0!==(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position))r={position:e.reloadAt.position};else if(void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.relative)){if(void 0===u)throw new Error("Can't reload to a relative position when previous content was not loaded.");r={position:e.reloadAt.relative+u}}else void 0!==u&&(r={position:u});void 0!==(null==e?void 0:e.autoPlay)?i=e.autoPlay:void 0!==l&&(i=!l);var d=Object.assign(Object.assign({},o),{initialManifest:s});void 0!==r&&(d.startAt=r),void 0!==i&&(d.autoPlay=i),this._priv_initializeContentPlayback(d)},i.createDebugElement=function(e){if(null===v.Z.createDebugElement)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");var t=new T.ZP;return v.Z.createDebugElement(e,this,t.signal),{dispose:function(){t.cancel()}}},i._priv_initializeContentPlayback=function(e){var t=this,n=e.autoPlay,r=e.enableFastSwitching,i=e.initialManifest,a=e.keySystems,o=e.lowLatencyMode,l=e.manualBitrateSwitchingMode,c=e.minimumManifestUpdateInterval,f=e.networkConfig,h=e.onCodecSwitch,m=e.startAt,g=e.transport,y=e.transportOptions,_=e.url;if(null===this.videoElement)throw new Error("the attached video element is disposed");var S,k="directfile"===g,w=new T.ZP,A=this.videoElement,I=null;if(k){if(null===v.Z.directfile)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(I=this._priv_initializeMediaElementTracksStore(w.signal),w.isUsed())return;S=new v.Z.directfile.initDirectFile({autoPlay:n,keySystems:a,speed:this._priv_speed,startAt:m,url:_})}else{var R=v.Z.transports[g];if("function"!=typeof R)throw this.stop(),this._priv_currentError=null,new Error('transport "'+g+'" not supported');var Z=R(y),x=f.offlineRetry,P=f.segmentRetry,M=f.manifestRetry,C=f.manifestRequestTimeout,D=f.segmentRequestTimeout,N={lowLatencyMode:o,maxRetryRegular:M,maxRetryOffline:x,requestTimeout:C,minimumManifestUpdateInterval:c,initialManifest:i},O=u(),L={throttleBitrate:{},limitWidth:{}};this._priv_throttleVideoBitrateWhenHidden&&(O?L.throttleBitrate={video:(0,E.lR)(Fn(this._priv_pictureInPictureRef,w.signal),(function(e){return e?1/0:0}),w.signal)}:s.Z.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),this._priv_limitVideoWidth&&(O?L.limitWidth={video:Vn(A,this._priv_pictureInPictureRef,w.signal)}:s.Z.warn("API: Can't apply limitVideoWidth because browser can't be trusted for video size."));var U={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:o,manualBitrates:this._priv_bitrateInfos.manualBitrates,minAutoBitrates:this._priv_bitrateInfos.minAutoBitrates,maxAutoBitrates:this._priv_bitrateInfos.maxAutoBitrates,throttlers:L},B="native"===e.textTrackMode?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},F=(0,b.Z)({enableFastSwitching:r,manualBitrateSwitchingMode:l,onCodecSwitch:h},this._priv_bufferOptions);S=new _n({adaptiveOptions:U,autoPlay:n,bufferOptions:F,keySystems:a,lowLatencyMode:o,manifestRequestSettings:N,transport:Z,segmentRequestOptions:{lowLatencyMode:o,maxRetryRegular:P,requestTimeout:D,maxRetryOffline:x},speed:this._priv_speed,startAt:m,textTrackOptions:B,url:_})}var V={contentId:Un(),originalUrl:_,currentContentCanceller:w,initializer:S,isDirectFile:k,segmentBuffersStore:null,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:I};S.addEventListener("error",(function(e){var n=(0,d.Z)(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});n.fatal=!0,V.currentContentCanceller.cancel(),t._priv_cleanUpCurrentContentState(),t._priv_currentError=n,s.Z.error("API: The player stopped because of an error",e instanceof Error?e:""),t._priv_setPlayerState("STOPPED"),t._priv_currentError===n&&t.trigger("error",n)})),S.addEventListener("warning",(function(e){var n=(0,d.Z)(e,{defaultCode:"NONE",defaultReason:"An unknown error happened."});s.Z.warn("API: Sending warning:",n),t.trigger("warning",n)})),S.addEventListener("reloadingMediaSource",(function(e){V.segmentBuffersStore=null,null!==V.tracksStore&&V.tracksStore.resetPeriodObjects(),t._priv_lastAutoPlay=e.autoPlay})),S.addEventListener("inbandEvents",(function(e){return t.trigger("inbandEvents",e)})),S.addEventListener("streamEvent",(function(e){return t.trigger("streamEvent",e)})),S.addEventListener("streamEventSkip",(function(e){return t.trigger("streamEventSkip",e)})),S.addEventListener("decipherabilityUpdate",(function(e){return t.trigger("decipherabilityUpdate",e.map((function(e){return{periodInfo:{start:e.period.start,end:e.period.end,id:e.period.id},trackType:e.adaptation.type,trackId:e.adaptation.id,representationId:e.representation.id,isDecipherable:e.representation.decipherable}})))})),S.addEventListener("activePeriodChanged",(function(e){return t._priv_onActivePeriodChanged(V,e)})),S.addEventListener("periodStreamReady",(function(e){return t._priv_onPeriodStreamReady(V,e)})),S.addEventListener("periodStreamCleared",(function(e){return t._priv_onPeriodStreamCleared(V,e)})),S.addEventListener("representationChange",(function(e){return t._priv_onRepresentationChange(V,e)})),S.addEventListener("adaptationChange",(function(e){return t._priv_onAdaptationChange(V,e)})),S.addEventListener("bitrateEstimationChange",(function(e){return t._priv_onBitrateEstimationChange(e)})),S.addEventListener("manifestReady",(function(e){return t._priv_onManifestReady(V,e)})),S.addEventListener("loaded",(function(e){V.segmentBuffersStore=e.segmentBuffersStore})),S.prepare(),this.stop();var z=new Tn(A,{withMediaSource:!k,lowLatencyMode:o});w.signal.register((function(){z.stop()}));var K=function(e,t,n,r){var i=(0,E.ZP)("LOADING",r);e.addEventListener("loaded",(function(){if("LOADING"===i.getValue()){if(i.setValue("LOADED"),!r.isCancelled()){var e=Dn(t,null);"PAUSED"!==e&&i.setValue(e)}}else i.setValueIfChanged(Dn(t,null))}),r),e.addEventListener("reloadingMediaSource",(function(){Nn(i.getValue())&&i.setValueIfChanged("RELOADING")}),r);var a=null;return e.addEventListener("stalled",(function(e){e!==a&&(Nn(i.getValue())&&i.setValueIfChanged(Dn(t,e)),a=e)}),r),e.addEventListener("unstalled",(function(){null!==a&&(Nn(i.getValue())&&i.setValueIfChanged(Dn(t,null)),a=null)}),r),n.listen((function(e){Nn(i.getValue())&&(0,p.Z)(["seeking","ended","play","pause"],e.event)&&i.setValueIfChanged(Dn(t,a))}),{clearSignal:r}),i}(S,A,z,w.signal);w.signal.register((function(){S.dispose()}));var G=function(e){switch(e){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":t._priv_reloadingMetadata.reloadInPause=!0,t._priv_reloadingMetadata.reloadPosition=z.getReference().getValue().position;break;default:var n=z.getReference().getValue();t._priv_reloadingMetadata.reloadInPause=n.paused,t._priv_reloadingMetadata.reloadPosition=n.position}},W=null,j=function(e){null!==W&&(W.cancel(),W=null),K.onUpdate((function(n,r){var i,a,o,s;Nn(n)&&(r(),null!==W&&W.cancel(),(W=new T.ZP).linkToSignal(w.signal),e!==!A.paused&&(A.paused?t.trigger("pause",null):t.trigger("play",null)),i=A,a=function(){return t.trigger("play",null)},o=function(){return t.trigger("pause",null)},(s=w.signal).isCancelled()||null===i||(i.addEventListener("play",a),i.addEventListener("pause",o),s.register((function(){i.removeEventListener("play",a),i.removeEventListener("pause",o)}))))}),{emitCurrentValue:!1,clearSignal:w.signal})};j(n),S.addEventListener("reloadingMediaSource",(function(e){j(e.autoPlay)}));var H=null;K.onUpdate((function(e){G(e),t._priv_setPlayerState(e),w.isUsed()||(null!==H?Nn(t.state)||(H.cancel(),H=null):Nn(t.state)&&((H=new T.ZP).linkToSignal(w.signal),function(e,t,n,r,i){if(!i.isCancelled()&&null!==e){var a=t.getReference().getValue().seeking;a&&(n(),i.isCancelled())||t.listen((function(e){"seeking"===e.event?(a=!0,n()):a&&"seeked"===e.event&&(a=!1,r())}),{includeLastObservation:!0,clearSignal:i})}}(A,z,(function(){return t.trigger("seeking",null)}),(function(){return t.trigger("seeked",null)}),H.signal)))}),{emitCurrentValue:!0,clearSignal:w.signal}),z.listen((function(e){G(t.state),t._priv_triggerPositionUpdate(V,e)}),{clearSignal:w.signal}),this._priv_currentError=null,this._priv_contentInfos=V,w.signal.register((function(){S.removeEventListener()})),this._priv_contentLock.onUpdate((function(e,t){e||(t(),S.start(A,z))}),{emitCurrentValue:!0,clearSignal:w.signal})},i.getError=function(){return this._priv_currentError},i.getVideoElement=function(){return this.videoElement},i.getPlayerState=function(){return this.state},i.isContentLoaded=function(){return!(0,p.Z)(["LOADING","RELOADING","STOPPED"],this.state)},i.isBuffering=function(){return(0,p.Z)(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)},i.isPaused=function(){return!this.videoElement||((0,p.Z)(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused)},i.isLive=function(){if(null===this._priv_contentInfos)return!1;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return!t&&null!==n&&n.isLive},i.areTrickModeTracksEnabled=function(){return this._priv_preferTrickModeTracks},i.getUrl=function(){if(null!==this._priv_contentInfos){var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest,r=e.originalUrl;return t?r:null!==n?n.getUrl():void 0}},i.updateContentUrls=function(e,t){if(null===this._priv_contentInfos)throw new Error("No content loaded");var n=!0===(null==t?void 0:t.refresh);this._priv_contentInfos.initializer.updateContentUrls(e,n)},i.getMediaDuration=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration},i.getCurrentBufferGap=function(){if(null===this.videoElement)throw new Error("Disposed player");var e=this.videoElement;return(0,S.L7)(e.buffered,e.currentTime)},i.getWallClockTime=function(){if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)return this.videoElement.currentTime;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){var r=a(this.videoElement);return(null!=r?r:0)+this.videoElement.currentTime}return null!==n?this.videoElement.currentTime+(void 0!==n.availabilityStartTime?n.availabilityStartTime:0):0},i.getPosition=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.currentTime},i.getLastStoredContentPosition=function(){return this._priv_reloadingMetadata.reloadPosition},i.getPlaybackRate=function(){return this._priv_speed.getValue()},i.setPlaybackRate=function(e,t){var n;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);var r=null==t?void 0:t.preferTrickModeTracks;if("boolean"==typeof r){this._priv_preferTrickModeTracks=r;var i=null===(n=this._priv_contentInfos)||void 0===n?void 0:n.tracksStore;(0,_.Z)(i)||(r&&!i.isTrickModeEnabled()?i.enableVideoTrickModeTracks():!r&&i.isTrickModeEnabled()&&i.disableVideoTrickModeTracks())}},i.getVideoBitrate=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e&&!(0,_.Z)(e.video))return e.video.bitrate},i.getAudioBitrate=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e&&!(0,_.Z)(e.audio))return e.audio.bitrate},i.getMinVideoBitrate=function(){return this._priv_bitrateInfos.minAutoBitrates.video.getValue()},i.getMinAudioBitrate=function(){return this._priv_bitrateInfos.minAutoBitrates.audio.getValue()},i.getMaxVideoBitrate=function(){return this._priv_bitrateInfos.maxAutoBitrates.video.getValue()},i.getMaxAudioBitrate=function(){return this._priv_bitrateInfos.maxAutoBitrates.audio.getValue()},i.play=function(){var e=this;if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement.play();return(0,_.Z)(t)||"function"!=typeof t.catch?Promise.resolve():t.catch((function(t){if("NotAllowedError"===t.name){var n=new c.Z("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());e.trigger("warning",n)}throw t}))},i.pause=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.pause()},i.seekTo=function(e){var t;if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)throw new Error("player: no content loaded");var n,r=this._priv_contentInfos,i=r.isDirectFile,o=r.manifest;if(!i&&null===o)throw new Error("player: the content did not load yet");if("number"==typeof e)n=e;else if("object"==typeof e){var u=e,l=this.videoElement.currentTime;if((0,_.Z)(u.relative))if((0,_.Z)(u.position)){if((0,_.Z)(u.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(null!==o)n=u.wallClockTime-(null!==(t=o.availabilityStartTime)&&void 0!==t?t:0);else if(i&&null!==this.videoElement){var d=a(this.videoElement);void 0!==d&&(n=u.wallClockTime-d)}void 0===n&&(n=u.wallClockTime)}else n=u.position;else n=l+u.relative}if(void 0===n)throw new Error("invalid time given");return s.Z.info("API: API Seek to",n),this.videoElement.currentTime=n,n},i.getVolume=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.volume},i.setVolume=function(e){if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement;e!==t.volume&&(t.volume=e,this.trigger("volumeChange",e))},i.isMute=function(){return 0===this.getVolume()},i.mute=function(){this._priv_mutedMemory=this.getVolume(),this.setVolume(0)},i.unMute=function(){var e=l.Z.getCurrent().DEFAULT_UNMUTED_VOLUME;0===this.getVolume()&&this.setVolume(0===this._priv_mutedMemory?e:this._priv_mutedMemory)},i.setMinVideoBitrate=function(e){var t=this._priv_bitrateInfos.maxAutoBitrates.video.getValue();if(e>t)throw new Error('Invalid minimum video bitrate given. Its value, "'+e+'" is superior the current maximum video birate, "'+t+'".');this._priv_bitrateInfos.minAutoBitrates.video.setValue(e)},i.setMinAudioBitrate=function(e){var t=this._priv_bitrateInfos.maxAutoBitrates.audio.getValue();if(e>t)throw new Error('Invalid minimum audio bitrate given. Its value, "'+e+'" is superior the current maximum audio birate, "'+t+'".');this._priv_bitrateInfos.minAutoBitrates.audio.setValue(e)},i.setMaxVideoBitrate=function(e){var t=this._priv_bitrateInfos.minAutoBitrates.video.getValue();if(e0||f.result.removedAdaptations.length>0)){var v=l.getPeriodObjectFromPeriod(u);if(void 0===v)return;var p=l.getAvailableAudioTracks(v);r._priv_triggerEventIfNotStopped("availableAudioTracksChange",null!=p?p:[],i);var h=l.getAvailableTextTracks(v);r._priv_triggerEventIfNotStopped("availableTextTracksChange",null!=h?h:[],i);var m=l.getAvailableVideoTracks(v);r._priv_triggerEventIfNotStopped("availableVideoTracksChange",null!=m?m:[],i)}return}}),e.currentContentCanceller.signal)}},i._priv_onActivePeriodChanged=function(e,t){var n,r,i,a,o,s,u=t.period;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.currentPeriod=u;var l=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==u&&(this._priv_contentEventsMemory.periodChange=u,this._priv_triggerEventIfNotStopped("periodChange",{start:u.start,end:u.end,id:u.id},l)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),l),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),l),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),l);var d=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.tracksStore;if((0,_.Z)(d))this._priv_triggerEventIfNotStopped("audioTrackChange",null,l),this._priv_triggerEventIfNotStopped("textTrackChange",null,l),this._priv_triggerEventIfNotStopped("videoTrackChange",null,l);else{var c=d.getPeriodObjectFromPeriod(u);if(c){var f=d.getChosenAudioTrack(c);this._priv_triggerEventIfNotStopped("audioTrackChange",f,l);var v=d.getChosenTextTrack(c);this._priv_triggerEventIfNotStopped("textTrackChange",v,l);var p=d.getChosenVideoTrack(c);this._priv_triggerEventIfNotStopped("videoTrackChange",p,l)}}var h=null!==(a=null===(i=this.__priv_getCurrentRepresentations())||void 0===i?void 0:i.audio)&&void 0!==a?a:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",h,l);var m=null!==(s=null===(o=this.__priv_getCurrentRepresentations())||void 0===o?void 0:o.video)&&void 0!==s?s:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",m,l)}},i._priv_onPeriodStreamReady=function(e,t){var n;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var r=t.type,i=t.manifest,a=t.period,o=t.adaptationRef,u=e.tracksStore;switch(r){case"video":case"audio":case"text":(0,_.Z)(u)?(s.Z.error("API: TracksStore not instanciated for a new "+r+" period"),o.setValue(null)):u.addTrackReference(r,i,a,o);break;default:(0,m.Z)(r)}}},i._priv_onPeriodStreamCleared=function(e,t){var n;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var r=t.type,i=t.period,a=e.tracksStore;switch(r){case"audio":case"text":case"video":(0,_.Z)(a)||a.removeTrackReference(r,i)}var o=e.activeAdaptations,s=e.activeRepresentations;if(!(0,_.Z)(o)&&!(0,_.Z)(o[i.id])){var u=o[i.id];delete u[r],0===Object.keys(u).length&&delete o[i.id]}if(!(0,_.Z)(s)&&!(0,_.Z)(s[i.id])){var l=s[i.id];delete l[r],0===Object.keys(l).length&&delete s[i.id]}}},i._priv_onAdaptationChange=function(e,t){var n,r=t.type,i=t.adaptation,a=t.period;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){null===e.activeAdaptations&&(e.activeAdaptations={});var o,s=e.activeAdaptations,u=e.currentPeriod,l=s[a.id];if((0,_.Z)(l))s[a.id]=((o={})[r]=i,o);else l[r]=i;var d=e.tracksStore,c=e.currentContentCanceller.signal;if(null!==d&&null!==u&&!(0,_.Z)(a)&&a.id===u.id){var f=d.getPeriodObjectFromPeriod(a);if(void 0===f)return;switch(r){case"audio":var v=d.getChosenAudioTrack(f);this._priv_triggerEventIfNotStopped("audioTrackChange",v,c);break;case"text":var p=d.getChosenTextTrack(f);this._priv_triggerEventIfNotStopped("textTrackChange",p,c);break;case"video":var h=d.getChosenVideoTrack(f);this._priv_triggerEventIfNotStopped("videoTrackChange",h,c)}}}},i._priv_onRepresentationChange=function(e,t){var n,r=t.type,i=t.period,a=t.representation;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){null===e.activeRepresentations&&(e.activeRepresentations={});var o,s=e.activeRepresentations,u=e.currentPeriod,l=s[i.id];if((0,_.Z)(l))s[i.id]=((o={})[r]=a,o);else l[r]=a;if(!(0,_.Z)(i)&&null!==u&&u.id===i.id){var d=this._priv_contentInfos.currentContentCanceller.signal;"video"===r?this._priv_triggerEventIfNotStopped("videoRepresentationChange",a,d):"audio"===r&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",a,d)}}},i._priv_onBitrateEstimationChange=function(e){var t=e.type,n=e.bitrate;void 0!==n&&(this._priv_bitrateInfos.lastBitrates[t]=n),this.trigger("bitrateEstimationChange",{type:t,bitrate:n})},i._priv_setPlayerState=function(e){this.state!==e&&(this.state=e,s.Z.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))},i._priv_triggerPositionUpdate=function(e,t){var n,r;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var i=e.isDirectFile,o=e.manifest;if((i||null!==o)&&!(0,_.Z)(t)){var s=null!==o?o.getMaximumSafePosition():void 0,u={position:t.position,duration:t.duration,playbackRate:t.playbackRate,maximumPosition:s,bufferGap:void 0!==t.bufferGap&&isFinite(t.bufferGap)?t.bufferGap:0};if(null!==o&&o.isLive&&t.position>0){var l=null!==(r=o.availabilityStartTime)&&void 0!==r?r:0;u.wallClockTime=t.position+l;var d=o.getLivePosition();void 0!==d&&(u.liveGap=d-t.position)}else if(i&&null!==this.videoElement){var c=a(this.videoElement);void 0!==c&&(u.wallClockTime=c+t.position)}this.trigger("positionUpdate",u)}}},i._priv_triggerEventIfNotStopped=function(e,t,n){n.isCancelled()||this.trigger(e,t)},i._priv_initializeMediaElementTracksStore=function(e){var t,n,r,i=this;(0,h.Z)(null!==v.Z.directfile,"Initializing `MediaElementTracksStore` without Directfile feature"),(0,h.Z)(null!==this.videoElement,"Initializing `MediaElementTracksStore` on a disposed RxPlayer");var a=new v.Z.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",a.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",a.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",a.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",null!==(t=a.getChosenAudioTrack())&&void 0!==t?t:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",null!==(n=a.getChosenTextTrack())&&void 0!==n?n:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",null!==(r=a.getChosenVideoTrack())&&void 0!==r?r:null,e),a.addEventListener("availableVideoTracksChange",(function(e){return i.trigger("availableVideoTracksChange",e)})),a.addEventListener("availableAudioTracksChange",(function(e){return i.trigger("availableAudioTracksChange",e)})),a.addEventListener("availableTextTracksChange",(function(e){return i.trigger("availableTextTracksChange",e)})),a.addEventListener("audioTrackChange",(function(e){return i.trigger("audioTrackChange",e)})),a.addEventListener("videoTrackChange",(function(e){return i.trigger("videoTrackChange",e)})),a.addEventListener("textTrackChange",(function(e){return i.trigger("textTrackChange",e)})),a},i._priv_callTracksStoreGetterSetter=function(e,t,n){var r,i;if(null===this._priv_contentInfos||null===this._priv_contentInfos.tracksStore)return s.Z.warn("API: Trying to call track API too soon"),t;var a=this._priv_contentInfos.tracksStore,o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,u=null!=e?e:null==o?void 0:o.id;if(void 0===u)return t;var l=u===(null==o?void 0:o.id)?a.getPeriodObjectFromPeriod(o):a.getPeriodObjectFromId(u);return void 0===l?t:n(a,l)},(0,e.Z)(r,null,[{key:"ErrorTypes",get:function(){return f.ZB}},{key:"ErrorCodes",get:function(){return f.SM}},{key:"LogLevel",get:function(){return s.Z.getLevel()},set:function(e){s.Z.setLevel(e)}}]),r}(g.Z);zn.version="3.31.0";var Kn=zn,Gn=n(7273);!function(){Gn.Z.ContentDecryptor=n(1266).ZP,Gn.Z.transports.smooth=n(5418).Z,Gn.Z.transports.dash=n(2047).Z,Gn.Z.dashParsers.js=n(8337).Z,Gn.Z.nativeTextTracksBuffer=n(9059).Z,Gn.Z.nativeTextTracksParsers.vtt=n(9405).Z,Gn.Z.nativeTextTracksParsers.ttml=n(1570).Z,Gn.Z.nativeTextTracksParsers.sami=n(1812).Z,Gn.Z.nativeTextTracksParsers.srt=n(8057).Z,Gn.Z.htmlTextTracksBuffer=n(5192).Z,Gn.Z.htmlTextTracksParsers.sami=n(5734).Z,Gn.Z.htmlTextTracksParsers.ttml=n(7439).Z,Gn.Z.htmlTextTracksParsers.srt=n(8675).Z,Gn.Z.htmlTextTracksParsers.vtt=n(4099).Z;var e=n(9372).Z,t=n(1932).Z;Gn.Z.directfile={initDirectFile:e,mediaElementTracksStore:t}}(),"boolean"==typeof __RX_PLAYER_DEBUG_MODE__&&__RX_PLAYER_DEBUG_MODE__&&s.Z.setLevel("DEBUG");var Wn=Kn}(),r=r.default}()})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RxPlayer=t():e.RxPlayer=t()}(self,(function(){return function(){var e={3774:function(e,t,n){"use strict";n.d(t,{J:function(){return a},c:function(){return o}});var r=n(1946),i=n(2203).Z?void 0:window,a=void 0===i?void 0:(0,r.Z)(i.MediaSource)?(0,r.Z)(i.MozMediaSource)?(0,r.Z)(i.WebKitMediaSource)?i.MSMediaSource:i.WebKitMediaSource:i.MozMediaSource:i.MediaSource,o={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4}},3666:function(e,t,n){"use strict";n.d(t,{$u:function(){return p},SB:function(){return c},YM:function(){return u},fq:function(){return s},kD:function(){return o},lV:function(){return m},l_:function(){return h},op:function(){return f},vS:function(){return d},vU:function(){return l},yS:function(){return v}});var r,i,a=n(2203),o=!1,s=!1,u=!1,l=!1,d=!1,c=!1,f=!1,v=!1,p=!1,h=!1,m=!1;a.Z||(void 0!==window.MSInputMethodContext&&void 0!==document.documentMode?(s=!0,u=!0):"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?u=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?o=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?l=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?c=!0:(Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>=0||"[object SafariRemoteNotification]"===(null===(i=null===(r=window.safari)||void 0===r?void 0:r.pushNotification)||void 0===i?void 0:i.toString()))&&(d=!0),/SamsungBrowser/.test(navigator.userAgent)&&(f=!0),-1!==navigator.userAgent.indexOf("PlayStation 5")?m=!0:/Tizen/.test(navigator.userAgent)?v=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(p=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent))):/[Pp]anasonic/.test(navigator.userAgent)&&(h=!0))},5767:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(3887),i=n(1946);function a(e){var t=e.textTracks;if(!(0,i.Z)(t)){for(var n=0;n=0;o--)if("track"===a[o].nodeName)try{e.removeChild(a[o])}catch(e){r.Z.warn("Compat: Could not remove text track child from element.")}}e.src="",e.removeAttribute("src")}},6139:function(e,t,n){"use strict";n.d(t,{N:function(){return P},Y:function(){return M}});var r,i=n(3714),a=n(811),o=n(3666),s=n(2203),u=n(5059),l=n(1656),d=function(){function e(e,t,n){this._keyType=e,this._mediaKeys=t,this._configuration=n}var t=e.prototype;return t.createMediaKeys=function(){var e=this;return new Promise((function(t){return t(e._mediaKeys)}))},t.getConfiguration=function(){return this._configuration},(0,l.Z)(e,[{key:"keySystem",get:function(){return this._keyType}}]),e}();if(!s.Z){var c=window.MSMediaKeys;void 0!==c&&void 0!==c.prototype&&"function"==typeof c.isTypeSupported&&"function"==typeof c.prototype.createSession&&(r=c)}var f,v=n(4578),p=n(1959),h=n(288),m=n(3038),g=function(e){function t(t){var n;return(n=e.call(this)||this).expiration=NaN,n.keyStatuses=new Map,n._mk=t,n._sessionClosingCanceller=new h.ZP,n.closed=new Promise((function(e){n._sessionClosingCanceller.signal.register((function(){return e()}))})),n.update=function(e){return new Promise((function(t,r){if(void 0===n._ss)return r("MediaKeySession not set.");try{t(n._ss.update(e,""))}catch(e){r(e)}}))},n}(0,v.Z)(t,e);var n=t.prototype;return n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r=t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer);n._ss=n._mk.createSession("video/mp4",r),m.RV(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"message",e)}),n._sessionClosingCanceller.signal),m.kk(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyadded",e)}),n._sessionClosingCanceller.signal),m.Dl(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyerror",e)}),n._sessionClosingCanceller.signal),e()}))},n.close=function(){var e=this;return new Promise((function(t){null!=e._ss&&(e._ss.close(),e._ss=void 0),e._sessionClosingCanceller.cancel(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},(0,l.Z)(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._ss)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(p.Z),y=function(){function e(e){if(void 0===r)throw new Error("No MSMediaKeys API.");this._mediaKeys=new r(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0!==this._videoElement.msSetMediaKeys)return this._videoElement.msSetMediaKeys(this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new g(this._mediaKeys)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();if(!s.Z){var _=window.MozMediaKeys;void 0!==_&&void 0!==_.prototype&&"function"==typeof _.isTypeSupported&&"function"==typeof _.prototype.createSession&&(f=_)}var b=n(9689),S=n(8894),E=n(3635);function T(e){return"function"==typeof e.webkitGenerateKeyRequest}var k=function(e){function t(t,n){var r;(r=e.call(this)||this)._vid=t,r._key=n,r.sessionId="",r._closeSession=S.Z,r.keyStatuses=new Map,r.expiration=NaN;var i=function(e){r.trigger(e.type,e)};return r.closed=new Promise((function(e){r._closeSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.removeEventListener(e,i),t.removeEventListener("webkit"+e,i)})),e()}})),["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.addEventListener(e,i),t.addEventListener("webkit"+e,i)})),r}(0,v.Z)(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){try{if(t._key.indexOf("clearkey")>=0){var i=e instanceof ArrayBuffer?new Uint8Array(e):e,a=JSON.parse((0,E.uR)(i)),o=(0,b.K)(a.keys[0].k),s=(0,b.K)(a.keys[0].kid);n(t._vid.webkitAddKey(t._key,o,s,""))}else n(t._vid.webkitAddKey(t._key,e,null,""))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){n._vid.webkitGenerateKeyRequest(n._key,t),e()}))},n.close=function(){var e=this;return new Promise((function(t){e._closeSession(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},t}(p.Z),w=function(){function e(e){this._keySystem=e}var t=e.prototype;return t._setVideo=function(e){if(!T(e))throw new Error("Video not attached to the MediaKeys");this._videoElement=e},t.createSession=function(){if(null==this._videoElement)throw new Error("Video not attached to the MediaKeys");return new k(this._videoElement,this._keySystem)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();var A=n(6968);var I=n(158);function R(e,t){var n=e;if(void 0===n.webkitSetMediaKeys)throw new Error("No webKitMediaKeys API.");return n.webkitSetMediaKeys(t)}var Z=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._serverCertificate=r,i._videoElement=t,i._keyType=n,i._unbindSession=S.Z,i._closeSession=S.Z,i.closed=new Promise((function(e){i._closeSession=e})),i.keyStatuses=new Map,i.expiration=NaN,i}(0,v.Z)(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){if(void 0===t._nativeSession||void 0===t._nativeSession.update||"function"!=typeof t._nativeSession.update)return r("Unavailable WebKit key session.");try{var i;i=e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e.buffer),n(t._nativeSession.update(i))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r,i,a,o=n._videoElement;if(void 0===(null===(r=o.webkitKeys)||void 0===r?void 0:r.createSession))throw new Error("No WebKitMediaKeys API.");if("com.apple.fps.1_0"===(a=n._keyType)||"com.apple.fps.2_0"===a){if(void 0===n._serverCertificate)throw new Error("A server certificate is needed for creating fairplay session.");i=function(e,t){var n=e instanceof Uint8Array?e:new Uint8Array(e),r=t instanceof Uint8Array?t:new Uint8Array(t);if((0,A.dN)(n,0)+4!==n.length)throw new Error("Unsupported WebKit initData.");var i=(0,E.wV)(n),a=i.indexOf("skd://"),o=a>-1?i.substring(a+6):i,s=(0,E.TZ)(o),u=0,l=new Uint8Array(n.byteLength+4+s.byteLength+4+r.byteLength);return l.set(n),u+=n.length,l.set((0,A.O_)(s.byteLength),u),u+=4,l.set(s,u),u+=s.byteLength,l.set((0,A.O_)(r.byteLength),u),u+=4,l.set(r,u),l}(t,n._serverCertificate)}else i=t;var s=o.webkitKeys.createSession("video/mp4",i);if(null==s)throw new Error("Impossible to get the key sessions");n._listenEvent(s),n._nativeSession=s,e()}))},n.close=function(){var e=this;return new Promise((function(t,n){e._unbindSession(),e._closeSession(),void 0!==e._nativeSession?(e._nativeSession.close(),t()):n("No session to close.")}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},n._listenEvent=function(e){var t=this;this._unbindSession();var n=function(e){t.trigger(e.type,e)};["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.addEventListener(t,n),e.addEventListener("webkit"+t,n)})),this._unbindSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.removeEventListener(t,n),e.removeEventListener("webkit"+t,n)}))}},(0,l.Z)(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._nativeSession)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(p.Z),x=function(){function e(e){if(void 0===I.t)throw new Error("No WebKitMediaKeys API.");this._keyType=e,this._mediaKeys=new I.t(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0===this._videoElement)throw new Error("Video not attached to the MediaKeys");return R(this._videoElement,this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new Z(this._videoElement,this._keyType,this._serverCertificate)},t.setServerCertificate=function(e){return this._serverCertificate=e,Promise.resolve()},e}();var P=null,M=function(e,t){var n=e;return"function"==typeof n.setMediaKeys?n.setMediaKeys(t):"function"==typeof n.webkitSetMediaKeys?n.webkitSetMediaKeys(t):"function"==typeof n.mozSetMediaKeys?n.mozSetMediaKeys(t):"function"==typeof n.msSetMediaKeys&&null!==t?n.msSetMediaKeys(t):void 0};if(s.Z||null!=navigator.requestMediaKeySystemAccess&&!(0,u.Z)())P=function(){var e;return(e=navigator).requestMediaKeySystemAccess.apply(e,arguments)};else{var C,D;if(T(HTMLVideoElement.prototype)){var N={isTypeSupported:function(e){var t=document.querySelector("video");return null==t&&(t=document.createElement("video")),null!=t&&"function"==typeof t.canPlayType&&!!t.canPlayType("video/mp4",e)},createCustomMediaKeys:function(e){return new w(e)},setMediaKeys:function(e,t){if(null!==t){if(!(t instanceof w))throw new Error("Custom setMediaKeys is supposed to be called with old webkit custom MediaKeys.");return t._setVideo(e)}}};C=N.isTypeSupported,D=N.createCustomMediaKeys,M=N.setMediaKeys}else if(void 0!==I.t){var O=function(){if(void 0===I.t)throw new Error("No WebKitMediaKeys API.");return{isTypeSupported:I.t.isTypeSupported,createCustomMediaKeys:function(e){return new x(e)},setMediaKeys:function(e,t){if(null===t)return R(e,t);if(!(t instanceof x))throw new Error("Custom setMediaKeys is supposed to be called with webkit custom MediaKeys.");return t._setVideo(e)}}}();C=O.isTypeSupported,D=O.createCustomMediaKeys,M=O.setMediaKeys}else if(o.fq&&void 0!==r){var L={isTypeSupported:function(e,t){if(void 0===r)throw new Error("No MSMediaKeys API.");return void 0!==t?r.isTypeSupported(e,t):r.isTypeSupported(e)},createCustomMediaKeys:function(e){return new y(e)},setMediaKeys:function(e,t){if(null!==t){if(!(t instanceof y))throw new Error("Custom setMediaKeys is supposed to be called with IE11 custom MediaKeys.");return t._setVideo(e)}}};C=L.isTypeSupported,D=L.createCustomMediaKeys,M=L.setMediaKeys}else if(void 0!==f){var U={isTypeSupported:function(e,t){if(void 0===f)throw new Error("No MozMediaKeys API.");return void 0!==t?f.isTypeSupported(e,t):f.isTypeSupported(e)},createCustomMediaKeys:function(e){if(void 0===f)throw new Error("No MozMediaKeys API.");return new f(e)},setMediaKeys:function(e,t){var n=e;if(void 0===n.mozSetMediaKeys||"function"!=typeof n.mozSetMediaKeys)throw new Error("Can't set video on MozMediaKeys.");return n.mozSetMediaKeys(t)}};C=U.isTypeSupported,D=U.createCustomMediaKeys,M=U.setMediaKeys}else{var B=window.MediaKeys,F=function(){if(void 0===B)throw new i.Z("MEDIA_KEYS_NOT_SUPPORTED","No `MediaKeys` implementation found in the current browser.");if(void 0===B.isTypeSupported){throw new Error("This browser seems to be unable to play encrypted contents currently. Note: Some browsers do not allow decryption in some situations, like when not using HTTPS.")}};C=function(e){return F(),(0,a.Z)("function"==typeof B.isTypeSupported),B.isTypeSupported(e)},D=function(e){return F(),new B(e)}}P=function(e,t){if(!C(e))return Promise.reject(new Error("Unsupported key type"));for(var n=0;n=t)return r.Z.warn("Compat: Invalid cue times: "+e+" - "+t),null;if((0,i.Z)(window.VTTCue)){if((0,i.Z)(window.TextTrackCue))throw new Error("VTT cues not supported in your target");return new TextTrackCue(e,t,n)}return new VTTCue(e,t,n)}},5059:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(3666),i=n(158);function a(){return(r.vS||r.SB)&&void 0!==i.t}},1669:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(3666);function i(){return r.op}},6872:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r={DEFAULT_UNMUTED_VOLUME:.1,DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_TEXT_TRACK_MODE:"native",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:-.7,video:-.1,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:"continue",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:"none",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,FORCE_DISCONTINUITY_SEEK_DELAY:5e3,BITRATE_REBUFFERING_RATIO:1.5,BUFFER_GC_GAPS:{CALM:240,BEEFY:30},DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:250,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs="avc1.4d401e"','video/mp4;codecs="avc1.42e01e"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"',"audio/webm;codecs=opus"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:["HW_SECURE_ALL","HW_SECURE_DECODE","HW_SECURE_CRYPTO","SW_SECURE_DECODE","SW_SECURE_CRYPTO"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:["3000","2000"],EME_KEY_SYSTEMS:{clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.microsoft.playready.recommendation","com.microsoft.playready","com.chromecast.playready","com.youtube.playready"],fairplay:["com.apple.fps.1_0"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:"reload",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:"seamless"},i=n(8026);function a(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function o(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r=e.length||(e[t].enabled=!0)}(this._audioTracks.map((function(e){return e.nativeTrack})),e)},t}(a.Z);function v(e){for(var t=0;te.length)return u.Z.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var i=e.subarray(n,n+r),a={systemId:(0,l.Y)(i,8),data:i};p(t,a)?u.Z.warn("Compat: Duplicated PSSH found in initialization data, removing it."):t.push(a),n+=r}return n!==e.length?(u.Z.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}]):t}(new Uint8Array(t));return{type:n,values:r}}var m=n(6872),g=n(5157),y=n(5389),_=n(3274),b=n(7714),S=n(1959),E=n(1946),T=n(288),k=n(6139),w=n(770);function A(e){w.Z.setState(e,null),(0,k.Y)(e,null)}function I(){return(I=(0,r.Z)(o().mark((function e(t,n,r){var i,a,s,l,d,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.keySystemOptions,a=n.loadedSessionsStore,s=n.mediaKeySystemAccess,l=n.mediaKeys,d=w.Z.getState(t),c=null!==d&&d.loadedSessionsStore!==a?d.loadedSessionsStore.closeAllSessions():Promise.resolve(),e.next=5,c;case 5:if(!r.isCancelled()){e.next=7;break}throw r.cancellationError;case 7:if(w.Z.setState(t,{keySystemOptions:i,mediaKeySystemAccess:s,mediaKeys:l,loadedSessionsStore:a}),t.mediaKeys!==l){e.next=10;break}return e.abrupt("return");case 10:u.Z.info("DRM: Attaching MediaKeys to the media element"),(0,k.Y)(t,l),u.Z.info("DRM: MediaKeys attached with success");case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function R(e){if(""===e.sessionId)return!1;var t=e.keyStatuses,n=[];return t.forEach((function(e){n.push(e)})),n.length<=0?(u.Z.debug("DRM: isSessionUsable: MediaKeySession given has an empty keyStatuses",e.sessionId),!1):(0,b.Z)(n,"expired")?(u.Z.debug("DRM: isSessionUsable: MediaKeySession given has an expired key",e.sessionId),!1):(0,b.Z)(n,"internal-error")?(u.Z.debug("DRM: isSessionUsable: MediaKeySession given has a key with an internal-error",e.sessionId),!1):(u.Z.debug("DRM: isSessionUsable: MediaKeySession is usable",e.sessionId),!0)}function Z(e,t,n,r){var i=e.loadedSessionsStore,a=e.persistentSessionsStore;return"temporary"===n?x(i,t):null===a?(u.Z.warn("DRM: Cannot create persistent MediaKeySession, PersistentSessionsStore not created."),x(i,t)):function(e,t,n,r){return P.apply(this,arguments)}(i,a,t,r)}function x(e,t){u.Z.info("DRM: Creating a new temporary session");var n=e.createSession(t,"temporary");return Promise.resolve({type:"created-session",value:n})}function P(){return P=(0,r.Z)(o().mark((function e(t,n,i,a){var s,l,d,c,f,v;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(v=function(){return v=(0,r.Z)(o().mark((function e(){var r,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===a.cancellationError){e.next=2;break}throw a.cancellationError;case 2:return u.Z.info("DRM: Removing previous persistent session."),null!==(r=n.get(i))&&n.delete(r.sessionId),e.prev=5,e.next=8,t.closeSession(s.mediaKeySession);case 8:e.next=15;break;case 10:if(e.prev=10,e.t0=e.catch(5),""===s.mediaKeySession.sessionId){e.next=14;break}throw e.t0;case 14:t.removeSessionWithoutClosingIt(s.mediaKeySession);case 15:if(null===a.cancellationError){e.next=17;break}throw a.cancellationError;case 17:return l=t.createSession(i,"persistent-license"),e.abrupt("return",{type:"created-session",value:l});case 19:case"end":return e.stop()}}),e,null,[[5,10]])}))),v.apply(this,arguments)},f=function(){return v.apply(this,arguments)},null===a.cancellationError){e.next=4;break}throw a.cancellationError;case 4:if(u.Z.info("DRM: Creating persistent MediaKeySession"),s=t.createSession(i,"persistent-license"),null!==(l=n.getAndReuse(i))){e.next=9;break}return e.abrupt("return",{type:"created-session",value:s});case 9:return e.prev=9,e.next=12,t.loadPersistentSession(s.mediaKeySession,l.sessionId);case 12:if(d=e.sent){e.next=19;break}return u.Z.warn("DRM: No data stored for the loaded session"),n.delete(l.sessionId),t.removeSessionWithoutClosingIt(s.mediaKeySession),c=t.createSession(i,"persistent-license"),e.abrupt("return",{type:"created-session",value:c});case 19:if(!d||!R(s.mediaKeySession)){e.next=23;break}return n.add(i,i.keyIds,s.mediaKeySession),u.Z.info("DRM: Succeeded to load persistent session."),e.abrupt("return",{type:"loaded-persistent-session",value:s});case 23:return u.Z.warn("DRM: Previous persistent session not usable anymore."),e.abrupt("return",f());case 27:return e.prev=27,e.t0=e.catch(9),u.Z.warn("DRM: Unable to load persistent session: "+(e.t0 instanceof Error?e.t0.toString():"Unknown Error")),e.abrupt("return",f());case 31:case"end":return e.stop()}}),e,null,[[9,27]])}))),P.apply(this,arguments)}function M(e,t){return C.apply(this,arguments)}function C(){return(C=(0,r.Z)(o().mark((function e(t,n){var r,i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n<0||n>=t.getLength())){e.next=2;break}return e.abrupt("return");case 2:for(u.Z.info("DRM: LSS cache limit exceeded",n,t.getLength()),r=[],i=t.getAll().slice(),a=i.length-n,s=0;s=s.length)){e.next=2;break}throw new g.Z("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");case 2:if(null!=k.N){e.next=4;break}throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");case 4:return r=s[t],i=r.keyType,a=r.keySystemOptions,d=B(r),u.Z.debug("DRM: Request keysystem access "+i+","+(t+1)+" of "+s.length),e.prev=8,e.next=11,(0,k.N)(i,d);case 11:return c=e.sent,u.Z.info("DRM: Found compatible keysystem",i,t+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:a,mediaKeySystemAccess:c}});case 16:if(e.prev=16,e.t0=e.catch(8),u.Z.debug("DRM: Rejected access to keysystem",i,t+1),null===n.cancellationError){e.next=21;break}throw n.cancellationError;case 21:return e.abrupt("return",l(t+1));case 22:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}}var z=n(2297);function V(e,t,n){var r;u.Z.debug("Compat: Calling generateRequest on the MediaKeySession");try{r=function(e){u.Z.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,n=new Uint8Array,r=new Uint8Array,i=0;ie.length)throw u.Z.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var o=e.subarray(i,i+a);if(16===e[i+12]&&119===e[i+13]&&239===e[i+14]&&236===e[i+15]&&192===e[i+16]&&178===e[i+17]&&77===e[i+18]&&2===e[i+19]&&172===e[i+20]&&227===e[i+21]&&60===e[i+22]&&30===e[i+23]&&82===e[i+24]&&226===e[i+25]&&251===e[i+26]&&75===e[i+27]){var s=(0,z.Xj)(o),l=null===s?void 0:o[s[1]];u.Z.info("Compat: CENC PSSH found with version",l),void 0===l?u.Z.warn("Compat: could not read version of CENC PSSH"):t===(1===l)?n=(0,c.zo)(n,o):1===l?(u.Z.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),n=o,t=!0):u.Z.warn("Compat: filtering out cenc pssh box with wrong version",l)}else r=(0,c.zo)(r,o);i+=a}if(i!==e.length)throw u.Z.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return(0,c.zo)(r,n)}(n)}catch(e){r=n}var i=null!=t?t:"";return e.generateRequest(i,r).catch((function(t){if(""!==i||!(t instanceof TypeError))throw t;return u.Z.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',t),e.generateRequest("cenc",r)}))}var K=100;function G(e,t){return j.apply(this,arguments)}function j(){return(j=(0,r.Z)(o().mark((function e(t,n){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u.Z.info("DRM: Load persisted session",n),e.next=3,t.load(n);case 3:if((r=e.sent)&&!(t.keyStatuses.size>0)){e.next=6;break}return e.abrupt("return",r);case 6:return e.abrupt("return",new Promise((function(e){t.addEventListener("keystatuseschange",i);var n=setTimeout(i,K);function i(){clearTimeout(n),t.removeEventListener("keystatuseschange",i),e(r)}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var H=n(7864);function W(e){var t=new T.ZP;return Promise.race([e.close().then((function(){t.cancel()})),e.closed.then((function(){t.cancel()})),function(){return n.apply(this,arguments)}()]);function n(){return(n=(0,r.Z)(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,H.Z)(1e3,t.signal);case 3:return e.next=5,i();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),!(e.t0 instanceof T.FU)){e.next=11;break}return e.abrupt("return");case 11:n=e.t0 instanceof Error?e.t0.message:"Unknown error made it impossible to close the session",u.Z.error("DRM: "+n);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function i(){return a.apply(this,arguments)}function a(){return(a=(0,r.Z)(o().mark((function n(){return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.update(new Uint8Array(1));case 3:n.next=13;break;case 5:if(n.prev=5,n.t0=n.catch(0),!t.isUsed()){n.next=9;break}return n.abrupt("return");case 9:if(!(n.t0 instanceof Error&&"The session is already closed."===n.t0.message)){n.next=11;break}return n.abrupt("return");case 11:return n.next=13,(0,H.Z)(1e3,t.signal);case 13:if(!t.isUsed()){n.next=15;break}return n.abrupt("return");case 15:throw new Error("Compat: Couldn't know if session is closed");case 16:case"end":return n.stop()}}),n,null,[[0,5]])})))).apply(this,arguments)}}var q=n(811);function Y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return X(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return X(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){if(null!==this._keyIds&&J(t,this._keyIds))return!0;if(void 0!==this._initializationData.keyIds)return J(t,this._initializationData.keyIds)}return this._checkInitializationDataCompatibility(e)},t._checkInitializationDataCompatibility=function(e){return void 0!==e.keyIds&&e.keyIds.length>0&&void 0!==this._initializationData.keyIds?J(e.keyIds,this._initializationData.keyIds):this._initializationData.type===e.type&&this._initializationData.values.isCompatibleWith(e.values)},e}();function re(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ie(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&n._storage[e].mediaKeySession===i&&n._storage.splice(e,1)})).catch((function(e){u.Z.warn("DRM-LSS: MediaKeySession.closed rejected: "+e)})),this._storage.push(Object.assign({},a)),u.Z.debug("DRM-LSS: MediaKeySession added",a.sessionType,this._storage.length),a},t.reuse=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.keySessionRecord.isCompatibleWith(e))return this._storage.splice(t,1),this._storage.push(n),u.Z.debug("DRM-LSS: Reusing session:",n.mediaKeySession.sessionId,n.sessionType),Object.assign({},n)}return null},t.getEntryForSession=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.mediaKeySession===e)return Object.assign({},n)}return null},t.generateLicenseRequest=function(){var e=(0,r.Z)(o().mark((function e(t,n,r){var i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=re(this._storage);case 1:if((s=a()).done){e.next=8;break}if((l=s.value).mediaKeySession!==t){e.next=6;break}return i=l,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==i){e.next=11;break}return u.Z.error("DRM-LSS: generateRequest error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",V(t,n,r));case 11:if(i.isGeneratingRequest=!0,"none"===i.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,V(t,n,r);case 17:e.next=26;break;case 19:if(e.prev=19,e.t0=e.catch(14),void 0!==i){e.next=23;break}throw e.t0;case 23:throw i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start(),e.t0;case 26:if(void 0!==i){e.next=28;break}return e.abrupt("return",void 0);case 28:i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start();case 30:case"end":return e.stop()}}),e,this,[[14,19]])})));return function(t,n,r){return e.apply(this,arguments)}}(),t.loadPersistentSession=function(){var e=(0,r.Z)(o().mark((function e(t,n){var r,i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=re(this._storage);case 1:if((a=i()).done){e.next=8;break}if((s=a.value).mediaKeySession!==t){e.next=6;break}return r=s,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==r){e.next=11;break}return u.Z.error("DRM-LSS: loadPersistentSession error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",G(t,n));case 11:if(r.isLoadingPersistentSession=!0,"none"===r.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,G(t,n);case 17:l=e.sent,e.next=27;break;case 20:if(e.prev=20,e.t0=e.catch(14),void 0!==r){e.next=24;break}throw e.t0;case 24:throw r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.t0;case 27:if(void 0!==r){e.next=29;break}return e.abrupt("return",l);case 29:return r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.abrupt("return",l);case 32:case"end":return e.stop()}}),e,this,[[14,20]])})));return function(t,n){return e.apply(this,arguments)}}(),t.closeSession=function(){var e=(0,r.Z)(o().mark((function e(t){var n,r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=re(this._storage);case 1:if((i=r()).done){e.next=8;break}if((a=i.value).mediaKeySession!==t){e.next=6;break}return n=a,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==n){e.next=11;break}return u.Z.warn("DRM-LSS: No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Promise.resolve(!1));case 11:return e.abrupt("return",this._closeEntry(n));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getLength=function(){return this._storage.length},t.getAll=function(){return this._storage},t.closeAllSessions=function(){var e=(0,r.Z)(o().mark((function e(){var t,n,r=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._storage,u.Z.debug("DRM-LSS: Closing all current MediaKeySessions",t.length),this._storage=[],n=t.map((function(e){return r._closeEntry(e)})),e.next=6,Promise.all(n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.removeSessionWithoutClosingIt=function(e){(0,q.Z)(""===e.sessionId,"Initialized `MediaKeySession`s should always be properly closed");for(var t=this._storage.length-1;t>=0;t--){if(this._storage[t].mediaKeySession===e)return u.Z.debug("DRM-LSS: Removing session without closing it",e.sessionId),this._storage.splice(t,1),!0}return!1},t.getIndex=function(e){for(var t=0;t=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0){var o=void 0===t?3:4,s=this._entries[a];if((null!==(r=s.version)&&void 0!==r?r:-1)>=o&&i===s.sessionId)return;u.Z.info("DRM-PSS: Updating session info.",i),this._entries.splice(a,1)}else u.Z.info("DRM-PSS: Add new session",i);var l=e.values.getFormattedValues().map((function(e){var t=e.systemId,n=e.data;return{systemId:t,hash:e.hash,data:new ce(n)}}));void 0===t?this._entries.push({version:3,sessionId:i,values:l,initDataType:e.type}):this._entries.push({version:4,sessionId:i,keyIds:t.map((function(e){return new ce(e)})),values:l,initDataType:e.type}),this._save()}else u.Z.warn("DRM-PSS: Invalid Persisten Session given.")},t.delete=function(e){for(var t=-1,n=0;n0&&(r=new g.Z("KEY_STATUS_CHANGE_ERROR","One or several problematic key statuses have been encountered",{keyStatuses:d})),{warning:r,blacklistedKeyIds:s,whitelistedKeyIds:l}}var Ce=s.Dl,De=s.RV,Ne=s.qo;function Oe(e,t,n,i,a){u.Z.info("DRM: Binding session events",e.sessionId);var s=t.getLicenseConfig,l=void 0===s?{}:s,d=new T.ZP;return d.linkToSignal(a),(0,E.Z)(e.closed)||e.closed.then((function(){return d.cancel()})).catch((function(e){a.isCancelled()||(d.cancel(),i.onError(e))})),Ce(e,(function(e){d.cancel(),i.onError(new g.Z("KEY_ERROR",e.type))}),d.signal),Ne(e,(function(){try{c()}catch(e){if(a.isCancelled()||d.isUsed()&&e instanceof T.XG)return;d.cancel(),i.onError(e)}}),d.signal),De(e,(function(n){var a,s=n,c=new Uint8Array(s.message),f=(0,de.Z)(s.messageType)?s.messageType:"license-request";u.Z.info("DRM: Received message event, type "+f,e.sessionId),function(e,t,n){var i=t.baseDelay,a=t.maxDelay,s=t.totalRetry,u=t.shouldRetry,l=t.onRetry,d=0;return c();function c(){return f.apply(this,arguments)}function f(){return(f=(0,r.Z)(o().mark((function t(){var r,f,v,p;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===n.cancellationError){t.next=2;break}throw n.cancellationError;case 2:return t.prev=2,t.next=5,e();case 5:return r=t.sent,t.abrupt("return",r);case 9:if(t.prev=9,t.t0=t.catch(2),null===n.cancellationError){t.next=13;break}throw n.cancellationError;case 13:if(!(!(0,E.Z)(u)&&!u(t.t0)||d++>=s)){t.next=15;break}throw t.t0;case 15:return"function"==typeof l&&l(t.t0,d),f=Math.min(i*Math.pow(2,d-1),a),v=(0,Ie.Z)(f),t.next=20,Re(v);case 20:return p=c(),t.abrupt("return",p);case 22:case"end":return t.stop()}}),t,null,[[2,9]])})))).apply(this,arguments)}}((function(){return function(e,n){var r;return new Promise((function(i,a){try{u.Z.debug("DRM: Calling `getLicense`",n);var o=t.getLicense(e,n),s=(0,E.Z)(l.timeout)?1e4:l.timeout;s>=0&&(r=setTimeout((function(){a(new Fe('"getLicense" timeout exceeded ('+s+" ms)"))}),s)),Promise.resolve(o).then(d,c)}catch(e){c(e)}function d(e){void 0!==r&&clearTimeout(r),i(e)}function c(e){void 0!==r&&clearTimeout(r),a(e)}}))}(c,f)}),{totalRetry:null!=(a=l.retry)?a:2,baseDelay:200,maxDelay:3e3,shouldRetry:function(e){return e instanceof Fe||(0,E.Z)(e)||!0!==e.noRetry},onRetry:function(e){return i.onWarning(Le(e))}},d.signal).then((function(t){if(d.isUsed())return Promise.resolve();if((0,E.Z)(t))u.Z.info("DRM: No license given, skipping session.update");else try{return function(e,t){return Ue.apply(this,arguments)}(e,t)}catch(e){d.cancel(),i.onError(e)}})).catch((function(e){if(!d.isUsed()){d.cancel();var t=Le(e);if(!(0,E.Z)(e))if(!0===e.fallbackOnLastTry)return u.Z.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void i.onError(new Be(t));i.onError(t)}}))}),d.signal),void c();function c(){if(u.Z.info("DRM: keystatuseschange event received",e.sessionId),!d.isUsed()&&0!==e.keyStatuses.size){var r=Me(e,t,n),a=r.warning,o=r.blacklistedKeyIds,s=r.whitelistedKeyIds;void 0!==a&&(i.onWarning(a),d.isUsed())||i.onKeyUpdate({whitelistedKeyIds:s,blacklistedKeyIds:o})}}}function Le(e){if(e instanceof Fe)return new g.Z("KEY_LOAD_TIMEOUT","The license server took too much time to respond.");var t=new g.Z("KEY_LOAD_ERROR","An error occured when calling `getLicense`.");return!(0,E.Z)(e)&&(0,de.Z)(e.message)&&(t.message=e.message),t}function Ue(){return(Ue=(0,r.Z)(o().mark((function e(t,n){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u.Z.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(n);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new g.Z("KEY_UPDATE_ERROR",r);case 10:u.Z.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}}),e,null,[[1,6]])})))).apply(this,arguments)}var Be=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf((0,we.Z)(r),t.prototype),r.sessionError=n,r}return(0,i.Z)(t,e),t}((0,Ae.Z)(Error)),Fe=function(e){function t(t){var n;return n=e.call(this)||this,Object.setPrototypeOf((0,we.Z)(n),Be.prototype),n.message=t,n}return(0,i.Z)(t,e),t}((0,Ae.Z)(Error)),ze=n(9822);function Ve(e,t){return Ke.apply(this,arguments)}function Ke(){return(Ke=(0,r.Z)(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(n);case 3:return r=e.sent,e.abrupt("return",r);case 7:throw e.prev=7,e.t0=e.catch(0),u.Z.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),i=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new g.Z("LICENSE_SERVER_CERTIFICATE_ERROR",i);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function Ge(e,t){return je.apply(this,arguments)}function je(){return(je=(0,r.Z)(o().mark((function e(t,n){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==ye.hasOne(t)){e.next=3;break}return u.Z.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});case 3:if("function"==typeof t.setServerCertificate){e.next=6;break}return u.Z.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});case 6:return u.Z.info("DRM: Setting server certificate on the MediaKeys"),ye.prepare(t),e.prev=8,e.next=11,Ve(t,n);case 11:return r=e.sent,ye.set(t,n),e.abrupt("return",{type:"success",value:r});case 16:return e.prev=16,e.t0=e.catch(8),i=(0,ze.Z)(e.t0)?e.t0:new g.Z("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:i});case 20:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}function He(e,t){if(!(isNaN(t)||t<0||t>=e.getLength())){var n=e.getLength(),r=n-t;u.Z.info("DRM: Too many stored persistent sessions, removing some.",n,r),e.deleteOldSessions(r)}}var We=n(9252);var qe=function(){function e(e){this._innerValues=e,this._lazyFormattedValues=null}var t=e.prototype;return t.constructRequestData=function(){return c.zo.apply(void 0,this._innerValues.map((function(e){return e.data})))},t.isCompatibleWith=function(t){var n=t instanceof e?t.getFormattedValues():t;return fe(this.getFormattedValues(),n)},t.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort((function(e,t){return e.systemId===t.systemId?0:void 0===e.systemId?1:void 0===t.systemId||e.systemId=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Xe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&G._currentSessions.splice(r),void 0!==t.content&&tt(t.content.manifest,[],[],O.record.getAssociatedKeyIds()),null===(n=i.persistentSessionsStore)||void 0===n||n.delete(U.sessionId),i.loadedSessionsStore.closeSession(U).catch((function(e){var t=e instanceof Error?e:"unknown error";u.Z.warn("DRM: failed to close expired session",t)})).then((function(){return G._unlockInitDataQueue()})).catch((function(e){return G._onFatalError(e)})),void(G._isStopped()||G.trigger("warning",e.reason))}if(e instanceof Be){if(O.blacklistedSessionError=e,void 0!==t.content){var a=t.content.manifest;u.Z.info("DRM: blacklisting Representations based on protection data."),nt(a,t)}G._unlockInitDataQueue()}else G._onFatalError(e)}},this._canceller.signal),void 0!==a.singleLicensePer&&"init-data"!==a.singleLicensePer||this._unlockInitDataQueue(),"created-session"!==N.type){e.next=67;break}return z=t.values.constructRequestData(),e.prev=54,e.next=57,i.loadedSessionsStore.generateLicenseRequest(U,t.type,z);case 57:e.next=67;break;case 59:if(e.prev=59,e.t0=e.catch(54),null!==(V=i.loadedSessionsStore.getEntryForSession(U))&&"none"===V.closingStatus.type){e.next=66;break}return(K=this._currentSessions.indexOf(O))>=0&&this._currentSessions.splice(K,1),e.abrupt("return",Promise.resolve());case 66:throw new g.Z("KEY_GENERATE_REQUEST_ERROR",e.t0 instanceof Error?e.t0.toString():"Unknown error");case 67:return e.abrupt("return",Promise.resolve());case 68:case"end":return e.stop()}}),e,this,[[54,59]])})));return function(t,n){return e.apply(this,arguments)}}(),n._tryToUseAlreadyCreatedSession=function(e,t){var n=t.stores,r=t.options,i=(0,_.Z)(this._currentSessions,(function(t){return t.record.isCompatibleWith(e)}));if(void 0===i)return!1;var a=i.blacklistedSessionError;if(!(0,E.Z)(a))return void 0===e.type||void 0===e.content?(u.Z.error("DRM: This initialization data has already been blacklisted but the current content is not known."),!0):(u.Z.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),nt(e.content.manifest,e),!0);if(void 0!==e.keyIds){var o;if(void 0===r.singleLicensePer||"init-data"===r.singleLicensePer){var s=i.keyStatuses.blacklisted;o=function(e,t){for(var n,r=function(){var e=n.value;if(t.some((function(t){return Q(t,e)})))return{v:!0}},i=Y(e);!(n=i()).done;){var a=r();if("object"==typeof a)return a.v}return!1}(e.keyIds,s)}else{var l=i.keyStatuses.whitelisted;o=!J(e.keyIds,l)}if(o)return void 0===e.content?(u.Z.error("DRM: Cannot forbid key id, the content is unknown."),!0):(u.Z.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),tt(e.content.manifest,[],e.keyIds,[]),!0)}if(null!==n.loadedSessionsStore.reuse(e))return u.Z.debug("DRM: Init data already processed. Skipping it."),!0;var d=this._currentSessions.indexOf(i);return-1===d?u.Z.error("DRM: Unable to remove processed init data: not found."):(u.Z.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(d,1)),!1},n._onFatalError=function(e){if(!this._canceller.isUsed()){var t=e instanceof Error?e:new y.Z("NONE","Unknown decryption error");this.error=t,this._initDataQueue.length=0,this._stateData={state:Qe.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",t),this._stateData.state===Qe.Error&&this.trigger("stateChange",this._stateData.state)}},n._isStopped=function(){return this._stateData.state===Qe.Disposed||this._stateData.state===Qe.Error},n._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},n._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},n._unlockInitDataQueue=function(){!0===this._stateData.isMediaKeysAttached?(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue()):u.Z.error("DRM: Trying to unlock in the wrong state")},t}(S.Z);function et(e){var t=e.getConfiguration().sessionTypes;return void 0!==t&&(0,b.Z)(t,"persistent-license")}function tt(e,t,n,r){e.updateRepresentationsDeciperability((function(e){if(void 0===e.contentProtections)return e.decipherable;var i=e.contentProtections.keyIds;if(void 0!==i)for(var a,o=Ye(i);!(a=o()).done;){for(var s,u=a.value,l=Ye(n);!(s=l()).done;){if(Q(s.value,u.keyId))return!1}for(var d,c=Ye(t);!(d=c()).done;){if(Q(d.value,u.keyId))return!0}for(var f,v=Ye(r);!(f=v()).done;){if(Q(f.value,u.keyId))return}}return e.decipherable}))}function nt(e,t){e.updateRepresentationsDeciperability((function(e){var n,r;if(!1===e.decipherable)return!1;for(var i,a=function(){var e=i.value;if((void 0===t.type||e.type===t.type)&&t.values.getFormattedValues().every((function(t){return e.values.some((function(e){return(void 0===t.systemId||e.systemId===t.systemId)&&(0,d.Z)(e.data,t.data)}))})))return{v:!1}},o=Ye(null!==(r=null===(n=e.contentProtections)||void 0===n?void 0:n.initData)&&void 0!==r?r:[]);!(i=o()).done;){var s=a();if("object"==typeof s)return s.v}return e.decipherable}))}function rt(e,t,n,r,i,a){for(var o,s,l=[].concat(i,a),d=function(){var e=s.value;l.some((function(t){return Q(t,e)}))||(u.Z.hasLevel("DEBUG")&&u.Z.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it",(0,f.ci)(e)),l.push(e))},c=Ye(t.getAssociatedKeyIds());!(s=c()).done;)d();if(void 0!==n&&"init-data"!==n){var v=e.keyIds,p=e.content;if(void 0!==v){var h=v.filter((function(e){return!l.some((function(t){return Q(t,e)}))}));h.length>0&&(u.Z.hasLevel("DEBUG")&&u.Z.debug("DRM: init data keys missing in the license, blacklisting them",h.map((function(e){return(0,f.ci)(e)})).join(", ")),l.push.apply(l,h))}if(r&&void 0!==p)if("content"===n){for(var m,g=new Set,y=Ye(p.manifest.periods);!(m=y()).done;){at(g,m.value)}it(g,l)}else if("periods"===n)for(var _,b=Ye(p.manifest.periods);!(_=b()).done;){var S=_.value,E=new Set;if(at(E,S),(null===(o=e.content)||void 0===o?void 0:o.period.id)===S.id)it(E,l);else for(var T=Array.from(E),k=function(){var e=A[w];if(l.some((function(t){return Q(t,e)})))return it(E,l),"break"},w=0,A=T;w=100?n:r<=0?0:n*(+r/100)}return 0}(e,s);return a.Z.debug("Init: Initial time calculated:",t),t}),o,(function(e){return n.trigger("warning",e)}),r).autoPlayResult.then((function(){return(0,l.Z)(t,e,!0,r).onUpdate((function(e,t){e&&(t(),n.trigger("loaded",{segmentBuffersStore:null}))}),{emitCurrentValue:!0,clearSignal:r})})).catch((function(e){r.isCancelled()||n._onFatalError(e)}))},t}(u.K)},379:function(e,t,n){"use strict";n.d(t,{K:function(){return i}});var r=n(4578),i=function(e){function t(){return e.apply(this,arguments)||this}return(0,r.Z)(t,e),t}(n(1959).Z)},1757:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var r=n(3666);var i=n(1669),a=n(5095),o=n(288);function s(e,t,n,s){var u=new o.ZP;u.linkToSignal(s);var l=(0,a.ZP)(!1,u.signal);return e.listen((function(e){if(null===e.rebuffering&&null===e.freezing&&0!==e.readyState)return!function(e,t){return!e||!r.SB||t}(n,t.hasAttribute("playsinline"))&&t.duration>0||e.readyState>=3&&null!==e.currentRange&&(!(0,i.Z)()||t.duration>0)?(l.setValue(!0),void u.cancel()):void 0}),{includeLastObservation:!0,clearSignal:u.signal}),l}},8833:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(1669),i=n(3774),a=n(3714),o=n(3887),s=n(5095);function u(e,t,n,u,l,d){var c,f,v=new Promise((function(e,t){c=e,f=t})),p=(0,s.$l)(!1,d),h=(0,s.$l)(!1,d);e.addEventListener("loadedmetadata",g),e.readyState>=i.c.HAVE_METADATA&&g();var m=d.register((function(t){e.removeEventListener("loadedmetadata",g),f(t)}));return{autoPlayResult:v,initialPlayPerformed:h,initialSeekPerformed:p};function g(){e.removeEventListener("loadedmetadata",g);var i="function"==typeof n?n():n;if(o.Z.info("Init: Set initial time",i),t.setCurrentTime(i),p.setValue(!0),p.finish(),(0,r.Z)()&&0===e.duration){var s=new a.Z("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content.");l(s)}d.isCancelled()||t.listen((function(t,n){!t.seeking&&null===t.rebuffering&&t.readyState>=1&&(n(),function(){var t,n;if(o.Z.info("Init: Can begin to play content"),!u)return e.autoplay&&o.Z.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),h.setValue(!0),h.finish(),m(),c({type:"skipped"});try{n=null!==(t=e.play())&&void 0!==t?t:Promise.resolve()}catch(e){return m(),f(e)}n.then((function(){if(!d.isCancelled())return h.setValue(!0),h.finish(),m(),c({type:"autoplay"})})).catch((function(e){if(m(),!d.isCancelled()){if(e instanceof Error&&"NotAllowedError"===e.name){o.Z.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var t=new a.Z("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(l(t),d.isCancelled())return;return c({type:"autoplay-blocked"})}f(e)}}))}())}),{includeLastObservation:!0,clearSignal:d})}}},8799:function(e,t,n){"use strict";n.d(t,{Z:function(){return d}});var r=n(6139);var i=n(5157),a=n(3887),o=n(5095),s=n(288),u=n(1266),l=n(276);function d(e,t,n,d,c){if(0===t.length){n.onUpdate((function(e,t){if(null!==e){t(),a.Z.error("Init: Encrypted event but EME feature not activated");var n=new i.Z("MEDIA_IS_ENCRYPTED_ERROR","EME feature not activated.");d.onError(n)}}),{clearSignal:c});var f=(0,o.ZP)({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return f.finish(),f}if("function"!=typeof r.N){n.onUpdate((function(e,t){if(null!==e){t(),a.Z.error("Init: Encrypted event but no EME API available");var n=new i.Z("MEDIA_IS_ENCRYPTED_ERROR","Encryption APIs not found.");d.onError(n)}}),{clearSignal:c});var v=(0,o.ZP)({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return v.finish(),v}var p=new s.ZP;p.linkToSignal(c);var h=(0,o.ZP)({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},c);a.Z.debug("Init: Creating ContentDecryptor");var m=new u.ZP(e,t);return m.addEventListener("stateChange",(function(e){if(e===l.u.WaitingForAttachment){var t=(0,o.ZP)(!1);t.onUpdate((function(t,n){t&&(n(),e===l.u.WaitingForAttachment&&m.attach())}),{clearSignal:p.signal}),h.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:t}},drmSystemId:m.systemId})}else e===l.u.ReadyForContent&&(h.setValue({initializationState:{type:"initialized",value:null},drmSystemId:m.systemId}),m.removeEventListener("stateChange"))})),m.addEventListener("error",(function(e){p.cancel(),d.onError(e)})),m.addEventListener("warning",(function(e){d.onWarning(e)})),n.onUpdate((function(e){null!==e&&m.onInitializationData(e)}),{clearSignal:p.signal}),p.signal.register((function(){m.dispose()})),h}},6199:function(e,t,n){"use strict";n.d(t,{Z:function(){return p}});var r=n(4578),i=n(3666).yS,a=n(6872),o=n(3714),s=n(3887),u=n(1959),l=n(2829),d=n(288);function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nT&&(s.Z.warn("Init: trying to seek to un-freeze player"),e._playbackObserver.setCurrentTime(e._playbackObserver.getCurrentTime()+k),o={attemptTimestamp:A}),A-y.timestamp>E)return null===g||null!==n?r.stopRebuffering():r.startRebuffering(),void e.trigger("stalled","freezing")}else o=null;var I;if(null===g)return r.stopRebuffering(),1===h?(I=u.seeking?null!==u.pendingInternalSeek?"internal-seek":"seeking":"not-ready",void e.trigger("stalled",I)):void e.trigger("unstalled",null);var R="seeking"===g.reason&&null!==u.pendingInternalSeek?"internal-seek":g.reason;if(null!==n){var Z=performance.now();if(Z-n0){var P=function(e,t,n){if(0===e.length)return null;for(var r=null,i=0;in)return r;var o=void 0;if(void 0===a.end||a.end>n){var u=e[i],l=u.discontinuity,d=u.position,c=l.start,f=l.end;if(n>=(null!=c?c:d)-v)if(null===f){var p=t.getPeriodAfter(a);null!==p?o=p.start+v:s.Z.warn("Init: discontinuity at Period's end but no next Period")}else no?r:o)}}return r}(c,e._manifest,x);if(null!==P){var M=P+.001;if(!(M<=e._playbackObserver.getCurrentTime()))return s.Z.warn("SA: skippable discontinuity found in the stream",p,M),e._playbackObserver.setCurrentTime(M),void e.trigger("warning",m(x,M));s.Z.info("Init: position to seek already reached, no seeking",e._playbackObserver.getCurrentTime(),M)}}var C=null!=x?x:p,D=(0,l.XS)(f,C);if(e._speed.getValue()>0&&D=0;O--){var L=e._manifest.periods[O];if(void 0!==L.end&&L.end<=C){if(e._manifest.periods[O+1].start>C&&e._manifest.periods[O+1].start>e._playbackObserver.getCurrentTime()){var U=e._manifest.periods[O+1];return e._playbackObserver.setCurrentTime(U.start),void e.trigger("warning",m(C,U.start))}break}}e.trigger("stalled",R)}else e.trigger("stalled",R)}}),{includeLastObservation:!0,clearSignal:this._canceller.signal})}},n.updateDiscontinuityInfo=function(e){this._isStarted||this.start();var t=this._playbackObserver.getReference().getValue();!function(e,t,n){for(;e.length>0&&void 0!==e[0].period.end&&e[0].period.end+10r.start)return void(h(t)&&e.splice(a,0,t));h(t)&&e.push(t)}(this._discontinuitiesStore,e,t)},n.onLockedStream=function(e,t){var n;this._isStarted||this.start();var r=this._playbackObserver.getReference().getValue();if(!(!r.rebuffering||r.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e)){var i=r.position,a=null!==(n=r.rebuffering.position)&&void 0!==n?n:i,o=t.start;i1)return this._currentFreezeTimestamp=null,!1;var a=performance.now();null===this._currentFreezeTimestamp&&(this._currentFreezeTimestamp=a);var o=null!==n&&a-n.timestamp>4e3,u=null!==r&&a-r.timestamp>4e3;if((o||u)&&performance.now()-this._currentFreezeTimestamp>4e3){for(var l=!0,d=!0,f=0,v=[this._segmentBuffersStore.getStatus("audio"),this._segmentBuffersStore.getStatus("video")];f=0;n--){if(e[n].startt)return e.slice(n,e.length)}return[]}function m(e,t,n){var r=Math.max(e.start,t),i=p(e.cues,t),a={start:e.start,end:r,cues:i},o=Math.min(n,e.end),s=h(e.cues,n);return[a,{start:o,end:e.end,cues:s}]}var g=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.get=function(e){for(var t=this._cuesBuffer,n=[],r=t.length-1;r>=0;r--){var i=t[r];if(e=i.start){for(var a=i.cues,o=0;o=a[o].start&&ee){var a=r[i];if(a.start>=n)return;if(a.end>=n){if(e<=a.start)a.cues=h(a.cues,n),a.start=n;else{var o=m(a,e,n),s=o[0],u=o[1];this._cuesBuffer[i]=s,r.splice(i+1,0,u)}return}a.start>=e?(r.splice(i,1),i--):(a.cues=p(a.cues,e),a.end=Math.max(e,a.start))}},t.insert=function(e,t,n){var r=this._cuesBuffer,i={start:t,end:n,cues:e};function a(e){var t=r[e];void 0===t||v(i.end,t.end)?r[e]=i:(t.start>=i.end||(t.cues=h(t.cues,i.end),t.start=i.end),r.splice(e,0,i))}for(var o=0;os.end);return void a(o)}if(ts.end);return void a(o)}if(v(s.end,n))return s.cues=p(s.cues,t),s.end=t,void r.splice(o+1,0,i);if(s.end>n){var u=m(s,t,n),l=u[0],d=u[1];return this._cuesBuffer[o]=l,r.splice(o+1,0,i),void r.splice(o+2,0,d)}s.cues=p(s.cues,t),s.end=t;var c=o+1;for(s=r[c];void 0!==s&&n>s.end;)r.splice(c,1),s=r[c];return void a(c)}}r.push(i)},e}();function y(e,t,n,r){for(var i=[t/n.columns,e/n.rows],a=r.getElementsByClassName("proportional-style"),o=0;o0}var _=i.M4,b=i.bQ,S=i.Q$;function E(e,t){try{e.removeChild(t)}catch(e){a.Z.warn("HTSB: Can't remove text track: not in the element.")}}function T(e){var t=e.getAttribute("data-resolution-rows"),n=e.getAttribute("data-resolution-columns");if(null===t||null===n)return null;var r=parseInt(t,10),i=parseInt(n,10);return null===r||null===i?null:{rows:r,columns:i}}var k=function(e){function t(t,n){var r;return a.Z.debug("HTSB: Creating HTMLTextSegmentBuffer"),(r=e.call(this)||this).bufferType="text",r._buffered=new c.Z,r._videoElement=t,r._textTrackElement=n,r._sizeUpdateCanceller=new l.ZP,r._canceller=new l.ZP,r._buffer=new g,r._currentCues=[],r.autoRefreshSubtitles(r._canceller.signal),r}(0,r.Z)(t,e);var n=t.prototype;return n.declareInitSegment=function(e){a.Z.warn("ISB: Declaring initialization segment for image SegmentBuffer",e)},n.freeInitSegment=function(e){a.Z.warn("ISB: Freeing initialization segment for image SegmentBuffer",e)},n.pushChunk=function(e){try{this.pushChunkSync(e)}catch(e){return Promise.reject(e)}return Promise.resolve()},n.removeBuffer=function(e,t){return this.removeBufferSync(e,t),Promise.resolve()},n.endOfSegment=function(e){return this._segmentInventory.completeSegment(e,this._buffered),Promise.resolve()},n.getBufferedRanges=function(){return this._buffered},n.dispose=function(){a.Z.debug("HTSB: Disposing HTMLTextSegmentBuffer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._canceller.cancel()},n.pushChunkSync=function(e){var t,n;a.Z.debug("HTSB: Appending new html text tracks");var r=e.data,i=r.timestampOffset,o=r.appendWindow,s=r.chunk;if(null!==s){var u,l,d=s.start,c=s.end,v=s.data,p=s.type,h=s.language,m=null!==(t=o[0])&&void 0!==t?t:0,g=null!==(n=o[1])&&void 0!==n?n:1/0,y=function(e,t,n,r){a.Z.debug("HTSB: Finding parser for html text tracks:",e);var i=f.Z.htmlTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");a.Z.debug("HTSB: Parser found, parsing...");var o=i(t,n,r);return a.Z.debug("HTTB: Parsed successfully!",o.length),o}(p,v,i,h);if(0!==m&&g!==1/0){for(var _=0;_=0&&y[_].start>=g;)_--;for(y.splice(_,y.length),_=y.length-1;_>=0&&y[_].end>g;)y[_].end=g,_--}if(void 0!==d)u=Math.max(m,d);else{if(y.length<=0)return void a.Z.warn("HTSB: Current text tracks have no cues nor start time. Aborting");a.Z.warn("HTSB: No start time given. Guessing from cues."),u=y[0].start}if(void 0!==c)l=Math.min(g,c);else{if(y.length<=0)return void a.Z.warn("HTSB: Current text tracks have no cues nor end time. Aborting");a.Z.warn("HTSB: No end time given. Guessing from cues."),l=y[y.length-1].end}l<=u?a.Z.warn("HTSB: Invalid text track appended: ","the start time is inferior or equal to the end time."):(null!==e.inventoryInfos&&this._segmentInventory.insertChunk(e.inventoryInfos),this._buffer.insert(y,u,l),this._buffered.insert(u,l))}},n.removeBufferSync=function(e,t){a.Z.debug("HTSB: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t)},n._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),this._currentCues.length>0){for(var e=0;e0){this._sizeUpdateCanceller=new l.ZP,this._sizeUpdateCanceller.linkToSignal(this._canceller.signal);var c=u.Z.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL,f=function(e,t,n){var r=e.getBoundingClientRect(),i=r.height,u=r.width,l=(0,o.ZP)({height:i,width:u},n),d=i,c=u;if(void 0!==s){var f=new s((function(e){if(0!==e.length){var t=e[0].contentRect,n=t.height,r=t.width;n===d&&r===c||(d=n,c=r,l.setValue({height:n,width:r}))}else a.Z.error("Compat: Resized but no observed element.")}));f.observe(e),n.register((function(){f.disconnect()}))}else{var v=setInterval((function(){var t=e.getBoundingClientRect(),n=t.height,r=t.width;n===d&&r===c||(d=n,c=r,l.setValue({height:n,width:r}))}),t);n.register((function(){clearInterval(v)}))}return l}(this._textTrackElement,c,this._sizeUpdateCanceller.signal);f.onUpdate((function(e){for(var t=e.height,n=e.width,r=0;r0?e.textTracks[o-1]:e.addTextTrack(a)).mode=null!==(t=n.SHOWING)&&void 0!==t?t:"showing"}else r=document.createElement("track"),e.appendChild(r),n=r.track,r.kind=a,n.mode="showing";return{track:n,trackElement:r}}(t),o=r.track,s=r.trackElement;return n.bufferType="text",n._buffered=new u.Z,n._videoElement=t,n._track=o,n._trackElement=s,n}(0,r.Z)(t,e);var n=t.prototype;return n.declareInitSegment=function(e){a.Z.warn("ISB: Declaring initialization segment for image SegmentBuffer",e)},n.freeInitSegment=function(e){a.Z.warn("ISB: Freeing initialization segment for image SegmentBuffer",e)},n.pushChunk=function(e){var t,n;if(a.Z.debug("NTSB: Appending new native text tracks"),null===e.data.chunk)return Promise.resolve();var r=e.data,i=r.timestampOffset,o=r.appendWindow,s=r.chunk,u=s.start,d=s.end,c=s.data,f=s.type,v=s.language,p=null!==(t=o[0])&&void 0!==t?t:0,h=null!==(n=o[1])&&void 0!==n?n:1/0;try{var m,g,y=function(e,t,n,r){a.Z.debug("NTSB: Finding parser for native text tracks:",e);var i=l.Z.nativeTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");a.Z.debug("NTSB: Parser found, parsing...");var o=i(t,n,r);return a.Z.debug("NTSB: Parsed successfully!",o.length),o}(f,c,i,v);if(0!==p&&h!==1/0){for(var _=0;_=0&&y[_].startTime>=h;)_--;for(y.splice(_,y.length),_=y.length-1;_>=0&&y[_].endTime>h;)y[_].endTime=h,_--}if(void 0!==u)m=Math.max(p,u);else{if(y.length<=0)return a.Z.warn("NTSB: Current text tracks have no cues nor start time. Aborting"),Promise.resolve();a.Z.warn("NTSB: No start time given. Guessing from cues."),m=y[0].startTime}if(void 0!==d)g=Math.min(h,d);else{if(y.length<=0)return a.Z.warn("NTSB: Current text tracks have no cues nor end time. Aborting"),Promise.resolve();a.Z.warn("NTSB: No end time given. Guessing from cues."),g=y[y.length-1].endTime}if(g<=m)return a.Z.warn("NTSB: Invalid text track appended: ","the start time is inferior or equal to the end time."),Promise.resolve();if(y.length>0){var b=y[0],S=this._track.cues;null!==S&&S.length>0&&b.startTime=0;i--){var s=r[i],u=s.startTime,l=s.endTime;u>=e&&u<=t&&l<=t&&o(n,s)}this._buffered.remove(e,t)},t}(s.C)},9612:function(e,t,n){"use strict";n.d(t,{C:function(){return _},f:function(){return g}});var r=n(6872),i=n(3887),a=n(520),o=n(5278);function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate 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 n=0,r=new Array(t);n0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){var a=this._history.length-this._maxHistoryLength;this._history=this._history.splice(a)}},e}();function d(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){var _=t[p+y-1];g={end:(0,o.Z)(_.bufferedEnd,_.end),precizeEnd:_.precizeEnd},i.Z.debug("SI: "+y+" segments GCed.",u);for(var b,S=d(t.splice(p,y));!(b=S()).done;){var E=b.value;void 0===E.bufferedStart&&void 0===E.bufferedEnd&&this._bufferedHistory.addBufferedSegment(E.infos,null)}n=p}if(void 0===a)return;if(v-(0,o.Z)(a.bufferedStart,a.start)>=s){if(h(a,f,g,u),n===t.length-1)return void m(a,v,u);a=t[++n];for(var T=(0,o.Z)(a.bufferedStart,a.start),k=(0,o.Z)(a.bufferedEnd,a.end),w=c=s&&(void 0===w||v-T>=k-w);){var A=t[n-1];void 0===A.bufferedEnd&&(A.bufferedEnd=a.precizeStart?a.start:A.end,i.Z.debug("SI: calculating buffered end of contiguous segment",u,A.bufferedEnd,A.end)),a.bufferedStart=A.bufferedEnd,void 0!==(a=t[++n])&&(T=(0,o.Z)(a.bufferedStart,a.start),k=(0,o.Z)(a.bufferedEnd,a.end))}}var I=t[n-1];void 0!==I&&m(I,v,u)}}if(null!=a){i.Z.debug("SI: last segments have been GCed",u,n,t.length);for(var R,Z=d(t.splice(n,t.length-n));!(R=Z()).done;){var x=R.value;void 0===x.bufferedStart&&void 0===x.bufferedEnd&&this._bufferedHistory.addBufferedSegment(x.infos,null)}}void 0!==u&&i.Z.hasLevel("DEBUG")&&i.Z.debug("SI: current "+u+" inventory timeline:\n"+function(e){var t=1/60,n={},r=[],i=null,a=null;function o(e){var t=String.fromCharCode(r.length+65);return r.push({letter:t,periodId:e.period.id,representationId:e.representation.id,bitrate:e.representation.bitrate}),t}for(var s="",u=0;u=u)i.Z.warn("SI: Invalid chunked inserted: starts before it ends",l,s,u);else{for(var d=this._inventory,c={partiallyPushed:!0,chunkSize:o,splitted:!1,start:s,end:u,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:a,period:t,adaptation:n,representation:r}},f=d.length-1;f>=0;f--){var v=d[f];if(v.start<=s){if(v.end<=s){for(i.Z.debug("SI: Pushing segment strictly after previous one.",l,s,v.end),this._inventory.splice(f+1,0,c),f+=2;fc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[f].start),d[f].start=c.end,d[f].bufferedStart=void 0,void(d[f].precizeStart=d[f].precizeStart&&c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[f].start,d[f].end),d.splice(f,1)}return}if(v.start===s){if(v.end<=u){for(i.Z.debug("SI: Segment pushed replace another one",l,s,u,v.end),this._inventory.splice(f,1,c),f+=1;fc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[f].start),d[f].start=c.end,d[f].bufferedStart=void 0,void(d[f].precizeStart=d[f].precizeStart&&c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[f].start,d[f].end),d.splice(f,1)}return}return i.Z.debug("SI: Segment pushed ends before another with the same start",l,s,u,v.end),d.splice(f,0,c),v.start=c.end,v.bufferedStart=void 0,void(v.precizeStart=v.precizeStart&&c.precizeEnd)}if(v.end<=c.end){for(i.Z.debug("SI: Segment pushed updates end of previous one",l,s,u,v.start,v.end),this._inventory.splice(f+1,0,c),v.end=c.start,v.bufferedEnd=void 0,v.precizeEnd=v.precizeEnd&&c.precizeStart,f+=2;fc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[f].start),d[f].start=c.end,d[f].bufferedStart=void 0,void(d[f].precizeStart=d[f].precizeStart&&c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[f].start,d[f].end),d.splice(f,1)}return}i.Z.warn("SI: Segment pushed is contained in a previous one",l,s,u,v.start,v.end);var p={partiallyPushed:v.partiallyPushed,chunkSize:v.chunkSize,splitted:!0,start:c.end,end:v.end,precizeStart:v.precizeStart&&v.precizeEnd&&c.precizeEnd,precizeEnd:v.precizeEnd,bufferedStart:void 0,bufferedEnd:v.end,infos:v.infos};return v.end=c.start,v.splitted=!0,v.bufferedEnd=void 0,v.precizeEnd=v.precizeEnd&&c.precizeStart,d.splice(f+1,0,c),void d.splice(f+2,0,p)}}var h=this._inventory[0];if(void 0===h)return i.Z.debug("SI: first segment pushed",l,s,u),void this._inventory.push(c);if(!(h.start>=u)){if(h.end<=u){for(i.Z.debug("SI: Segment pushed starts before and completely recovers the previous first one",l,s,u,h.start,h.end),this._inventory.splice(0,1,c);d.length>1&&d[1].startc.end)return i.Z.debug("SI: Segment pushed updates the start of the next one",l,c.end,d[1].start),d[1].start=c.end,d[1].bufferedStart=void 0,void(d[1].precizeStart=c.precizeEnd);i.Z.debug("SI: Segment pushed removes the next one",l,s,u,d[1].start,d[1].end),d.splice(1,1)}return}return i.Z.debug("SI: Segment pushed start of the next one",l,s,u,h.start,h.end),h.start=u,h.bufferedStart=void 0,h.precizeStart=c.precizeEnd,void this._inventory.splice(0,0,c)}i.Z.debug("SI: Segment pushed comes before all previous ones",l,s,u,h.start),this._inventory.splice(0,0,c)}}},t.completeSegment=function(e,t){if(!e.segment.isInit){for(var n=this._inventory,r=[],o=0;o0&&(s=!0,1===r.length&&(i.Z.warn("SI: Completed Segment is splitted.",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));var u=o,l=n[o].chunkSize;for(o+=1;o0&&(this._inventory.splice(u+1,v),o-=v),this._inventory[u].partiallyPushed=!1,this._inventory[u].chunkSize=l,this._inventory[u].end=p,this._inventory[u].bufferedEnd=h,this._inventory[u].splitted=s,r.push(this._inventory[u])}if(0===r.length)i.Z.warn("SI: Completed Segment not found",e.segment.id,e.segment.time);else{this.synchronizeBuffered(t);for(var m,g=d(r);!(m=g()).done;){var y=m.value;void 0!==y.bufferedStart&&void 0!==y.bufferedEnd?this._bufferedHistory.addBufferedSegment(y.infos,{start:y.bufferedStart,end:y.bufferedEnd}):i.Z.debug("SI: buffered range not known after sync. Skipping history.",y.start,y.end)}}}},t.getInventory=function(){return this._inventory},t.getHistoryFor=function(e){return this._bufferedHistory.getHistoryFor(e)},e}();function v(e){if(void 0===e.bufferedStart||e.partiallyPushed)return!1;var t=e.start,n=e.end-t,i=r.Z.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(t-e.bufferedStart)<=a&&(void 0===e.bufferedEnd||e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-n)<=Math.min(o,n/3))}function p(e){if(void 0===e.bufferedEnd||e.partiallyPushed)return!1;var t=e.start,n=e.end,i=n-t,a=r.Z.getCurrent(),o=a.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,s=a.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(n-e.bufferedEnd)<=o&&null!=e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-i)<=Math.min(s,i/3)}function h(e,t,n,a){var o=r.Z.getCurrent().MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE;void 0!==e.bufferedStart?(e.bufferedStartt&&(n.precizeEnd||e.start-n.end<=o)?(i.Z.debug("SI: buffered start is end of previous segment",a,t,e.start,n.end),e.bufferedStart=n.end,v(e)&&(e.start=n.end,e.precizeStart=!0)):e.start-t<=o?(i.Z.debug("SI: found true buffered start",a,t,e.start),e.bufferedStart=t,v(e)&&(e.start=t,e.precizeStart=!0)):tt&&(i.Z.debug("SI: Segment partially GCed at the end",n,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=a&&p(e)&&(e.precizeEnd=!0,e.end=t)):e.precizeEnd?(i.Z.debug("SI: buffered end is precize end",n,e.end),e.bufferedEnd=e.end):t-e.end<=a?(i.Z.debug("SI: found true buffered end",n,t,e.end),e.bufferedEnd=t,p(e)&&(e.end=t,e.precizeEnd=!0)):t>e.end?(i.Z.debug("SI: range end too far from expected end",n,t,e.end),e.bufferedEnd=e.end):(i.Z.debug("SI: Segment appears immediately garbage collected at the end",n,e.bufferedEnd,t),e.bufferedEnd=t)}var g,y=f,_=function(){function e(){this._segmentInventory=new y}var t=e.prototype;return t.synchronizeInventory=function(){this._segmentInventory.synchronizeBuffered(this.getBufferedRanges())},t.getInventory=function(){return this._segmentInventory.getInventory()},t.getPendingOperations=function(){return[]},t.getSegmentHistory=function(e){return this._segmentInventory.getHistoryFor(e)},e}();!function(e){e[e.Push=0]="Push",e[e.Remove=1]="Remove",e[e.EndOfSegment=2]="EndOfSegment"}(g||(g={}))},4309:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(2829),i=function(){function e(){this._ranges=[],this.length=0}var t=e.prototype;return t.insert=function(e,t){(0,r.kR)(this._ranges,{start:e,end:t}),this.length=this._ranges.length},t.remove=function(e,t){var n=[];e>0&&n.push({start:0,end:e}),t<1/0&&n.push({start:t,end:1/0}),this._ranges=(0,r.tn)(this._ranges,n),this.length=this._ranges.length},t.start=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}()},7839:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(7326),i=n(4578),a=function(e){function t(n,i,a){var o;return o=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(o),t.prototype),o.name="CustomLoaderError",o.message=n,o.canRetry=i,o.xhr=a,o}return(0,i.Z)(t,e),t}((0,n(2146).Z)(Error))},5157:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i,a){var u;return u=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(u),t.prototype),u.name="EncryptedMediaError",u.type=o.ZB.ENCRYPTED_MEDIA_ERROR,u.code=n,u.message=(0,s.Z)(u.name,u.code,i),u.fatal=!1,"string"==typeof(null==a?void 0:a.keyStatuses)&&(u.keyStatuses=a.keyStatuses),u}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},5992:function(e,t,n){"use strict";n.d(t,{SM:function(){return a},ZB:function(){return r},br:function(){return i}});var r={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},i={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},a={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"}},7367:function(e,t,n){"use strict";function r(e,t,n){return e+" ("+t+") "+n}n.d(t,{Z:function(){return r}})},8750:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(9822),i=n(5389);function a(e,t){var n=t.defaultCode,a=t.defaultReason;if((0,r.Z)(e))return e;var o=e instanceof Error?e.toString():a;return new i.Z(n,o)}},9822:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(5157),i=n(5992),a=n(3714),o=n(9362),s=n(5389);function u(e){return(e instanceof r.Z||e instanceof a.Z||e instanceof s.Z||e instanceof o.Z)&&Object.keys(i.ZB).indexOf(e.type)>=0}},3714:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i,a){var u;u=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(u),t.prototype),u.name="MediaError",u.type=o.ZB.MEDIA_ERROR,u.code=n,u.message=(0,s.Z)(u.name,u.code,i),u.fatal=!1;var l=null==a?void 0:a.adaptation;if(void 0!==l)switch(l.type){case"audio":u.trackInfo={type:"audio",track:l.toAudioTrack(!1)};break;case"video":u.trackInfo={type:"video",track:l.toVideoTrack(!1)};break;case"text":u.trackInfo={type:"text",track:l.toTextTrack()}}return u}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},9362:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i){var a;return a=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(a),t.prototype),a.name="NetworkError",a.type=o.ZB.NETWORK_ERROR,a.url=i.url,a.status=i.status,a.errorType=i.type,a.code=n,a.message=(0,s.Z)(a.name,a.code,i.message),a.fatal=!1,a}return(0,i.Z)(t,e),t.prototype.isHttpError=function(e){return this.errorType===o.br.ERROR_HTTP_CODE&&this.status===e},t}((0,a.Z)(Error))},5389:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(7326),i=n(4578),a=n(2146),o=n(5992),s=n(7367),u=function(e){function t(n,i){var a;return a=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(a),t.prototype),a.name="OtherError",a.type=o.ZB.OTHER_ERROR,a.code=n,a.message=(0,s.Z)(a.name,a.code,i),a.fatal=!1,a}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},9105:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(7326),i=n(4578),a=function(e){function t(n,i,a){var o;return o=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(o),t.prototype),o.name="RequestError",o.url=n,o.status=i,o.type=a,o.message=a,o}return(0,i.Z)(t,e),t}((0,n(2146).Z)(Error))},7273:function(e,t){"use strict";t.Z={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,ContentDecryptor:null,htmlTextTracksBuffer:null,htmlTextTracksParsers:{},nativeTextTracksBuffer:null,nativeTextTracksParsers:{},transports:{}}},7874:function(e,t,n){"use strict";var r=n(7273);t.Z=r.Z},3887:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(8894),i=new(function(){function e(){this.error=r.Z,this.warn=r.Z,this.info=r.Z,this.debug=r.Z,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentLevel="NONE"}var t=e.prototype;return t.setLevel=function(e){var t,n=this._levels[e];"number"==typeof n?(t=n,this._currentLevel=e):(t=0,this._currentLevel="NONE"),this.error=t>=this._levels.ERROR?console.error.bind(console):r.Z,this.warn=t>=this._levels.WARNING?console.warn.bind(console):r.Z,this.info=t>=this._levels.INFO?console.info.bind(console):r.Z,this.debug=t>=this._levels.DEBUG?console.log.bind(console):r.Z},t.getLevel=function(){return this._currentLevel},t.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},e}())},9665:function(e,t,n){"use strict";n.d(t,{r:function(){return v},Z:function(){return p}});var r=n(3887),i=n(3274),a=n(1946),o=n(5288),s=n(3774);var u=n(4791);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(this.trickModeTracks=i.map((function(t){return new e(t)})));for(var d=t.representations,c=[],v=!1,p=0;p0&&!r.isSupported){var i=new d.Z("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{adaptation:r});n.contentWarnings.push(i)}return r})).filter((function(e){return e.representations.length>0}));if(o.every((function(e){return!e.isSupported}))&&a.length>0&&("video"===i||"audio"===i))throw new d.Z("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+i+" adaptations",{adaptation:void 0});return o.length>0&&(r[i]=o),r}),{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new d.Z("MANIFEST_PARSE_ERROR","No supported audio and video tracks.");this.duration=e.duration,this.start=e.start,null!=this.duration&&null!=this.start&&(this.end=this.start+this.duration),this.streamEvents=void 0===e.streamEvents?[]:e.streamEvents}var t=e.prototype;return t.getAdaptations=function(){var e=this.adaptations;return(0,c.Z)(e).reduce((function(e,t){return null!=t?e.concat(t):e}),[])},t.getAdaptationsForType=function(e){var t=this.adaptations[e];return null==t?[]:t},t.getAdaptation=function(e){return(0,o.Z)(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},t.getSupportedAdaptations=function(e){if(void 0===e)return this.getAdaptations().filter((function(e){return e.isSupported}));var t=this.adaptations[e];return void 0===t?[]:t.filter((function(e){return e.isSupported}))},t.containsTime=function(e){return e>=this.start&&(void 0===this.end||e=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0)a.Z.warn("Manifest: "+y.length+" new Representations found when merging."),(m=t.representations).push.apply(m,y),v.push.apply(v,y)}l=e},l=0;l0){a.Z.warn("Manifest: "+s.length+" new Adaptations found when merging.");for(var d,c=h(s);!(d=c()).done;){var f=d.value,v=e.adaptations[f.type];void 0===v?e.adaptations[f.type]=[f]:v.push(f),i.addedAdaptations.push(f)}}return i}function y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=t.start&&(void 0===t.end||t.end>e)}))},n.getNextPeriod=function(e){return(0,o.Z)(this.periods,(function(t){return t.start>e}))},n.getPeriodAfter=function(e){var t=e.end;if(void 0===t)return null;var n=(0,o.Z)(this.periods,(function(e){return void 0===e.end||t0&&this.trigger("decipherabilityUpdate",t)},n.getAdaptations=function(){(0,l.Z)("manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead");var e=this.periods[0];if(void 0===e)return[];var t=e.adaptations,n=[];for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];n.push.apply(n,i)}return n},n.getAdaptationsForType=function(e){(0,l.Z)("manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead");var t=this.periods[0];if(void 0===t)return[];var n=t.adaptations[e];return void 0===n?[]:n},n.getAdaptation=function(e){return(0,l.Z)("manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead"),(0,o.Z)(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n._performUpdate=function(e,t){var n;if(this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.contentWarnings=e.contentWarnings,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime,t===r.Full)this._timeBounds=e._timeBounds,this.uris=e.uris,n=function(e,t){for(var n={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},i=0,o=0;oe.length)return a.Z.error("Manifest: error when updating Periods"),n;if(i0&&(e.push.apply(e,b),(_=n.addedPeriods).push.apply(_,b)),n}(this.periods,e.periods);else{this._timeBounds.maximumTimeData=e._timeBounds.maximumTimeData,this.updateUrl=e.uris[0],n=function(e,t){var n,i={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(0===e.length)return e.splice.apply(e,[0,0].concat(t)),(n=i.addedPeriods).push.apply(n,t),i;if(0===t.length)return i;var o=e[e.length-1];if(o.startc){var T;a.Z.warn("Manifest: old Periods not found in new when updating, removing");var k=e.splice(c,h-c);(T=i.removedPeriods).push.apply(T,k),h=c}var w=g(e[h],v,r.Full);i.updatedPeriods.push({period:e[h],result:w})}c++}if(c0;){var o=this.periods[0];if(void 0===o.end||o.end>i)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",n)},t}(s.Z);var E=S},520:function(e,t,n){"use strict";n.d(t,{K:function(){return a},z:function(){return i}});var r=n(1946);function i(e,t){return e.segment.id===t.segment.id&&e.representation.uniqueId===t.representation.uniqueId}function a(e){if((0,r.Z)(e))return"";var t=e.period,n=e.adaptation,i=e.representation,a=e.segment;return n.type+" P: "+t.id+" A: "+n.id+" R: "+i.id+" S: "+(a.isInit?"init":a.complete?a.time+"-"+a.duration:""+a.time)}},2689:function(e,t,n){"use strict";n.d(t,{s:function(){return r}});var r=Math.pow(2,32)-1},2297:function(e,t,n){"use strict";n.d(t,{Qy:function(){return f},Xj:function(){return p},iz:function(){return c},lp:function(){return d},nR:function(){return v},t_:function(){return l},vA:function(){return u}});var r=n(3887),i=n(811),a=n(6968);function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ni)return null;s=(0,a.pV)(e,r),r+=8}if(s<0)throw new Error("ISOBMFF: Size out of range");if(n===t)return 1970628964===t&&(r+=16),[o,r,o+s];o+=s}return null}function v(e,t,n,r,i){for(var o,s=e.length,u=0;us)return;o=(0,a.pV)(e,l),l+=8}if(1970628964===d&&l+16<=s&&(0,a.pX)(e,l)===t&&(0,a.pX)(e,l+4)===n&&(0,a.pX)(e,l+8)===r&&(0,a.pX)(e,l+12)===i)return l+=16,e.subarray(l,u+o)}}function p(e){var t=e.length;if(t<8)return r.Z.warn("ISOBMFF: box inferior to 8 bytes, cannot find offsets"),null;var n=0,i=(0,a.pX)(e,n);n+=4;var o=(0,a.pX)(e,n);if(n+=4,0===i)i=t;else if(1===i){if(n+8>t)return r.Z.warn("ISOBMFF: box too short, cannot find offsets"),null;i=(0,a.pV)(e,n),n+=8}if(i<0)throw new Error("ISOBMFF: Size out of range");return 1970628964===o&&(n+=16),[0,n,i]}},6807:function(e,t,n){"use strict";n.d(t,{E3:function(){return u},Le:function(){return o},XA:function(){return i},fs:function(){return s},uq:function(){return a}});var r=n(2297);function i(e){var t=(0,r.t_)(e,1836019558);return null===t?null:(0,r.t_)(t,1953653094)}function a(e){return(0,r.lp)(e,1836019558).reduce((function(e,t){var n=(0,r.t_)(t,1953653094);return null!==n&&e.push(n),e}),[])}function o(e){return(0,r.t_)(e,1835295092)}function s(e){var t=(0,r.t_)(e,1836019574);if(null===t)return null;var n=(0,r.t_)(t,1953653099);return null===n?null:(0,r.t_)(n,1835297121)}function u(e,t){return void 0===t&&(t=0),(0,r.t_)(e.subarray(t),1701671783)}},6490:function(e,t,n){"use strict";n.d(t,{Z:function(){return s},Y:function(){return u}});var r=n(3887);var i="function"==typeof Uint8Array.prototype.slice?function(e,t,n){return e.slice(t,n)}:function(e,t,n){return new Uint8Array(Array.prototype.slice.call(e,t,n))},a=n(3635),o=n(2297);function s(e){var t=0,n=(0,o.t_)(e,1836019574);if(null===n)return[];for(var a=[];t1)r.Z.warn("ISOBMFF: un-handled PSSH version");else{var n=t+4;if(!(n+16>e.length)){var o=i(e,n,n+16);return(0,a.ci)(o)}}}},4644:function(e,t,n){"use strict";n.d(t,{J6:function(){return m},LD:function(){return h},MM:function(){return p},Qx:function(){return f},R0:function(){return y},Wf:function(){return c},s9:function(){return g}});var r=n(3887),i=n(6968),a=n(3635),o=n(2689),s=n(2297),u=n(6807);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0;){var v=(0,i.pX)(e,o);o+=4;var p=2147483647&v;if(1===(2147483648&v)>>>31)throw new Error("sidx with reference_type `1` not yet implemented");var h=(0,i.pX)(e,o);o+=4,o+=4,c.push({time:l,duration:h,timescale:d,range:[r,r+p-1]}),l+=h,r+=p}return c}function f(e){var t=(0,u.XA)(e);if(null!==t){var n=(0,s.t_)(t,1952867444);if(null!==n){var r=n[0];return 1===r?(0,i.pV)(n,4):0===r?(0,i.pX)(n,4):void 0}}}function v(e){var t=(0,s.t_)(e,1952868452);if(null!==t){var n=1,r=(0,i.QI)(t,n);if(n+=3,(8&r)>0)return n+=4,(1&r)>0&&(n+=8),(2&r)>0&&(n+=4),(0,i.pX)(t,n)}}function p(e){var t=(0,u.uq)(e);if(0!==t.length){for(var n,r=0,a=l(t);!(n=a()).done;){var o=n.value,d=(0,s.t_)(o,1953658222);if(null===d)return;var c=0,f=d[c];if(c+=1,f>1)return;var p=(0,i.QI)(d,c);c+=3;var h=(256&p)>0,m=0;if(!h&&void 0===(m=v(o)))return;var g=(1&p)>0,y=(4&p)>0,_=(512&p)>0,b=(1024&p)>0,S=(2048&p)>0,E=(0,i.pX)(d,c);c+=4,g&&(c+=4),y&&(c+=4);for(var T=E,k=0;T-- >0;)h?(k+=(0,i.pX)(d,c),c+=4):k+=m,_&&(c+=4),b&&(c+=4),S&&(c+=4);r+=k}return r}}function h(e){var t=(0,u.fs)(e);if(null!==t){var n=(0,s.t_)(t,1835296868);if(null!==n){var r=0,a=n[r];return r+=4,1===a?(0,i.pX)(n,r+16):0===a?(0,i.pX)(n,r+8):void 0}}}function m(e){var t=e.length;if(t<4)throw new Error("Cannot update box length: box too short");var n=(0,i.pX)(e,0);if(0===n){if(t>o.s){var r=new Uint8Array(t+8);return r.set((0,i.kh)(1),0),r.set(e.subarray(4,8),4),r.set((0,i.el)(t+8),8),r.set(e.subarray(8,t),16),r}return e.set((0,i.kh)(t),0),e}if(1===n){if(t<16)throw new Error("Cannot update box length: box too short");return e.set((0,i.el)(t),8),e}if(t<=o.s)return e.set((0,i.kh)(t),0),e;var a=new Uint8Array(t+8);return a.set((0,i.kh)(1),0),a.set(e.subarray(4,8),4),a.set((0,i.el)(t+8),8),a.set(e.subarray(8,t),16),a}function g(e){for(var t=[],n=0;n=0;t--){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,s=null;if(void 0!==r){var u=d(r);if(void 0===u)return{safe:void 0,unsafe:void 0};a=u}if(void 0!==i){var l=d(i);if(void 0===l)return{safe:void 0,unsafe:void 0};s=l}if(void 0!==r&&null===a||void 0!==i&&null===s)return o.Z.info("Parser utils: found Period with no segment. ","Going to previous one to calculate last position"),{safe:void 0,unsafe:void 0};if(null!==s)return null!==a?{safe:Math.min(a,s),unsafe:Math.max(a,s)}:{safe:s,unsafe:s};if(null!==a)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}(e);return{minimumSafePosition:t,maximumSafePosition:n.safe,maximumUnsafePosition:n.unsafe}}var v=n(9592),p=n(908),h=n(1679),m=n(3635);var g=function(){function e(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=e.isDynamic&&void 0!==e.timeShiftBufferDepth?e.timeShiftBufferDepth:null}var t=e.prototype;return t.setLastPosition=function(e,t){this._lastPosition=e,this._positionTime=t},t.lastPositionIsKnown=function(){return this._isDynamic?null!=this._positionTime&&null!=this._lastPosition:null!=this._lastPosition},t.estimateMinimumBound=function(){if(!this._isDynamic||null===this._timeShiftBufferDepth)return 0;var e=this.estimateMaximumBound();return void 0!==e?e-this._timeShiftBufferDepth:void 0},t.estimateMaximumBound=function(){return this._isDynamic&&null!=this._positionTime&&null!=this._lastPosition?Math.max(this._lastPosition-this._positionTime+performance.now()/1e3,0):this._lastPosition},e}(),y=n(9665),_=n(5138),b=n(7714),S=n(6923);function E(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=a?o:(new Array(a+1).join("0")+o).slice(-a)}}function P(e,t,n){return function(e,t,n){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,x(void 0===n?0:n))}(e,t,n)}function M(e,t){return function(n){return-1===n.indexOf("$")?n:n.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,(function(e,n,r){if(void 0===t)throw new Error("Segment number not defined in a $Number$ scheme");return x(t)(e,n,r)})).replace(/\$Time(\%0(\d+)d)?\$/g,(function(t,n,r){if(void 0===e)throw new Error("Segment time not defined in a $Time$ scheme");return x(e)(t,n,r)}))}}function C(e,t,n,r,i){for(var a,o,s=(0,R.gT)(t,e),u=(0,R.gT)(t+n,e),l=e.timeline,d=e.timescale,c=e.segmentUrlTemplate,f=e.startNumber,v=e.endNumber,p=null!=f?f:1,h=[],m=l.length,g=0;g0?Math.floor(o/a):0),w=b+k*_;wv)break;var I=null===c?null:M(w,A)(c),Z=w-e.indexTimeOffset,x=_;Z<0&&(x=_+Z,Z=0);var P={id:String(w),time:Z/d,end:(Z+x)/d,duration:x/d,isInit:!1,range:S,timescale:1,url:I,number:A,timestampOffset:-e.indexTimeOffset/d,complete:T,privateInfos:{isEMSGWhitelisted:r}};h.push(P),w=b+ ++k*_}if(w>=u)return h;if(p+=E+1,void 0!==v&&p>v)return h}return h}function D(e,t){if(t.timescale!==e.timescale){var n=e.timescale;e.timeline.push({start:t.time/t.timescale*n,duration:t.duration/t.timescale*n,repeatCount:void 0===t.count?0:t.count,range:t.range})}else e.timeline.push({start:t.time,duration:t.duration,repeatCount:void 0===t.count?0:t.count,range:t.range});return!0}var N=function(){function e(e,t){var n,r,i,a=t.periodStart,o=t.periodEnd,s=t.representationId,u=t.representationBitrate,l=t.isEMSGWhitelisted,d=null!==(n=e.timescale)&&void 0!==n?n:1,c=(null!=e.presentationTimeOffset?e.presentationTimeOffset:0)-a*d,f=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:P(e.initialization.media,s,u),v=void 0===e.media?null:P(e.media,s,u),p=void 0!==e.initialization?e.initialization.range:void 0!==e.indexRange?[0,e.indexRange[0]-1]:void 0;this._index={indexRange:e.indexRange,indexTimeOffset:c,initialization:{url:f,range:p},segmentUrlTemplate:v,startNumber:e.startNumber,endNumber:e.endNumber,timeline:null!==(i=e.timeline)&&void 0!==i?i:[],timescale:d},this._scaledPeriodStart=(0,R.gT)(a,this._index),this._scaledPeriodEnd=null==o?void 0:(0,R.gT)(o,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=l}var t=e.prototype;return t.getInitSegment=function(){return Z(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){return C(this._index,e,t,this._isEMSGWhitelisted,this._scaledPeriodEnd)},t.shouldRefresh=function(){return!1},t.getFirstAvailablePosition=function(){var e=this._index;return 0===e.timeline.length?null:(0,R.zG)(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)},t.getLastAvailablePosition=function(){var e,t=this._index.timeline;if(0===t.length)return null;var n=t[t.length-1],r=Math.min((0,R.jH)(n,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0);return(0,R.zG)(r,this._index)},t.getEnd=function(){return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(){return!1},t.isSegmentStillAvailable=function(){return!0},t.checkDiscontinuity=function(){return null},t.canBeOutOfSyncError=function(){return!1},t.isFinished=function(){return!0},t.isInitialized=function(){return this._isInitialized},t.initialize=function(e){if(!this._isInitialized){for(var t=0;t0){var s=i-a.start;if(s%a.duration==0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(++o>=e.length)return null;if((a=e[o]).start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}else for(var u=0,l=t[0],d=i;;){var c=l.getAttribute("d"),f=null===c?null:parseInt(c,10);if(null===f||Number.isNaN(f))return null;var v=l.getAttribute("r"),p=null===v?null:parseInt(v,10);if(null!==p){if(Number.isNaN(p)||p<0)return null;if(p>0){var h=n-d;if(h%f==0&&h/f<=p)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:u}}d+=f*(p+1)}else d+=f;if(++u>=t.length)return null;var m=(l=t[u]).getAttribute("t"),g=null===m?null:parseInt(m,10);if(null!==g){if(Number.isNaN(g))return null;d=g}if(d===n)return{newElementsIdx:u,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(d>i)return null}}(t,e);if(null===r)return o.Z.warn('DASH: Cannot perform "based" update. Common segment not found.'),j(e);var i=r.prevSegmentsIdx,a=r.newElementsIdx,s=r.repeatNumberInPrevSegments,u=r.repeatNumberInNewElements,l=t.length-i+a-1;if(l>=e.length)return o.Z.info('DASH: Cannot perform "based" update. New timeline too short'),j(e);var d=t.slice(i);if(s>0){var c=d[0];c.start+=c.duration*s,d[0].repeatCount-=s}if(u>0&&0!==a)return o.Z.info('DASH: Cannot perform "based" update. The new timeline has a different form.'),j(e);var f=d[d.length-1],v=G(e[l]),p=(null!==(n=v.repeatCount)&&void 0!==n?n:0)-u;if(v.duration!==f.duration||f.repeatCount>p)return o.Z.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),j(e);void 0!==v.repeatCount&&v.repeatCount>f.repeatCount&&(f.repeatCount=v.repeatCount);for(var h=[],m=[],g=l+1;g0){var s=i[i.length-1];if((0,R.jH)(s,null,this._scaledPeriodEnd)+a>=Math.min(o,null!==(n=this._scaledPeriodEnd)&&void 0!==n?n:1/0))return!1}return void 0===this._scaledPeriodEnd?o+a>this._scaledPeriodStart&&void 0:(0,R.gT)(e,this._index)-athis._scaledPeriodStart},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index,n=t.timeline,r=t.timescale,i=t.indexTimeOffset;return(0,F.Z)(e,n,r,i)},t.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),(0,R._j)({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},t.canBeOutOfSyncError=function(e){return!!this._isDynamic&&(e instanceof L.Z&&e.isHttpError(404))},t._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},t._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),(0,z.Z)(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},t.isFinished=function(){if(!this._isDynamic||!this._isLastPeriod)return!0;null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;if(void 0===this._scaledPeriodEnd||0===e.length)return!1;var t=e[e.length-1];return(0,R.jH)(t,null,this._scaledPeriodEnd)+V(this._index.timescale)>=this._scaledPeriodEnd},t.isInitialized=function(){return!0},t.initialize=function(){o.Z.error("A `TimelineRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){o.Z.warn("Cannot add predicted segments to a `TimelineRepresentationIndex`")},e.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},t._refreshTimeline=function(){if(null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic){var e=this._manifestBoundsCalculator.estimateMinimumBound();if(null!=e){var t=(0,R.gT)(e,this._index),n=(0,B.Z)(this._index.timeline,t);void 0!==this._index.startNumber?this._index.startNumber+=n:void 0!==this._index.endNumber&&(this._index.startNumber=n+1)}}},e.getIndexEnd=function(e,t){return e.length<=0?null:Math.min((0,R.jH)(e[e.length-1],null,t),null!=t?t:1/0)},t._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(o.Z.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,n=a.Z.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.lengthn){if(r===n+1)return e.slice(0,i+1);var o=e.slice(0,i),s=Object.assign({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,n-u),o.push(s),o}}return e}var Y=W,X=function(){function e(e,t){var n,r,i=t.availabilityTimeOffset,a=t.manifestBoundsCalculator,o=t.isDynamic,s=t.periodEnd,u=t.periodStart,l=t.representationId,d=t.representationBitrate,c=t.isEMSGWhitelisted,f=null!==(n=e.timescale)&&void 0!==n?n:1;this._availabilityTimeOffset=i,this._manifestBoundsCalculator=a;var v=null!=e.presentationTimeOffset?e.presentationTimeOffset:0,p=v-u*f;if(void 0===e.duration)throw new Error("Invalid SegmentTemplate: no duration");var h=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:P(e.initialization.media,l,d),m=void 0===e.media?null:P(e.media,l,d);this._index={duration:e.duration,timescale:f,indexRange:e.indexRange,indexTimeOffset:p,initialization:null==e.initialization?void 0:{url:h,range:e.initialization.range},url:m,presentationTimeOffset:v,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=o,this._periodStart=u,this._scaledRelativePeriodEnd=void 0===s?void 0:(s-u)*f,this._isEMSGWhitelisted=c}var t=e.prototype;return t.getInitSegment=function(){return Z(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){var n=this._index,r=n.duration,i=n.startNumber,a=n.endNumber,o=n.timescale,s=n.url,u=this._periodStart*o,l=this._scaledRelativePeriodEnd,d=e*o-u,c=(e+t)*o-u,f=this._getFirstSegmentStart(),v=this._getLastSegmentStart();if(null==f||null==v)return[];var p=Math.max(f,d),h=Math.min(v,c);if(h+r<=p)return[];for(var m=[],g=null!=i?i:1,y=Math.floor(p/r),_=y*r;_<=h;_+=r){var b=y+g;if(void 0!==a&&b>a)return m;var S=null!=l&&_+r>l?l-_:r,E=_+u,T=_+this._index.presentationTimeOffset,k=null===s?null:M(T,b)(s),w={id:String(b),number:b,time:E/o,end:(E+S)/o,duration:S/o,timescale:1,isInit:!1,scaledDuration:S/o,url:k,timestampOffset:-n.indexTimeOffset/o,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(w),y++}return m},t.getFirstAvailablePosition=function(){var e=this._getFirstSegmentStart();return null==e?e:e/this._index.timescale+this._periodStart},t.getLastAvailablePosition=function(){var e=this._getLastSegmentStart();if((0,i.Z)(e))return e;var t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,null!=t?t:1/0)/this._index.timescale+this._periodStart},t.getEnd=function(){if(!this._isDynamic)return this.getLastAvailablePosition();var e=this._estimateRelativeScaledEnd();if(void 0!==e){var t=this._index.timescale;return(e+this._periodStart*t)/t}},t.awaitSegmentBetween=function(e,t){if((0,U.Z)(e<=t),!this._isDynamic)return!1;var n=this._index.timescale,r=V(n),i=this._periodStart*n,a=t*n-i,o=this._estimateRelativeScaledEnd();return void 0===o?a+r>=0:e*n-i-r=e},t.isInitialized=function(){return!0},t.initialize=function(){o.Z.error("A `TemplateRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){o.Z.warn("Cannot add predicted segments to a `TemplateRepresentationIndex`")},t._replace=function(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator},t._update=function(e){this._replace(e)},t._getFirstSegmentStart=function(){if(!this._isDynamic)return 0;if(0===this._scaledRelativePeriodEnd||void 0===this._scaledRelativePeriodEnd){var e=this._manifestBoundsCalculator.estimateMaximumBound();if(void 0!==e&&ethis._periodStart?(i-this._periodStart)*r:0;return Math.floor(a/n)*n}},t._getLastSegmentStart=function(){var e,t=this._index,n=t.duration,r=t.timescale,i=t.endNumber,o=t.startNumber,s=void 0===o?1:o;if(this._isDynamic){var u=this._manifestBoundsCalculator.estimateMaximumBound();if(void 0===u)return;if(void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<(u-this._periodStart)*this._index.timescale){var l=Math.ceil(this._scaledRelativePeriodEnd/n);return void 0!==i&&i-s+1m||p<2?h:(p-2)*n},t._estimateRelativeScaledEnd=function(){var e,t;if(void 0!==this._index.endNumber){var n=this._index.endNumber-(null!==(e=this._index.startNumber)&&void 0!==e?e:1)+1;return Math.max(Math.min(n*this._index.duration,null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:1/0),0)}if(void 0!==this._scaledRelativePeriodEnd)return Math.max(this._scaledRelativePeriodEnd,0)},e}();function Q(e,t){var n;if(0===t.length)return e;var r=t.map((function(e){return{url:e.value}}));if(0===e.length)return r;for(var i=[],a=0;a=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){var g=t.parentSegmentTemplates.slice(),y=e.children.segmentTemplate;void 0!==y&&g.push(y);var _=I.Z.apply(void 0,[{}].concat(g));p.availabilityTimeComplete=null!==(n=_.availabilityTimeComplete)&&void 0!==n?n:t.availabilityTimeComplete,p.availabilityTimeOffset=(null!==(r=_.availabilityTimeOffset)&&void 0!==r?r:0)+t.availabilityTimeOffset,i=Y.isTimelineIndexArgument(_)?new Y(_,p):new X(_,p)}else{var b=t.adaptation.children;if(void 0!==b.segmentBase){var S=b.segmentBase;i=new N(S,p)}else if(void 0!==b.segmentList){var E=b.segmentList;i=new O(E,p)}else i=new X({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:""},p)}return i}(e,(0,I.Z)({},n,{availabilityTimeOffset:m,availabilityTimeComplete:h,unsafelyBaseOnPreviousRepresentation:v,adaptation:t,inbandEventStreams:p}));null==e.attributes.bitrate?(o.Z.warn("DASH: No usable bitrate found in the Representation."),f=0):f=e.attributes.bitrate;var y,_=Q(n.baseURLs,e.children.baseURLs),b={bitrate:f,cdnMetadata:0===_.length?[{baseUrl:"",id:void 0}]:_.map((function(e){return{baseUrl:e.url,id:e.serviceLocation}})),index:g,id:c};null!=e.attributes.codecs?y=e.attributes.codecs:null!=t.attributes.codecs&&(y=t.attributes.codecs),null!=y&&(y="mp4a.40.02"===y?"mp4a.40.2":y,b.codecs=y),null!=e.attributes.frameRate?b.frameRate=e.attributes.frameRate:null!=t.attributes.frameRate&&(b.frameRate=t.attributes.frameRate),null!=e.attributes.height?b.height=e.attributes.height:null!=t.attributes.height&&(b.height=t.attributes.height),null!=e.attributes.mimeType?b.mimeType=e.attributes.mimeType:null!=t.attributes.mimeType&&(b.mimeType=t.attributes.mimeType),null!=e.attributes.width?b.width=e.attributes.width:null!=t.attributes.width&&(b.width=t.attributes.width);var S=void 0!==t.children.contentProtections?t.children.contentProtections:[];if(void 0!==e.children.contentProtections&&S.push.apply(S,e.children.contentProtections),S.length>0){var E=S.reduce((function(e,t){var n;if(void 0!==t.attributes.schemeIdUri&&"urn:uuid:"===t.attributes.schemeIdUri.substring(0,9)&&(n=t.attributes.schemeIdUri.substring(9).replace(/-/g,"").toLowerCase()),void 0!==t.attributes.keyId&&t.attributes.keyId.length>0){var r={keyId:t.attributes.keyId,systemId:n};void 0===e.keyIds?e.keyIds=[r]:e.keyIds.push(r)}if(void 0!==n){for(var i,a=[],o=$(t.children.cencPssh);!(i=o()).done;){var u=i.value;a.push({systemId:n,data:u})}if(a.length>0){var l,d=(0,s.Z)(e.initData,(function(e){return"cenc"===e.type}));if(void 0===d)e.initData.push({type:"cenc",values:a});else(l=d.values).push.apply(l,a)}}return e}),{keyIds:void 0,initData:[]});(Object.keys(E.initData).length>0||void 0!==E.keyIds&&E.keyIds.length>0)&&(b.contentProtections=E)}b.hdrInfo=ee({adaptationProfiles:t.attributes.profiles,supplementalProperties:t.children.supplementalProperties,essentialProperties:t.children.essentialProperties,manifestProfiles:n.manifestProfiles,codecs:y}),d.push(b)},f=$(e);!(l=f()).done;)c();return d}function ne(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return re(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return re(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function re(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(n.sort(le),e[t]=n.map((function(e){return e[0]}))),e}),{});return d.video.sort(le),k(re,c),re}(I.children.adaptations,F),V=(null!==(u=t.xmlNamespaces)&&void 0!==u?u:[]).concat(null!==(l=I.attributes.namespaces)&&void 0!==l?l:[]),K=function(e,t,n){for(var r,i,a,o=[],s=de(e);!(a=s()).done;)for(var u,l=a.value,d=l.attributes,c=d.schemeIdUri,f=void 0===c?"":c,v=d.timescale,p=void 0===v?1:v,h=n.concat(null!==(r=l.attributes.namespaces)&&void 0!==r?r:[]),g=de(l.children.events);!(u=g()).done;){var y=u.value;if(void 0!==y.eventStreamData){var _=(null!==(i=y.presentationTime)&&void 0!==i?i:0)/p+t,b=void 0===y.duration?void 0:_+y.duration/p,S=void 0;if(y.eventStreamData instanceof Element)S=y.eventStreamData;else{var E=h.reduce((function(e,t){return e+"xmlns:"+t.key+'="'+t.value+'" '}),"","application/xml").documentElement.childNodes[0]}o.push({start:_,end:b,id:y.id,data:{type:"dash-event-stream",value:{schemeIdUri:f,timescale:p,element:S}}})}}return o}(I.children.eventStreams,P,V),G={id:g,start:P,end:C,duration:M,adaptations:z,streamEvents:K};if(d.unshift(G),!E.lastPositionIsKnown()){var j=function(e){for(var t,n=null,r=!0,i=(0,h.Z)(e).filter((function(e){return null!=e})),a=de((0,v.Z)(i,(function(e){return e})));!(t=a()).done;)for(var o,s=de(t.value.representations);!(o=s()).done;){var u=o.value.index.getLastAvailablePosition();null!==u&&(r=!1,"number"==typeof u&&(n=null==n?u:Math.max(n,u)))}if(null!=n)return n;if(r)return null;return}(z);if(f)if("number"==typeof j){var H=performance.now()/1e3;E.setLastPosition(j,H)}else{var W=pe(t,P);if(void 0!==W){var q=W[0],Y=W[1];E.setLastPosition(q,Y)}}else"number"==typeof j&&E.setLastPosition(j)}},w=e.length-1;w>=0;w--)T();if(t.isDynamic&&!E.lastPositionIsKnown()){var I=pe(t,0);if(void 0!==I){var R=I[0],Z=I[1];E.setLastPosition(R,Z)}}return function(e){if(0===e.length)return[];for(var t=[e[0]],n=1;nr.start)&&(o.Z.warn("DASH: Updating overlapping Periods.",null==i?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));)t.pop(),i=t[t.length-1];t.push(r)}return t}(d)}function pe(e,t){if(null!=e.clockOffset){var n=e.clockOffset/1e3-e.availabilityStartTime,r=performance.now()/1e3,i=r+n;if(i>=t)return[i,r]}else{var a=Date.now()/1e3;if(a>=t)return o.Z.warn("DASH Parser: no clock synchronization mechanism found. Using the system clock instead."),[a-e.availabilityStartTime,performance.now()/1e3]}}function he(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return me(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?t[0].value:void 0}(t);if(null!=y&&y.length>0)return{type:"needs-clock",value:{url:y,continue:function(i){return i.success?(n.externalClockOffset=l(i.data),e(t,n,r,!0)):(r.push(i.error),o.Z.warn("DASH Parser: Error on fetching the clock ressource",i.error),e(t,n,r,!0))}}}}}for(var _=[],b=0;b=0&&(d=0===h.minimumUpdatePeriod?a.Z.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:h.minimumUpdatePeriod);var I=f(k),R=I.minimumSafePosition,Z=I.maximumSafePosition,x=I.maximumUnsafePosition,P=performance.now();if(m){var M,C;if(c=R,A=null!=b?b:null,void 0!==x&&(C=x),void 0!==Z)M=Z;else{var D=null!=_?_:0,N=t.externalClockOffset;if(void 0===N)o.Z.warn("DASH Parser: use system clock to define maximum position"),M=Date.now()/1e3-D;else M=(performance.now()+N)/1e3-D}void 0===C&&(C=M),v={isLinear:!0,maximumSafePosition:M,livePosition:C,time:P},null!==A&&void 0!==c&&M-c>A&&(A=M-c)}else{c=void 0!==R?R:void 0!==(null===(i=k[0])||void 0===i?void 0:i.start)?k[0].start:0;var O=null!=w?w:1/0;if(void 0!==k[k.length-1]){var L=k[k.length-1],U=null!==(s=L.end)&&void 0!==s?s:void 0!==L.duration?L.start+L.duration:void 0;void 0!==U&&U=0;o--){var s,u=_[o].index,l=a[o],f=l.parsed,v=l.warnings,p=l.receivedTime,h=l.sendingTime,m=l.url;v.length>0&&r.push.apply(r,v);for(var g,y=he(f);!(g=y()).done;){var b=g.value;d.set(b,{receivedTime:p,sendingTime:h,url:m})}(s=c.periods).splice.apply(s,[u,1].concat(f))}return e(t,n,r,i,d)}}}};function ye(e){var t=e.textContent,n=[];return null===t||0===t.length?[void 0,n]:[{value:t},n]}function _e(e){for(var t={},n=0;n0){var s=Ce(a,"cenc:pssh"),u=s[0],l=s[1];null!==l&&(o.Z.warn(l.message),t.push(l)),null!==u&&n.push(u)}}}return[{cencPssh:n},t]}(e.childNodes),n=t[0],r=t[1];return[{children:n,attributes:function(e){for(var t={},n=0;n0&&(r=r.concat(c));break;case"SegmentList":var f=Ve(a),v=f[0],p=f[1];r=r.concat(p),t.segmentList=v;break;case"SegmentTemplate":var h=Ge(a),m=h[0],g=h[1];r=r.concat(g),t.segmentTemplate=m;break;case"ContentProtection":var y=Ue(a),_=y[0],b=y[1];b.length>0&&(r=r.concat(b)),void 0!==_&&n.push(_)}}return n.length>0&&(t.contentProtections=n),[t,r]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Oe(t,n),i=0;i0&&(r=r.concat(u));break;case"ContentComponent":t.contentComponent=_e(a);break;case"EssentialProperty":null==t.essentialProperties?t.essentialProperties=[Ne(a)]:t.essentialProperties.push(Ne(a));break;case"InbandEventStream":void 0===t.inbandEventStreams&&(t.inbandEventStreams=[]),t.inbandEventStreams.push(Ne(a));break;case"Label":var l=a.textContent;null!=l&&(t.label=l);break;case"Representation":var d=je(a),c=d[0],f=d[1];t.representations.push(c),f.length>0&&(r=r.concat(f));break;case"Role":null==t.roles?t.roles=[Ne(a)]:t.roles.push(Ne(a));break;case"SupplementalProperty":null==t.supplementalProperties?t.supplementalProperties=[Ne(a)]:t.supplementalProperties.push(Ne(a));break;case"SegmentBase":var v=Fe(a),p=v[0],h=v[1];t.segmentBase=p,h.length>0&&(r=r.concat(h));break;case"SegmentList":var m=Ve(a),g=m[0],y=m[1];t.segmentList=g,y.length>0&&(r=r.concat(y));break;case"SegmentTemplate":var _=Ge(a),b=_[0],S=_[1];t.segmentTemplate=b,S.length>0&&(r=r.concat(S));break;case"ContentProtection":var E=Ue(a),T=E[0],k=E[1];k.length>0&&(r=r.concat(k)),void 0!==T&&n.push(T)}}return n.length>0&&(t.contentProtections=n),[t,r]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Oe(t,n),i=0;i0&&(n=n.concat(d))}}return[t,n]}function qe(e){for(var t={eventStreamData:e},n=[],r=Oe(t,n),i=0;i0&&(i=i.concat(_))}}return[{baseURLs:n,adaptations:r,eventStreams:a,segmentTemplate:t},i]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Oe(t,n),i=0;i",c=(new DOMParser).parseFromString(d,"text/xml");if(null==c||0===c.children.length)throw new Error("DASH parser: Invalid external ressources");for(var f=c.children[0].children,v=[],p=[],h=0;h0;){var r=e[0];if(r.start>=t)return n;if(-1===r.repeatCount)return n;if(0===r.repeatCount)e.shift(),n+=1;else{var i=e[1];if(void 0!==i&&i.start<=t)e.shift(),n+=1;else{if(r.duration<=0)return n;for(var a=r.start+r.duration,o=1;ar.repeatCount)){var s=r.repeatCount-o;return r.start=a,r.repeatCount=s,n+=o}e.shift(),n=r.repeatCount+1}}}return n}n.d(t,{Z:function(){return r}})},3911:function(e,t,n){"use strict";n.d(t,{KF:function(){return i},PZ:function(){return u},_j:function(){return l},gT:function(){return o},jH:function(){return a},zG:function(){return s}});var r=n(1946);function i(e,t,n){var i,a=e.repeatCount;return a>=0?a:(i=(0,r.Z)(t)?void 0!==n?n:Number.MAX_VALUE:t.start,Math.ceil((i-e.start)/e.duration)-1)}function a(e,t,n){var r=e.start,a=e.duration;return a<=0?r:r+(i(e,t,n)+1)*a}function o(e,t){var n;return e*t.timescale+(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0)}function s(e,t){var n;return(e-(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0))/t.timescale}function u(e,t,n){return[e*n,(e+t)*n]}function l(e,t,n){var r=e.timeline,i=o(t,e);if(i<0)return null;var u=function(e,t){for(var n=0,r=e.length;n>>1;e[i].start<=t?n=i+1:r=i}return n-1}(r,i);if(u<0||u>=r.length-1)return null;var l=r[u];if(l.duration<=0)return null;var d=r[u+1];if(void 0===d)return null;var c=d.start;return i>=a(l,d,n)&&ie.time)return!1;if(o===e.time)return void 0===a.range?void 0===e.range:null!=e.range&&a.range[0]===e.range[0]&&a.range[1]===e.range[1];if(a.repeatCount>=0&&void 0!==a.duration){var s=(o-a.start)/a.duration-1;return s%1==0&&s<=a.repeatCount}}return!1}n.d(t,{Z:function(){return r}})},5505:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(3714),i=n(3887),a=n(3911);function o(e,t){if(0===e.length)return e.push.apply(e,t),!0;if(0===t.length)return!1;var n=e.length,o=t[0].start,s=e[n-1];if((0,a.jH)(s,t[0])=0;u--){var l=e[u].start;if(l===o){var d=n-u;return e.splice.apply(e,[u,d].concat(t)),!1}if(lo)return i.Z.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,n].concat(t)),!0;if(void 0===c.repeatCount||c.repeatCount<=0)return c.repeatCount<0&&(c.repeatCount=Math.floor((o-c.start)/c.duration)-1),e.splice.apply(e,[u+1,n-(u+1)].concat(t)),!1;if(c.start+c.duration*(c.repeatCount+1)<=o)return e.splice.apply(e,[u+1,n-(u+1)].concat(t)),!1;var f=(o-c.start)/c.duration-1;if(f%1==0&&c.duration===t[0].duration){var v=t[0].repeatCount<0?-1:t[0].repeatCount+f+1;return e.splice.apply(e,[u,n-u].concat(t)),e[u].start=c.start,e[u].repeatCount=v,!1}return i.Z.warn("RepresentationIndex: Manifest update removed previous segments"),e[u].repeatCount=Math.floor(f),e.splice.apply(e,[u+1,n-(u+1)].concat(t)),!1}}var p=e[e.length-1],h=t[t.length-1];return void 0!==p.repeatCount&&p.repeatCount<0?p.start>h.start?(i.Z.warn("RepresentationIndex: The new index is older than the previous one"),!1):(i.Z.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0):p.start+p.duration*(p.repeatCount+1)>=h.start+h.duration*(h.repeatCount+1)?(i.Z.warn("RepresentationIndex: The new index is older than the previous one"),!1):(i.Z.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0)}},5734:function(e,t,n){"use strict";var r=n(6923),i=/&#([0-9]+);/g,a=/
/gi,o=/]*>([\s\S]*?)<\/style[^>]*>/i,s=/\s*

]+))?>(.*)/i,u=/]+?start="?([0-9]*)"?[^0-9]/i;function l(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}t.Z=function(e,t,n){var d,c,f=/]/gi,v=/]|<\/body>/gi,p=[],h=o.exec(e),m=Array.isArray(h)?h[1]:"";v.exec(e);var g,y=function(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,n={},r=t.exec(e);null!==r;){var i=r[1],a=l(r[2],"lang");null!=i&&null!=a&&(n[a]=i),r=t.exec(e)}return n}(m),_=function(e){var t=/p\s*{([^}]*)}/gi.exec(e);return null===t?"":t[1]}(m);if((0,r.Z)(n)&&void 0===(g=y[n]))throw new Error("sami: could not find lang "+n+" in CSS");for(;d=f.exec(e),c=v.exec(e),null!==d||null!==c;){if(null===d||null===c||d.index>=c.index)throw new Error("parse error");var b=e.slice(d.index,c.index),S=u.exec(b);if(!Array.isArray(S))throw new Error("parse error (sync time attribute)");var E=+S[1];if(isNaN(E))throw new Error("parse error (sync time attribute NaN)");T(b.split("\n"),E/1e3)}return p;function T(e,n){for(var o=e.length;--o>=0;){var u=s.exec(e[o]);if(Array.isArray(u)){var l=u[1],d=u[2];if(g===l)if(" "===d)p[p.length-1].end=n;else{var c=document.createElement("DIV");c.className="rxp-texttrack-region";var f=document.createElement("DIV");f.className="rxp-texttrack-div",f.style.position="absolute",f.style.bottom="0",f.style.width="100%",f.style.color="#fff",f.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000";var v=document.createElement("div");v.className="rxp-texttrack-p",(0,r.Z)(_)&&(v.style.cssText=_);for(var h=d.split(a),m=0;m/gi,s=/]*>([\s\S]*?)<\/style[^>]*>/i,u=/\s*

]+))?>(.*)/i,l=/]+?start="?([0-9]*)"?[^0-9]/i;function d(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}t.Z=function(e,t,n){var c,f,v=/]/gi,p=/]|<\/body>/gi,h=[],m=s.exec(e),g=null!==m?m[1]:"";p.exec(e);var y,_=function(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,n={},r=t.exec(e);Array.isArray(r);){var i=r[1],a=d(r[2],"lang");null!=i&&null!=a&&(n[a]=i),r=t.exec(e)}return n}(g);if((0,i.Z)(n)&&void 0===(y=_[n]))throw new Error("sami: could not find lang "+n+" in CSS");for(;c=v.exec(e),f=p.exec(e),null!==c||null!==f;){if(null===c||null===f||c.index>=f.index)throw new Error("parse error");var b=e.slice(c.index,f.index),S=l.exec(b);if(null===S)throw new Error("parse error (sync time attribute)");var E=+S[1];if(isNaN(E))throw new Error("parse error (sync time attribute NaN)");T(b.split("\n"),E/1e3)}return function(e){for(var t=[],n=0;n=0;)if(null!==(r=u.exec(e[s]))){var l=r,d=l[1],c=l[2];y===d&&(" "===c?h[h.length-1].end=n:h.push({text:(i=c,i.replace(o,"\n").replace(a,(function(e,t){return String.fromCharCode(Number(t))}))),start:n+t}))}}}},2061:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(6923);function i(e,t){for(var n=t+1;(0,r.Z)(e[n]);)n++;return n}function a(e){for(var t=[],n=0;n0&&(1===o.length?o[0].indexOf("--\x3e")>=0&&t.push(o):(o[1].indexOf("--\x3e")>=0||o[0].indexOf("--\x3e")>=0)&&t.push(o)),n=a}return t}},8675:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(2061),i=n(788);function a(e,t){for(var n=e.split(/\r\n|\n|\r/),a=(0,r.Z)(n),s=[],u=0;u0){var l=document.createTextNode(o[s]);r.appendChild(l)}}else if("B"===a.nodeName){var d=e(a);d.style.fontWeight="bold",r.appendChild(d)}else if("I"===a.nodeName){var c=e(a);c.style.fontStyle="italic",r.appendChild(c)}else if("U"===a.nodeName){var f=e(a);f.style.textDecoration="underline",r.appendChild(f)}else if(u(a)&&"string"==typeof a.color){var v=e(a);v.style.color=a.color,r.appendChild(v)}else{var p=e(a);r.appendChild(p)}}return r}(t)}function u(e){return"FONT"===e.nodeName&&"color"in e}},8057:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(7253),i=n(2061),a=n(788);function o(e,t){for(var n,o,s,u,l,d=e.split(/\r\n|\n|\r/),c=(0,i.Z)(d),f=[],v=0;v0){var _=p.getAttribute("xml:space"),b=(0,l.Z)(_)?"default"===_:o,E=(0,d.Z)({},i,(0,c.U)(g,[p],n,t));u.push.apply(u,e(p,E,[p].concat(a),b))}}return u}(e,(0,d.Z)({},r),[],i)}(e,n,r,i,s),E=0;E|\u2265/g,">").replace(/\u200E/g,"‎").replace(/\u200F/g,"‏").replace(/\u00A0/g," ")}else if((0,l.OE)(s))i+="\n";else if((0,l.jg)(s)&&s.nodeType===Node.ELEMENT_NODE&&s.childNodes.length>0){var c=s.getAttribute("xml:space");i+=n(s,(0,o.Z)(c)?"default"===c:t)}}return i}return n(e,t)}(t,v),y=(0,i.Z)(h+n,m+n,g);return null===y?null:((0,a.Z)(y)&&function(e,t){var n=t.extent;if((0,o.Z)(n)){var r=u._0.exec(n);null!=r&&(e.size=Number(r[1]))}switch(t.writingMode){case"tb":case"tblr":e.vertical="lr";break;case"tbrl":e.vertical="rl"}var i=t.origin;if((0,o.Z)(i))u._0.exec(i);var a=t.align;if((0,o.Z)(a)){e.align=a,"center"===a&&("center"!==e.align&&(e.align="middle"),e.position="auto");var s=c[a];e.positionAlign=void 0===s?"":s;var l=d[a];e.lineAlign=void 0===l?"":l}}(y,r),y)}var v=function(e,t){for(var n=(0,r.Z)(e,t),i=[],a=0;a0&&(t=n)}return t}function a(e){var t=e.getElementsByTagName("body");if(t.length>0)return t[0];var n=e.getElementsByTagName("tt:body");return n.length>0?n[0]:null}function o(e){var t=e.getElementsByTagName("style");if(t.length>0)return t;var n=e.getElementsByTagName("tt:style");return n.length>0?n:t}function s(e){var t=e.getElementsByTagName("region");if(t.length>0)return t;var n=e.getElementsByTagName("tt:region");return n.length>0?n:t}function u(e){var t=e.getElementsByTagName("p");if(t.length>0)return t;var n=e.getElementsByTagName("tt:p");return n.length>0?n:t}function l(e){return"br"===e.nodeName||"tt:br"===e.nodeName}function d(e){return"span"===e.nodeName||"tt:span"===e.nodeName}n.d(t,{DM:function(){return s},H:function(){return a},OE:function(){return l},jF:function(){return i},jg:function(){return d},kd:function(){return u},vU:function(){return o}})},1138:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(6923),i=n(360);function a(e,t){for(var n=[],a=t;a=2)for(var r=function(r){var o=e[r];if(Array.isArray(/::cue {/.exec(o)))for(o=e[++r];(0,i.Z)(o)&&!Array.isArray(/}/.exec(o))&&0!==o.length;)n+=o,o=e[++r];else{for(var s=[],u=/::cue\(\.?(.*?)\)(?:,| {)/.exec(o);(0,i.Z)(o)&&Array.isArray(u);)s.push(u[1]),o=e[++r],u=/::cue\(\.?(.*?)\)(?:,| {)/.exec(o);for(var l="";(0,i.Z)(o)&&!Array.isArray(/}/.exec(o))&&0!==o.length;)l+=o,o=e[++r];s.forEach((function(e){void 0===t[e]?t[e]=l:t[e]+=l}))}a=r},a=1;a0&&n.appendChild(document.createElement("br")),o[s].length>0){var u=document.createTextNode(o[s]);n.appendChild(u)}}else{var c=e.nodeName.toLowerCase().split("."),f=[];if(c.forEach((function(e){(0,i.Z)(t[e])&&f.push(t[e])})),0!==f.length){var v=document.createAttribute("style");f.forEach((function(e){v.value+=e}));var p=(0,l.Z)(r,a)?a:"span";(n=document.createElement(p)).setAttributeNode(v)}else{var h=(0,l.Z)(r,a)?a:"span";n=document.createElement(h)}for(var m=0;m/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3"),r=(new DOMParser).parseFromString(n,"text/html").body.childNodes,i=[],a=0;a=2){var a=parseInt(i[1],10);isNaN(a)||(t.position=a,void 0!==i[2]&&(t.positionAlign=i[2]))}}(0,u.Z)(e.size)&&(t.size=e.size),"string"==typeof e.align&&(0,s.Z)(["start","center","end","left"],e.align)&&(t.align=e.align)}var d=n(7253);var c=function(e,t){var n=e.split(/\r\n|\n|\r/);if(!/^WEBVTT($| |\t)/.test(n[0]))throw new Error("Can't parse WebVTT: Invalid file.");for(var s,u,c,f,v=(0,o.yE)(n),p=(0,i.Z)(n,v),h=[],m=0;m/;if(o.test(e[0]))n=e[0],r=e.slice(1,e.length);else{if(!o.test(e[1]))return null;a=e[0],n=e[1],r=e.slice(2,e.length)}var s=function(e){var t=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(e);if(null===t)return null;var n=i(t[1]),r=i(t[2]);return null==n||null==r?null:{start:n,end:r,settings:t[3].split(/ |\t/).reduce((function(e,t){var n=t.split(":");return 2===n.length&&(e[n[0]]=n[1]),e}),{})}}(n);return null===s?null:{start:s.start+t,end:s.end+t,settings:s.settings,payload:r,header:a}}},360:function(e,t,n){"use strict";n.d(t,{$4:function(){return s},JF:function(){return a},tq:function(){return o},yE:function(){return i}});var r=n(6923);function i(e){for(var t=0;t=0)return!0;var r=e[t+1];return void 0!==r&&r.indexOf("--\x3e")>=0}function s(e,t){for(var n=t+1;(0,r.Z)(e[n]);)n++;return n}},2047:function(e,t,n){"use strict";n.d(t,{Z:function(){return ue}});var r=n(7874),i=n(8791),a=n(6872),o=n(8750),s=n(3887),u=n(8619),l=n(8026),d=n(4597),c=n(3635);function f(e){var t=e.referenceDateTime,n=void 0!==e.serverSyncInfos?e.serverSyncInfos.serverTimestamp-e.serverSyncInfos.clientTime:void 0;return function(i,f,v,p,h){var m,g=i.responseData,y=f.externalClockOffset,_=null!==(m=i.url)&&void 0!==m?m:f.originalUrl,b=null!=n?n:y,S={unsafelyBaseOnPreviousManifest:f.unsafeMode?f.previousManifest:null,url:_,referenceDateTime:t,externalClockOffset:b},E=r.Z.dashParsers;if(null===E.wasm||"uninitialized"===E.wasm.status||"failure"===E.wasm.status)return s.Z.debug("DASH: WASM MPD Parser not initialized. Running JS one."),k();var T=function(e){if(e instanceof ArrayBuffer)return e;if("string"==typeof e)return(0,c.tG)(e).buffer;if(e instanceof Document)return(0,c.tG)(e.documentElement.innerHTML).buffer;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(g);return function(e){var t=new DataView(e);if(61371===t.getUint16(0)&&191===t.getUint8(2))return!0;if(65279===t.getUint16(0)||65534===t.getUint16(0))return!1;return!0}(T)?"initialized"===E.wasm.status?(s.Z.debug("DASH: Running WASM MPD Parser."),w(E.wasm.runWasmParser(T,S))):(s.Z.debug("DASH: Awaiting WASM initialization before parsing the MPD."),E.wasm.waitForInitialization().catch((function(){})).then((function(){return null===E.wasm||"initialized"!==E.wasm.status?(s.Z.warn("DASH: WASM MPD parser initialization failed. Running JS parser instead"),k()):(s.Z.debug("DASH: Running WASM MPD Parser."),w(E.wasm.runWasmParser(T,S)))}))):(s.Z.info("DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one."),k());function k(){if(null===E.js)throw new Error("No MPD parser is imported");var e=function(e){if(e instanceof ArrayBuffer)return(new DOMParser).parseFromString((0,c.uR)(new Uint8Array(e)),"text/xml");if("string"==typeof e)return(new DOMParser).parseFromString(e,"text/xml");if(e instanceof Document)return e;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(g);return w(E.js(e,S))}function w(t){if("done"===t.type)return t.value.warnings.length>0&&v(t.value.warnings),p.isCancelled()?Promise.reject(p.cancellationError):{manifest:new u.ZP(t.value.parsed,e),url:_};var n=t.value,r=n.urls.map((function(e){return h((function(){var t=a.Z.getCurrent().DEFAULT_REQUEST_TIMEOUT;return"string"===n.format?(0,d.ZP)({url:e,responseType:"text",timeout:t,cancelSignal:p}):(0,d.ZP)({url:e,responseType:"arraybuffer",timeout:t,cancelSignal:p})})).then((function(e){if("string"===n.format){if("string"!=typeof e.responseData)throw new Error("External DASH resources should have been a string");return(0,l.Z)(e,{responseData:{success:!0,data:e.responseData}})}if(!(e.responseData instanceof ArrayBuffer))throw new Error("External DASH resources should have been ArrayBuffers");return(0,l.Z)(e,{responseData:{success:!0,data:e.responseData}})}),(function(e){var t=(0,o.Z)(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"An unknown error occured when parsing ressources."});return(0,l.Z)({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:t}})}))}));return Promise.all(r).then((function(e){return n.format,w(n.continue(e))}))}}}var v=n(7839),p=n(5861),h=n(4687),m=n.n(h),g=n(9105),y=n(5992),_=n(1946),b="function"==typeof Headers?Headers:null,S="function"==typeof AbortController?AbortController:null;function E(){return"function"==typeof window.fetch&&!(0,_.Z)(S)&&!(0,_.Z)(b)}var T=n(8806),k=n(281);function w(e,t){return"audio"===e||"video"===e?"video/mp4"===t||"audio/mp4"===t?"mp4":"video/webm"===t||"audio/webm"===t?"webm":void 0:"text"===e&&"application/mp4"===t?"mp4":void 0}var A=n(288),I=n(4460);function R(e){return function(t,n,r,i,a){return new Promise((function(s,u){var l=new A.ZP,d=l.linkToSignal(i);function c(){l.signal.deregister(u),d()}l.signal.register(u),e(t,n,r,l.signal,Object.assign(Object.assign({},a),{onNewChunk:function(e){try{o(e),a.onNewChunk(e)}catch(e){c(),l.cancel(),u(e)}}})).then((function(e){if(c(),!l.isUsed()){if("segment-loaded"===e.resultType)try{o(e.resultData.responseData)}catch(e){return void u(e)}s(e)}}),(function(e){c(),u(e)}))}));function o(e){(e instanceof ArrayBuffer||e instanceof Uint8Array)&&"mp4"===w(n.type,n.mimeType)&&(0,I.Z)(new Uint8Array(e),n.segment.isInit)}}}var Z=n(9829);function x(e,t){return null===e?null:null===t.url?e.baseUrl:(0,Z.Z)(e.baseUrl,t.url)}var P=n(6968);function M(e,t,n,r,i){if(void 0===t.range)return(0,d.ZP)({url:e,responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(void 0===t.indexRange)return(0,d.ZP)({url:e,headers:{Range:(0,k.Z)(t.range)},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(t.range[1]+1===t.indexRange[0])return(0,d.ZP)({url:e,headers:{Range:(0,k.Z)([t.range[0],t.indexRange[1]])},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));var a=(0,d.ZP)({url:e,headers:{Range:(0,k.Z)(t.range)},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress}),o=(0,d.ZP)({url:e,headers:{Range:(0,k.Z)(t.indexRange)},responseType:"arraybuffer",timeout:n.timeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then((function(t){var n=t[0],r=t[1],i=(0,P.zo)(new Uint8Array(n.responseData),new Uint8Array(r.responseData)),a=Math.min(n.sendingTime,r.sendingTime),o=Math.max(n.receivedTime,r.receivedTime);return{resultType:"segment-loaded",resultData:{url:e,responseData:i,size:n.size+r.size,requestDuration:o-a,sendingTime:a,receivedTime:o}}}))}var C=n(8766);function D(e,t,n,r,i){var a=t.segment,o=void 0!==a.range?{Range:(0,k.Z)(a.range)}:void 0,u=null;return function(e){var t;if(!(0,_.Z)(e.headers))if((0,_.Z)(b))t=e.headers;else{t=new b;for(var n=Object.keys(e.headers),r=0;r=300)throw s.Z.warn("Fetch: Request HTTP Error",t.status,t.url),new g.Z(t.url,t.status,y.br.ERROR_HTTP_CODE);if((0,_.Z)(t.body))throw new g.Z(t.url,t.status,y.br.PARSE_ERROR);var n=t.headers.get("Content-Length"),r=(0,_.Z)(n)||isNaN(+n)?void 0:+n,i=t.body.getReader(),o=0;return u();function u(){return d.apply(this,arguments)}function d(){return(d=(0,p.Z)(m().mark((function n(){var a,s,d,c,v;return m().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,i.read();case 2:if((a=n.sent).done||(0,_.Z)(a.value)){n.next=11;break}return o+=a.value.byteLength,s=performance.now(),d={url:t.url,currentTime:s,duration:s-l,sendingTime:l,chunkSize:a.value.byteLength,chunk:a.value.buffer,size:o,totalSize:r},e.onData(d),n.abrupt("return",u());case 11:if(!a.done){n.next=16;break}return f(),c=performance.now(),v=c-l,n.abrupt("return",{requestDuration:v,receivedTime:c,sendingTime:l,size:o,status:t.status,url:t.url});case 16:return n.abrupt("return",u());case 17:case"end":return n.stop()}}),n)})))).apply(this,arguments)}})).catch((function(t){if(null!==o)throw o;if(f(),u)throw s.Z.warn("Fetch: Request timeouted."),new g.Z(e.url,0,y.br.TIMEOUT);if(t instanceof g.Z)throw t;throw s.Z.warn("Fetch: Request Error",t instanceof Error?t.toString():""),new g.Z(e.url,0,y.br.ERROR_EVENT)}))}({url:e,headers:o,onData:function(e){var t=new Uint8Array(e.chunk),n=function(e){for(var t=0,n=[];te.length)return[n,r];var o=(0,C.Z)(r,1835295092);if(o<0)return[n,r];var s=t+o+(0,P.pX)(e,o+t);if(s>e.length)return[n,r];var u=Math.max(a,s),l=e.subarray(t,u);n.push(l),t=u}return[n,null]}(null!==u?(0,P.zo)(u,t):t),a=n[0];u=n[1];for(var o=0;o0)for(var v=0;v=Math.pow(2,8-n))return n}function Q(e,t){var n=X(e,t);if(null==n)return s.Z.warn("webm: unrepresentable length"),null;if(t+n>e.length)return s.Z.warn("webm: impossible length"),null;for(var r=0,i=0;ie.length)return s.Z.warn("webm: impossible length"),null;for(var r=(e[t]&(1<<8-n)-1)*Math.pow(2,8*(n-1)),i=1;i=i)return!0}return!1}(r,t);return{inbandEvents:a,needsManifestRefresh:o}}}function re(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.segment,o=n.periodStart,s=n.periodEnd,u=e.data,l=e.isChunked,d=[o,s];if(null===u)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:d};var c=u instanceof Uint8Array?u:new Uint8Array(u),f=w(n.type,n.mimeType),v="mp4"===f||void 0===f,p=[];if(v){var h,m=(0,O.Z)(c);a.isInit&&(h=null!==(i=(0,L.R0)(c))&&void 0!==i?i:void 0),(m.length>0||void 0!==h)&&p.push({initDataType:"cenc",keyId:h,initData:m})}if(!a.isInit){var g=v?te(c,l,a,r):null,y=(0,ee.Z)(a.timestampOffset,0);if(v){var b=(0,L.s9)(c);if(void 0!==b){var S=ne(b.filter((function(e){return void 0!==a.privateInfos&&void 0!==a.privateInfos.isEMSGWhitelisted&&a.privateInfos.isEMSGWhitelisted(e)})),n.manifestPublishTime);if(void 0!==S){var E=S.needsManifestRefresh,T=S.inbandEvents;return{segmentType:"media",chunkData:c,chunkSize:c.length,chunkInfos:g,chunkOffset:y,appendWindow:d,inbandEvents:T,protectionData:p,needsManifestRefresh:E}}}}return{segmentType:"media",chunkData:c,chunkSize:c.length,chunkInfos:g,chunkOffset:y,protectionData:p,appendWindow:d}}var k,A=a.indexRange;if("webm"===f)k=function(e,t){var n=W(U,[],e,[t,e.length]);if(null==n)return null;var r=n[0],i=n[1],a=q(e,r);if(null==a)return null;var o=Y(e,r);if(null==o)return null;var s=W(V,[],e,[r,i]);if(null==s)return null;for(var u=[],l=s[0];l0)){var I=k[k.length-1];Array.isArray(I.range)&&(I.range[1]=1/0)}var R=v?(0,L.LD)(c):"webm"===f?q(c,0):void 0,Z=(0,_.Z)(R)?void 0:R;return{segmentType:"init",initializationData:c,initializationDataSize:c.length,protectionData:p,initTimescale:Z,segmentList:null!=k?k:void 0}}}var ie=n(6807);function ae(e,t,n,r){var i,a,o=e.segment,u=e.language,l=e.codecs;if(o.isInit)return null;null===n?r?(i=o.time,a=o.end):s.Z.warn("Transport: Unavailable time data for current text track."):(i=n.time,void 0!==n.duration?a=i+n.duration:!r&&o.complete&&(a=i+o.duration));var d=function(e){if(void 0===e)throw new Error("Cannot parse subtitles: unknown format");switch(e.toLowerCase()){case"stpp":case"stpp.ttml.im1t":return"ttml";case"wvtt":return"vtt"}throw new Error('The codec used for the subtitles "'+e+'" is not managed yet.')}(l),f=function(e){var t=(0,ie.Le)(e);return null===t?"":(0,c.uR)(t)}(t);return{data:f,type:d,language:u,start:i,end:a}}function oe(e,t,n){var r,i,a=e.segment;return a.isInit?null:(n?s.Z.warn("Transport: Unavailable time data for current text track."):(r=a.time,a.complete&&(i=a.time+a.duration)),{data:t,type:function(e,t){switch(t){case"application/ttml+xml":return"ttml";case"application/x-sami":case"application/smil":return"sami";case"text/vtt":return"vtt"}if(void 0!==e&&"srt"===e.toLowerCase())return"srt";throw new Error("could not find a text-track parser for the type "+(null!=t?t:""))}(e.codecs,e.mimeType),language:e.language,start:r,end:i})}function se(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=e.data,l=e.isChunked;if(null===u)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:null!==(i=s.timestampOffset)&&void 0!==i?i:0,protectionData:[],appendWindow:[a,o]};var d=w(n.type,n.mimeType);if("webm"===d)throw new Error("Text tracks with a WEBM container are not yet handled.");return"mp4"===d?function(e,t,n,r,i){var a=n.segment,o=a.isInit,s=a.indexRange,u="string"==typeof e?(0,c.tG)(e):e instanceof Uint8Array?e:new Uint8Array(e);if(o){var l=(0,L.Wf)(u,Array.isArray(s)?s[0]:0);if(!0===i&&null!==l&&l.length>0){var d=l[l.length-1];Array.isArray(d.range)&&(d.range[1]=1/0)}return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:(0,L.LD)(u),segmentList:null!=l?l:void 0}}var f=te(u,t,a,r),v=ae(n,u,f,t),p=(0,ee.Z)(a.timestampOffset,0);return{segmentType:"media",chunkData:v,chunkSize:u.length,chunkInfos:f,chunkOffset:p,protectionData:[],appendWindow:[n.periodStart,n.periodEnd]}}(u,l,n,r,t):function(e,t,n){var r,i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=s.timestampOffset,l=void 0===u?0:u;if(s.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if("string"!=typeof e){var d=e instanceof Uint8Array?e:new Uint8Array(e);r=(0,c.uR)(d),i=d.length}else r=e;return{segmentType:"media",chunkData:oe(n,r,t),chunkSize:i,chunkInfos:null,chunkOffset:l,protectionData:[],appendWindow:[a,o]}}(u,l,n)}}var ue=function(e){var t=(0,i.Z)({customManifestLoader:e.manifestLoader},null===r.Z.dashParsers.wasm||"initialized"!==r.Z.dashParsers.wasm.status&&"initializing"!==r.Z.dashParsers.wasm.status?"arraybuffer":"text"),n=f(e),a=function(e){var t=e.lowLatencyMode,n=e.segmentLoader;return!0!==e.checkMediaSegmentIntegrity?r:R(r);function r(e,r,i,a,o){var s=x(e,r.segment);return null==s?Promise.resolve({resultType:"segment-created",resultData:null}):t||void 0===n?N(s,r,t,i,o,a):new Promise((function(e,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(h);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a DASH segment through a custom segmentLoader.",o=new v.Z(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(t){d||a.isCancelled()||(d=!0,a.deregister(h),e({resultType:"segment-loaded",resultData:{responseData:t.data,size:t.size,requestDuration:t.duration}}))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(h),N(s,r,t,i,o,a).then(e,u))}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:s},p=n(f,c);function h(e){d||(d=!0,"function"==typeof p&&p(),u(e))}a.register(h)}))}}(e),o=re(e),s=function(e){var t=e.lowLatencyMode;return!0!==e.checkMediaSegmentIntegrity?n:R(n);function n(e,n,r,i,a){var o=n.segment,s=o.range,u=x(e,o);if(null===u)return Promise.resolve({resultType:"segment-created",resultData:null});if(o.isInit)return M(u,o,r,i,a);var l=w(n.type,n.mimeType),c="mp4"===l||void 0===l;if(t&&c){if(E())return D(u,n,r,a,i);(0,T.Z)("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}return c?(0,d.ZP)({url:u,responseType:"arraybuffer",headers:Array.isArray(s)?{Range:(0,k.Z)(s)}:null,timeout:r.timeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}})):(0,d.ZP)({url:u,responseType:"text",headers:Array.isArray(s)?{Range:(0,k.Z)(s)}:null,timeout:r.timeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}}(e);return{manifest:{loadManifest:t,parseManifest:n},audio:{loadSegment:a,parseSegment:o},video:{loadSegment:a,parseSegment:o},text:{loadSegment:s,parseSegment:se(e)}}}},5418:function(e,t,n){"use strict";n.d(t,{Z:function(){return le}});var r=n(3887),i=n(8619),a=n(6807),o=n(9665),s=n(7714),u=n(811),l=n(6968),d=n(6923),c=n(8026),f=n(9829),v=n(3635),p=n(5278),h=n(2689),m={};function g(e){if(null!=m[e])return m[e];var t=(0,v.tG)(e);return m[e]=t,t}function y(e,t){var n=t.length+8;return n<=h.s?(0,l.zo)((0,l.kh)(n),g(e),t):(0,l.zo)((0,l.kh)(1),g(e),(0,l.el)(n+8),t)}function _(e,t){return y(e,l.zo.apply(void 0,t))}function b(e){var t=[];e.periods.forEach((function(n){var i=n.id;if((0,s.Z)(t,i)){r.Z.warn("Two periods with the same ID found. Updating.");var a=i+"-dup";n.id=a,b(e),t.push(a)}else t.push(i);var o=n.adaptations,u=[];Object.keys(o).forEach((function(t){var n=o[t];void 0!==n&&n.forEach((function(t){var n=t.id;if((0,s.Z)(u,n)){r.Z.warn("Two adaptations with the same ID found. Updating.",n);var i=n+"-dup";t.id=i,b(e),u.push(i)}else u.push(n);var a=[];t.representations.forEach((function(t){var n=t.id;if((0,s.Z)(a,n)){r.Z.warn("Two representations with the same ID found. Updating.",n);var i=n+"-dup";t.id=i,b(e),a.push(i)}else a.push(n)}))}))}))}))}var S=n(9689);function E(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:(0,l.zo)([8,1,18,16],e)}]}function T(e,t){if(void 0===t&&(t=E),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var n=e.firstElementChild,r=(0,S.K)(null===n.textContent?"":n.textContent),i=function(e){var t=(0,l.qb)(e,8),n=(0,v.wV)(e.subarray(10,t+10)),r=(new DOMParser).parseFromString(n,"application/xml").querySelector("KID");if(null===r)throw new Error("Cannot parse PlayReady private data: invalid XML");var i=null===r.textContent?"":r.textContent,a=(0,v.wO)((0,S.K)(i));return(0,v.ci)(a).toLowerCase()}(r),a=(0,v.nr)(i),o=n.getAttribute("SystemID");return{keyId:a,keySystems:[{systemId:(null!==o?o:"").toLowerCase().replace(/\{|\}/g,""),privateData:r}].concat(t(a))}}var k=n(9362),w=n(3911),A=n(1091);function I(e,t){return e.replace(/\{start time\}/g,String(t))}function R(e,t,n){var r=t-e;return r>0?Math.floor(r/n):0}function Z(e,t){var n=e.repeatCount;if(void 0!==e.duration&&n<0){var r=void 0!==t?t.start:1/0;n=Math.ceil((r-e.start)/e.duration)-1}return n}var x=function(){function e(e){var t=e.isLive,n=e.segmentPrivateInfos,r=e.media,i=e.sharedSmoothTimeline;if(this._sharedSmoothTimeline=i,this._initSegmentInfos={bitsPerSample:n.bitsPerSample,channels:n.channels,codecPrivateData:n.codecPrivateData,packetSize:n.packetSize,samplingRate:n.samplingRate,timescale:i.timescale,height:n.height,width:n.width,protection:n.protection},this._isLive=t,this._media=r,0!==i.timeline.length&&t){var a=i.timeline,o=i.validityTime,s=a[a.length-1],u=(0,w.jH)(s,null),l=o/1e3*i.timescale;this._scaledLiveGap=l-u}}var t=e.prototype;return t.getInitSegment=function(){return{id:"init",isInit:!0,privateInfos:{smoothInitSegment:this._initSegmentInfos},url:null,time:0,end:0,duration:0,timescale:1,complete:!0}},t.getSegments=function(e,t){this._refreshTimeline();for(var n,r=this._sharedSmoothTimeline,i=r.timescale,a=r.timeline,o=function(e,t,n){var r=void 0===e||0===e?1:e;return{up:t*r,to:(t+n)*r}}(i,e,t),s=o.up,u=o.to,l=this._media,d=[],c=a.length,f=void 0===this._scaledLiveGap?void 0:performance.now()/1e3*i-this._scaledLiveGap,v=0;v=u)return d;void 0!==n&&(n+=g+1)}return d},t.shouldRefresh=function(e,t){if(this._refreshTimeline(),!this._isLive)return!1;var n=this._sharedSmoothTimeline,r=n.timeline,i=n.timescale,a=r[r.length-1];if(void 0===a)return!1;var o=a.repeatCount,s=a.start+(o+1)*a.duration;return!(t*i=s||e*i>a.start+o*a.duration)},t.getFirstAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;return 0===t.length?null:t[0].start/n},t.getLastAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;if(void 0===this._scaledLiveGap){var r=t[t.length-1];return(0,w.jH)(r,null)/n}for(var i=t.length-1;i>=0;i--)for(var a=t[i],o=performance.now()/1e3*n,s=a.start,u=a.duration,l=a.repeatCount;l>=0;l--){var d=s+u*(l+1);if(d<=o-this._scaledLiveGap)return d/n}},t.getEnd=function(){if(!this._isLive)return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(e,t){var n;if((0,u.Z)(e<=t),this.isFinished())return!1;var r=this.getLastAvailablePosition();return!(void 0!==r&&t(null!==(n=this.getFirstAvailablePosition())&&void 0!==n?n:0)&&void 0)},t.checkDiscontinuity=function(e){return this._refreshTimeline(),(0,w._j)(this._sharedSmoothTimeline,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();var t=this._sharedSmoothTimeline,n=t.timeline,r=t.timescale;return(0,A.Z)(e,n,r,0)},t.canBeOutOfSyncError=function(e){return!!this._isLive&&(e instanceof k.Z&&(e.isHttpError(404)||e.isHttpError(412)))},t._replace=function(e){this._initialScaledLastPosition=e._initialScaledLastPosition,this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.replace(e._sharedSmoothTimeline)},t._update=function(e){this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.update(e._sharedSmoothTimeline)},t.isFinished=function(){return!this._isLive},t.isInitialized=function(){return!0},t.initialize=function(){r.Z.error("A `SmoothRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(e,t){this._sharedSmoothTimeline.addPredictedSegments(e,t)},t._refreshTimeline=function(){this._sharedSmoothTimeline.refresh()},e}(),P=n(8232),M=n(5505);function C(e,t,n,r){var i=e[e.length-1],a=n.timescale===t?{time:n.time,duration:n.duration}:{time:n.time/n.timescale*t,duration:n.duration/n.timescale*t};return!(r.time===a.time)&&(a.time>=(0,w.jH)(i,null)&&(i.duration===a.duration?i.repeatCount++:e.push({duration:a.duration,start:a.time,repeatCount:0}),!0))}var D=function(){function e(e){var t=e.timeline,n=e.timescale,r=e.timeShiftBufferDepth,i=e.manifestReceivedTime;this.timeline=t,this.timescale=n;var a=null!=i?i:performance.now();if(this.validityTime=a,this._timeShiftBufferDepth=r,0!==t.length){var o=t[t.length-1],s=(0,w.jH)(o,null);this._initialScaledLastPosition=s}}var t=e.prototype;return t.refresh=function(){if(void 0!==this._initialScaledLastPosition){var e=this._timeShiftBufferDepth,t=(performance.now()-this.validityTime)/1e3+this._initialScaledLastPosition/this.timescale;if(void 0!==e){var n=(t-e)*this.timescale;(0,P.Z)(this.timeline,n)}}},t.replace=function(e){var t=this.timeline,n=e.timeline,i=this.timescale,a=e.timescale;if(this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime,0!==t.length&&0!==n.length&&i===a){var o=t[t.length-1],s=n[n.length-1],u=(0,w.jH)(s,null);if(!((0,w.jH)(o,null)<=u))for(var l=0;lu){if(d.duration!==s.duration)return;var f=u-d.start;if(0===f)return r.Z.warn("Smooth Parser: a discontinuity detected in the previous manifest has been resolved."),void(this.timeline=this.timeline.concat(t.slice(l)));if(f<0||f%d.duration!=0)return;var v=f/d.duration-1,p=d.repeatCount-v;if(p<0)return;s.repeatCount+=p;var h=t.slice(l+1);return void(this.timeline=this.timeline.concat(h))}}}},t.update=function(e){(0,M.Z)(this.timeline,e.timeline),this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime},t.addPredictedSegments=function(e,t){var n;if(void 0!==(null===(n=t.privateInfos)||void 0===n?void 0:n.smoothMediaSegment)){this.refresh();for(var i=0;i>3:2)?"mp4a.40.2":"mp4a.40."+n}(u,l);return{audiotag:void 0!==a?parseInt(a,10):a,bitrate:h,bitsPerSample:void 0!==o?parseInt(o,10):o,channels:void 0!==s?parseInt(s,10):s,codecPrivateData:u,codecs:m,customAttributes:n,mimeType:void 0!==l?L[l]:l,packetSize:void 0!==c?parseInt(c,10):c,samplingRate:void 0!==f?parseInt(f,10):f};case"video":var g=i("CodecPrivateData"),y=i("FourCC"),_=i("MaxWidth"),b=i("MaxHeight"),S=i("Bitrate"),E=void 0===S||isNaN(parseInt(S,10))?0:parseInt(S,10);if(void 0!==y&&void 0===L[y]||void 0===g)return r.Z.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null;var T=function(e){var t=/00000001\d7([0-9a-fA-F]{6})/.exec(e);return null!==t&&(0,d.Z)(t[1])?"avc1."+t[1]:"avc1.4D401E"}(g);return{bitrate:E,customAttributes:n,mimeType:void 0!==y?L[y]:y,codecPrivateData:g,codecs:T,width:void 0!==_?parseInt(_,10):void 0,height:void 0!==b?parseInt(b,10):void 0};case"text":var k=i("CodecPrivateData"),w=i("FourCC"),A=i("Bitrate");return{bitrate:void 0===A||isNaN(parseInt(A,10))?0:parseInt(A,10),customAttributes:n,mimeType:void 0!==w?L[w]:w,codecPrivateData:(0,p.Z)(k,"")};default:return r.Z.error("Smooth Parser: Unrecognized StreamIndex type: "+t),null}}function m(e){var t=e.root,i=e.timescale,a=e.baseUrl,f=e.protections,p=e.timeShiftBufferDepth,m=e.manifestReceivedTime,g=e.isLive,_=t.getAttribute("Timescale"),b=null===_||isNaN(+_)?i:+_,S=t.getAttribute("Type");if(null===S)throw new Error("StreamIndex without type.");(0,s.Z)(o.r,S)||r.Z.warn("Smooth Parser: Unrecognized adaptation type:",S);var E=S,T=t.getAttribute("Subtype"),k=t.getAttribute("Language"),w=t.getAttribute("Url"),A=null===w?"":w;var I,R=N(t,(function(e,t,r){switch(t){case"QualityLevel":var i=h(r,E);if(null===i)return e;("video"!==E||i.bitrate>n)&&e.qualityLevels.push(i);break;case"c":e.cNodes.push(r)}return e}),{qualityLevels:[],cNodes:[]}),Z=R.qualityLevels,P=R.cNodes,M=new D({timeline:(I=P,I.reduce((function(e,t,n){var r=t.getAttribute("d"),i=t.getAttribute("t"),a=t.getAttribute("r"),o=null!==a?+a-1:0,s=null!==i?+i:void 0,u=null!==r?+r:void 0;if(0===n)s=void 0===s||isNaN(s)?0:s;else{var l=e[n-1];if(null==s||isNaN(s)){if(null==l.duration||isNaN(l.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");s=l.start+l.duration*(l.repeatCount+1)}}if(null==u||isNaN(u)){var c=I[n+1];if(void 0===c)return e;var f=c.getAttribute("t"),v=(0,d.Z)(f)?+f:null;if(null===v)throw new Error("Can't build index timeline from Smooth Manifest.");u=v-s}return e.push({duration:u,start:s,repeatCount:o}),e}),[])),timescale:b,timeShiftBufferDepth:p,manifestReceivedTime:m});(0,u.Z)(0!==Z.length,"Adaptation should have at least one playable representation.");var C=E+((0,d.Z)(k)?"_"+k:""),L=Z.map((function(e){var t,n,r,i,o=(t=A,n=e.bitrate,r=e.customAttributes,t.replace(/\{bitrate\}/g,String(n)).replace(/{CustomAttributes}/g,r.length>0?r[0]:"")),s=(0,d.Z)(e.mimeType)?e.mimeType:O[E],u=e.codecs,p=C+"_"+(null!=E?E+"-":"")+(null!=s?s+"-":"")+(null!=u?u+"-":"")+String(e.bitrate),h=[];f.length>0&&(i=f[0],f.forEach((function(e){var t=e.keyId;e.keySystems.forEach((function(e){h.push({keyId:t,systemId:e.systemId})}))})));var m={bitsPerSample:e.bitsPerSample,channels:e.channels,codecPrivateData:e.codecPrivateData,packetSize:e.packetSize,samplingRate:e.samplingRate,height:e.height,width:e.width,protection:null!=i?{keyId:i.keyId}:void 0},_=new x({isLive:g,sharedSmoothTimeline:M,media:o,segmentPrivateInfos:m}),b=(0,c.Z)({},e,{index:_,cdnMetadata:[{baseUrl:a}],mimeType:s,codecs:u,id:p});if(h.length>0||void 0!==i){var S=void 0===i?[]:i.keySystems.map((function(e){var t=e.systemId,n=e.privateData,r=t.replace(/-/g,""),i=function(e,t){if(32!==e.length)throw new Error("HSS: wrong system id length");var n=0;return y("pssh",(0,l.zo)([n,0,0,0],(0,v.nr)(e),(0,l.kh)(t.length),t))}(r,n);return{systemId:r,data:i}}));if(S.length>0){var T=[{type:"cenc",values:S}];b.contentProtections={keyIds:h,initData:T}}else b.contentProtections={keyIds:h,initData:[]}}return b}));if("ADVT"===T)return null;var U={id:C,type:E,representations:L,language:null==k?void 0:k};return"text"===E&&"DESC"===T&&(U.closedCaption=!0),U}return function(n,r,i){var o="";if(void 0!==r){var s=(0,f.$)(r);o=r.substring(0,s)}var u=n.documentElement;if(null==u||"SmoothStreamingMedia"!==u.nodeName)throw new Error("document root should be SmoothStreamingMedia");var l=u.getAttribute("MajorVersion"),c=u.getAttribute("MinorVersion");if(null===l||null===c||!/^[2]-[0-2]$/.test(l+"-"+c))throw new Error("Version should be 2.0, 2.1 or 2.2");var v,p,h=u.getAttribute("Timescale"),g=(0,d.Z)(h)?isNaN(+h)?1e7:+h:1e7,y=N(u,(function(t,n,r){switch(n){case"Protection":t.protections.push(T(r,e.keySystems));break;case"StreamIndex":t.adaptationNodes.push(r)}return t}),{adaptationNodes:[],protections:[]}),_=y.protections,S=y.adaptationNodes,E="boolean"==typeof(v=u.getAttribute("IsLive"))?v:"string"==typeof v&&"TRUE"===v.toUpperCase();if(E){var k=u.getAttribute("DVRWindowLength");null==k||isNaN(+k)||0==+k||(p=+k/g)}var w,A,I,R,Z,x,P,M=S.reduce((function(e,t){var n=m({root:t,baseUrl:o,timescale:g,protections:_,isLive:E,timeShiftBufferDepth:p,manifestReceivedTime:i});if(null===n)return e;var r=n.type,a=e[r];return void 0===a?e[r]=[n]:a.push(n),e}),{}),C=null,D=void 0!==M.video?M.video[0]:void 0,O=void 0!==M.audio?M.audio[0]:void 0;if(void 0!==D||void 0!==O){var L=[],U=[];if(void 0!==D){var B=D.representations[0];if(void 0!==B){var F=B.index.getFirstAvailablePosition(),z=B.index.getLastAvailablePosition();null!=F&&L.push(F),null!=z&&U.push(z)}}if(void 0!==O){var V=O.representations[0];if(void 0!==V){var K=V.index.getFirstAvailablePosition(),G=V.index.getLastAvailablePosition();null!=K&&L.push(K),null!=G&&U.push(G)}}L.length>0&&(Z=Math.max.apply(Math,L)),U.length>0&&(x=Math.min.apply(Math,U),P=Math.max.apply(Math,U))}var j=u.getAttribute("Duration"),H=null!==j&&0!=+j?+j/g:void 0;if(E){w=e.suggestedPresentationDelay,A=t,I=null!=Z?Z:A;var W=P;void 0===W&&(W=Date.now()/1e3-A);var q=x;void 0===q&&(q=W),R={isLinear:!0,maximumSafePosition:q,livePosition:W,time:performance.now()},C=null!=p?p:null}else{I=null!=Z?Z:0,R={isLinear:!1,maximumSafePosition:void 0!==x?x:void 0!==H?I+H:1/0,livePosition:void 0,time:performance.now()}}var Y=E?0:I,X=E?void 0:R.maximumSafePosition,Q={availabilityStartTime:void 0===A?0:A,clockOffset:a,isLive:E,isDynamic:E,isLastPeriodKnown:!0,timeBounds:{minimumSafePosition:I,timeshiftDepth:C,maximumTimeData:R},periods:[{adaptations:M,duration:void 0!==X?X-Y:H,end:X,id:"gen-smooth-period-0",start:Y}],suggestedPresentationDelay:w,transportType:"smooth",uris:null==r?[]:[r]};return b(Q),Q}},B=U,F=n(4597),z=n(4460),V=n(8791),K=n(4644),G=n(2297);function j(e,t,n,i,o){var s,u,d,c=[];if(o){var f=(0,a.XA)(e);null!==f?(d=function(e){var t=(0,G.nR)(e,3565190898,3392751253,2387879627,2655430559);if(void 0===t)return[];for(var n=[],r=t[0],i=t[4],a=0;a=0}var W=n(3666);function q(e,t){return y("schm",(0,l.zo)(4,(0,v.tG)(e),(0,l.kh)(t)))}function Y(e){return y("frma",(0,v.tG)(e))}function X(e){var t=[7,[e.length]];return y("stsd",l.zo.apply(void 0,t.concat(e)))}function Q(e,t,n){return y("tenc",(0,l.zo)(6,[e,t],n))}function $(e,t,n,r,i){var a=[e,t,n];return void 0!==i&&a.push(y("senc",i),function(e){if(0===e.length)return y("saiz",new Uint8Array(0));var t=(0,l.pX)(e,0),n=(0,l.pX)(e,4),r=new Uint8Array(n+9);r.set((0,l.kh)(n),5);for(var i,a,o=9,s=8;s0;if(n)return e;var r=new Uint8Array(e.length+4);return r.set(e.subarray(0,t+8),0),r[t+3]=1|r[t+3],r.set([0,0,0,0],t+8),r.set(e.subarray(t+8,e.length),t+12),(0,K.J6)(r)}(d,s[1]-s[0]),v=$(u,c,f,i,(0,G.nR)(a,2721664850,1520127764,2722393154,2086964724)),p=_("moof",[i,v]),h=(0,G.Qy)(p,1836019558),m=(0,G.Qy)(v,1953653094),g=(0,G.Qy)(f,1953658222);if(null===h||null===m||null===g)throw new Error("Smooth: Invalid moof, trun or traf generation");var b=h[1]-h[0]+i.length+(m[1]-m[0])+u.length+c.length+(g[1]-g[0])+8,S=n[2]-n[0],E=p.length-S,T=(0,G.Qy)(e,1835295092);if(null===T)throw new Error("Smooth: Invalid ISOBMFF given");if(!W.YM&&(0===E||E<=-8)){var k=T[1];return p.set((0,l.kh)(k),b),e.set(p,n[0]),E<=-8&&e.set(y("free",new Uint8Array(-E-8)),p.length),e}var w=T[1]+E;p.set((0,l.kh)(w),b);var A=new Uint8Array(e.length+E),I=e.subarray(0,n[0]),R=e.subarray(n[2],e.length);return A.set(I,0),A.set(p,I.length),A.set(R,I.length+p.length),A}var ee=n(7839),te=n(281);function ne(e,t,n,r,i,a){var o,s,u,d=_("stbl",[n,y("stts",new Uint8Array(8)),y("stsc",new Uint8Array(8)),y("stsz",new Uint8Array(12)),y("stco",new Uint8Array(8))]),c=function(e){return y("dref",(0,l.zo)(7,[1],e))}(y("url ",new Uint8Array([0,0,0,1]))),f=_("dinf",[c]),p=_("minf",[r,f,d]),h=function(e){var t,n;switch(e){case"video":t="vide",n="VideoHandler";break;case"audio":t="soun",n="SoundHandler";break;default:t="hint",n=""}return y("hdlr",(0,l.zo)(8,(0,v.tG)(t),12,(0,v.tG)(n),1))}(t),m=function(e){return y("mdhd",(0,l.zo)(12,(0,l.kh)(e),8))}(e),g=_("mdia",[m,h,p]),b=function(e,t,n){return y("tkhd",(0,l.zo)((0,l.kh)(7),8,(0,l.kh)(n),20,[1,0,0,0],[0,1,0,0],12,[0,1,0,0],12,[64,0,0,0],(0,l.XT)(e),2,(0,l.XT)(t),2))}(i,a,1),S=_("trak",[b,g]),E=_("mvex",[(o=1,y("trex",(0,l.zo)(4,(0,l.kh)(o),[0,0,0,1],12)))]),T=function(e,t){return y("mvhd",(0,l.zo)(12,(0,l.kh)(e),4,[0,1],2,[1,0],10,[0,1],14,[0,1],14,[64,0,0,0],26,(0,l.XT)(t+1)))}(e,1),k=function(e,t,n){return _("moov",[e,t,n])}(T,E,S),w=(s="isom",u=["isom","iso2","iso6","avc1","dash"],y("ftyp",l.zo.apply(void 0,[(0,v.tG)(s),[0,0,0,1]].concat(u.map(v.tG)))));return(0,l.zo)(w,k)}function re(e,t,n,r,i,a,o,s){var u=o.split("00000001"),d=u[1],c=u[2];if(void 0===d||void 0===c)throw new Error("Smooth: unsupported codec private data.");var f,p,h=function(e,t,n){var r=2===n?1:4===n?3:0,i=e[1],a=e[2],o=e[3];return y("avcC",(0,l.zo)([1,i,a,o,252|r,225],(0,l.XT)(e.length),e,[1],(0,l.XT)(t.length),t))}((0,v.nr)(d),(0,v.nr)(c),a);if(void 0===s){var m=function(e,t,n,r,i,a,o){return y("avc1",(0,l.zo)(6,(0,l.XT)(1),16,(0,l.XT)(e),(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),6,[0,1,i.length],(0,v.tG)(i),31-i.length,(0,l.XT)(a),[255,255],o))}(t,n,r,i,"AVC Coding",24,h);f=X([m])}else{var g=_("schi",[Q(1,8,s)]),b=q("cenc",65536),S=function(e,t,n,r,i,a,o,s){return y("encv",(0,l.zo)(6,(0,l.XT)(1),16,(0,l.XT)(e),(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),6,[0,1,i.length],(0,v.tG)(i),31-i.length,(0,l.XT)(a),[255,255],o,s))}(t,n,r,i,"AVC Coding",24,h,_("sinf",[Y("avc1"),b,g]));f=X([S])}return ne(e,"video",f,((p=new Uint8Array(12))[3]=1,y("vmhd",p)),t,n)}var ie=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function ae(e,t,n,r,i,a,o){var s,u,d,c=function(e,t){return y("esds",(0,l.zo)(4,[3,25],(0,l.XT)(e),[0,4,17,64,21],11,[5,2],(0,v.nr)(t),[6,1,2]))}(1,0===a.length?(s=i,u=t,d=((d=((d=(63&2)<<4)|31&ie.indexOf(s))<<4)|31&u)<<3,(0,v.ci)((0,l.XT)(d))):a),f=function(){if(void 0===o){var e=function(e,t,n,r,i,a){return y("mp4a",(0,l.zo)(6,(0,l.XT)(e),8,(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),(0,l.XT)(i),2,a))}(1,t,n,r,i,c);return X([e])}var a=_("schi",[Q(1,8,o)]),s=q("cenc",65536),u=_("sinf",[Y("mp4a"),s,a]),d=function(e,t,n,r,i,a,o){return y("enca",(0,l.zo)(6,(0,l.XT)(e),8,(0,l.XT)(t),(0,l.XT)(n),2,(0,l.XT)(r),(0,l.XT)(i),2,a,o))}(1,t,n,r,i,c,u);return X([d])}();return ne(e,"audio",f,y("smhd",new Uint8Array(8)),0,0)}function oe(e,t,n,r,i,a){var o,s=t.segment.range;return Array.isArray(s)&&(o={Range:(0,te.Z)(s)}),(0,F.ZP)({url:e,responseType:"arraybuffer",headers:o,timeout:r.timeout,cancelSignal:i,onProgress:n.onProgress}).then((function(e){if(!H(t.mimeType)||!0!==a)return{resultType:"segment-loaded",resultData:e};var n=new Uint8Array(e.responseData);return(0,z.Z)(n,t.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},e),{responseData:n})}}))}var se=function(e){var t=e.checkMediaSegmentIntegrity,n=e.customSegmentLoader;return function(e,r,i,a,o){var s=r.segment;if(s.isInit){if(void 0===s.privateInfos||void 0===s.privateInfos.smoothInitSegment)throw new Error("Smooth: Invalid segment format");var u,l=s.privateInfos.smoothInitSegment,d=l.codecPrivateData,c=l.timescale,f=l.height,v=l.width,p=l.protection,h=void 0===p?{keyId:void 0,keySystems:void 0}:p;if(void 0===d)throw new Error("Smooth: no codec private data.");switch(r.type){case"video":u=re(c,null!=v?v:0,null!=f?f:0,72,72,4,d,h.keyId);break;case"audio":var m=l.channels,g=void 0===m?0:m,y=l.bitsPerSample,_=void 0===y?0:y,b=l.packetSize,S=void 0===b?0:b,E=l.samplingRate;u=ae(c,g,_,S,void 0===E?0:E,d,h.keyId);break;default:0,u=new Uint8Array(0)}return Promise.resolve({resultType:"segment-created",resultData:u})}return null===e?Promise.resolve({resultType:"segment-created",resultData:null}):"function"!=typeof n?oe(e,r,o,i,a,t):new Promise((function(s,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a Smooth segment through a custom segmentLoader.",o=new ee.Z(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(e){if(!d&&!a.isCancelled()){d=!0,a.deregister(p),H(r.mimeType)&&!0===t||s({resultType:"segment-loaded",resultData:{responseData:e.data,size:e.size,requestDuration:e.duration}});var n=e.data instanceof Uint8Array?e.data:new Uint8Array(e.data);(0,z.Z)(n,r.segment.isInit),s({resultType:"segment-loaded",resultData:{responseData:n,size:e.size,requestDuration:e.duration}})}},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),oe(e,r,o,i,a,t).then(s,u))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:e},v=n(f,c);function p(e){d||((d=!0)||"function"!=typeof v||v(),u(e))}a.register(p)}))}};function ue(e,t){return null===e?null:null===t.url?e.baseUrl:(0,f.Z)(e.baseUrl,t.url)}var le=function(e){var t=B(e),n=se(e),o={customManifestLoader:e.manifestLoader},s={loadSegment:function(e,t,r,i,a){var o=ue(e,t.segment);return n(o,t,r,i,a)},parseSegment:function(e,t,n){var r,i,a=t.segment,o=e.data,s=e.isChunked;if(null===o)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var u=o instanceof Uint8Array?o:new Uint8Array(o);if(a.isInit){var l=null===(i=null===(r=a.privateInfos)||void 0===r?void 0:r.smoothInitSegment)||void 0===i?void 0:i.timescale;return{segmentType:"init",initializationData:o,initializationDataSize:o.byteLength,initTimescale:l,protectionData:[]}}var d=void 0!==n?j(u,s,n,a,t.isLive):null;if(null===d||null===d.chunkInfos||void 0===d.scaledSegmentTime)throw new Error("Smooth Segment without time information");var c=d.nextSegments,f=d.chunkInfos,v=J(u,d.scaledSegmentTime),p=c.length>0?c:void 0;return{segmentType:"media",chunkData:v,chunkInfos:f,chunkOffset:0,chunkSize:v.length,protectionData:[],predictedSegments:p,appendWindow:[void 0,void 0]}}};return{manifest:{loadManifest:(0,V.Z)(o,"text"),parseManifest:function(n,r){var a,o=null!==(a=n.url)&&void 0!==a?a:r.originalUrl,s=n.receivedTime,u=n.responseData,l="string"==typeof u?(new DOMParser).parseFromString(u,"text/xml"):u,d=t(l,o,s);return{manifest:new i.ZP(d,{representationFilter:e.representationFilter}),url:o}}},audio:s,video:s,text:{loadSegment:function(t,n,r,i,a){var o=n.segment,s=ue(t,o);return o.isInit||null===s?Promise.resolve({resultType:"segment-created",resultData:null}):H(n.mimeType)?(0,F.ZP)({url:s,responseType:"arraybuffer",timeout:r.timeout,cancelSignal:i,onProgress:a.onProgress}).then((function(t){if(!0!==e.checkMediaSegmentIntegrity)return{resultType:"segment-loaded",resultData:t};var r=new Uint8Array(t.responseData);return(0,z.Z)(r,n.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},t),{responseData:r})}})):(0,F.ZP)({url:s,responseType:"text",timeout:r.timeout,cancelSignal:i,onProgress:a.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))},parseSegment:function(e,t,n){var i,o,s,u=t.segment,l=t.language,d=t.mimeType,c=void 0===d?"":d,f=t.codecs,p=void 0===f?"":f,h=H(t.mimeType),m=e.data,g=e.isChunked;if(u.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if(null===m)return{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var y,_,b,S,E=null;if(h){var T;o=(T="string"==typeof m?(0,v.tG)(m):m instanceof Uint8Array?m:new Uint8Array(m)).length;var k=void 0!==n?j(T,g,n,u,t.isLive):null;s=null==k?void 0:k.nextSegments,null===(E=null!==(i=null==k?void 0:k.chunkInfos)&&void 0!==i?i:null)?g?r.Z.warn("Smooth: Unavailable time data for current text track."):(y=u.time,_=u.end):(y=E.time,_=void 0!==E.duration?E.time+E.duration:u.end);var w=p.toLowerCase();if("application/ttml+xml+mp4"===c||"stpp"===w||"stpp.ttml.im1t"===w)S="ttml";else{if("wvtt"!==w)throw new Error("could not find a text-track parser for the type "+c);S="vtt"}var A=(0,a.Le)(T);b=null===A?"":(0,v.uR)(A)}else{var I;if(y=u.time,_=u.end,"string"!=typeof m){var R=m instanceof Uint8Array?m:new Uint8Array(m);o=R.length,I=(0,v.uR)(R)}else I=m;switch(c){case"application/x-sami":case"application/smil":S="sami";break;case"application/ttml+xml":S="ttml";break;case"text/vtt":S="vtt"}if(void 0===S){if("srt"!==p.toLowerCase())throw new Error("could not find a text-track parser for the type "+c);S="srt"}b=I}return{segmentType:"media",chunkData:{type:S,data:b,start:y,end:_,language:l},chunkSize:o,chunkInfos:E,chunkOffset:null!=y?y:0,protectionData:[],predictedSegments:Array.isArray(s)&&s.length>0?s:void 0,appendWindow:[void 0,void 0]}}}}}},281:function(e,t,n){"use strict";function r(e){var t=e[0],n=e[1];return n===1/0?"bytes="+t+"-":"bytes="+t+"-"+n}n.d(t,{Z:function(){return r}})},4460:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(5389),i=n(8766);function a(e,t){if(t){if((0,i.Z)(e,1718909296)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `ftyp` box");if((0,i.Z)(e,1836019574)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `moov` box")}else{if((0,i.Z)(e,1836019558)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `moof` box");if((0,i.Z)(e,1835295092)<0)throw new r.Z("INTEGRITY_ERROR","Incomplete `mdat` box")}}},8766:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(6968);function i(e,t){for(var n=e.length,i=0;i+8<=n;){var a=(0,r.pX)(e,i);if(0===a)a=n-i;else if(1===a){if(i+16>n)return-1;a=(0,r.pV)(e,i+8)}if(isNaN(a)||a<=0)return-1;if((0,r.pX)(e,i+4)===t)return i+a<=n?i:-1;i+=a}return-1}},8791:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(7904),i=n(4597),a=n(7839);function o(e,t){var n=e.customManifestLoader,o=function(e){return function(t,n,a){if(void 0===t)throw new Error("Cannot perform HTTP(s) request. URL not known");switch(e){case"arraybuffer":return(0,i.ZP)({url:t,responseType:"arraybuffer",timeout:n.timeout,cancelSignal:a});case"text":return(0,i.ZP)({url:t,responseType:"text",timeout:n.timeout,cancelSignal:a});case"document":return(0,i.ZP)({url:t,responseType:"document",timeout:n.timeout,cancelSignal:a});default:(0,r.Z)(e)}}}(t);return"function"!=typeof n?o:function(e,t){return function(n,r,i){return new Promise((function(o,s){var u=Date.now()-performance.now(),l=!1,d={reject:function(e){var t,n;if(!l&&!i.isCancelled()){l=!0,i.deregister(f);var r=e,o=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching the Manifest through a custom manifestLoader.",u=new a.Z(o,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);s(u)}},resolve:function(e){if(!l&&!i.isCancelled()){l=!0,i.deregister(f);var t=void 0!==e.receivingTime?e.receivingTime-u:void 0,n=void 0!==e.sendingTime?e.sendingTime-u:void 0;o({responseData:e.data,size:e.size,requestDuration:e.duration,url:e.url,receivedTime:t,sendingTime:n})}},fallback:function(){l||i.isCancelled()||(l=!0,i.deregister(f),t(n,r,i).then(o,s))}},c=e({url:n,timeout:r.timeout},d);function f(e){l||(l=!0,"function"==typeof c&&c(),s(e))}i.register(f)}))}}(n,o)}},4791:function(e,t,n){"use strict";function r(e,t){if(e.length!==t.length)return!1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return!1;return!0}n.d(t,{Z:function(){return r}})},3274:function(e,t,n){"use strict";function r(e,t,n){if("function"==typeof Array.prototype.find)return e.find(t,n);for(var r=e.length>>>0,i=0;i>>0,i=0;i>>0;if(0===r)return!1;for(var i,a,o=0|n,s=o>=0?Math.min(o,r-1):Math.max(r+o,0);s=a.length)throw new Error("Unable to parse base64 string.");var t=a[e];if(255===t)throw new Error("Unable to parse base64 string.");return t}function s(e){var t,n="",r=e.length;for(t=2;t>2],n+=i[(3&e[t-2])<<4|e[t-1]>>4],n+=i[(15&e[t-1])<<2|e[t]>>6],n+=i[63&e[t]];return t===r+1&&(n+=i[e[t-2]>>2],n+=i[(3&e[t-2])<<4],n+="=="),t===r&&(n+=i[e[t-2]>>2],n+=i[(3&e[t-2])<<4|e[t-1]>>4],n+=i[(15&e[t-1])<<2],n+="="),n}function u(e){var t=e.length%4,n=e;0!==t&&(r.Z.warn("base64ToBytes: base64 given miss padding"),n+=3===t?"=":2===t?"==":"===");var i=n.indexOf("=");if(-1!==i&&i>16,l[c+1]=a>>8&255,l[c+2]=255&a;return l.subarray(0,l.length-s)}},6968:function(e,t,n){"use strict";function r(){for(var e,t=arguments.length,n=-1,r=0;++n0&&(i.set(e,a),a+=e.length);return i}function i(e,t){return(e[t+0]<<8)+(e[t+1]<<0)}function a(e,t){return 65536*e[t+0]+256*e[t+1]+e[t+2]}function o(e,t){return 16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3]}function s(e,t){return 4294967296*(16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3])+16777216*e[t+4]+65536*e[t+5]+256*e[t+6]+e[t+7]}function u(e){return new Uint8Array([e>>>8&255,255&e])}function l(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function d(e){var t=e%4294967296,n=(e-t)/4294967296;return new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function c(e,t){return(e[t+0]<<0)+(e[t+1]<<8)}function f(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}function v(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}n.d(t,{O_:function(){return v},QI:function(){return a},XT:function(){return u},dN:function(){return f},el:function(){return d},kh:function(){return l},pV:function(){return s},pX:function(){return o},qb:function(){return c},zK:function(){return i},zo:function(){return r}})},7864:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(7733);function i(e,t){return(0,r.Z)(t,(function(t){var n=setTimeout((function(){return t()}),e);return function(){return clearTimeout(n)}}))}},7733:function(e,t,n){"use strict";function r(e,t){var n;return new Promise((function(r,i){if(null!==e.cancellationError)return i(e.cancellationError);var a=!1;function o(e){void 0!==n&&n(),i(e)}n=t((function(t){e.deregister(o),a=!0,r(t)}),(function(t){e.deregister(o),a=!0,i(t)})),a||e.register(o)}))}n.d(t,{Z:function(){return r}})},1959:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(3887),i=n(1946),a=function(){function e(){this._listeners={}}var t=e.prototype;return t.addEventListener=function(e,t,n){var r=this,i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],void 0!==n&&n.register((function(){r.removeEventListener(e,t)}))},t.removeEventListener=function(e,t){if((0,i.Z)(e))this._listeners={};else{var n=this._listeners[e];if(Array.isArray(n))if((0,i.Z)(t))delete this._listeners[e];else{var r=n.indexOf(t);-1!==r&&n.splice(r,1),0===n.length&&delete this._listeners[e]}}},t.trigger=function(e,t){var n=this._listeners[e];Array.isArray(n)&&n.slice().forEach((function(e){try{e(t)}catch(e){r.Z.error("EventEmitter: listener error",e instanceof Error?e:null)}}))},e}()},9592:function(e,t,n){"use strict";function r(e,t){return"function"==typeof Array.prototype.flatMap?e.flatMap(t):e.reduce((function(e,n){var r=t(n);return Array.isArray(r)?(e.push.apply(e,r),e):(e.push(r),e)}),[])}n.d(t,{Z:function(){return r}})},2572:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=.3;function i(e){return e*((2*Math.random()-1)*r+1)}},908:function(e,t,n){"use strict";function r(){var e="",t=-1;return function(){return++t>=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}n.d(t,{Z:function(){return r}})},6923:function(e,t,n){"use strict";function r(e){return"string"==typeof e&&e.length>0}n.d(t,{Z:function(){return r}})},1946:function(e,t,n){"use strict";function r(e){return null==e}n.d(t,{Z:function(){return r}})},5288:function(e,t,n){"use strict";n.d(t,{ZP:function(){return u}});var r=n(6923),i=n(1946),a={aa:"aar",ab:"abk",ae:"ave",af:"afr",ak:"aka",am:"amh",an:"arg",ar:"ara",as:"asm",av:"ava",ay:"aym",az:"aze",ba:"bak",be:"bel",bg:"bul",bi:"bis",bm:"bam",bn:"ben",bo:"bod",br:"bre",bs:"bos",ca:"cat",ce:"che",ch:"cha",co:"cos",cr:"cre",cs:"ces",cu:"chu",cv:"chv",cy:"cym",da:"dan",de:"deu",dv:"div",dz:"dzo",ee:"ewe",el:"ell",en:"eng",eo:"epo",es:"spa",et:"est",eu:"eus",fa:"fas",ff:"ful",fi:"fin",fj:"fij",fo:"fao",fr:"fra",fy:"fry",ga:"gle",gd:"gla",gl:"glg",gn:"grn",gu:"guj",gv:"glv",ha:"hau",he:"heb",hi:"hin",ho:"hmo",hr:"hrv",ht:"hat",hu:"hun",hy:"hye",hz:"her",ia:"ina",id:"ind",ie:"ile",ig:"ibo",ii:"iii",ik:"ipk",io:"ido",is:"isl",it:"ita",iu:"iku",ja:"jpn",jv:"jav",ka:"kat",kg:"kon",ki:"kik",kj:"kua",kk:"kaz",kl:"kal",km:"khm",kn:"kan",ko:"kor",kr:"kau",ks:"kas",ku:"kur",kv:"kom",kw:"cor",ky:"kir",la:"lat",lb:"ltz",lg:"lug",li:"lim",ln:"lin",lo:"lao",lt:"lit",lu:"lub",lv:"lav",mg:"mlg",mh:"mah",mi:"mri",mk:"mkd",ml:"mal",mn:"mon",mr:"mar",ms:"msa",mt:"mlt",my:"mya",na:"nau",nb:"nob",nd:"nde",ne:"nep",ng:"ndo",nl:"nld",nn:"nno",no:"nor",nr:"nbl",nv:"nav",ny:"nya",oc:"oci",oj:"oji",om:"orm",or:"ori",os:"oss",pa:"pan",pi:"pli",pl:"pol",ps:"pus",pt:"por",qu:"que",rm:"roh",rn:"run",ro:"ron",ru:"rus",rw:"kin",sa:"san",sc:"srd",sd:"snd",se:"sme",sg:"sag",si:"sin",sk:"slk",sl:"slv",sm:"smo",sn:"sna",so:"som",sq:"sqi",sr:"srp",ss:"ssw",st:"sot",su:"sun",sv:"swe",sw:"swa",ta:"tam",te:"tel",tg:"tgk",th:"tha",ti:"tir",tk:"tuk",tl:"tgl",tn:"tsn",to:"ton",tr:"tur",ts:"tso",tt:"tat",tw:"twi",ty:"tah",ug:"uig",uk:"ukr",ur:"urd",uz:"uzb",ve:"ven",vi:"vie",vo:"vol",wa:"wln",wo:"wol",xh:"xho",yi:"yid",yo:"yor",za:"zha",zh:"zho",zu:"zul"},o={alb:"sqi",arm:"hye",baq:"eus",bur:"mya",chi:"zho",cze:"ces",dut:"nld",fre:"fra",geo:"kat",ger:"deu",gre:"ell",ice:"isl",mac:"mkd",mao:"mri",may:"msa",per:"fas",slo:"slk",rum:"ron",tib:"bod",wel:"cym"};function s(e){if((0,i.Z)(e)||""===e)return"";var t=function(e){var t;switch(e.length){case 2:t=a[e];break;case 3:t=o[e]}return t}((""+e).toLowerCase().split("-")[0]);return(0,r.Z)(t)?t:e}var u=s},8894:function(e,t,n){"use strict";function r(){}n.d(t,{Z:function(){return r}})},8026:function(e,t){"use strict";t.Z="function"==typeof Object.assign?Object.assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=0;n<(arguments.length<=1?0:arguments.length-1);n++){var r=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}},1679:function(e,t,n){"use strict";t.Z="function"==typeof Object.values?Object.values:function(e){return Object.keys(e).map((function(t){return e[t]}))}},2829:function(e,t,n){"use strict";n.d(t,{A1:function(){return s},F_:function(){return p},JN:function(){return c},L7:function(){return h},Ti:function(){return u},XS:function(){return v},kR:function(){return m},rx:function(){return f},tn:function(){return y},uH:function(){return _}});var r=1/60;function i(e,t){return Math.abs(e-t)=0;n--){var r=e.start(n);if(t>=r){var i=e.end(n);if(t=o?r.push({start:a,end:o}):n={start:a,end:o}}return{outerRanges:r,innerRange:n}}function h(e,t){var n=f(e,t);return null!==n?n.end-t:1/0}function m(e,t){if(t.start===t.end)return e;for(var n=t,r=0;r0)for(var o=0;o0)for(var s=0;sl&&n.push({start:l,end:a[d].start}),l=a[d].end;l=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&i.splice(e,1)}}i.push(r),!0===(null==t?void 0:t.emitCurrentValue)&&e(n,o),a||r.hasBeenCleared?o():void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.register(o)},waitUntilDefined:function(e,t){this.onUpdate((function(t,r){void 0!==t&&(r(),e(n))}),{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:!0})},finish:o};function o(){void 0!==t&&t.deregister(o),a=!0;for(var e,n=r(i.slice());!(e=n()).done;){var s=e.value;try{s.hasBeenCleared||(s.complete(),s.hasBeenCleared=!0)}catch(e){}}i.length=0}}function o(e,t,n){var r=a(t(e.getValue()),n);return e.onUpdate((function(e){r.setValue(t(e))}),{clearSignal:n}),r}n.d(t,{$l:function(){return a},ZP:function(){return a},lR:function(){return o}})},4597:function(e,t,n){"use strict";n.d(t,{ZP:function(){return o}});var r=n(9105),i=n(6923),a=n(1946);var o=function(e){var t={url:e.url,headers:e.headers,responseType:(0,a.Z)(e.responseType)?"json":e.responseType,timeout:e.timeout};return new Promise((function(n,o){var s,u=e.onProgress,l=e.cancelSignal,d=t.url,c=t.headers,f=t.responseType,v=t.timeout,p=new XMLHttpRequest;if(p.open("GET",d,!0),void 0!==v&&(p.timeout=v,s=window.setTimeout((function(){_(),o(new r.Z(d,p.status,"TIMEOUT"))}),v+3e3)),p.responseType=f,"document"===p.responseType&&p.overrideMimeType("text/xml"),!(0,a.Z)(c)){var h=c;for(var m in h)h.hasOwnProperty(m)&&p.setRequestHeader(m,h[m])}var g=performance.now(),y=null;function _(){void 0!==s&&clearTimeout(s),null!==y&&y()}void 0!==l&&(y=l.register((function(e){_(),(0,a.Z)(p)||4===p.readyState||p.abort(),o(e)})),l.isCancelled())||(p.onerror=function(){_(),o(new r.Z(d,p.status,"ERROR_EVENT"))},p.ontimeout=function(){_(),o(new r.Z(d,p.status,"TIMEOUT"))},void 0!==u&&(p.onprogress=function(e){var t=performance.now();u({url:d,duration:t-g,sendingTime:g,currentTime:t,size:e.loaded,totalSize:e.total})}),p.onload=function(e){if(4===p.readyState)if(_(),p.status>=200&&p.status<300){var t,s=performance.now(),u=p.response instanceof ArrayBuffer?p.response.byteLength:e.total,l=p.status,c=p.responseType,f=(0,i.Z)(p.responseURL)?p.responseURL:d;if(t="json"===c?"object"==typeof p.response?p.response:function(e){try{return JSON.parse(e)}catch(e){return null}}(p.responseText):p.response,(0,a.Z)(t))return void o(new r.Z(d,p.status,"PARSE_ERROR"));n({status:l,url:f,responseType:c,sendingTime:g,receivedTime:s,requestDuration:s-g,size:u,responseData:t})}else o(new r.Z(d,p.status,"ERROR_HTTP_CODE"))},p.send())}))}},9829:function(e,t,n){"use strict";n.d(t,{$:function(){return o},Z:function(){return a}});var r=/^(?:[a-z]+:)?\/\//i,i=/\/\.{1,2}\//;function a(){var e=arguments.length;if(0===e)return"";for(var t="",n=0;n=0&&t===n+1)return e.length}var i=e.indexOf("?");return i>=0&&i>8&255}return n}function u(e){if(a)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";r.Z.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var n="",i=0;i=t?n:new Array(t-n.length+1).join("0")+n}function c(e){if(a)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";r.Z.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var n=e;239===n[0]&&187===n[1]&&191===n[2]&&(n=n.subarray(3));var i,o=function(e){for(var t="",n=0;n=256?"%u"+d(l,4):"%"+d(l,2)}}return decodeURIComponent(i)}function f(e){for(var t=e.length,n=new Uint8Array(t/2),r=0,i=0;r>>4).toString(16),n+=(15&e[r]).toString(16),t.length>0&&r0;)try{var n=t._listeners.pop();null==n||n(e)}catch(e){o.Z.error("Error while calling clean up listener",e instanceof Error?e.toString():"Unknown error")}}))}var t=e.prototype;return t.isCancelled=function(){return this._isCancelled},t.register=function(e){var t=this;return this._isCancelled?((0,s.Z)(null!==this.cancellationError),e(this.cancellationError),u.Z):(this._listeners.push(e),function(){return t.deregister(e)})},t.deregister=function(e){for(var t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)},e}(),c=function(e){function t(){var n;return n=e.call(this)||this,Object.setPrototypeOf((0,r.Z)(n),t.prototype),n.name="CancellationError",n.message="This task was cancelled.",n}return(0,i.Z)(t,e),t}((0,a.Z)(Error))},8806:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(7714),i=[];function a(e){(0,r.Z)(i,e)||(console.warn(e),i.push(e))}},7473:function(e){"use strict";var t=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e},n=function(e){var n,r,i=document.createTextNode(""),a=0;return new e((function(){var e;if(n)r&&(n=r.concat(n));else{if(!r)return;n=r}if(r=n,n=null,"function"==typeof r)return e=r,r=null,void e();for(i.data=a=++a%2;r;)e=r.shift(),r.length||(r=null),e()})).observe(i,{characterData:!0}),function(e){t(e),n?"function"==typeof n?n=[n,e]:n.push(e):(n=e,i.data=a=++a%2)}};e.exports=function(){if("object"==typeof process&&process&&"function"==typeof process.nextTick)return process.nextTick;if("function"==typeof queueMicrotask)return function(e){queueMicrotask(t(e))};if("object"==typeof document&&document){if("function"==typeof MutationObserver)return n(MutationObserver);if("function"==typeof WebKitMutationObserver)return n(WebKitMutationObserver)}return"function"==typeof setImmediate?function(e){setImmediate(t(e))}:"function"==typeof setTimeout||"object"==typeof setTimeout?function(e){setTimeout(t(e),0)}:null}()},7061:function(e,t,n){var r=n(8698).default;function i(){"use strict";e.exports=i=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,a=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",d=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof h?t:h,a=Object.create(i.prototype),s=new R(r||[]);return o(a,"_invoke",{value:k(e,n,s)}),a}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p={};function h(){}function m(){}function g(){}var y={};c(y,u,(function(){return this}));var _=Object.getPrototypeOf,b=_&&_(_(Z([])));b&&b!==n&&a.call(b,u)&&(y=b);var S=g.prototype=h.prototype=Object.create(y);function E(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(i,o,s,u){var l=v(e[i],e,o);if("throw"!==l.type){var d=l.arg,c=d.value;return c&&"object"==r(c)&&a.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){d.value=e,s(d)}),(function(e){return n("throw",e,s,u)}))}u(l.arg)}var i;o(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}})}function k(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return x()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=w(o,n);if(s){if(s===p)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=v(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var i=v(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,p;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function Z(e){if(e){var t=e[u];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),u=a.call(i,"finallyLoc");if(s&&u){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;I(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:Z(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),p}},t}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},8698:function(e){function t(n){return e.exports=t="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},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},4687:function(e,t,n){var r=n(7061)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},7326:function(e,t,n){"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,{Z:function(){return r}})},5861:function(e,t,n){"use strict";function r(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var o=e.apply(t,n);function s(e){r(o,i,a,s,u,"next",e)}function u(e){r(o,i,a,s,u,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return i}})},1656:function(e,t,n){"use strict";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)}function i(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===r(t)?t:String(t)}function a(e,t){for(var n=0;ni)break}if(l<0||n.length!==t.length)return s.Z.error("ABR: Current Bitrate not found in the calculated levels"),n[0];void 0!==a&&(u=0===o?a.score:a.score/o);var f=isFinite(r)?r:0,v=performance.now();if(f=0;m--)if(f>=t[m])return n[m];return n[0]}if(void 0!==this._lastUnsuitableQualityTimestamp&&v-this._lastUnsuitableQualityTimestampg)return e}();if(void 0!==y&&r>=t[y])return s.Z.debug("ABR: Raising quality in BufferBasedChooser",n[y]),n[y];return i},e}(),F=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var n=Math.pow(this._alpha,e),r=t*(1-n)+n*this._lastEstimate;isNaN(r)||(this._lastEstimate=r,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function z(e){if(!(e.progress.length<5)){for(var t=new F(2),n=e.progress,r=1;r=u.outOfStarvationGap&&(s.Z.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(s.Z.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&(o=function(e,t,n,r,i){if(!r){var a=t.bufferGap,o=t.speed,s=t.position,u=isFinite(a)?a:0,l=function(e,t){for(var n=-1,r=0;r-1.2){n=r;break}if(a>t&&t-i.time>-1.2){n=r;break}}}if(n<0)return[];for(var o=e[n],s=o.content.segment.time,u=[o],l=n+1;l0?d.progress[d.progress.length-1]:void 0,p=z(d);if(void 0!==v&&void 0!==p){var h=V(v,p);if((c-v.timestamp)/1e3<=h&&h-u/o>2500)return p}if(d.content.segment.complete){var m=d.content.segment.duration,g=(c-d.requestTimestamp)/1e3;if(null!=n&&!(g<=(1.5*m+2)/o)){var y=m/g,_=n.bitrate*Math.min(.7,y);return void 0===i||_1&&(a/=e.speed),{bandwidthEstimate:o,bitrateChosen:a}},t.isUrgent=function(e,t,n,r){return null===t||!(e>=t.bitrate)&&function(e,t,n){if(n)return!0;var r=isFinite(e.bufferGap)?e.bufferGap:0,i=e.position.last+r,a=(0,p.Z)(t,(function(e){var t=e.content;return t.segment.duration>0&&t.segment.time+t.segment.duration>i}));if(void 0===a)return!0;var o=performance.now(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=z(a);if(void 0===s||void 0===u)return!0;var l=V(s,u);return(o-s.timestamp)/1e3>1.2*l||l-r/e.speed>-1.5}(r,n,this._lowLatencyMode)},e}();function G(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nu.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var l=this._scoreCalculator.getEstimate(n);if(2!==this._lastAbrEstimate.algorithmType){if(void 0===l)return null;if(this._canGuessHigher(a,o,l)){var d=W(e,n);if(null!==d)return d}return null}if(this._isLastGuessValidated(u,r,l)&&(s.Z.debug("ABR: Guessed Representation validated",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),n.id!==u.id)return u;if(this._shouldStopGuess(n,l,a,i))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=performance.now()+Math.min(15e3*this._consecutiveWrongGuesses,12e4),function(e,t){var n=(0,L.Z)(e,(function(e){return e.id===t.id}));if(n<0)return s.Z.error("ABR: Current Representation not found."),null;for(;--n>=0;)if(e[n].bitrate=2.5&&performance.now()>this._blockGuessesUntil&&1===i&&r/t>1.01},t._shouldStopGuess=function(e,t,n,r){if(void 0!==t&&t.score<1.01)return!0;if((void 0===t||t.score<1.2)&&n<.6)return!0;for(var i,a=r.filter((function(t){return t.content.representation.id===e.id})),o=performance.now(),s=G(a);!(i=s()).done;){var u=i.value,l=o-u.requestTimestamp;if(u.content.segment.isInit){if(l>1e3)return!0}else{if(l>1e3*u.content.segment.duration+200)return!0;var d=z(u);if(void 0!==d&&d<.8*e.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,n){return void 0!==n&&1===n.confidenceLevel&&n.score>1.5||t>=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitratet.bitrate)return e[r];return null}var q=function(){function e(){var e=l.Z.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new F(t),this._slowEWMA=new F(n),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){if(!(t1&&this._lastRepresentationWithGoodScore!==e&&(s.Z.debug("ABR: New last stable representation",e.bitrate),this._lastRepresentationWithGoodScore=e)},t.getEstimate=function(e){if(null!==this._currentRepresentationData&&this._currentRepresentationData.representation.id===e.id){var t=this._currentRepresentationData,n=t.ewma,r=t.loadedSegments,i=t.loadedDuration;return{score:n.getEstimate(),confidenceLevel:r>=5&&i>=10?1:0}}},t.getLastStableRepresentation=function(){return this._lastRepresentationWithGoodScore},e}();function J(e,t){var n=(0,L.Z)(e,(function(e){return e.bitrate>t}));return-1===n?e[e.length-1]:0===n?e[0]:e[n-1]}var ee=(0,T.ZP)(void 0);ee.finish();var te=(0,T.ZP)(1/0);te.finish();var ne=function(e){var t={},n=e.initialBitrates,r=e.throttlers,i=e.lowLatencyMode;return function(e,a,o,u,d){var c=e.adaptation.type,f=function(e){var n=t[e];if(null==n){s.Z.debug("ABR: Creating new BandwidthEstimator for ",e);var r=new q;return t[e]=r,r}return n}(c),v=(0,O.Z)(n[c],0);return function(e,t){var n=e.bandwidthEstimator,r=e.context,i=e.currentRepresentation,a=e.filters,o=e.initialBitrate,u=e.lowLatencyMode,d=e.playbackObserver,c=e.representations,f=new $,v=new K(null!=o?o:0,u),h=new Q,m=N.Z,g={metrics:w,requestBegin:A,requestProgress:I,requestEnd:R,addedSegment:function(e){m(e)}},y=new k.ZP;y.linkToSignal(t);var _=b(c.getValue(),y.signal);return c.onUpdate(S,{clearSignal:t}),{estimates:_,callbacks:g};function b(e,t){if(1===e.length)return(0,T.ZP)({bitrate:void 0,representation:e[0],urgent:!0,knownStableBitrate:void 0});var o,c=!1,g=e.map((function(e){return e.bitrate})),y=new B(g),_=new Y,b=new H(f,_),S=d.getReference().getValue(),k=(0,T.ZP)(A());return d.listen((function(e){S=e,w()}),{includeLastObservation:!1,clearSignal:t}),m=function(e){if(null!==S){var t=S,n=t.position,r=t.speed,i=e.buffered,a=(0,E.L7)(i,n.last),s=e.content.representation,u=f.getEstimate(s),l={bufferGap:a,currentBitrate:s.bitrate,currentScore:u,speed:r};o=y.getEstimate(l),w()}},t.register((function(){m=N.Z})),a.throttleBitrate.onUpdate(w,{clearSignal:t}),a.limitResolution.onUpdate(w,{clearSignal:t}),k;function w(){k.setValue(A())}function A(){var t=S,d=t.bufferGap,m=t.position,g=t.maximumPosition,y=a.limitResolution.getValue(),E=a.throttleBitrate.getValue(),T=i.getValue(),k=function(e,t,n){var r=e;void 0!==n&&n<1/0&&(r=function(e,t){if(0===e.length)return[];e.sort((function(e,t){return e.bitrate-t.bitrate}));var n=e[0].bitrate,r=Math.max(t,n),i=(0,L.Z)(e,(function(e){return e.bitrate>r}));return-1===i?e:e.slice(0,i)}(r,n));void 0!==t&&(r=function(e,t){if(void 0===t.width||void 0===t.height)return e;var n=t.width*t.pixelRatio,r=t.height*t.pixelRatio,i=e.slice().sort((function(e,t){return(0,O.Z)(e.width,0)-(0,O.Z)(t.width,0)})),a=(0,p.Z)(i,(function(e){return"number"==typeof e.width&&e.width>=n&&"number"==typeof e.height&&e.height>=r}));if(void 0===a)return e;var o="number"==typeof a.width?a.width:0;return e.filter((function(e){return"number"!=typeof e.width||e.width<=o}))}(r,t));return r}(e,y,E),w=h.getRequests(),A=v.getBandwidthEstimate(S,n,T,w,_.bandwidth),I=A.bandwidthEstimate,R=A.bitrateChosen,Z=f.getLastStableRepresentation(),x=null===Z?void 0:Z.bitrate/(S.speed>0?S.speed:1),P=l.Z.getCurrent(),M=P.ABR_ENTER_BUFFER_BASED_ALGO,C=P.ABR_EXIT_BUFFER_BASED_ALGO;c&&d<=C?c=!1:!c&&isFinite(d)&&d>=M&&(c=!0);var D=J(k,R),N=D.bitrate,U=null;c&&void 0!==o&&o>N&&(N=(U=J(k,o)).bitrate);var B=null;return u&&null!==T&&r.manifest.isDynamic&&g-m.last<40&&(B=b.getGuess(e,S,T,N,w)),null!==B&&B.bitrate>N?(s.Z.debug("ABR: Choosing representation with guess-based estimation.",B.bitrate,B.id),_.update(B,I,2),{bitrate:I,representation:B,urgent:null===T||B.bitrate=500||404===h.status||415===h.status||412===h.status:h.type===f.br.TIMEOUT||h.type===f.br.ERROR_EVENT:h instanceof se.Z?"boolean"==typeof h.canRetry?h.canRetry:void 0!==h.xhr&&(h.xhr.status>=500||404===h.xhr.status||415===h.xhr.status||412===h.xhr.status):(0,ue.Z)(h)&&"INTEGRITY_ERROR"===h.code){e.next=18;break}return s.blockedUntil=void 0,s.isBlacklisted=!0,e.abrupt("return",g(e.t0));case 18:return s.errorCounter>l?(s.blockedUntil=void 0,s.isBlacklisted=!0):(d=s.errorCounter,v=Math.min(o*Math.pow(2,d-1),u),p=(0,de.Z)(v),s.blockedUntil=performance.now()+p),e.abrupt("return",g(e.t0));case 20:case"end":return e.stop()}var h}),e,null,[[0,7]])})))).apply(this,arguments)},h=function(e){return m.apply(this,arguments)},p=function(){if(null===t){var e=c.get(null);if(void 0!==e&&e.isBlacklisted)return;return null}if(null===n)return b(t);var r=n.getCdnPreferenceForResource(t);return b(r)},null===a.cancellationError){e.next=9;break}return e.abrupt("return",Promise.reject(a.cancellationError));case 9:if(o=i.baseDelay,u=i.maxDelay,l=i.maxRetry,d=i.onRetry,null!==t&&0===t.length&&s.Z.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),c=new Map,void 0!==(v=p())){e.next=15;break}throw new Error("No CDN to request");case 15:return e.abrupt("return",h(v));case 16:case"end":return e.stop()}}),e)}))),fe.apply(this,arguments)}function ve(e,t,n){return ce(null,null,e,t,n)}function pe(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return he(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return he(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?this._consecutiveUnsafeMode=d,v=void 0===r?0:performance.now()-r,p=Math.max(this._settings.minimumManifestUpdateInterval-v,0),h=new k.ZP;if(h.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=function(t){var i=t.enablePartialRefresh,a=t.delay,o=t.canUseUnsafeMode&&f,s=void 0===r?0:performance.now()-r,u=Math.max(n._settings.minimumManifestUpdateInterval-s,0),l=setTimeout((function(){h.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:i,unsafeMode:o})}),Math.max((null!=a?a:0)-s,u));h.signal.register((function(){clearTimeout(l)}))},null!==e.expired){var m=setTimeout((function(){var t;null===(t=e.expired)||void 0===t||t.then((function(){h.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:f})}),N.Z)}),p);h.signal.register((function(){clearTimeout(m)}))}if(void 0!==e.lifetime&&e.lifetime>=0){var g,y=1e3*e.lifetime-v;void 0===c?g=y:e.lifetime<3&&c>=100?(g=Math.min(Math.max(3e3-v,Math.max(y,0)+c),6*y),s.Z.info("MUS: Manifest update rythm is too frequent. Postponing next request.",y,g)):c>=1e3*e.lifetime/10?(g=Math.min(Math.max(y,0)+c,6*y),s.Z.info("MUS: Manifest took too long to parse. Postponing next request",g,g)):g=y;var _=setTimeout((function(){h.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:f})}),Math.max(g,p));h.signal.register((function(){clearTimeout(_)}))}},r._triggerNextManifestRefresh=function(e,t){var n,r,i=this,a=t.enablePartialRefresh,o=t.unsafeMode,u=e.updateUrl;null!==this._prioritizedContentUrl?(n=!0,r=this._prioritizedContentUrl,this._prioritizedContentUrl=null):r=(n=!a||void 0===u)?e.getUrls()[0]:u;var d=e.clockOffset;o?(this._consecutiveUnsafeMode+=1,s.Z.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):this._consecutiveUnsafeMode>0&&(s.Z.info('Init: Not parsing the Manifest in "unsafeMode" anymore after '+String(this._consecutiveUnsafeMode)+" consecutive times."),this._consecutiveUnsafeMode=0),this._isRefreshPending||(this._isRefreshPending=!0,this._fetchManifest(r).then((function(t){return t.parse({externalClockOffset:d,previousManifest:e,unsafeMode:o})})).then((function(t){i._isRefreshPending=!1;var r=t.manifest,a=t.sendingTime,o=t.parsingTime,u=performance.now();if(n)e.replace(r);else try{e.update(r)}catch(t){var d=t instanceof Error?t.message:"unknown error";s.Z.warn("MUS: Attempt to update Manifest failed: "+d,"Re-downloading the Manifest fully");var c=l.Z.getCurrent().FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY,f=void 0===a?0:performance.now()-a,v=Math.max(i._settings.minimumManifestUpdateInterval-f,0),p=N.Z,h=setTimeout((function(){p(),i._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})}),Math.max(c-f,v));return void(p=i._canceller.signal.register((function(){clearTimeout(h)})))}var m=performance.now()-u;i._recursivelyRefreshManifest(e,{sendingTime:a,parsingTime:o,updatingTime:m})})).catch((function(e){i._isRefreshPending=!1,i._onFatalError(e)})))},r._onFatalError=function(e){this._canceller.isUsed()||(this.trigger("error",e),this.dispose())},n}(y.Z);var ge=me;function ye(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _e(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _e(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&this._removeIndexFromDowngradeList(n);var r=l.Z.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;this._downgradedCdnList.metadata.push(e);var i=window.setTimeout((function(){var n=Se(t._downgradedCdnList.metadata,e);n>=0&&t._removeIndexFromDowngradeList(n),t.trigger("priorityChange",null)}),r);this._downgradedCdnList.timeouts.push(i),this.trigger("priorityChange",null)},r._innerGetCdnPreferenceForResource=function(e){var t=this,n=e.reduce((function(e,n){return t._downgradedCdnList.metadata.some((function(e){return e.id===n.id&&e.baseUrl===n.baseUrl}))?e[1].push(n):e[0].push(n),e}),[[],[]]),r=n[0],i=n[1];return r.concat(i)},r._removeIndexFromDowngradeList=function(e){this._downgradedCdnList.metadata.splice(e,1);var t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])},n}(y.Z);function Se(e,t){return 0===e.length?-1:void 0!==t.id?(0,L.Z)(e,(function(e){return e.id===t.id})):(0,L.Z)(e,(function(e){return e.baseUrl===t.baseUrl}))}var Ee=n(520),Te=function(){function e(){this._cache=new WeakMap}var t=e.prototype;return t.add=function(e,t){var n=e.representation;e.segment.isInit&&this._cache.set(n,t)},t.get=function(e){var t=e.representation;if(e.segment.isInit){var n=this._cache.get(t);if(void 0!==n)return n}return null},e}(),ke=(0,_.Z)();var we=function(){function e(e){var t=e.prioritySteps;if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=t,this._prioritySteps.high>=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,n,r){var i,a=this;return(0,D.Z)(r,(function(o,s){return i={hasEnded:!1,priority:t,trigger:function(){if(!i.hasEnded){var e=function(){u(),a._endTask(i)},t=new k.ZP,u=t.linkToSignal(r);i.interrupter=t,t.signal.register((function(){i.interrupter=null,r.isCancelled()||n.beforeInterrupted()})),a._minPendingPriority=null===a._minPendingPriority?i.priority:Math.min(a._minPendingPriority,i.priority),a._pendingTasks.push(i),i.taskFn(t.signal).then((function(t){n.beforeEnded(),e(),o(t)})).catch((function(n){!r.isCancelled()&&t.isUsed()&&n instanceof k.FU||function(t){e(),s(t)}(n)}))}},taskFn:e,interrupter:null},a._canBeStartedNow(i)?(i.trigger(),a._isRunningHighPriorityTasks()&&a._interruptCancellableTasks()):a._waitingQueue.push(i),function(){return a._endTask(i)}}))},t._endTask=function(e){e.hasEnded=!0;var t=Ae(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{var n=Ae(e.taskFn,this._pendingTasks);if(n<0)return;this._pendingTasks.splice(n,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}},t.updatePriority=function(e,t){var n=Ae(e,this._waitingQueue);if(n>=0){var r=this._waitingQueue[n];if(r.priority===t)return;if(r.priority=t,!this._canBeStartedNow(r))return;return this._findAndRunWaitingQueueTask(n),void(this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks())}var i=Ae(e,this._pendingTasks);if(i<0)s.Z.warn("TP: request to update the priority of a non-existent task");else{var a=this._pendingTasks[i];if(a.priority!==t){var o=a.priority;a.priority=t,null===this._minPendingPriority||tt.priority?t.priority:e}),null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(s.Z.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t,n=Ae(e.taskFn,this._pendingTasks);n<0?s.Z.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(n,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))),null===(t=e.interrupter)||void 0===t||t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function Ae(e,t){return(0,L.Z)(t,(function(t){return t.taskFn===e}))}var Ie=function(){function e(e,t,n){var r=new be(n),i=l.Z.getCurrent(),a=i.MIN_CANCELABLE_PRIORITY,o=i.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new we({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=r,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,t){var n,r,i,a,o,u,c,f,v,p,m,g,y=(n=this._backoffOptions,r=n.maxRetry,i=n.lowLatencyMode,a=n.requestTimeout,o=l.Z.getCurrent(),u=o.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,c=o.DEFAULT_REQUEST_TIMEOUT,f=o.INITIAL_BACKOFF_DELAY_BASE,v=o.MAX_BACKOFF_DELAY_BASE,{maxRetry:null!=r?r:u,baseDelay:i?f.LOW_LATENCY:f.REGULAR,maxDelay:i?v.LOW_LATENCY:v.REGULAR,requestTimeout:(0,b.Z)(a)?c:a}),_=function(e,t,n,r,i){var a={timeout:i.requestTimeout<0?void 0:i.requestTimeout},o=(0,h.Z)(["audio","video"],e)?new Te:void 0,u=t.loadSegment,l=t.parseSegment;return function(){var e=(0,w.Z)(I().mark((function e(t,c,f){var v,p,h,m,g,y,_,E,T,w,A,R,Z,x,P,M,C,D,N,O,L,U,B,F;return I().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(F=function(){var e;x||!(0,b.Z)(A)&&void 0!==A.size&&void 0!==A.requestDuration&&R.length>0&&R.every((function(e){return e}))&&(x=!0,null===(e=r.onMetrics)||void 0===e||e.call(r,{size:A.size,requestDuration:A.requestDuration,content:t,segmentDuration:Z}))},B=function(e){c.onRetry(oe(e))},U=function(e,t){R.push(!1);var n=R.length-1;return function(r){var i={data:e,isChunked:t};try{var a=l(i,P,r);return R[n]||(Z=void 0!==Z&&"media"===a.segmentType&&null!==a.chunkInfos&&void 0!==a.chunkInfos.duration?Z+a.chunkInfos.duration:void 0,R[n]=!0,F()),a}catch(e){throw(0,d.Z)(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown parsing error"})}}},L=function(e){return u(e,P,a,f,M)},O=function(){var e;void 0===A&&(s.Z.debug("SF: Segment request cancelled",T),A=null,null===(e=r.onRequestEnd)||void 0===e||e.call(r,{id:w}))},m=t.segment,g=t.adaptation,y=t.representation,_=t.manifest,E=t.period,T=(0,Ee.K)(t),w=ke(),R=[],Z=0,x=!1,P={segment:m,type:g.type,language:g.language,isLive:_.isLive,periodStart:E.start,periodEnd:E.end,mimeType:y.mimeType,codecs:y.codec,manifestPublishTime:_.publishTime},M={onProgress:function(e){var t;void 0===A&&void 0!==e.totalSize&&e.size0;){var e=this._queue.shift();void 0!==e&&e.reject(new k.FU)}if("open"===this._mediaSource.readyState)try{this._sourceBuffer.abort()}catch(e){s.Z.warn("AVSB: Failed to abort a "+this.bufferType+" SourceBuffer:",e instanceof Error?e:"")}},r._onPendingTaskError=function(e){if(this._lastInitSegmentUniqueId=null,null!==this._pendingTask){var t=e instanceof Error?e:new Error("An unknown error occured when doing operations on the SourceBuffer");this._pendingTask.reject(t)}},r._addToQueue=function(e,t){var n=this;return(0,D.Z)(t,(function(t,r){var i=0===n._queue.length&&null===n._pendingTask,a=(0,S.Z)({resolve:t,reject:r},e);return n._queue.push(a),i&&n._flush(),function(){var e=n._queue.indexOf(a);e>=0&&n._queue.splice(e,1),a.resolve=N.Z,a.reject=N.Z}}))},r._flush=function(){if(!this._sourceBuffer.updating){if(null!==this._pendingTask){var e=this._pendingTask;if(e.type!==xe.f.Push||0===e.data.length){switch(e.type){case xe.f.Push:null!==e.inventoryData&&this._segmentInventory.insertChunk(e.inventoryData);break;case xe.f.EndOfSegment:this._segmentInventory.completeSegment(e.value,this.getBufferedRanges());break;case xe.f.Remove:this.synchronizeInventory();break;default:(0,g.Z)(e)}var t=e.resolve;return this._pendingTask=null,t(),void this._flush()}}else{var n=this._queue.shift();if(void 0===n)return;if(n.type!==xe.f.Push)this._pendingTask=n;else{var r,i=n.value;try{r=this._preparePushOperation(i.data)}catch(e){this._pendingTask=(0,S.Z)({data:[],inventoryData:i.inventoryInfos},n);var a=e instanceof Error?e:new Error("An unknown error occured when preparing a push operation");return this._lastInitSegmentUniqueId=null,void n.reject(a)}this._pendingTask=(0,S.Z)({data:r,inventoryData:i.inventoryInfos},n)}}try{switch(this._pendingTask.type){case xe.f.EndOfSegment:return s.Z.debug("AVSB: Acknowledging complete segment",(0,Ee.K)(this._pendingTask.value)),void this._flush();case xe.f.Push:var o=this._pendingTask.data.shift();if(void 0===o)return void this._flush();s.Z.debug("AVSB: pushing segment",this.bufferType,(0,Ee.K)(this._pendingTask.inventoryData)),this._sourceBuffer.appendBuffer(o);break;case xe.f.Remove:var u=this._pendingTask.value,l=u.start,d=u.end;s.Z.debug("AVSB: removing data from SourceBuffer",this.bufferType,l,d),this._sourceBuffer.remove(l,d);break;default:(0,g.Z)(this._pendingTask)}}catch(e){this._onPendingTaskError(e)}}},r._preparePushOperation=function(e){var t=[],n=e.codec,r=e.timestampOffset,i=e.appendWindow,a=!1;if(void 0!==n&&n!==this.codec&&(s.Z.debug("AVSB: updating codec",n),a=function(e,t){if("function"==typeof e.changeType){try{e.changeType(t)}catch(e){return s.Z.warn("Could not call 'changeType' on the given SourceBuffer:",e instanceof Error?e:""),!1}return!0}return!1}(this._sourceBuffer,n),a?this.codec=n:s.Z.debug("AVSB: could not update codec",n,this.codec)),this._sourceBuffer.timestampOffset!==r){var o=r;s.Z.debug("AVSB: updating timestampOffset",this.bufferType,this._sourceBuffer.timestampOffset,o),this._sourceBuffer.timestampOffset=o}if(void 0===i[0]?this._sourceBuffer.appendWindowStart>0&&(this._sourceBuffer.appendWindowStart=0):i[0]!==this._sourceBuffer.appendWindowStart&&(i[0]>=this._sourceBuffer.appendWindowEnd&&(this._sourceBuffer.appendWindowEnd=i[0]+1),this._sourceBuffer.appendWindowStart=i[0]),void 0===i[1]?this._sourceBuffer.appendWindowEnd!==1/0&&(this._sourceBuffer.appendWindowEnd=1/0):i[1]!==this._sourceBuffer.appendWindowEnd&&(this._sourceBuffer.appendWindowEnd=i[1]),null!==e.initSegmentUniqueId&&(a||!this._isLastInitSegment(e.initSegmentUniqueId))){var u=this._initSegmentsMap.get(e.initSegmentUniqueId);if(void 0===u)throw new Error("Invalid initialization segment uniqueId");t.push(u),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return null!==e.chunk&&t.push(e.chunk),t},r._isLastInitSegment=function(e){return null!==this._lastInitSegmentUniqueId&&this._lastInitSegmentUniqueId===e},n}(xe.C),Ce=["audio","video","text"];function De(e){return"audio"===e||"video"===e}var Ne=function(){function e(e,t){this._mediaElement=e,this._mediaSource=t,this._initializedSegmentBuffers={},this._onNativeBufferAddedOrDisabled=[]}e.isNative=function(e){return De(e)};var t=e.prototype;return t.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null==v.Z.nativeTextTracksBuffer&&null==v.Z.htmlTextTracksBuffer||e.push("text"),e},t.getNativeBufferTypes=function(){return"AUDIO"===this._mediaElement.nodeName?["audio"]:["video","audio"]},t.getStatus=function(e){var t=this._initializedSegmentBuffers[e];return void 0===t?{type:"uninitialized"}:null===t?{type:"disabled"}:{type:"initialized",value:t}},t.waitForUsableBuffers=function(e){var t=this;return this._areNativeBuffersUsable()?Promise.resolve():(0,D.Z)(e,(function(e){var n,r=function(){var e=t._onNativeBufferAddedOrDisabled.indexOf(n);e>=0&&t._onNativeBufferAddedOrDisabled.splice(e,1)};return n=function(){t._areNativeBuffersUsable()&&(r(),e())},t._onNativeBufferAddedOrDisabled.push(n),r}))},t.disableSegmentBuffer=function(t){var n=this._initializedSegmentBuffers[t];if(null!==n){if(void 0!==n)throw new Error("Cannot disable an active SegmentBuffer.");this._initializedSegmentBuffers[t]=null,e.isNative(t)&&this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()}))}else s.Z.warn("SBS: The "+t+" SegmentBuffer was already disabled.")},t.createSegmentBuffer=function(e,t,n){void 0===n&&(n={});var r,i=this._initializedSegmentBuffers[e];if(De(e)){if(null!=i)return i instanceof Me&&i.codec!==t?s.Z.warn("SB: Reusing native SegmentBuffer with codec",i.codec,"for codec",t):s.Z.info("SB: Reusing native SegmentBuffer with codec",t),i;s.Z.info("SB: Adding native SegmentBuffer with codec",t);var a=new Me(e,t,this._mediaSource);return this._initializedSegmentBuffers[e]=a,this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()})),a}if(null!=i)return s.Z.info("SB: Reusing a previous custom SegmentBuffer for the type",e),i;if("text"===e){if(s.Z.info("SB: Creating a new text SegmentBuffer"),"html"===n.textTrackMode){if(null==v.Z.htmlTextTracksBuffer)throw new Error("HTML Text track feature not activated");r=new v.Z.htmlTextTracksBuffer(this._mediaElement,n.textTrackElement)}else{if(null==v.Z.nativeTextTracksBuffer)throw new Error("Native Text track feature not activated");r=new v.Z.nativeTextTracksBuffer(this._mediaElement)}return this._initializedSegmentBuffers.text=r,r}throw s.Z.error("SB: Unknown buffer type:",e),new c.Z("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentBuffer of an unknown type.")},t.disposeSegmentBuffer=function(e){var t=this._initializedSegmentBuffers[e];null!=t?(s.Z.info("SB: Aborting SegmentBuffer",e),t.dispose(),delete this._initializedSegmentBuffers[e]):s.Z.warn("SB: Trying to dispose a SegmentBuffer that does not exist")},t.disposeAll=function(){var e=this;Ce.forEach((function(t){"initialized"===e.getStatus(t).type&&e.disposeSegmentBuffer(t)}))},t._areNativeBuffersUsable=function(){var e=this,t=this.getNativeBufferTypes();return!t.some((function(t){return void 0===e._initializedSegmentBuffers[t]}))&&!t.every((function(t){return null===e._initializedSegmentBuffers[t]}))},e}(),Oe=n(7473),Le=n.n(Oe),Ue=function(){function e(e){this._array=[],this._sortingFn=e}var t=e.prototype;return t.add=function(){for(var e=arguments.length,t=new Array(e),n=0;n=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return(0,p.Z)(this._array,e)},t.has=function(e){return(0,h.Z)(this._array,e)},t.removeElement=function(e){var t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}(),Be=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t=this._weakMap.get(e);if(void 0===t){var n=this._fn(e);return this._weakMap.set(e,n),n}return t},t.destroy=function(e){this._weakMap.delete(e)},e}();function Fe(e,t){var n,r=e.segmentBuffer,i=e.playbackObserver,a=e.maxBufferBehind,o=e.maxBufferAhead;function u(){(function(e,t,n,r,i){return ze.apply(this,arguments)})(r,n,a.getValue(),o.getValue(),t).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";s.Z.error("Could not run BufferGarbageCollector:",t)}))}i.listen((function(e){var t;n=null!==(t=e.position.pending)&&void 0!==t?t:e.position.last,u()}),{includeLastObservation:!0,clearSignal:t}),a.onUpdate(u,{clearSignal:t}),o.onUpdate(u,{clearSignal:t}),u()}function ze(){return(ze=(0,w.Z)(I().mark((function e(t,n,r,i,a){var o,u,l,d,c,f,v,p;return I().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(r)||isFinite(i)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:o=[],u=(0,E.F_)(t.getBufferedRanges(),n),l=u.innerRange,d=u.outerRanges,c=function(){if(isFinite(i)){for(var e=0;et.start&&o.push({start:n+i,end:t.end})}null!=l&&n+i=t.end?o.push(t):n>=t.end&&n-r>t.start&&n-rl.start&&o.push({start:l.start,end:n-r})}}(),c(),f=0,v=o;case 9:if(!(f0&&n[0].segment.id===e._mediaSegmentAwaitingInitMetadata)){var r=e._mediaSegmentRequest;if(0===n.length){if(null===r)return;return s.Z.debug("Stream: no more media segment to request. Cancelling queue.",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()}if(null===r)return s.Z.debug("Stream: Media segments now need to be requested. Starting queue.",e._content.adaptation.type,n.length),void e._restartMediaSegmentDownloadingQueue();var i=n[0];return r.segment.id!==i.segment.id?(s.Z.debug("Stream: Next media segment changed, cancelling previous",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()):void(r.priority!==i.priority&&(s.Z.debug("Stream: Priority of next media segment changed, updating",e._content.adaptation.type,r.priority,i.priority),e._segmentFetcher.updatePriority(r.request,i.priority)))}}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate((function(t){var n,r=e._initSegmentRequest;null===t.initSegment||null===r?(null===(n=t.initSegment)||void 0===n?void 0:n.segment.id)!==(null==r?void 0:r.segment.id)&&(null===t.initSegment&&s.Z.debug("Stream: no more init segment to request. Cancelling queue.",e._content.adaptation.type),e._restartInitSegmentDownloadingQueue(t.initSegment)):t.initSegment.priority!==r.priority&&e._segmentFetcher.updatePriority(r.request,t.initSegment.priority)}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))},r.stop=function(){var e;null===(e=this._currentCanceller)||void 0===e||e.cancel(),this._currentCanceller=null},r._restartMediaSegmentDownloadingQueue=function(){var e=this;null!==this._mediaSegmentRequest&&this._mediaSegmentRequest.canceller.cancel();!function t(n){if(null!==e._currentCanceller&&e._currentCanceller.isUsed())e._mediaSegmentRequest=null;else{if(void 0===n)return e._mediaSegmentRequest=null,void e.trigger("emptyQueue",null);var r=new k.ZP,i=null===e._currentCanceller?N.Z:r.linkToSignal(e._currentCanceller.signal),a=n.segment,o=n.priority,u=(0,S.Z)({segment:a},e._content),l=!1,d=!1;r.signal.register((function(){e._mediaSegmentRequest=null,l||(e._mediaSegmentAwaitingInitMetadata===a.id&&(e._mediaSegmentAwaitingInitMetadata=null),l=!0,d=!1)}));var c=function(t){(0,m.Z)("media"===t.segmentType,"Should have loaded a media segment."),e.trigger("parsedMediaSegment",(0,S.Z)({},t,{segment:a}))},f=function(){var n=e._downloadQueue.getValue().segmentQueue;if(0===n.length)return l=!0,void e.trigger("emptyQueue",null);n[0].segment.id===a.id&&n.shift(),l=!0,t(n[0])},v=e._segmentFetcher.createRequest(u,o,{onRetry:function(t){e.trigger("requestRetry",{segment:a,error:t})},beforeInterrupted:function(){s.Z.info("Stream: segment request interrupted temporarly.",a.id,a.time)},onChunk:function(t){var n=e._initSegmentInfoRef.getValue();void 0!==n?c(t(null!=n?n:void 0)):(d=!0,e._initSegmentInfoRef.waitUntilDefined((function(e){c(t(null!=e?e:void 0))}),{clearSignal:r.signal}))},onAllChunksReceived:function(){d?(e._mediaSegmentAwaitingInitMetadata=a.id,e._initSegmentInfoRef.waitUntilDefined((function(){e._mediaSegmentAwaitingInitMetadata=null,d=!1,e.trigger("fullyLoadedSegment",a)}),{clearSignal:r.signal})):e.trigger("fullyLoadedSegment",a)},beforeEnded:function(){i(),e._mediaSegmentRequest=null,d?e._initSegmentInfoRef.waitUntilDefined(f,{clearSignal:r.signal}):f()}},r.signal);v.catch((function(t){i(),l||(l=!0,e.stop(),e.trigger("error",t))})),e._mediaSegmentRequest={segment:a,priority:o,request:v,canceller:r}}}(this._downloadQueue.getValue().segmentQueue[0])},r._restartInitSegmentDownloadingQueue=function(e){var t=this;if((null===this._currentCanceller||!this._currentCanceller.isUsed())&&(null!==this._initSegmentRequest&&this._initSegmentRequest.canceller.cancel(),null!==e)){var n=new k.ZP,r=null===this._currentCanceller?N.Z:n.linkToSignal(this._currentCanceller.signal),i=e.segment,a=e.priority,o=(0,S.Z)({segment:i},this._content),u=!1,l=this._segmentFetcher.createRequest(o,a,{onRetry:function(e){t.trigger("requestRetry",{segment:i,error:e})},beforeInterrupted:function(){s.Z.info("Stream: init segment request interrupted temporarly.",i.id)},beforeEnded:function(){r(),t._initSegmentRequest=null,u=!0},onChunk:function(e){var n,r=e(void 0);(0,m.Z)("init"===r.segmentType,"Should have loaded an init segment."),t.trigger("parsedInitSegment",(0,S.Z)({},r,{segment:i})),"init"===r.segmentType&&t._initSegmentInfoRef.setValue(null!==(n=r.initTimescale)&&void 0!==n?n:null)},onAllChunksReceived:function(){t.trigger("fullyLoadedSegment",i)}},n.signal);l.catch((function(e){r(),u||(u=!0,t.stop(),t.trigger("error",e))})),n.signal.register((function(){t._initSegmentRequest=null,u||(u=!0)})),this._initSegmentRequest={segment:i,priority:a,request:l,canceller:n}}},n}(y.Z);function Ke(e,t,n,r,i){var a=e.period,o=e.adaptation,u=e.representation,l=function(e,t){for(var n=0;n=t.end)return null;if(r.bufferedEnd>t.start)return n}return null}(i,t);if(null===l){if(null===n){if(r&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var d=u.index.checkDiscontinuity(t.start);if(null!==d)return{start:void 0,end:d}}return null}var c=i[l];if(void 0!==c.bufferedStart&&c.bufferedStart>t.start&&(null===n||c.infos.segment.end<=n)){var f=c.bufferedStart;return r||!1===u.index.awaitSegmentBetween(t.start,f)?(s.Z.debug("RS: current discontinuity encountered",o.type,c.bufferedStart),{start:void 0,end:f}):null}var v=function(e,t,n){if(n<=0)return s.Z.error("RS: Asked to check a discontinuity before the first chunk."),null;for(var r=n;r=t.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}(i,t,l+1);if(null!==v){var p=i[v-1],h=i[v];if(null===n||h.infos.segment.end<=n){if(!r&&!1!==u.index.awaitSegmentBetween(p.infos.segment.end,h.infos.segment.time))return null;var m=p.bufferedEnd,g=h.bufferedStart;return s.Z.debug("RS: future discontinuity encountered",o.type,m,g),{start:m,end:g}}}if(null===n){if(r&&void 0!==a.end){if(t.end=0;n--){var r=e[n];if(void 0===r.bufferedStart)return null;if(r.bufferedStart=a.end)return null;for(var b=i.length-1;b>=0;b--){var S=i[b];if(void 0===S.bufferedStart)break;if(S.bufferedStart=n.length-1?null:n[t+1],u=null;if(function(e,t,n){var r=l.Z.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedStart)return s.Z.warn("Stream: Start of a segment unknown. Assuming it is garbage collected by default.",e.start),!0;if(null!==t&&void 0!==t.bufferedEnd&&e.bufferedStart-t.bufferedEnd<.1)return!1;if(nr)return s.Z.info("Stream: The start of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,r,o.start)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.start;if(void 0!==t&&void 0!==a&&t-a>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.start;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(u=a(e.infos),e.bufferedStart))return!1;s.Z.debug("Stream: skipping segment gc-ed at the start",e.start,e.bufferedStart)}if(function(e,t,n){var r=l.Z.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedEnd)return s.Z.warn("Stream: End of a segment unknown. Assuming it is garbage collected by default.",e.end),!0;if(null!==t&&void 0!==t.bufferedStart&&t.bufferedStart-e.bufferedEnd<.1)return!1;if(n>e.bufferedEnd&&e.end-e.bufferedEnd>r)return s.Z.info("Stream: The end of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,i,o.end)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.end;if(void 0!==t&&void 0!==a&&a-t>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.end;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(u=null!=u?u:a(e.infos),e.bufferedEnd))return!1;s.Z.debug("Stream: skipping segment gc-ed at the end",e.end,e.bufferedEnd)}return!0})),m=l.Z.getCurrent(),g=m.MINIMUM_SEGMENT_SIZE,y=m.MIN_BUFFER_AHEAD,_=!1,b=Math.min(1/60,g),E=!1,T=[],k=p.filter((function(e){var t=(0,S.Z)({segment:e},n);if(u.length>0&&u.some((function(e){return(0,Ee.z)(t,e)})))return!1;var l=e.duration,d=e.time,p=e.end;if(e.isInit)return!0;if(_)return T.push(e),!1;if(e.complete&&l0&&u.some((function(e){if(e.period.id!==n.period.id||e.adaptation.id!==n.adaptation.id)return!1;var a=e.segment;return!(a.time-b>d)&&(!(a.end+b-b&&w.end-p>-b)return!1}}var A=l*n.representation.bitrate;if(v-A<0&&(E=!0,d>o.start+y))return _=!0,T.push(e),!1;var I=a(t);if(I.length>1){var R=I[I.length-1],Z=I[I.length-2];if(null===R.buffered&&null===Z.buffered)return s.Z.warn("Stream: Segment GCed multiple times in a row, ignoring it.","If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering."+c.type,f.id,e.time),!1}for(var x=0;xd){var M=P.start>d+b||je(h,x).ende[n].start;)n++;return e[--n]}function He(e,t,n,r){var i=l.Z.getCurrent().CONTENT_REPLACEMENT_PADDING;return e.period.id===t.period.id&&(!(e.segment.timea}return rr}(e.representation,t.representation,r)))}function We(e,t){for(var n=e-t,r=l.Z.getCurrent().SEGMENT_PRIORITIES_STEPS,i=0;i=u&&l.isInitialized()&&l.isFinished()&&function(e,t,n){var r;return t.containsTime(n)&&e.isLastPeriodKnown&&t.id===(null===(r=e.periods[e.periods.length-1])||void 0===r?void 0:r.id)}(a,o,t)?u-1:t-.1;var d,c=i+n;d=!(!s.index.isInitialized()||!s.index.isFinished()||void 0===o.end)&&(void 0===u?c>=o.end:null===u||c>=u);return{start:Math.max(i,o.start),end:Math.min(c,null!==(r=o.end)&&void 0!==r?r:1/0),hasReachedPeriodEnd:d}}(e,u,i),c=s.index.shouldRefresh(d.start,d.end),f=o.getPendingOperations().filter((function(e){return e.type===xe.f.EndOfSegment})).map((function(e){return e.value})),v=function(e,t){for(var n=l.Z.getCurrent().MINIMUM_SEGMENT_SIZE,r=Math.max(1/60,n),i=e.start+r,a=e.end-r,o=[],s=t.length-1;s>=0;s--){var u=t[s],d=u.infos.representation;if(!u.partiallyPushed&&!1!==d.decipherable&&d.isSupported){var c=u.infos.segment,f=c.time/c.timescale;((c.complete?f+c.duration/c.timescale:u.end)>i&&fi&&u.start0&&(S=Math.min.apply(Math,f.map((function(e){return e.segment.time})))),m.length>0&&(S=null!==S?Math.min(S,m[0].time):m[0].time),y.length>0&&(S=null!==S?Math.min(S,y[0].segment.time):y[0].segment.time),{imminentDiscontinuity:Ke(e,d,S,_,v),hasFinishedLoading:_,neededSegments:y,isBufferFull:g,shouldRefreshManifest:c}}function Ye(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xe(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Xe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nl.end||e+ni.start&&o.push({start:i.start,end:e-n}),e+n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function at(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&R.every((function(e){return void 0!==e.keyIds}))&&(I=!0,t.encryptionDataEncountered(R.map((function(e){return(0,S.Z)({content:r},e)}))),_.isUsed()))return}var Z=new Ve(r,w,u,A);return Z.addEventListener("error",(function(e){b.signal.isCancelled()||(_.cancel(),t.error(e))})),Z.addEventListener("parsedInitSegment",P),Z.addEventListener("parsedMediaSegment",P),Z.addEventListener("emptyQueue",x),Z.addEventListener("requestRetry",(function(e){if(t.warning(e.error),!b.signal.isCancelled()){var n=e.segment,r=v.index;!1===r.isSegmentStillAvailable(n)?x():r.canBeOutOfSyncError(e.error,n)&&t.manifestMightBeOufOfSync()}})),Z.addEventListener("fullyLoadedSegment",(function(e){o.endOfSegment((0,S.Z)({segment:e},r),_.signal).catch(M)})),Z.start(),b.signal.register((function(){Z.removeEventListener(),Z.stop()})),a.listen(x,{includeLastObservation:!1,clearSignal:b.signal}),p.onUpdate(x,{emitCurrentValue:!1,clearSignal:b.signal}),h.onUpdate(x,{emitCurrentValue:!1,clearSignal:b.signal}),d.onUpdate(x,{emitCurrentValue:!1,clearSignal:b.signal}),void x();function x(){var e,n;if(!b.isUsed()){var i=a.getReference().getValue(),u=null!==(e=i.position.pending)&&void 0!==e?e:i.position.last,f=qe(r,u,a,g.getValue(),p.getValue(),h.getValue(),o),m=f.neededSegments,S=null;if(v.index.isInitialized()){if(m.length>0&&!E.isLoaded&&null!==E.segment){var T=m[0].priority;S={segment:E.segment,priority:T}}}else if(null===E.segment)s.Z.warn("Stream: Uninitialized index without an initialization segment");else if(E.isLoaded)s.Z.warn("Stream: Uninitialized index with an already loaded initialization segment");else{var k=null!==(n=i.position.pending)&&void 0!==n?n:i.position.last;S={segment:E.segment,priority:We(c.start,k)}}var A=d.getValue();if(null===A)w.setValue({initSegment:S,segmentQueue:m});else{if(A.urgent)return s.Z.debug("Stream: Urgent switch, terminate now.",y),w.setValue({initSegment:null,segmentQueue:[]}),w.finish(),b.cancel(),void t.terminating();var I=m[0],R=Z.getRequestedInitSegment(),x=Z.getRequestedMediaSegment(),P=null===x||void 0===I||x.id!==I.segment.id?[]:[I],C=null===R?null:S;if(w.setValue({initSegment:C,segmentQueue:P}),0===P.length&&null===C)return s.Z.debug("Stream: No request left, terminate",y),w.finish(),b.cancel(),void t.terminating()}if(t.streamStatusUpdate({period:c,position:i.position.last,bufferType:y,imminentDiscontinuity:f.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:f.hasFinishedLoading,neededSegments:f.neededSegments}),!b.signal.isCancelled()){var D=l.Z.getCurrent().UPTO_CURRENT_POSITION_CLEANUP;if(f.isBufferFull){var N=Math.max(0,u-D);N>0&&o.removeBuffer(0,N,_.signal).catch(M)}f.shouldRefreshManifest&&t.needsManifestRefresh()}}}function P(e){if(!_.isUsed()){for(var n,i=it(e.protectionData);!(n=i()).done;){var s=n.value;v.addProtectionData(s.initDataType,s.keyId,s.initData)}if(!I){var u=v.getAllEncryptionData();if(u.length>0&&(t.encryptionDataEncountered(u.map((function(e){return(0,S.Z)({content:r},e)}))),I=!0,_.isUsed()))return}if("init"!==e.segmentType){var l=e.inbandEvents,d=e.predictedSegments,c=e.needsManifestRefresh;if(!(void 0!==d&&v.index.addPredictedSegments(d,e.segment),!0===c&&(t.needsManifestRefresh(),_.isUsed())||void 0!==l&&l.length>0&&(t.inbandEvent(l),_.isUsed()))){var f=E.uniqueId;(function(e,t){return rt.apply(this,arguments)})({playbackObserver:a,content:r,initSegmentUniqueId:f,parsedSegment:e,segment:e.segment,segmentBuffer:o},_.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(M)}}else{if(v.index.isInitialized()||void 0===e.segmentList||v.index.initialize(e.segmentList),E.isLoaded=!0,null!==e.initializationData){var p=v.uniqueId;E.uniqueId=p,o.declareInitSegment(p,e.initializationData),function(e,t){return nt.apply(this,arguments)}({playbackObserver:a,content:r,initSegmentUniqueId:p,segment:e.segment,segmentData:e.initializationData,segmentBuffer:o},_.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(M)}x()}}}function M(e){_.isUsed()&&e instanceof k.FU||(_.cancel(),t.error(e))}};function st(e,t,n,r,i){i.isCancelled()||Le()((function(){e.listen((function(i){var a,o,s,u=e.getCurrentTime()+n;u=Math.min(Math.max(null!==(a=r.start)&&void 0!==a?a:0,u),null!==(o=r.end)&&void 0!==o?o:1/0);var l=!(null!==(s=i.paused.pending)&&void 0!==s?s:e.getIsPaused());t({position:u,autoPlay:l})}),{includeLastObservation:!0,clearSignal:i})}))}function ut(e,t){for(var n=0;n=t.start)return n>0?e[n-1]:null;return e.length>0?e[e.length-1]:null}function lt(e,t){for(var n=0;nt.start)return e[n];return null}function dt(e,t,n,r,i){if("lazy"===n.switchingMode)return{type:"continue",value:void 0};var a=r.getBufferedRanges();if(0===a.length)return{type:"continue",value:void 0};var o=(0,E.JN)(a),s=e.start,u=null==e.end?1/0:e.end,d=(0,E.tn)(o,[{start:s,end:u}]);if(0===d.length)return{type:"continue",value:void 0};r.synchronizeInventory();var c=r.getInventory(),f=function(e,t,n,r){return e.reduce((function(e,i){if(i.infos.period.id!==t.id||i.infos.adaptation.id!==n.id||!r.some((function(e){return e.id===i.infos.representation.id})))return e;var a=i.bufferedStart,o=i.bufferedEnd;return void 0===a||void 0===o||e.push({start:a,end:o}),e}),[])}(c,e,t,n.representations),v=(0,E.uH)(d,f);if(0===v.length)return{type:"continue",value:void 0};var p=i.getCurrentTime(),h=i.getReadyState();if("reload"===n.switchingMode&&(0,E.Ti)({start:s,end:u},p)&&h>1&&!(0,E.A1)(f,p))return{type:"needs-reload",value:void 0};var m="direct"===n.switchingMode,g=[],y=ut(c,e);if(null!==y&&(void 0===y.bufferedEnd||e.start-y.bufferedEnd<1)&&g.push({start:0,end:e.start+1}),!m){var _=l.Z.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,b=t.type,S=_[b].before;null==S&&(S=0);var T=_[b].after;null==T&&(T=0),g.push({start:p-S,end:p+T})}if(void 0!==e.end){var k=lt(c,e);null!==k&&(void 0===k.bufferedStart||k.bufferedStart-e.end<1)&&g.push({start:e.end-1,end:Number.MAX_VALUE})}var w=(0,E.uH)(v,g);return 0===w.length?{type:"continue",value:void 0}:m?{type:"flush-buffer",value:w}:{type:"clean-buffer",value:w}}function ct(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ft(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ft(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ft(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nh.start)break}}),o)}},pt=n(9252);var ht=function(e,t){var n=e.split(";"),r=n[0],i=n.slice(1),a=t.split(";"),o=a[0],s=a.slice(1);if(r!==o)return!1;var u=(0,p.Z)(i,(function(e){return(0,pt.Z)(e,"codecs=")})),l=(0,p.Z)(s,(function(e){return(0,pt.Z)(e,"codecs=")}));if(void 0===u||void 0===l)return!1;var d=u.substring(7),c=l.substring(7);return d.split(".")[0]===c.split(".")[0]};function mt(e,t,n,r,i,a){if(void 0!==e.codec&&"reload"===a.onCodecSwitch&&!function(e,t){return e.getPlayableRepresentations().some((function(e){return ht(e.getMimeTypeString(),t)}))}(n,e.codec))return{type:"needs-reload",value:void 0};var o=e.getBufferedRanges();if(0===o.length)return{type:"continue",value:void 0};var s=(0,E.JN)(o),u=t.start,d=null==t.end?1/0:t.end,c=(0,E.tn)(s,[{start:u,end:d}]);if(0===c.length)return{type:"continue",value:void 0};e.synchronizeInventory();var f=e.getInventory();if(!f.some((function(e){return e.infos.period.id===t.id&&e.infos.adaptation.id!==n.id})))return{type:"continue",value:void 0};var v=function(e,t,n){return e.reduce((function(e,r){if(r.infos.period.id!==t.id||r.infos.adaptation.id!==n.id)return e;var i=r.bufferedStart,a=r.bufferedEnd;return void 0===i||void 0===a||e.push({start:i,end:a}),e}),[])}(f,t,n),p=(0,E.uH)(c,v);if(0===p.length)return{type:"continue",value:void 0};var h=i.currentTime;if("reload"===r&&(0,E.Ti)({start:u,end:d},h)&&(i.readyState>1||!n.getPlayableRepresentations().some((function(t){var n;return ht(t.getMimeTypeString(),null!==(n=e.codec)&&void 0!==n?n:"")})))&&!(0,E.A1)(v,h))return{type:"needs-reload",value:void 0};var m="direct"===r,g=[],y=ut(f,t);null!==y&&(void 0===y.bufferedEnd||t.start-y.bufferedEnd<1)&&g.push({start:0,end:t.start+1});var _=n.type,b=l.Z.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,S=b[_].before;null==S&&(S=0);var T=b[_].after;if(null==T&&(T=0),m||g.push({start:h-S,end:h+T}),void 0!==t.end){var k=lt(f,t);null!==k&&(void 0===k.bufferedStart||k.bufferedStart-t.end<1)&&g.push({start:t.end-1,end:Number.MAX_VALUE})}var w=(0,E.uH)(p,g);return 0===w.length?{type:"continue",value:void 0}:m&&"text"!==n.type?{type:"flush-buffer",value:w}:{type:"clean-buffer",value:w}}function gt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=o.end&&(s.Z.debug('Stream: full "empty" AdaptationStream',n),u=!0),i.streamStatusUpdate({period:o,bufferType:n,position:l,imminentDiscontinuity:null,isEmptyStream:!0,hasFinishedLoading:u,neededSegments:[]})}t.onUpdate(l,{emitCurrentValue:!1,clearSignal:a}),e.listen(l,{includeLastObservation:!1,clearSignal:a}),l()}var St=function(e,t,n){var r=e.bufferType,i=e.content,a=e.garbageCollectors,o=e.playbackObserver,u=e.representationEstimator,c=e.segmentFetcherCreator,f=e.segmentBuffersStore,v=e.options,p=e.wantedBufferAhead,h=e.maxVideoBufferSize,m=i.manifest,g=i.period,y=(0,T.ZP)(void 0,n);if(t.periodStreamReady({type:r,manifest:m,period:g,adaptationRef:y}),!n.isCancelled()){var _,b=!0;y.onUpdate((function(e){(0,w.Z)(I().mark((function i(){var u,d,c,h,y,S,E,T,w,R,Z,x,P,M,C,D,N,O;return I().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==e){i.next=2;break}return i.abrupt("return");case 2:if((d=new k.ZP).linkToSignal(n),null==_||_.cancel(),_=d,null!==e){i.next=34;break}if(s.Z.info("Stream: Set no "+r+" Adaptation. P:",g.start),"initialized"!==(c=f.getStatus(r)).type){i.next=26;break}if(s.Z.info("Stream: Clearing previous "+r+" SegmentBuffer"),!Ne.isNative(r)){i.next=15;break}return i.abrupt("return",st(o,(function(e){var n=e.position,i=e.autoPlay;t.waitingMediaSourceReload({bufferType:r,period:g,position:n,autoPlay:i})}),0,g,d.signal));case 15:if(h=null!==(u=g.end)&&void 0!==u?u:1/0,!(g.start>h)){i.next=20;break}s.Z.warn("Stream: Can't free buffer: period's start is after its end"),i.next=24;break;case 20:return i.next=22,c.value.removeBuffer(g.start,h,d.signal);case 22:if(!d.isUsed()){i.next=24;break}return i.abrupt("return");case 24:i.next=30;break;case 26:if("uninitialized"!==c.type){i.next=30;break}if(f.disableSegmentBuffer(r),!d.isUsed()){i.next=30;break}return i.abrupt("return");case 30:if(t.adaptationChange({type:r,adaptation:null,period:g}),!d.isUsed()){i.next=33;break}return i.abrupt("return");case 33:return i.abrupt("return",bt(o,p,r,{period:g},t,d.signal));case 34:if(y=l.Z.getCurrent(),S=y.DELTA_POSITION_AFTER_RELOAD,E=b?0:"audio"===r?S.trackSwitch.audio:"video"===r?S.trackSwitch.video:S.trackSwitch.other,b=!1,!Ne.isNative(r)||"disabled"!==f.getStatus(r).type){i.next=39;break}return i.abrupt("return",st(o,(function(e){var n=e.position,i=e.autoPlay;t.waitingMediaSourceReload({bufferType:r,period:g,position:n,autoPlay:i})}),E,g,d.signal));case 39:if(m.addEventListener("manifestUpdate",(function(e){for(var n,i=gt(e.updatedPeriods);!(n=i()).done;){var a=n.value;if(a.period.id===g.id)for(var s,u=gt(a.result.removedAdaptations);!(s=u()).done;){if(s.value.id===T.id)return st(o,(function(e){var n=e.position,i=e.autoPlay;t.waitingMediaSourceReload({bufferType:r,period:g,position:n,autoPlay:i})}),E,g,d.signal)}else if(a.period.start>g.start)break}}),_.signal),T=e.adaptation,w=e.representations,s.Z.info("Stream: Updating "+r+" adaptation","A: "+T.id,"P: "+g.start),t.adaptationChange({type:r,adaptation:T,period:g}),!d.isUsed()){i.next=45;break}return i.abrupt("return");case 45:if(R=o.getReadyState(),Z=_t(f,r,T,v),x={currentTime:o.getCurrentTime(),readyState:R},"needs-reload"!==(P=mt(Z,g,T,e.switchingMode,x,v)).type){i.next=51;break}return i.abrupt("return",st(o,(function(e){var n=e.position,i=e.autoPlay;t.waitingMediaSourceReload({bufferType:r,period:g,position:n,autoPlay:i})}),E,g,d.signal));case 51:return i.next=53,f.waitForUsableBuffers(d.signal);case 53:if(!d.isUsed()){i.next=55;break}return i.abrupt("return");case 55:if("flush-buffer"!==P.type&&"clean-buffer"!==P.type){i.next=69;break}M=gt(P.value);case 57:if((C=M()).done){i.next=65;break}return D=C.value,N=D.start,O=D.end,i.next=61,Z.removeBuffer(N,O,d.signal);case 61:if(!d.isUsed()){i.next=63;break}return i.abrupt("return");case 63:i.next=57;break;case 65:if("flush-buffer"!==P.type){i.next=69;break}if(t.needsBufferFlush(),!d.isUsed()){i.next=69;break}return i.abrupt("return");case 69:a.get(Z)(d.signal),A(T,w,Z,d.signal);case 71:case"end":return i.stop()}}),i)})))().catch((function(e){e instanceof k.FU||(null==_||_.cancel(),t.error(e))}))}),{clearSignal:n,emitCurrentValue:!0})}function A(e,n,i,a){var l=function(e,t){return e.deriveReadOnlyObserver((function(e,n){var r=(0,T.ZP)(i(),n);return e.onUpdate(a,{clearSignal:n,emitCurrentValue:!1}),r;function i(){var n=e.getValue(),r=t.getBufferedRanges(),i=(0,E.L7)(r,n.position.last);return(0,S.Z)({},n,{bufferGap:i})}function a(){r.setValue(i())}}))}(o,i);vt({content:{manifest:m,period:g,adaptation:e,representations:n},options:v,playbackObserver:l,representationEstimator:u,segmentBuffer:i,segmentFetcherCreator:c,wantedBufferAhead:p,maxVideoBufferSize:h},Object.assign(Object.assign({},t),{error:function(e){if(!Ne.isNative(r)){s.Z.error("Stream: "+r+" Stream crashed. Aborting it.",e instanceof Error?e:""),f.disposeSegmentBuffer(r);var n=(0,d.Z)(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"});if(t.warning(n),a.isCancelled())return;return bt(o,p,r,{period:g},t,a)}s.Z.error("Stream: "+r+" Stream crashed. Stopping playback.",e instanceof Error?e:""),t.error(e)}}),a)}};function Et(e,t){if(0===t.length)return[];e.synchronizeInventory();for(var n=[],r=e.getInventory(),i=function(){var i=r[a];if(t.some((function(e){return i.infos.period.id===e.period.id&&i.infos.adaptation.id===e.adaptation.id&&i.infos.representation.id===e.representation.id}))){var o=i.bufferedStart,u=i.bufferedEnd;if(void 0===o||void 0===u){s.Z.warn("SO: No buffered start or end found from a segment.");var l=e.getBufferedRanges(),d=l.length;return 0===d?{v:[]}:{v:[{start:l.start(0),end:l.end(d-1)}]}}var c=n[n.length-1];void 0!==c&&c.end===o?c.end=u:n.push({start:o,end:u})}},a=0;a=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0?t[t.length-1].end>=n-5:t[0].start<=n+5}var At=function(e,t,n,r,i,a,o,u){for(var d,f=e.manifest,v=e.initialPeriod,p=a.maxBufferAhead,h=a.maxBufferBehind,m=a.wantedBufferAhead,g=a.maxVideoBufferSize,y=l.Z.getCurrent(),_=y.MAXIMUM_MAX_BUFFER_AHEAD,b=y.MAXIMUM_MAX_BUFFER_BEHIND,S=new Be((function(e){var n=e.bufferType,r=null!=b[n]?b[n]:1/0,i=null!=_[n]?_[n]:1/0;return function(n){Fe({segmentBuffer:e,playbackObserver:t,maxBufferBehind:(0,T.lR)(h,(function(e){return Math.min(e,r)}),n),maxBufferAhead:(0,T.lR)(p,(function(e){return Math.min(e,i)}),n)},n)}})),E=Tt(r.getBufferTypes());!(d=E()).done;){A(d.value,v)}function A(e,n){var i=new Ue((function(e,t){return e.start-t.start})),a=!1,l=new k.ZP;return l.linkToSignal(u),t.listen((function(t){var n,r,c=t.position,v=null!==(n=c.pending)&&void 0!==n?n:c.last;if(a&&function(e){var t=i.head(),n=i.last();if(null==t||null==n)return!0;return t.start>e||(null==n.end?1/0:n.end)0;){var p=i.get(i.length()-1);i.removeElement(p),o.periodStreamCleared({type:e,manifest:f,period:p})}l.cancel(),(l=new k.ZP).linkToSignal(u);var h=null!==(r=f.getPeriodForTime(v))&&void 0!==r?r:f.getNextPeriod(v);void 0!==h?d(h):s.Z.warn("Stream: The wanted position is not found in the Manifest.")}}),{clearSignal:u,includeLastObservation:!0}),f.addEventListener("decipherabilityUpdate",(function(e){u.isCancelled()||function(e){return v.apply(this,arguments)}(e).catch((function(e){u.isCancelled()||(l.cancel(),o.error(e))}))}),u),d(n);function d(t){var n=Object.assign(Object.assign({},o),{waitingMediaSourceReload:function(e){var t=i.head();if(void 0===t||t.id!==e.period.id)o.lockedStream({bufferType:e.bufferType,period:e.period});else{var n=e.position,r=e.autoPlay;o.needsMediaSourceReload({position:n,autoPlay:r})}},periodStreamReady:function(e){a=!0,i.add(e.period),o.periodStreamReady(e)},periodStreamCleared:function(e){i.removeElement(e.period),o.periodStreamCleared(e)},error:function(e){l.cancel(),o.error(e)}});R(e,t,n,l.signal)}function v(){return v=(0,w.Z)(I().mark((function n(v){var p,h,m,g,y,_,b,S,E,T,w,A,R;return I().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(p=r.getStatus(e),0!==(h=v.filter((function(t){return t.adaptation.type===e}))).length&&"initialized"===p.type&&!h.every((function(e){return!0===e.representation.decipherable}))){n.next=4;break}return n.abrupt("return");case 4:for(m=p.value,g=h.filter((function(e){return void 0===e.representation.decipherable})),y=h.filter((function(e){return!1===e.representation.decipherable})),_=Et(m,y),b=Et(m,g),a=!1,s.Z.info("Stream: Destroying all PeriodStreams for decipherability matters",e);i.length()>0;)S=i.get(i.length()-1),i.removeElement(S),o.periodStreamCleared({type:e,manifest:f,period:S});l.cancel(),(l=new k.ZP).linkToSignal(u),E=0,T=[].concat(_,b);case 16:if(!(E=o.end&&(s.Z.info("Stream: Destroying PeriodStream as the current playhead moved above it",e,o.start,null!==(i=a.pending)&&void 0!==i?i:a.last,o.end),n(),u.periodStreamCleared({type:e,manifest:f,period:o}),c.cancel())}),{clearSignal:l,includeLastObservation:!0});var v,p={bufferType:e,content:{manifest:f,period:o},garbageCollectors:S,maxVideoBufferSize:g,segmentFetcherCreator:i,segmentBuffersStore:r,options:a,playbackObserver:t,representationEstimator:n,wantedBufferAhead:m},h=Object.assign(Object.assign({},u),{streamStatusUpdate:function(t){if(t.hasFinishedLoading){var n=f.getPeriodAfter(o);null!==n&&function(t){if(null!==d){if(d.period.id===t.id)return;s.Z.warn("Stream: Creating next `PeriodStream` while one was already created.",e,t.id,d.period.id),u.periodStreamCleared({type:e,manifest:f,period:d.period}),d.canceller.cancel()}var n=new k.ZP;n.linkToSignal(l),d={canceller:n,period:t},R(e,t,u,d.canceller.signal)}(n)}else null!==d&&(s.Z.info("Stream: Destroying next PeriodStream due to current one being active",e,d.period.start),u.periodStreamCleared({type:e,manifest:f,period:d.period}),d.canceller.cancel(),d=null);u.streamStatusUpdate(t)},error:function(e){null!==d&&(d.canceller.cancel(),d=null),c.cancel(),u.error(e)}});St(p,h,c.signal),v=c.signal,f.addEventListener("manifestUpdate",(function(n){for(var r,i=function(){var n=r.value;if(n.id===o.id)f.periods.length>0&&f.periods[0].start<=n.start&&st(t,(function(t){var r=t.position,i=t.autoPlay;u.waitingMediaSourceReload({bufferType:e,period:n,position:r,autoPlay:i})}),0,{start:void 0,end:void 0},v);else if(n.start>o.start)return"break"},a=Tt(n.removedPeriods);!(r=a()).done&&"break"!==i(););if(n.addedPeriods.length>0&&null!==d){var l=f.getPeriodAfter(o);null!==l&&d.period.id===l.id||(s.Z.warn("Stream: Destroying next PeriodStream due to new one being added",e,d.period.start),u.periodStreamCleared({type:e,manifest:f,period:d.period}),d.canceller.cancel(),d=null)}}),v)}},It=At,Rt=n(379);function Zt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return xt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function xt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);na.getMaximumAvailablePosition()){var u=new c.Z("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest.");i.trigger("warning",u)}}),{includeLastObservation:!0,clearSignal:o}),t.addEventListener("manifestUpdate",(function(){i.trigger("durationUpdate",i._getManifestDuration()),o.isCancelled()||i._checkEndOfStream()}),o),i}(0,t.Z)(n,e);var r=n.prototype;return r.getCurrentDuration=function(){return this._getManifestDuration()},r.onAdaptationChange=function(e,t,n){if(this._manifest.isLastPeriodKnown){var r=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(null==r?void 0:r.id)&&("audio"===e||"video"===e)){"audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(n):this._maximumPositionCalculator.updateLastVideoAdaptation(n);var i=this._maximumPositionCalculator.getEndingPosition(),a=void 0!==i?{isEnd:!0,duration:i}:{isEnd:!1,duration:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger("durationUpdate",a)}}this._canceller.isUsed()||null===n&&this._addActivelyLoadedPeriod(t,e)},r.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},r.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},r.onLastSegmentFinishedLoading=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},r.onLastSegmentLoadingResume=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},r.dispose=function(){this.removeEventListener(),this._canceller.cancel()},r._addActivelyLoadedPeriod=function(e,t){var n=this._lazilyCreateActiveStreamInfo(t);n.activePeriods.has(e)||(n.activePeriods.add(e),this._checkCurrentPeriod())},r._removeActivelyLoadedPeriod=function(e,t){var n=this._activeStreams.get(t);void 0!==n&&n.activePeriods.has(e)&&(n.activePeriods.removeElement(e),this._checkCurrentPeriod())},r._checkCurrentPeriod=function(){var e=this;if(0!==this._allBufferTypes.length){var t=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==t)for(var n,r=function(){for(var t=n.value,r=!0,i=1;i=0;a--){var o=i[a];try{"open"===r&&(s.Z.info("Init: Removing SourceBuffer from mediaSource"),o.abort()),t.removeSourceBuffer(o)}catch(e){s.Z.warn("Init: Error while disposing SourceBuffer",e instanceof Error?e:"")}}i.length>0&&s.Z.warn("Init: Not all SourceBuffers could have been removed.")}if((0,Nt.Z)(e),null!==n)try{s.Z.debug("Init: Revoking previous URL"),URL.revokeObjectURL(n)}catch(e){s.Z.warn("Init: Error while revoking the media source URL",e instanceof Error?e:"")}}function Bt(e,t){return(0,D.Z)(t,(function(n){var r=function(e,t){if(null==Ot.J)throw new c.Z("MEDIA_SOURCE_NOT_SUPPORTED","No MediaSource Object was found in the current browser.");var n=(0,Lt.Z)(e.src)?e.src:null;Ut(e,null,n),s.Z.info("Init: Creating MediaSource");var r=new Ot.J,i=URL.createObjectURL(r);return s.Z.info("Init: Attaching MediaSource URL to the media element",i),e.src=i,t.register((function(){Ut(e,r,i)})),r}(e,t);i.u_(r,(function(){n(r)}),t)}))}function Ft(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0?r:Math.max(i,r+d)}if(!(0,b.Z)(n.percentage)){s.Z.debug("Init: using startAt.percentage");var c=n.percentage;return c>100?r:c<0?i:i+(r-i)*(+c/100)}}var f=e.getMinimumSafePosition();if(e.isLive){var v,p=e.suggestedPresentationDelay,h=e.clockOffset,m=e.getMaximumSafePosition(),g=l.Z.getCurrent().DEFAULT_LIVE_GAP;if(void 0===h)s.Z.info("Init: no clock offset found for a live content, starting close to maximum available position"),v=m;else{s.Z.info("Init: clock offset found for a live content, checking if we can start close to it");var y=void 0===e.availabilityStartTime?0:e.availabilityStartTime,_=(performance.now()+h)/1e3-y;v=Math.min(m,_)}var S=void 0!==p?p:t?g.LOW_LATENCY:g.DEFAULT;return s.Z.debug("Init: "+v+" defined as the live time, applying a live gap of "+S),Math.max(v-S,f)}return s.Z.info("Init: starting at the minimum available position:",f),f}var Wt=n(1757),qt=n(8833),Yt=n(8799);var Xt=31536e3,Qt=function(){function e(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}var t=e.prototype;return t.updateDuration=function(e,t){null!==this._currentMediaSourceDurationUpdateCanceller&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new k.ZP;var n=this._mediaSource,r=this._currentMediaSourceDurationUpdateCanceller.signal,a=function(e,t){var n=(0,T.ZP)("open"===e.readyState,t);return(0,i.u_)(e,(function(){n.setValueIfChanged(!0)}),t),(0,i.N8)(e,(function(){n.setValueIfChanged(!1)}),t),(0,i.k6)(e,(function(){n.setValueIfChanged(!1)}),t),n}(n,r),o=new k.ZP;o.linkToSignal(r),a.onUpdate((function(){if(o.cancel(),!a.getValue())return;(o=new k.ZP).linkToSignal(r);var i=function(e,t){if(0===e.length){var n=(0,T.ZP)(!1);return n.finish(),n}var r=(0,T.ZP)(!1,t);o();for(var i=function(){var n=e[a];n.addEventListener("updatestart",o),n.addEventListener("update",o),t.register((function(){n.removeEventListener("updatestart",o),n.removeEventListener("update",o)}))},a=0;a0&&(i=Math.max(u.buffered.end(l-1)))}if(r===e.duration)return"success";if(i>r){if(i=.1?c=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function on(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nl||void 0!==h&&l>=h)&&(sn(v)&&c.push(v.publicEvent),o.delete(v)):p<=l&&void 0!==h&&l=(null!=h?h:p)&&(u?d.push({type:"stream-event-skip",value:v.publicEvent}):(d.push({type:"stream-event",value:v.publicEvent}),sn(v)&&c.push(v.publicEvent)))}if(d.length>0)for(var m,g=an(d);!(m=g()).done;){var y=m.value;if("stream-event"===y.type?r(y.value):i(y.value),a.isCancelled())return}if(c.length>0)for(var _,b=an(c);!(_=b()).done;){var S=_.value;if("function"==typeof S.onExit&&S.onExit(),a.isCancelled())return}}(s.getValue(),c,e,d.signal),c=e}function h(){var e=n.getReference().getValue().seeking;return{currentTime:t.currentTime,isSeeking:e}}}),{emitCurrentValue:!0,clearSignal:a})},ln=n(4576);function dn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nd.end&&(n=d.end-1)}}else n=s;return{maximumPosition:e.getMaximumSafePosition(),position:{last:u.position,pending:n},duration:u.duration,paused:{last:u.paused,pending:i.getValue()||!r===u.paused?void 0:!r},readyState:u.readyState,speed:l}}function d(){u.setValue(l())}}))}(u,v,{autoPlay:a,initialPlayPerformed:k,initialSeekPerformed:w,speed:g,startTime:s}),I=this._createRebufferingController(v,u,b,g,n);I.addEventListener("needsReload",(function(){var e=w.getValue()?v.getCurrentTime():s,n=k.getValue()?!v.getIsPaused():a;t({position:e,autoPlay:n})}),n);var R=this._createContentTimeBoundariesObserver(u,f,A,b,n);E.then((function(){(0,Wt.Z)(v,d,!1,n).onUpdate((function(e,t){e&&(t(),i.trigger("loaded",{segmentBuffersStore:b}))}),{emitCurrentValue:!0,clearSignal:n})})).catch((function(e){n.isCancelled()||i._onFatalError(e)}));var Z=this;It({manifest:u,initialPeriod:y},A,h,b,m,o,{needsBufferFlush:function(){var e=d.currentTime+.001;v.setCurrentTime(e),v.listen((function(t,n){(null!==t.currentRange||t.position>e+.1)&&(n(),v.setCurrentTime(t.position+.001))}),{includeLastObservation:!1,clearSignal:n})},streamStatusUpdate:function(e){var t=e.period,r=e.bufferType,i=e.imminentDiscontinuity,a=e.position;I.updateDiscontinuityInfo({period:t,bufferType:r,discontinuity:i,position:a}),n.isCancelled()||u.isLastPeriodKnown&&e.period.id===u.periods[u.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?R.onLastSegmentFinishedLoading(e.bufferType):R.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return Z._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=l.Z.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;Z._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return I.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){Z.trigger("adaptationChange",e),n.isCancelled()||R.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){Z.trigger("representationChange",e),n.isCancelled()||R.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return Z.trigger("inbandEvents",e)},warning:function(e){return Z.trigger("warning",e)},periodStreamReady:function(e){return Z.trigger("periodStreamReady",e)},periodStreamCleared:function(e){R.onPeriodCleared(e.type,e.period),n.isCancelled()||Z.trigger("periodStreamCleared",e)},bitrateEstimateChange:function(e){return Z.trigger("bitrateEstimateChange",e)},addedSegment:function(e){return Z.trigger("addedSegment",e)},needsMediaSourceReload:function(e){return t(e)},needsDecipherabilityFlush:function(e){var n,r=M(d);void 0===(n=null==r?void 0:r[0])||n.indexOf("widevine")<0?t(e):e.position+.001=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(i="internal-seeking",r=t._internalSeeksIncoming.shift());var a=null!=e?e:t._generateInitialObservation(),o=yn(t._mediaElement,i,t._withMediaSource),u=null;o.seeking&&("number"==typeof r?u=r:null!==a.pendingInternalSeek&&"seeking"!==n&&(u=a.pendingInternalSeek));var d=function(e,t,n){var r,i,a=n.withMediaSource,o=n.lowLatencyMode,s=l.Z.getCurrent().REBUFFERING_GAP,u=t.event,d=t.position,c=t.bufferGap,f=t.currentRange,v=t.duration,p=t.paused,h=t.readyState,m=t.ended,g=e.rebuffering,y=e.event,_=e.position,b=function(e,t,n,r,i){var a=l.Z.getCurrent().REBUFFERING_GAP,o=i?"LOW_LATENCY":"DEFAULT";if(void 0===t)return n&&Math.abs(r-e)<=a[o];return null!==t&&r-t.end<=a[o]}(d,f,m,v,o),S=h>=1&&"loadedmetadata"!==u&&null===g&&!(b||m),E=null,T=o?s.LOW_LATENCY:s.DEFAULT;if(a){if(S)c===1/0?(r=!0,E=d):void 0===c?h<3&&(r=!0,E=void 0):c<=T&&(r=!0,E=d+c);else if(null!==g){var k=gn(g,o);!0!==r&&null!==g&&h>1&&(b||m||void 0!==c&&isFinite(c)&&c>k)||void 0===c&&h>=3?i=!0:void 0===c?E=void 0:c===1/0?E=d:c<=k&&(E=d+c)}}else S&&(!p&&"timeupdate"===u&&"timeupdate"===y&&d===_||"seeking"===u&&(c===1/0||void 0===c&&h<3))?r=!0:null!==g&&("seeking"!==u&&d!==_||"canplay"===u||void 0===c&&h>=3||void 0!==c&&c<1/0&&(c>gn(g,o)||b||m))&&(i=!0);if(!0===i)return null;var w;if(!0===r||null!==g)return w="seeking"===u||null!==g&&"seeking"===g.reason||t.seeking?"seeking":1===h?"not-ready":"buffering",null!==g&&g.reason===w?{reason:g.reason,timestamp:g.timestamp,position:E}:{reason:w,timestamp:performance.now(),position:E};return null}(a,o,{lowLatencyMode:t._lowLatencyMode,withMediaSource:t._withMediaSource}),c=function(e,t){var n=l.Z.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position!==t.position?null:e.freezing;return"timeupdate"===t.event&&void 0!==t.bufferGap&&t.bufferGap>n&&!t.ended&&!t.paused&&t.readyState>=1&&0!==t.playbackRate&&t.position===e.position?{timestamp:performance.now()}:null}(a,o),f=(0,S.Z)({},{rebuffering:d,freezing:c,pendingInternalSeek:u},o);return s.Z.hasLevel("DEBUG")&&s.Z.debug("API: current media element state tick","event",f.event,"position",f.position,"seeking",f.seeking,"internalSeek",f.pendingInternalSeek,"rebuffering",null!==f.rebuffering,"freezing",null!==f.freezing,"ended",f.ended,"paused",f.paused,"playbackRate",f.playbackRate,"readyState",f.readyState),f},u=(0,T.ZP)(o("init"),this._canceller.signal),d=function(t){var n=o(t);s.Z.hasLevel("DEBUG")&&s.Z.debug("API: current playback timeline:\n"+function(e,t){for(var n="",r="",i=0;it){var d=n.length-Math.floor(l.length/2);r=" ".repeat(d)+"^"+t}if(i=3?(r=void 0,i=void 0):i=null!==(r=(0,E.rx)(a,o))?r.end-o:1/0,{bufferGap:i,buffered:a,currentRange:r,position:o,duration:s,ended:u,paused:l,playbackRate:d,readyState:c,seeking:f,event:t}}function _n(e,t,n){var r=t(e.getReference(),n);return{getCurrentTime:function(){return e.getCurrentTime()},getReadyState:function(){return e.getReadyState()},getPlaybackRate:function(){return e.getPlaybackRate()},getIsPaused:function(){return e.getIsPaused()},getReference:function(){return r},listen:function(e,t){var i;n.isCancelled()||!0===(null===(i=null==t?void 0:t.clearSignal)||void 0===i?void 0:i.isCancelled())||r.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},deriveReadOnlyObserver:function(e){return _n(this,e,n)}}}var bn=function(e){function n(t,n){var r;return(r=e.call(this)||this)._canceller=new k.ZP,r._manifest=t,r._adaptationRef=n,r._updateToken=!1,r}(0,t.Z)(n,e);var r=n.prototype;return r.start=function(e){if(this._updateToken=!0,null===e)return this._lastEmitted=null,this._updateToken=!1,void this._adaptationRef.setValue(null);var t=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:e.adaptation,switchingMode:e.switchingMode,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptation:e.adaptation,switchingMode:e.switchingMode,representations:t}))},r.updateTrack=function(e){if(this._updateToken=!0,null===e){if(null===this._lastEmitted)return;return this._updateToken=!1,this._canceller.cancel(),this._canceller=new k.ZP,this._lastEmitted=null,void this._adaptationRef.setValue(null)}var t=e.adaptation,n=e.switchingMode;this._canceller.cancel(),this._canceller=new k.ZP;var r=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:t,switchingMode:n,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptation:t,switchingMode:n,representations:r}))},r._constructLockedRepresentationsReference=function(e){var t=this._manifest,n=(0,T.ZP)({representations:[],switchingMode:"lazy"}),r=this;return t.addEventListener("decipherabilityUpdate",i),t.addEventListener("manifestUpdate",i),this._canceller.signal.register((function(){t.removeEventListener("decipherabilityUpdate",i),t.removeEventListener("manifestUpdate",i)})),e.lockedRepresentations.onUpdate(i,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),i(),n;function i(){var t,i,a=e.lockedRepresentations.getValue();if(null===a)i=e.adaptation.getPlayableRepresentations(),t="lazy";else{var o=a.representations;if(t=a.switchingMode,0===(i=o.filter((function(e){return e.isPlayable()}))).length)return void r.trigger("noPlayableLockedRepresentation",null)}if(i.length<=0)return e.adaptation.isSupported=!1,void r.trigger("noPlayableRepresentation",null);var s=n.getValue(),u=i.slice().sort();if(u.length===s.representations.length){for(var l=0;l=e;v--)i._storedPeriodInfo[v].inManifest=!1,Tn(i._storedPeriodInfo[v])&&i._removePeriodObject(v);else if(l===c){d++;var p=i._storedPeriodInfo[e].text.storedSettings;if(null!==p)if(!c.getSupportedAdaptations("text").some((function(e){return e.id===p.adaptation.id}))){s.Z.warn("TS: Chosen text Adaptation not available anymore");var h=i._storedPeriodInfo[e];if(h.text.storedSettings=null,i.trigger("trackUpdate",{period:An(c),trackType:"text",reason:"missing"}),i._isDisposed)return{v:void 0};var m=En(i._storedPeriodInfo,h.period.id);void 0!==m&&null===m.text.storedSettings&&(null===(t=m.text.dispatcher)||void 0===t||t.updateTrack(null))}var g=i._storedPeriodInfo[e].video.storedSettings;if(null!==g){var y=c.getSupportedAdaptations("video");if(!y.some((function(e){return e.id===g.adaptation.id}))){s.Z.warn("TS: Chosen video Adaptation not available anymore");var _,b=i._storedPeriodInfo[e];if(0===y.length)_=null;else{var S=y[0],E=kn(S,i._isTrickModeTrackEnabled),k=(0,T.ZP)(null);_={adaptationBase:S,adaptation:E,switchingMode:a,lockedRepresentations:k}}if(b.video.storedSettings=_,i.trigger("trackUpdate",{period:An(c),trackType:"video",reason:"missing"}),i._isDisposed)return{v:void 0};var w=En(i._storedPeriodInfo,b.period.id);void 0!==w&&w.video.storedSettings===_&&(null===(n=w.video.dispatcher)||void 0===n||n.updateTrack(_))}}var A=i._storedPeriodInfo[e].audio.storedSettings;if(null!==A){var I=c.getSupportedAdaptations("audio");if(!I.some((function(e){return e.id===A.adaptation.id}))){s.Z.warn("TS: Chosen audio Adaptation not available anymore");var R=i._storedPeriodInfo[e],Z=0===I.length?null:{adaptation:I[0],switchingMode:i._defaultAudioTrackSwitchingMode,lockedRepresentations:(0,T.ZP)(null)};if(R.audio.storedSettings=Z,i.trigger("trackUpdate",{period:An(c),trackType:"audio",reason:"missing"}),i._isDisposed)return{v:void 0};var x=En(i._storedPeriodInfo,R.period.id);void 0!==x&&x.audio.storedSettings===Z&&(null===(r=x.audio.dispatcher)||void 0===r||r.updateTrack(Z))}}}else if(l.start<=c.start)i._storedPeriodInfo[e].inManifest=!1,Tn(i._storedPeriodInfo[e])&&(i._removePeriodObject(e),e--);else{var P=wn(c,!0,i._isTrickModeTrackEnabled,i._defaultAudioTrackSwitchingMode);i._storedPeriodInfo.splice(e,0,P),u.push(P),d++}f=e},f=0;f0&&this.trigger("newAvailablePeriods",m)},r.addTrackReference=function(e,t,n,r){var i=this,a=En(this._storedPeriodInfo,n.id);if(void 0===a&&(a=this._addPeriod(n),this.trigger("newAvailablePeriods",[{id:n.id,start:n.start,end:n.end}])),null===a[e].dispatcher){var o=a[e].storedSettings,u=new bn(t,r);a[e].dispatcher=u,u.addEventListener("noPlayableRepresentation",(function(){var t,r,a,o=(0,p.Z)(n.getAdaptationsForType(e),(function(e){return e.getPlayableRepresentations().length>0}));if(void 0===o){var s=new c.Z("NO_PLAYABLE_REPRESENTATION","No "+e+" Representation can be played",{adaptation:void 0});return i.trigger("error",s),void i.dispose()}var u=null===(t=En(i._storedPeriodInfo,n.id))||void 0===t?void 0:t[e];if(!(0,b.Z)(u)){var l={adaptation:o,switchingMode:"audio"===e?i._defaultAudioTrackSwitchingMode:"reload",lockedRepresentations:(0,T.ZP)(null)};u.storedSettings=l,i.trigger("trackUpdate",{period:An(n),trackType:e,reason:"no-playable-representation"}),i._isDisposed||(u=null===(r=En(i._storedPeriodInfo,n.id))||void 0===r?void 0:r[e],(0,b.Z)(u)||u.storedSettings!==l||null===(a=u.dispatcher)||void 0===a||a.updateTrack(l))}})),u.addEventListener("noPlayableLockedRepresentation",(function(){null==o||o.lockedRepresentations.setValue(null),i.trigger("brokenRepresentationsLock",{period:{id:n.id,start:n.start,end:n.end},trackType:e})})),u.start(o)}else s.Z.error("TS: Subject already added for "+e+" and Period "+n.start)},r.removeTrackReference=function(e,t){var n=function(e,t){for(var n=0;n=0;r--){var i=this._storedPeriodInfo[r];null===(e=i.audio.dispatcher)||void 0===e||e.dispose(),i.audio.dispatcher=null,null===(t=i.video.dispatcher)||void 0===t||t.dispose(),i.video.dispatcher=null,null===(n=i.text.dispatcher)||void 0===n||n.dispose(),i.text.dispatcher=null,i.inManifest||this._removePeriodObject(r)}},r.isTrickModeEnabled=function(){return this._isTrickModeTrackEnabled},r.setAudioTrack=function(e,t,n,r){return this._setAudioOrTextTrack("audio",e,t,null!=n?n:this._defaultAudioTrackSwitchingMode,r)},r.setTextTrack=function(e,t){return this._setAudioOrTextTrack("text",e,t,"direct",null)},r._setAudioOrTextTrack=function(e,t,n,r,i){var a,o=t.period,s=(0,p.Z)(o.getSupportedAdaptations(e),(function(e){return e.id===n}));if(void 0===s)throw new Error("Wanted "+e+" track not found.");var u,l=t[e];if(null===i)u=(0,T.ZP)(null);else{var d=this._getRepresentationsToLock(s,i),c="audio"===e?this._defaultAudioTrackSwitchingMode:"direct";u=(0,T.ZP)({representations:d,switchingMode:c})}var f={adaptation:s,switchingMode:r,lockedRepresentations:u};if(l.storedSettings=f,this.trigger("trackUpdate",{period:An(o),trackType:e,reason:"manual"}),!this._isDisposed){var v=En(this._storedPeriodInfo,o.id);void 0!==v&&v[e].storedSettings===f&&(null===(a=v[e].dispatcher)||void 0===a||a.updateTrack(f))}},r.setVideoTrack=function(e,t,n,r){var i,a=e.period,o=(0,p.Z)(a.getSupportedAdaptations("video"),(function(e){return e.id===t}));if(void 0===o)throw new Error("Wanted video track not found.");var s,u=l.Z.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=e.video,c=kn(o,this._isTrickModeTrackEnabled);if(null===r)s=(0,T.ZP)(null);else{var f=this._getRepresentationsToLock(o,r),v=u;s=(0,T.ZP)({representations:f,switchingMode:v})}var h={adaptationBase:o,switchingMode:null!=n?n:u,adaptation:c,lockedRepresentations:s};if(d.storedSettings=h,this.trigger("trackUpdate",{period:An(a),trackType:"video",reason:"manual"}),!this._isDisposed){var m=En(this._storedPeriodInfo,a.id);void 0!==m&&m.video.storedSettings===h&&(null===(i=m.video.dispatcher)||void 0===i||i.updateTrack(h))}},r.disableTrack=function(e,t){var n,r,i=e[t];if(null!==i.storedSettings&&("text"!==t&&(null===(n=e[t].storedSettings)||void 0===n||n.lockedRepresentations.finish()),i.storedSettings=null,this.trigger("trackUpdate",{period:An(e.period),trackType:t,reason:"manual"}),!this._isDisposed)){var a=En(this._storedPeriodInfo,e.period.id);void 0!==a&&null===a[t].storedSettings&&(null===(r=a[t].dispatcher)||void 0===r||r.updateTrack(null))}},r.getChosenAudioTrack=function(e){return null===e.audio.storedSettings?null:e.audio.storedSettings.adaptation.toAudioTrack(!0)},r.getChosenTextTrack=function(e){return null===e.text.storedSettings?null:e.text.storedSettings.adaptation.toTextTrack()},r.getChosenVideoTrack=function(e){return null===e.video.storedSettings?null:e.video.storedSettings.adaptation.toVideoTrack(!0)},r.getAvailableAudioTracks=function(e){var t=e.audio.storedSettings,n=null!==t?t.adaptation.id:null;return e.period.getSupportedAdaptations("audio").map((function(e){var t=null!==n&&n===e.id;return(0,S.Z)(e.toAudioTrack(!0),{active:t})}))},r.getAvailableTextTracks=function(e){var t=e.text.storedSettings,n=null!==t?t.adaptation.id:null;return e.period.getSupportedAdaptations("text").map((function(e){var t=null!==n&&n===e.id;return(0,S.Z)(e.toTextTrack(),{active:t})}))},r.getAvailableVideoTracks=function(e){var t=e.video.storedSettings,n=null===t?void 0:t.adaptation.id;return e.period.getSupportedAdaptations("video").map((function(e){var t=null!==n&&n===e.id,r=e.toVideoTrack(!0),i=void 0!==r.trickModeTracks?r.trickModeTracks.map((function(e){var t=null!==n&&n===e.id;return(0,S.Z)(e,{active:t})})):[],a=(0,S.Z)(r,{active:t});return void 0!==i&&(a.trickModeTracks=i),a}))},r.getLockedAudioRepresentations=function(e){var t=e.audio.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representations.map((function(e){return e.id}))},r.getLockedVideoRepresentations=function(e){var t=e.video.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representations.map((function(e){return e.id}))},r.lockAudioRepresentations=function(e,t){var n,r=e.audio.storedSettings;if(null!==r){var i=l.Z.getCurrent().DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representations:a,switchingMode:o})}},r.lockVideoRepresentations=function(e,t){var n,r=e.video.storedSettings;if(null!==r){var i=l.Z.getCurrent().DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representations:a,switchingMode:o})}},r.unlockAudioRepresentations=function(e){var t=e.audio.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.unlockVideoRepresentations=function(e){var t=e.video.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.dispose=function(){for(this._isDisposed=!0;;){var e=this._storedPeriodInfo.pop();if(void 0===e)return;e.isRemoved=!0}},r._addPeriod=function(e){for(var t=wn(e,!1,this._isTrickModeTrackEnabled,this._defaultAudioTrackSwitchingMode),n=0;ne.start)return this._storedPeriodInfo.splice(n,0,t),t;return this._storedPeriodInfo.push(t),t},r._resetVideoTrackChoices=function(e){for(var t,n=0;n0){if(null!=a){var h=(0,p.Z)(v,(function(e){return e.normalizedLanguage===a.normalizedLanguage}));void 0!==h&&(f=h)}null===f&&(f=null!==(i=(0,p.Z)(v,(function(e){return void 0===e.normalizedLanguage})))&&void 0!==i?i:null)}var m=null;return null!==f&&(m={adaptation:f,switchingMode:"direct",lockedRepresentations:(0,T.ZP)(null)}),{period:e,inManifest:t,isRemoved:!1,audio:{storedSettings:d,dispatcher:null},video:{storedSettings:c,dispatcher:null},text:{storedSettings:m,dispatcher:null}}}function An(e){return{start:e.start,end:e.end,id:e.id}}function In(e,t){var n=l.Z.getCurrent().FORCED_ENDED_THRESHOLD;if(e.ended)return"ENDED";if(null!==t){var r=Math.abs(e.duration-e.currentTime);return null!=n&&r=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function xn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||c.result.removedAdaptations.length>0)){if(void 0===u.getPeriodObjectFromPeriod(s))return;r._priv_onAvailableTracksMayHaveChanged("audio"),r._priv_onAvailableTracksMayHaveChanged("text"),r._priv_onAvailableTracksMayHaveChanged("video")}return}}),e.currentContentCanceller.signal),t.addEventListener("decipherabilityUpdate",(function(t){for(var n,i=t.reduce((function(t,n){var r,i,a;if(!(void 0===(0,p.Z)(t,(function(e){return e[0].id===n.period.id&&e[1]===n.adaptation.type})))){var o=e.tracksStore;if(null===o)return t;var s=!1,u=o.getPeriodObjectFromPeriod(n.period);if(void 0===u)return t;switch(n.adaptation.type){case"audio":s=(null===(r=o.getChosenAudioTrack(u))||void 0===r?void 0:r.id)===n.adaptation.id;break;case"video":s=(null===(i=o.getChosenVideoTrack(u))||void 0===i?void 0:i.id)===n.adaptation.id;break;case"text":s=(null===(a=o.getChosenTextTrack(u))||void 0===a?void 0:a.id)===n.adaptation.id}s&&t.push([n.period,n.adaptation.type])}return t}),[]),a=Zn(i);!(n=a()).done;){var o=n.value,s=o[0],u=o[1];r._priv_triggerEventIfNotStopped("representationListUpdate",{period:s,trackType:u,reason:"decipherability-update"},e.currentContentCanceller.signal)}}),e.currentContentCanceller.signal)}},i._priv_onActivePeriodChanged=function(e,t){var n,r,i,a,o,s,u=t.period;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.currentPeriod=u;var l=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==u&&(this._priv_contentEventsMemory.periodChange=u,this._priv_triggerEventIfNotStopped("periodChange",{start:u.start,end:u.end,id:u.id},l)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),l),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),l),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),l);var d=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.tracksStore;if((0,b.Z)(d))this._priv_triggerEventIfNotStopped("audioTrackChange",null,l),this._priv_triggerEventIfNotStopped("textTrackChange",null,l),this._priv_triggerEventIfNotStopped("videoTrackChange",null,l);else{var c=d.getPeriodObjectFromPeriod(u);if(c){var f=d.getChosenAudioTrack(c);this._priv_triggerEventIfNotStopped("audioTrackChange",f,l);var v=d.getChosenTextTrack(c);this._priv_triggerEventIfNotStopped("textTrackChange",v,l);var p=d.getChosenVideoTrack(c);this._priv_triggerEventIfNotStopped("videoTrackChange",p,l)}}var h=null!==(a=null===(i=this.__priv_getCurrentRepresentations())||void 0===i?void 0:i.audio)&&void 0!==a?a:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",h,l);var m=null!==(s=null===(o=this.__priv_getCurrentRepresentations())||void 0===o?void 0:o.video)&&void 0!==s?s:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",m,l)}},i._priv_onPeriodStreamReady=function(e,t){var n;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var r=t.type,i=t.manifest,a=t.period,o=t.adaptationRef,u=e.tracksStore;switch(r){case"video":case"audio":case"text":(0,b.Z)(u)?(s.Z.error("API: TracksStore not instanciated for a new "+r+" period"),o.setValue(null)):u.addTrackReference(r,i,a,o);break;default:(0,g.Z)(r)}}},i._priv_onPeriodStreamCleared=function(e,t){var n;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var r=t.type,i=t.period,a=e.tracksStore;switch(r){case"audio":case"text":case"video":(0,b.Z)(a)||a.removeTrackReference(r,i)}var o=e.activeAdaptations,s=e.activeRepresentations;if(!(0,b.Z)(o)&&!(0,b.Z)(o[i.id])){var u=o[i.id];delete u[r],0===Object.keys(u).length&&delete o[i.id]}if(!(0,b.Z)(s)&&!(0,b.Z)(s[i.id])){var l=s[i.id];delete l[r],0===Object.keys(l).length&&delete s[i.id]}}},i._priv_onAdaptationChange=function(e,t){var n,r=t.type,i=t.adaptation,a=t.period;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){null===e.activeAdaptations&&(e.activeAdaptations={});var o,s=e.activeAdaptations,u=e.currentPeriod,l=s[a.id];if((0,b.Z)(l))s[a.id]=((o={})[r]=i,o);else l[r]=i;var d=e.tracksStore,c=e.currentContentCanceller.signal;if(null!==d&&null!==u&&!(0,b.Z)(a)&&a.id===u.id){var f=d.getPeriodObjectFromPeriod(a);if(void 0===f)return;switch(r){case"audio":var v=d.getChosenAudioTrack(f);this._priv_triggerEventIfNotStopped("audioTrackChange",v,c);break;case"text":var p=d.getChosenTextTrack(f);this._priv_triggerEventIfNotStopped("textTrackChange",p,c);break;case"video":var h=d.getChosenVideoTrack(f);this._priv_triggerEventIfNotStopped("videoTrackChange",h,c)}}}},i._priv_onRepresentationChange=function(e,t){var n,r=t.type,i=t.period,a=t.representation;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){null===e.activeRepresentations&&(e.activeRepresentations={});var o,s=e.activeRepresentations,u=e.currentPeriod,l=s[i.id];if((0,b.Z)(l))s[i.id]=((o={})[r]=a,o);else l[r]=a;if(!(0,b.Z)(i)&&null!==u&&u.id===i.id){var d=this._priv_contentInfos.currentContentCanceller.signal;"video"===r?this._priv_triggerEventIfNotStopped("videoRepresentationChange",a,d):"audio"===r&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",a,d)}}},i._priv_onBitrateEstimateChange=function(e){var t=e.type,n=e.bitrate;void 0!==n&&(this._priv_bitrateInfos.lastBitrates[t]=n),this.trigger("__priv_bitrateEstimateChange",{type:t,bitrate:n})},i._priv_setPlayerState=function(e){this.state!==e&&(this.state=e,s.Z.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))},i._priv_triggerPositionUpdate=function(e,t){var n,r;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var i=e.isDirectFile,o=e.manifest;if((i||null!==o)&&!(0,b.Z)(t)){var s=null!==o?o.getMaximumSafePosition():void 0,u={position:t.position,duration:t.duration,playbackRate:t.playbackRate,maximumPosition:s,bufferGap:void 0!==t.bufferGap&&isFinite(t.bufferGap)?t.bufferGap:0};if(null!==o&&o.isLive&&t.position>0){var l=null!==(r=o.availabilityStartTime)&&void 0!==r?r:0;u.wallClockTime=t.position+l;var d=o.getLivePosition();void 0!==d&&(u.liveGap=d-t.position)}else if(i&&null!==this.videoElement){var c=a(this.videoElement);void 0!==c&&(u.wallClockTime=c+t.position)}this.trigger("positionUpdate",u)}}},i._priv_triggerEventIfNotStopped=function(e,t,n){n.isCancelled()||this.trigger(e,t)},i._priv_initializeMediaElementTracksStore=function(e){var t,n,r,i=this;(0,m.Z)(null!==v.Z.directfile,"Initializing `MediaElementTracksStore` without Directfile feature"),(0,m.Z)(null!==this.videoElement,"Initializing `MediaElementTracksStore` on a disposed RxPlayer");var a=new v.Z.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",a.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",a.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",a.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",null!==(t=a.getChosenAudioTrack())&&void 0!==t?t:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",null!==(n=a.getChosenTextTrack())&&void 0!==n?n:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",null!==(r=a.getChosenVideoTrack())&&void 0!==r?r:null,e),a.addEventListener("availableVideoTracksChange",(function(e){return i.trigger("availableVideoTracksChange",e)})),a.addEventListener("availableAudioTracksChange",(function(e){return i.trigger("availableAudioTracksChange",e)})),a.addEventListener("availableTextTracksChange",(function(e){return i.trigger("availableTextTracksChange",e)})),a.addEventListener("audioTrackChange",(function(e){return i.trigger("audioTrackChange",e)})),a.addEventListener("videoTrackChange",(function(e){return i.trigger("videoTrackChange",e)})),a.addEventListener("textTrackChange",(function(e){return i.trigger("textTrackChange",e)})),a},i._priv_callTracksStoreGetterSetter=function(e,t,n){var r,i;if(null===this._priv_contentInfos||null===this._priv_contentInfos.tracksStore)return s.Z.warn("API: Trying to call track API too soon"),t;var a=this._priv_contentInfos.tracksStore,o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,u=null!=e?e:null==o?void 0:o.id;if(void 0===u)return t;var l=u===(null==o?void 0:o.id)?a.getPeriodObjectFromPeriod(o):a.getPeriodObjectFromId(u);return void 0===l?t:n(a,l)},i._priv_onAvailableTracksMayHaveChanged=function(e,t){var n=this._priv_contentInfos;if(null!==n){var r=n.currentPeriod,i=n.tracksStore,a=n.currentContentCanceller.signal;if(!(0,b.Z)(r)&&null!==i){var o=null!=t?t:i.getPeriodObjectFromPeriod(r);if(void 0!==o)switch(e){case"video":var s=i.getAvailableVideoTracks(o);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",null!=s?s:[],a);break;case"audio":var u=i.getAvailableAudioTracks(o);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",null!=u?u:[],a);break;case"text":var l=i.getAvailableTextTracks(o);this._priv_triggerEventIfNotStopped("availableTextTracksChange",null!=l?l:[],a);break;default:(0,g.Z)(e)}}}},i._priv_onFatalError=function(e,t){var n=(0,d.Z)(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});n.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=n,s.Z.error("API: The player stopped because of an error",n),this._priv_setPlayerState("STOPPED"),this._priv_currentError===n&&this.trigger("error",n)},(0,e.Z)(r,null,[{key:"ErrorTypes",get:function(){return f.ZB}},{key:"ErrorCodes",get:function(){return f.SM}},{key:"LogLevel",get:function(){return s.Z.getLevel()},set:function(e){s.Z.setLevel(e)}}]),r}(y.Z);On.version="4.0.0-beta.2";var Ln=On,Un=n(7273);!function(){Un.Z.ContentDecryptor=n(1266).ZP,Un.Z.transports.smooth=n(5418).Z,Un.Z.transports.dash=n(2047).Z,Un.Z.dashParsers.js=n(8337).Z,Un.Z.nativeTextTracksBuffer=n(9059).Z,Un.Z.nativeTextTracksParsers.vtt=n(9405).Z,Un.Z.nativeTextTracksParsers.ttml=n(1570).Z,Un.Z.nativeTextTracksParsers.sami=n(1812).Z,Un.Z.nativeTextTracksParsers.srt=n(8057).Z,Un.Z.htmlTextTracksBuffer=n(5192).Z,Un.Z.htmlTextTracksParsers.sami=n(5734).Z,Un.Z.htmlTextTracksParsers.ttml=n(7439).Z,Un.Z.htmlTextTracksParsers.srt=n(8675).Z,Un.Z.htmlTextTracksParsers.vtt=n(4099).Z;var e=n(9372).Z,t=n(1932).Z;Un.Z.directfile={initDirectFile:e,mediaElementTracksStore:t}}(),"boolean"==typeof __RX_PLAYER_DEBUG_MODE__&&__RX_PLAYER_DEBUG_MODE__&&s.Z.setLevel("DEBUG");var Bn=Ln}(),r=r.default}()})); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5a5e6f87724..da6da4bc89b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rx-player", - "version": "3.31.0", + "version": "4.0.0-beta.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rx-player", - "version": "3.31.0", + "version": "4.0.0-beta.2", "license": "Apache-2.0", "dependencies": { "next-tick": "1.1.0" diff --git a/package.json b/package.json index f3d71c0492d..69b648be56f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "rx-player", "author": "Canal+", - "version": "3.31.0", + "version": "4.0.0-beta.2", "description": "Canal+ HTML5 Video Player", "main": "./dist/rx-player.js", "keywords": [ diff --git a/sonar-project.properties b/sonar-project.properties index ecb18c7ef4d..c0fb69ca5d8 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=rx-player sonar.organization=rx-player sonar.projectName=rx-player -sonar.projectVersion=3.31.0 +sonar.projectVersion=4.0.0-beta.2 sonar.sources=./src,./demo,./tests sonar.exclusions=demo/full/bundle.js,demo/standalone/lib.js,demo/bundle.js sonar.host.url=https://sonarcloud.io diff --git a/src/core/api/public_api.ts b/src/core/api/public_api.ts index 9380d25ddc3..6b5cb38c472 100644 --- a/src/core/api/public_api.ts +++ b/src/core/api/public_api.ts @@ -336,7 +336,7 @@ class Player extends EventEmitter { // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624 videoElement.preload = "auto"; - this.version = /* PLAYER_VERSION */"3.31.0"; + this.version = /* PLAYER_VERSION */"4.0.0-beta.2"; this.log = log; this.state = "STOPPED"; this.videoElement = videoElement; @@ -2758,7 +2758,7 @@ class Player extends EventEmitter { } } } -Player.version = /* PLAYER_VERSION */"3.31.0"; +Player.version = /* PLAYER_VERSION */"4.0.0-beta.2"; /** Every events sent by the RxPlayer's public API. */ interface IPublicAPIEvent { From 8e8e87c16e2c57f95ff36d2e7bcd0c40bd3e9472 Mon Sep 17 00:00:00 2001 From: Paul Berberian Date: Thu, 15 Jun 2023 17:01:25 +0200 Subject: [PATCH 2/3] Fix issues numbers in CHANGELOG.md --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a6e48aa9a..a5bfab991cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,13 @@ ### Changes - - If all Representations from the current track become undecipherable, automatically switch to another track (also send a `trackUpdate` event) instead of stopping on error [#1240] - - Only send `MediaError` errors with the `NO_PLAYABLE_REPRESENTATION` error code when no Representation from all tracks of a given type can be played [#1240] + - If all Representations from the current track become undecipherable, automatically switch to another track (also send a `trackUpdate` event) instead of stopping on error [#1234] + - Only send `MediaError` errors with the `NO_PLAYABLE_REPRESENTATION` error code when no Representation from all tracks of a given type can be played [#1234] ### Features - - Add `representationListUpdate` event for when the list of available Representation for a current track changes [#877] - - Add `"no-playable-representation"` as a `reason` for `trackUpdate` events when the track switch is due to encrypted Representations [#1240] + - Add `representationListUpdate` event for when the list of available Representation for a current track changes [#1240] + - Add `"no-playable-representation"` as a `reason` for `trackUpdate` events when the track switch is due to encrypted Representations [#1234] ### Other improvements From eb99f4bfb734f8f87de738de6a431ecde56e156f Mon Sep 17 00:00:00 2001 From: Paul Berberian Date: Thu, 15 Jun 2023 17:54:00 +0200 Subject: [PATCH 3/3] Fix issues seen by sonarcloud --- tests/integration/scenarios/dash_forced-subtitles.js | 2 +- tests/performance/src/main.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/scenarios/dash_forced-subtitles.js b/tests/integration/scenarios/dash_forced-subtitles.js index 1bc48686d1a..685264d3d7e 100644 --- a/tests/integration/scenarios/dash_forced-subtitles.js +++ b/tests/integration/scenarios/dash_forced-subtitles.js @@ -85,7 +85,7 @@ describe("DASH forced-subtitles content (SegmentTimeline)", function () { reject(err); } }); - loadContent(); + loadContent().catch(reject); }); }); }); diff --git a/tests/performance/src/main.js b/tests/performance/src/main.js index 03401762210..c1eb6eefb1a 100644 --- a/tests/performance/src/main.js +++ b/tests/performance/src/main.js @@ -43,6 +43,9 @@ function sendLog(log) { headers: { "Content-Type": "application/json" }, method: "POST", body: JSON.stringify({ type: "log", data: log }), + }).catch(err => { + // eslint-disable-next-line no-console + console.error("Error: Cannot send log due to a request error.", err); }); }