@hakit/components
Version:
A series of components to work with @hakit/core
1 lines • 1.14 MB
Source Map (JSON)
{"version":3,"file":"hls.light-utYKyTGG.cjs","sources":["../../../node_modules/hls.js/dist/hls.light.mjs"],"sourcesContent":["function getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nvar urlToolkit = {exports: {}};\n\n(function (module, exports) {\n\t// see https://tools.ietf.org/html/rfc1808\n\n\t(function (root) {\n\t var URL_REGEX =\n\t /^(?=((?:[a-zA-Z0-9+\\-.]+:)?))\\1(?=((?:\\/\\/[^\\/?#]*)?))\\2(?=((?:(?:[^?#\\/]*\\/)*[^;?#\\/]*)?))\\3((?:;[^?#]*)?)(\\?[^#]*)?(#[^]*)?$/;\n\t var FIRST_SEGMENT_REGEX = /^(?=([^\\/?#]*))\\1([^]*)$/;\n\t var SLASH_DOT_REGEX = /(?:\\/|^)\\.(?=\\/)/g;\n\t var SLASH_DOT_DOT_REGEX = /(?:\\/|^)\\.\\.\\/(?!\\.\\.\\/)[^\\/]*(?=\\/)/g;\n\n\t var URLToolkit = {\n\t // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or //\n\t // E.g\n\t // With opts.alwaysNormalize = false (default, spec compliant)\n\t // http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g\n\t // With opts.alwaysNormalize = true (not spec compliant)\n\t // http://a.com/b/cd + /e/f/../g => http://a.com/e/g\n\t buildAbsoluteURL: function (baseURL, relativeURL, opts) {\n\t opts = opts || {};\n\t // remove any remaining space and CRLF\n\t baseURL = baseURL.trim();\n\t relativeURL = relativeURL.trim();\n\t if (!relativeURL) {\n\t // 2a) If the embedded URL is entirely empty, it inherits the\n\t // entire base URL (i.e., is set equal to the base URL)\n\t // and we are done.\n\t if (!opts.alwaysNormalize) {\n\t return baseURL;\n\t }\n\t var basePartsForNormalise = URLToolkit.parseURL(baseURL);\n\t if (!basePartsForNormalise) {\n\t throw new Error('Error trying to parse base URL.');\n\t }\n\t basePartsForNormalise.path = URLToolkit.normalizePath(\n\t basePartsForNormalise.path\n\t );\n\t return URLToolkit.buildURLFromParts(basePartsForNormalise);\n\t }\n\t var relativeParts = URLToolkit.parseURL(relativeURL);\n\t if (!relativeParts) {\n\t throw new Error('Error trying to parse relative URL.');\n\t }\n\t if (relativeParts.scheme) {\n\t // 2b) If the embedded URL starts with a scheme name, it is\n\t // interpreted as an absolute URL and we are done.\n\t if (!opts.alwaysNormalize) {\n\t return relativeURL;\n\t }\n\t relativeParts.path = URLToolkit.normalizePath(relativeParts.path);\n\t return URLToolkit.buildURLFromParts(relativeParts);\n\t }\n\t var baseParts = URLToolkit.parseURL(baseURL);\n\t if (!baseParts) {\n\t throw new Error('Error trying to parse base URL.');\n\t }\n\t if (!baseParts.netLoc && baseParts.path && baseParts.path[0] !== '/') {\n\t // If netLoc missing and path doesn't start with '/', assume everthing before the first '/' is the netLoc\n\t // This causes 'example.com/a' to be handled as '//example.com/a' instead of '/example.com/a'\n\t var pathParts = FIRST_SEGMENT_REGEX.exec(baseParts.path);\n\t baseParts.netLoc = pathParts[1];\n\t baseParts.path = pathParts[2];\n\t }\n\t if (baseParts.netLoc && !baseParts.path) {\n\t baseParts.path = '/';\n\t }\n\t var builtParts = {\n\t // 2c) Otherwise, the embedded URL inherits the scheme of\n\t // the base URL.\n\t scheme: baseParts.scheme,\n\t netLoc: relativeParts.netLoc,\n\t path: null,\n\t params: relativeParts.params,\n\t query: relativeParts.query,\n\t fragment: relativeParts.fragment,\n\t };\n\t if (!relativeParts.netLoc) {\n\t // 3) If the embedded URL's <net_loc> is non-empty, we skip to\n\t // Step 7. Otherwise, the embedded URL inherits the <net_loc>\n\t // (if any) of the base URL.\n\t builtParts.netLoc = baseParts.netLoc;\n\t // 4) If the embedded URL path is preceded by a slash \"/\", the\n\t // path is not relative and we skip to Step 7.\n\t if (relativeParts.path[0] !== '/') {\n\t if (!relativeParts.path) {\n\t // 5) If the embedded URL path is empty (and not preceded by a\n\t // slash), then the embedded URL inherits the base URL path\n\t builtParts.path = baseParts.path;\n\t // 5a) if the embedded URL's <params> is non-empty, we skip to\n\t // step 7; otherwise, it inherits the <params> of the base\n\t // URL (if any) and\n\t if (!relativeParts.params) {\n\t builtParts.params = baseParts.params;\n\t // 5b) if the embedded URL's <query> is non-empty, we skip to\n\t // step 7; otherwise, it inherits the <query> of the base\n\t // URL (if any) and we skip to step 7.\n\t if (!relativeParts.query) {\n\t builtParts.query = baseParts.query;\n\t }\n\t }\n\t } else {\n\t // 6) The last segment of the base URL's path (anything\n\t // following the rightmost slash \"/\", or the entire path if no\n\t // slash is present) is removed and the embedded URL's path is\n\t // appended in its place.\n\t var baseURLPath = baseParts.path;\n\t var newPath =\n\t baseURLPath.substring(0, baseURLPath.lastIndexOf('/') + 1) +\n\t relativeParts.path;\n\t builtParts.path = URLToolkit.normalizePath(newPath);\n\t }\n\t }\n\t }\n\t if (builtParts.path === null) {\n\t builtParts.path = opts.alwaysNormalize\n\t ? URLToolkit.normalizePath(relativeParts.path)\n\t : relativeParts.path;\n\t }\n\t return URLToolkit.buildURLFromParts(builtParts);\n\t },\n\t parseURL: function (url) {\n\t var parts = URL_REGEX.exec(url);\n\t if (!parts) {\n\t return null;\n\t }\n\t return {\n\t scheme: parts[1] || '',\n\t netLoc: parts[2] || '',\n\t path: parts[3] || '',\n\t params: parts[4] || '',\n\t query: parts[5] || '',\n\t fragment: parts[6] || '',\n\t };\n\t },\n\t normalizePath: function (path) {\n\t // The following operations are\n\t // then applied, in order, to the new path:\n\t // 6a) All occurrences of \"./\", where \".\" is a complete path\n\t // segment, are removed.\n\t // 6b) If the path ends with \".\" as a complete path segment,\n\t // that \".\" is removed.\n\t path = path.split('').reverse().join('').replace(SLASH_DOT_REGEX, '');\n\t // 6c) All occurrences of \"<segment>/../\", where <segment> is a\n\t // complete path segment not equal to \"..\", are removed.\n\t // Removal of these path segments is performed iteratively,\n\t // removing the leftmost matching pattern on each iteration,\n\t // until no matching pattern remains.\n\t // 6d) If the path ends with \"<segment>/..\", where <segment> is a\n\t // complete path segment not equal to \"..\", that\n\t // \"<segment>/..\" is removed.\n\t while (\n\t path.length !== (path = path.replace(SLASH_DOT_DOT_REGEX, '')).length\n\t ) {}\n\t return path.split('').reverse().join('');\n\t },\n\t buildURLFromParts: function (parts) {\n\t return (\n\t parts.scheme +\n\t parts.netLoc +\n\t parts.path +\n\t parts.params +\n\t parts.query +\n\t parts.fragment\n\t );\n\t },\n\t };\n\n\t module.exports = URLToolkit;\n\t})(); \n} (urlToolkit));\n\nvar urlToolkitExports = urlToolkit.exports;\n\nfunction ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nfunction _objectSpread2(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {\n _defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\n}\nfunction _toPrimitive(t, r) {\n if (\"object\" != typeof t || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != typeof i) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nfunction _toPropertyKey(t) {\n var i = _toPrimitive(t, \"string\");\n return \"symbol\" == typeof i ? i : String(i);\n}\nfunction _defineProperty(obj, key, value) {\n key = _toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nfunction _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}\n\n// https://caniuse.com/mdn-javascript_builtins_number_isfinite\nconst isFiniteNumber = Number.isFinite || function (value) {\n return typeof value === 'number' && isFinite(value);\n};\n\n// https://caniuse.com/mdn-javascript_builtins_number_issafeinteger\nconst isSafeInteger = Number.isSafeInteger || function (value) {\n return typeof value === 'number' && Math.abs(value) <= MAX_SAFE_INTEGER;\n};\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;\n\nlet Events = /*#__PURE__*/function (Events) {\n Events[\"MEDIA_ATTACHING\"] = \"hlsMediaAttaching\";\n Events[\"MEDIA_ATTACHED\"] = \"hlsMediaAttached\";\n Events[\"MEDIA_DETACHING\"] = \"hlsMediaDetaching\";\n Events[\"MEDIA_DETACHED\"] = \"hlsMediaDetached\";\n Events[\"BUFFER_RESET\"] = \"hlsBufferReset\";\n Events[\"BUFFER_CODECS\"] = \"hlsBufferCodecs\";\n Events[\"BUFFER_CREATED\"] = \"hlsBufferCreated\";\n Events[\"BUFFER_APPENDING\"] = \"hlsBufferAppending\";\n Events[\"BUFFER_APPENDED\"] = \"hlsBufferAppended\";\n Events[\"BUFFER_EOS\"] = \"hlsBufferEos\";\n Events[\"BUFFER_FLUSHING\"] = \"hlsBufferFlushing\";\n Events[\"BUFFER_FLUSHED\"] = \"hlsBufferFlushed\";\n Events[\"MANIFEST_LOADING\"] = \"hlsManifestLoading\";\n Events[\"MANIFEST_LOADED\"] = \"hlsManifestLoaded\";\n Events[\"MANIFEST_PARSED\"] = \"hlsManifestParsed\";\n Events[\"LEVEL_SWITCHING\"] = \"hlsLevelSwitching\";\n Events[\"LEVEL_SWITCHED\"] = \"hlsLevelSwitched\";\n Events[\"LEVEL_LOADING\"] = \"hlsLevelLoading\";\n Events[\"LEVEL_LOADED\"] = \"hlsLevelLoaded\";\n Events[\"LEVEL_UPDATED\"] = \"hlsLevelUpdated\";\n Events[\"LEVEL_PTS_UPDATED\"] = \"hlsLevelPtsUpdated\";\n Events[\"LEVELS_UPDATED\"] = \"hlsLevelsUpdated\";\n Events[\"AUDIO_TRACKS_UPDATED\"] = \"hlsAudioTracksUpdated\";\n Events[\"AUDIO_TRACK_SWITCHING\"] = \"hlsAudioTrackSwitching\";\n Events[\"AUDIO_TRACK_SWITCHED\"] = \"hlsAudioTrackSwitched\";\n Events[\"AUDIO_TRACK_LOADING\"] = \"hlsAudioTrackLoading\";\n Events[\"AUDIO_TRACK_LOADED\"] = \"hlsAudioTrackLoaded\";\n Events[\"SUBTITLE_TRACKS_UPDATED\"] = \"hlsSubtitleTracksUpdated\";\n Events[\"SUBTITLE_TRACKS_CLEARED\"] = \"hlsSubtitleTracksCleared\";\n Events[\"SUBTITLE_TRACK_SWITCH\"] = \"hlsSubtitleTrackSwitch\";\n Events[\"SUBTITLE_TRACK_LOADING\"] = \"hlsSubtitleTrackLoading\";\n Events[\"SUBTITLE_TRACK_LOADED\"] = \"hlsSubtitleTrackLoaded\";\n Events[\"SUBTITLE_FRAG_PROCESSED\"] = \"hlsSubtitleFragProcessed\";\n Events[\"CUES_PARSED\"] = \"hlsCuesParsed\";\n Events[\"NON_NATIVE_TEXT_TRACKS_FOUND\"] = \"hlsNonNativeTextTracksFound\";\n Events[\"INIT_PTS_FOUND\"] = \"hlsInitPtsFound\";\n Events[\"FRAG_LOADING\"] = \"hlsFragLoading\";\n Events[\"FRAG_LOAD_EMERGENCY_ABORTED\"] = \"hlsFragLoadEmergencyAborted\";\n Events[\"FRAG_LOADED\"] = \"hlsFragLoaded\";\n Events[\"FRAG_DECRYPTED\"] = \"hlsFragDecrypted\";\n Events[\"FRAG_PARSING_INIT_SEGMENT\"] = \"hlsFragParsingInitSegment\";\n Events[\"FRAG_PARSING_USERDATA\"] = \"hlsFragParsingUserdata\";\n Events[\"FRAG_PARSING_METADATA\"] = \"hlsFragParsingMetadata\";\n Events[\"FRAG_PARSED\"] = \"hlsFragParsed\";\n Events[\"FRAG_BUFFERED\"] = \"hlsFragBuffered\";\n Events[\"FRAG_CHANGED\"] = \"hlsFragChanged\";\n Events[\"FPS_DROP\"] = \"hlsFpsDrop\";\n Events[\"FPS_DROP_LEVEL_CAPPING\"] = \"hlsFpsDropLevelCapping\";\n Events[\"MAX_AUTO_LEVEL_UPDATED\"] = \"hlsMaxAutoLevelUpdated\";\n Events[\"ERROR\"] = \"hlsError\";\n Events[\"DESTROYING\"] = \"hlsDestroying\";\n Events[\"KEY_LOADING\"] = \"hlsKeyLoading\";\n Events[\"KEY_LOADED\"] = \"hlsKeyLoaded\";\n Events[\"LIVE_BACK_BUFFER_REACHED\"] = \"hlsLiveBackBufferReached\";\n Events[\"BACK_BUFFER_REACHED\"] = \"hlsBackBufferReached\";\n Events[\"STEERING_MANIFEST_LOADED\"] = \"hlsSteeringManifestLoaded\";\n return Events;\n}({});\n\n/**\n * Defines each Event type and payload by Event name. Used in {@link hls.js#HlsEventEmitter} to strongly type the event listener API.\n */\n\nlet ErrorTypes = /*#__PURE__*/function (ErrorTypes) {\n ErrorTypes[\"NETWORK_ERROR\"] = \"networkError\";\n ErrorTypes[\"MEDIA_ERROR\"] = \"mediaError\";\n ErrorTypes[\"KEY_SYSTEM_ERROR\"] = \"keySystemError\";\n ErrorTypes[\"MUX_ERROR\"] = \"muxError\";\n ErrorTypes[\"OTHER_ERROR\"] = \"otherError\";\n return ErrorTypes;\n}({});\nlet ErrorDetails = /*#__PURE__*/function (ErrorDetails) {\n ErrorDetails[\"KEY_SYSTEM_NO_KEYS\"] = \"keySystemNoKeys\";\n ErrorDetails[\"KEY_SYSTEM_NO_ACCESS\"] = \"keySystemNoAccess\";\n ErrorDetails[\"KEY_SYSTEM_NO_SESSION\"] = \"keySystemNoSession\";\n ErrorDetails[\"KEY_SYSTEM_NO_CONFIGURED_LICENSE\"] = \"keySystemNoConfiguredLicense\";\n ErrorDetails[\"KEY_SYSTEM_LICENSE_REQUEST_FAILED\"] = \"keySystemLicenseRequestFailed\";\n ErrorDetails[\"KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED\"] = \"keySystemServerCertificateRequestFailed\";\n ErrorDetails[\"KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED\"] = \"keySystemServerCertificateUpdateFailed\";\n ErrorDetails[\"KEY_SYSTEM_SESSION_UPDATE_FAILED\"] = \"keySystemSessionUpdateFailed\";\n ErrorDetails[\"KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED\"] = \"keySystemStatusOutputRestricted\";\n ErrorDetails[\"KEY_SYSTEM_STATUS_INTERNAL_ERROR\"] = \"keySystemStatusInternalError\";\n ErrorDetails[\"MANIFEST_LOAD_ERROR\"] = \"manifestLoadError\";\n ErrorDetails[\"MANIFEST_LOAD_TIMEOUT\"] = \"manifestLoadTimeOut\";\n ErrorDetails[\"MANIFEST_PARSING_ERROR\"] = \"manifestParsingError\";\n ErrorDetails[\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\"] = \"manifestIncompatibleCodecsError\";\n ErrorDetails[\"LEVEL_EMPTY_ERROR\"] = \"levelEmptyError\";\n ErrorDetails[\"LEVEL_LOAD_ERROR\"] = \"levelLoadError\";\n ErrorDetails[\"LEVEL_LOAD_TIMEOUT\"] = \"levelLoadTimeOut\";\n ErrorDetails[\"LEVEL_PARSING_ERROR\"] = \"levelParsingError\";\n ErrorDetails[\"LEVEL_SWITCH_ERROR\"] = \"levelSwitchError\";\n ErrorDetails[\"AUDIO_TRACK_LOAD_ERROR\"] = \"audioTrackLoadError\";\n ErrorDetails[\"AUDIO_TRACK_LOAD_TIMEOUT\"] = \"audioTrackLoadTimeOut\";\n ErrorDetails[\"SUBTITLE_LOAD_ERROR\"] = \"subtitleTrackLoadError\";\n ErrorDetails[\"SUBTITLE_TRACK_LOAD_TIMEOUT\"] = \"subtitleTrackLoadTimeOut\";\n ErrorDetails[\"FRAG_LOAD_ERROR\"] = \"fragLoadError\";\n ErrorDetails[\"FRAG_LOAD_TIMEOUT\"] = \"fragLoadTimeOut\";\n ErrorDetails[\"FRAG_DECRYPT_ERROR\"] = \"fragDecryptError\";\n ErrorDetails[\"FRAG_PARSING_ERROR\"] = \"fragParsingError\";\n ErrorDetails[\"FRAG_GAP\"] = \"fragGap\";\n ErrorDetails[\"REMUX_ALLOC_ERROR\"] = \"remuxAllocError\";\n ErrorDetails[\"KEY_LOAD_ERROR\"] = \"keyLoadError\";\n ErrorDetails[\"KEY_LOAD_TIMEOUT\"] = \"keyLoadTimeOut\";\n ErrorDetails[\"BUFFER_ADD_CODEC_ERROR\"] = \"bufferAddCodecError\";\n ErrorDetails[\"BUFFER_INCOMPATIBLE_CODECS_ERROR\"] = \"bufferIncompatibleCodecsError\";\n ErrorDetails[\"BUFFER_APPEND_ERROR\"] = \"bufferAppendError\";\n ErrorDetails[\"BUFFER_APPENDING_ERROR\"] = \"bufferAppendingError\";\n ErrorDetails[\"BUFFER_STALLED_ERROR\"] = \"bufferStalledError\";\n ErrorDetails[\"BUFFER_FULL_ERROR\"] = \"bufferFullError\";\n ErrorDetails[\"BUFFER_SEEK_OVER_HOLE\"] = \"bufferSeekOverHole\";\n ErrorDetails[\"BUFFER_NUDGE_ON_STALL\"] = \"bufferNudgeOnStall\";\n ErrorDetails[\"INTERNAL_EXCEPTION\"] = \"internalException\";\n ErrorDetails[\"INTERNAL_ABORTED\"] = \"aborted\";\n ErrorDetails[\"UNKNOWN\"] = \"unknown\";\n return ErrorDetails;\n}({});\n\nconst noop = function noop() {};\nconst fakeLogger = {\n trace: noop,\n debug: noop,\n log: noop,\n warn: noop,\n info: noop,\n error: noop\n};\nlet exportedLogger = fakeLogger;\n\n// let lastCallTime;\n// function formatMsgWithTimeInfo(type, msg) {\n// const now = Date.now();\n// const diff = lastCallTime ? '+' + (now - lastCallTime) : '0';\n// lastCallTime = now;\n// msg = (new Date(now)).toISOString() + ' | [' + type + '] > ' + msg + ' ( ' + diff + ' ms )';\n// return msg;\n// }\n\nfunction consolePrintFn(type) {\n const func = self.console[type];\n if (func) {\n return func.bind(self.console, `[${type}] >`);\n }\n return noop;\n}\nfunction exportLoggerFunctions(debugConfig, ...functions) {\n functions.forEach(function (type) {\n exportedLogger[type] = debugConfig[type] ? debugConfig[type].bind(debugConfig) : consolePrintFn(type);\n });\n}\nfunction enableLogs(debugConfig, id) {\n // check that console is available\n if (typeof console === 'object' && debugConfig === true || typeof debugConfig === 'object') {\n exportLoggerFunctions(debugConfig,\n // Remove out from list here to hard-disable a log-level\n // 'trace',\n 'debug', 'log', 'info', 'warn', 'error');\n // Some browsers don't allow to use bind on console object anyway\n // fallback to default if needed\n try {\n exportedLogger.log(`Debug logs enabled for \"${id}\" in hls.js version ${\"1.5.18\"}`);\n } catch (e) {\n exportedLogger = fakeLogger;\n }\n } else {\n exportedLogger = fakeLogger;\n }\n}\nconst logger = exportedLogger;\n\nconst DECIMAL_RESOLUTION_REGEX = /^(\\d+)x(\\d+)$/;\nconst ATTR_LIST_REGEX = /(.+?)=(\".*?\"|.*?)(?:,|$)/g;\n\n// adapted from https://github.com/kanongil/node-m3u8parse/blob/master/attrlist.js\nclass AttrList {\n constructor(attrs) {\n if (typeof attrs === 'string') {\n attrs = AttrList.parseAttrList(attrs);\n }\n _extends(this, attrs);\n }\n get clientAttrs() {\n return Object.keys(this).filter(attr => attr.substring(0, 2) === 'X-');\n }\n decimalInteger(attrName) {\n const intValue = parseInt(this[attrName], 10);\n if (intValue > Number.MAX_SAFE_INTEGER) {\n return Infinity;\n }\n return intValue;\n }\n hexadecimalInteger(attrName) {\n if (this[attrName]) {\n let stringValue = (this[attrName] || '0x').slice(2);\n stringValue = (stringValue.length & 1 ? '0' : '') + stringValue;\n const value = new Uint8Array(stringValue.length / 2);\n for (let i = 0; i < stringValue.length / 2; i++) {\n value[i] = parseInt(stringValue.slice(i * 2, i * 2 + 2), 16);\n }\n return value;\n } else {\n return null;\n }\n }\n hexadecimalIntegerAsNumber(attrName) {\n const intValue = parseInt(this[attrName], 16);\n if (intValue > Number.MAX_SAFE_INTEGER) {\n return Infinity;\n }\n return intValue;\n }\n decimalFloatingPoint(attrName) {\n return parseFloat(this[attrName]);\n }\n optionalFloat(attrName, defaultValue) {\n const value = this[attrName];\n return value ? parseFloat(value) : defaultValue;\n }\n enumeratedString(attrName) {\n return this[attrName];\n }\n bool(attrName) {\n return this[attrName] === 'YES';\n }\n decimalResolution(attrName) {\n const res = DECIMAL_RESOLUTION_REGEX.exec(this[attrName]);\n if (res === null) {\n return undefined;\n }\n return {\n width: parseInt(res[1], 10),\n height: parseInt(res[2], 10)\n };\n }\n static parseAttrList(input) {\n let match;\n const attrs = {};\n const quote = '\"';\n ATTR_LIST_REGEX.lastIndex = 0;\n while ((match = ATTR_LIST_REGEX.exec(input)) !== null) {\n let value = match[2];\n if (value.indexOf(quote) === 0 && value.lastIndexOf(quote) === value.length - 1) {\n value = value.slice(1, -1);\n }\n const name = match[1].trim();\n attrs[name] = value;\n }\n return attrs;\n }\n}\n\n// Avoid exporting const enum so that these values can be inlined\n\nfunction isDateRangeCueAttribute(attrName) {\n return attrName !== \"ID\" && attrName !== \"CLASS\" && attrName !== \"START-DATE\" && attrName !== \"DURATION\" && attrName !== \"END-DATE\" && attrName !== \"END-ON-NEXT\";\n}\nfunction isSCTE35Attribute(attrName) {\n return attrName === \"SCTE35-OUT\" || attrName === \"SCTE35-IN\";\n}\nclass DateRange {\n constructor(dateRangeAttr, dateRangeWithSameId) {\n this.attr = void 0;\n this._startDate = void 0;\n this._endDate = void 0;\n this._badValueForSameId = void 0;\n if (dateRangeWithSameId) {\n const previousAttr = dateRangeWithSameId.attr;\n for (const key in previousAttr) {\n if (Object.prototype.hasOwnProperty.call(dateRangeAttr, key) && dateRangeAttr[key] !== previousAttr[key]) {\n logger.warn(`DATERANGE tag attribute: \"${key}\" does not match for tags with ID: \"${dateRangeAttr.ID}\"`);\n this._badValueForSameId = key;\n break;\n }\n }\n // Merge DateRange tags with the same ID\n dateRangeAttr = _extends(new AttrList({}), previousAttr, dateRangeAttr);\n }\n this.attr = dateRangeAttr;\n this._startDate = new Date(dateRangeAttr[\"START-DATE\"]);\n if (\"END-DATE\" in this.attr) {\n const endDate = new Date(this.attr[\"END-DATE\"]);\n if (isFiniteNumber(endDate.getTime())) {\n this._endDate = endDate;\n }\n }\n }\n get id() {\n return this.attr.ID;\n }\n get class() {\n return this.attr.CLASS;\n }\n get startDate() {\n return this._startDate;\n }\n get endDate() {\n if (this._endDate) {\n return this._endDate;\n }\n const duration = this.duration;\n if (duration !== null) {\n return new Date(this._startDate.getTime() + duration * 1000);\n }\n return null;\n }\n get duration() {\n if (\"DURATION\" in this.attr) {\n const duration = this.attr.decimalFloatingPoint(\"DURATION\");\n if (isFiniteNumber(duration)) {\n return duration;\n }\n } else if (this._endDate) {\n return (this._endDate.getTime() - this._startDate.getTime()) / 1000;\n }\n return null;\n }\n get plannedDuration() {\n if (\"PLANNED-DURATION\" in this.attr) {\n return this.attr.decimalFloatingPoint(\"PLANNED-DURATION\");\n }\n return null;\n }\n get endOnNext() {\n return this.attr.bool(\"END-ON-NEXT\");\n }\n get isValid() {\n return !!this.id && !this._badValueForSameId && isFiniteNumber(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class);\n }\n}\n\nclass LoadStats {\n constructor() {\n this.aborted = false;\n this.loaded = 0;\n this.retry = 0;\n this.total = 0;\n this.chunkCount = 0;\n this.bwEstimate = 0;\n this.loading = {\n start: 0,\n first: 0,\n end: 0\n };\n this.parsing = {\n start: 0,\n end: 0\n };\n this.buffering = {\n start: 0,\n first: 0,\n end: 0\n };\n }\n}\n\nvar ElementaryStreamTypes = {\n AUDIO: \"audio\",\n VIDEO: \"video\",\n AUDIOVIDEO: \"audiovideo\"\n};\nclass BaseSegment {\n constructor(baseurl) {\n this._byteRange = null;\n this._url = null;\n // baseurl is the URL to the playlist\n this.baseurl = void 0;\n // relurl is the portion of the URL that comes from inside the playlist.\n this.relurl = void 0;\n // Holds the types of data this fragment supports\n this.elementaryStreams = {\n [ElementaryStreamTypes.AUDIO]: null,\n [ElementaryStreamTypes.VIDEO]: null,\n [ElementaryStreamTypes.AUDIOVIDEO]: null\n };\n this.baseurl = baseurl;\n }\n\n // setByteRange converts a EXT-X-BYTERANGE attribute into a two element array\n setByteRange(value, previous) {\n const params = value.split('@', 2);\n let start;\n if (params.length === 1) {\n start = (previous == null ? void 0 : previous.byteRangeEndOffset) || 0;\n } else {\n start = parseInt(params[1]);\n }\n this._byteRange = [start, parseInt(params[0]) + start];\n }\n get byteRange() {\n if (!this._byteRange) {\n return [];\n }\n return this._byteRange;\n }\n get byteRangeStartOffset() {\n return this.byteRange[0];\n }\n get byteRangeEndOffset() {\n return this.byteRange[1];\n }\n get url() {\n if (!this._url && this.baseurl && this.relurl) {\n this._url = urlToolkitExports.buildAbsoluteURL(this.baseurl, this.relurl, {\n alwaysNormalize: true\n });\n }\n return this._url || '';\n }\n set url(value) {\n this._url = value;\n }\n}\n\n/**\n * Object representing parsed data from an HLS Segment. Found in {@link hls.js#LevelDetails.fragments}.\n */\nclass Fragment extends BaseSegment {\n constructor(type, baseurl) {\n super(baseurl);\n this._decryptdata = null;\n this.rawProgramDateTime = null;\n this.programDateTime = null;\n this.tagList = [];\n // EXTINF has to be present for a m3u8 to be considered valid\n this.duration = 0;\n // sn notates the sequence number for a segment, and if set to a string can be 'initSegment'\n this.sn = 0;\n // levelkeys are the EXT-X-KEY tags that apply to this segment for decryption\n // core difference from the private field _decryptdata is the lack of the initialized IV\n // _decryptdata will set the IV for this segment based on the segment number in the fragment\n this.levelkeys = void 0;\n // A string representing the fragment type\n this.type = void 0;\n // A reference to the loader. Set while the fragment is loading, and removed afterwards. Used to abort fragment loading\n this.loader = null;\n // A reference to the key loader. Set while the key is loading, and removed afterwards. Used to abort key loading\n this.keyLoader = null;\n // The level/track index to which the fragment belongs\n this.level = -1;\n // The continuity counter of the fragment\n this.cc = 0;\n // The starting Presentation Time Stamp (PTS) of the fragment. Set after transmux complete.\n this.startPTS = void 0;\n // The ending Presentation Time Stamp (PTS) of the fragment. Set after transmux complete.\n this.endPTS = void 0;\n // The starting Decode Time Stamp (DTS) of the fragment. Set after transmux complete.\n this.startDTS = void 0;\n // The ending Decode Time Stamp (DTS) of the fragment. Set after transmux complete.\n this.endDTS = void 0;\n // The start time of the fragment, as listed in the manifest. Updated after transmux complete.\n this.start = 0;\n // Set by `updateFragPTSDTS` in level-helper\n this.deltaPTS = void 0;\n // The maximum starting Presentation Time Stamp (audio/video PTS) of the fragment. Set after transmux complete.\n this.maxStartPTS = void 0;\n // The minimum ending Presentation Time Stamp (audio/video PTS) of the fragment. Set after transmux complete.\n this.minEndPTS = void 0;\n // Load/parse timing information\n this.stats = new LoadStats();\n // Init Segment bytes (unset for media segments)\n this.data = void 0;\n // A flag indicating whether the segment was downloaded in order to test bitrate, and was not buffered\n this.bitrateTest = false;\n // #EXTINF segment title\n this.title = null;\n // The Media Initialization Section for this segment\n this.initSegment = null;\n // Fragment is the last fragment in the media playlist\n this.endList = void 0;\n // Fragment is marked by an EXT-X-GAP tag indicating that it does not contain media data and should not be loaded\n this.gap = void 0;\n // Deprecated\n this.urlId = 0;\n this.type = type;\n }\n get decryptdata() {\n const {\n levelkeys\n } = this;\n if (!levelkeys && !this._decryptdata) {\n return null;\n }\n if (!this._decryptdata && this.levelkeys && !this.levelkeys.NONE) {\n const key = this.levelkeys.identity;\n if (key) {\n this._decryptdata = key.getDecryptData(this.sn);\n } else {\n const keyFormats = Object.keys(this.levelkeys);\n if (keyFormats.length === 1) {\n return this._decryptdata = this.levelkeys[keyFormats[0]].getDecryptData(this.sn);\n }\n }\n }\n return this._decryptdata;\n }\n get end() {\n return this.start + this.duration;\n }\n get endProgramDateTime() {\n if (this.programDateTime === null) {\n return null;\n }\n if (!isFiniteNumber(this.programDateTime)) {\n return null;\n }\n const duration = !isFiniteNumber(this.duration) ? 0 : this.duration;\n return this.programDateTime + duration * 1000;\n }\n get encrypted() {\n var _this$_decryptdata;\n // At the m3u8-parser level we need to add support for manifest signalled keyformats\n // when we want the fragment to start reporting that it is encrypted.\n // Currently, keyFormat will only be set for identity keys\n if ((_this$_decryptdata = this._decryptdata) != null && _this$_decryptdata.encrypted) {\n return true;\n } else if (this.levelkeys) {\n const keyFormats = Object.keys(this.levelkeys);\n const len = keyFormats.length;\n if (len > 1 || len === 1 && this.levelkeys[keyFormats[0]].encrypted) {\n return true;\n }\n }\n return false;\n }\n setKeyFormat(keyFormat) {\n if (this.levelkeys) {\n const key = this.levelkeys[keyFormat];\n if (key && !this._decryptdata) {\n this._decryptdata = key.getDecryptData(this.sn);\n }\n }\n }\n abortRequests() {\n var _this$loader, _this$keyLoader;\n (_this$loader = this.loader) == null ? void 0 : _this$loader.abort();\n (_this$keyLoader = this.keyLoader) == null ? void 0 : _this$keyLoader.abort();\n }\n setElementaryStreamInfo(type, startPTS, endPTS, startDTS, endDTS, partial = false) {\n const {\n elementaryStreams\n } = this;\n const info = elementaryStreams[type];\n if (!info) {\n elementaryStreams[type] = {\n startPTS,\n endPTS,\n startDTS,\n endDTS,\n partial\n };\n return;\n }\n info.startPTS = Math.min(info.startPTS, startPTS);\n info.endPTS = Math.max(info.endPTS, endPTS);\n info.startDTS = Math.min(info.startDTS, startDTS);\n info.endDTS = Math.max(info.endDTS, endDTS);\n }\n clearElementaryStreamInfo() {\n const {\n elementaryStreams\n } = this;\n elementaryStreams[ElementaryStreamTypes.AUDIO] = null;\n elementaryStreams[ElementaryStreamTypes.VIDEO] = null;\n elementaryStreams[ElementaryStreamTypes.AUDIOVIDEO] = null;\n }\n}\n\n/**\n * Object representing parsed data from an HLS Partial Segment. Found in {@link hls.js#LevelDetails.partList}.\n */\nclass Part extends BaseSegment {\n constructor(partAttrs, frag, baseurl, index, previous) {\n super(baseurl);\n this.fragOffset = 0;\n this.duration = 0;\n this.gap = false;\n this.independent = false;\n this.relurl = void 0;\n this.fragment = void 0;\n this.index = void 0;\n this.stats = new LoadStats();\n this.duration = partAttrs.decimalFloatingPoint('DURATION');\n this.gap = partAttrs.bool('GAP');\n this.independent = partAttrs.bool('INDEPENDENT');\n this.relurl = partAttrs.enumeratedString('URI');\n this.fragment = frag;\n this.index = index;\n const byteRange = partAttrs.enumeratedString('BYTERANGE');\n if (byteRange) {\n this.setByteRange(byteRange, previous);\n }\n if (previous) {\n this.fragOffset = previous.fragOffset + previous.duration;\n }\n }\n get start() {\n return this.fragment.start + this.fragOffset;\n }\n get end() {\n return this.start + this.duration;\n }\n get loaded() {\n const {\n elementaryStreams\n } = this;\n return !!(elementaryStreams.audio || elementaryStreams.video || elementaryStreams.audiovideo);\n }\n}\n\nconst DEFAULT_TARGET_DURATION = 10;\n\n/**\n * Object representing parsed data from an HLS Media Playlist. Found in {@link hls.js#Level.details}.\n */\nclass LevelDetails {\n constructor(baseUrl) {\n this.PTSKnown = false;\n this.alignedSliding = false;\n this.averagetargetduration = void 0;\n this.endCC = 0;\n this.endSN = 0;\n this.fragments = void 0;\n this.fragmentHint = void 0;\n this.partList = null;\n this.dateRanges = void 0;\n this.live = true;\n this.ageHeader = 0;\n this.advancedDateTime = void 0;\n this.updated = true;\n this.advanced = true;\n this.availabilityDelay = void 0;\n // Manifest reload synchronization\n this.misses = 0;\n this.startCC = 0;\n this.startSN = 0;\n this.startTimeOffset = null;\n this.targetduration = 0;\n this.totalduration = 0;\n this.type = null;\n this.url = void 0;\n this.m3u8 = '';\n this.version = null;\n this.canBlockReload = false;\n this.canSkipUntil = 0;\n this.canSkipDateRanges = false;\n this.skippedSegments = 0;\n this.recentlyRemovedDateranges = void 0;\n this.partHoldBack = 0;\n this.holdBack = 0;\n this.partTarget = 0;\n this.preloadHint = void 0;\n this.renditionReports = void 0;\n this.tuneInGoal = 0;\n this.deltaUpdateFailed = void 0;\n this.driftStartTime = 0;\n this.driftEndTime = 0;\n this.driftStart = 0;\n this.driftEnd = 0;\n this.encryptedFragments = void 0;\n this.playlistParsingError = null;\n this.variableList = null;\n this.hasVariableRefs = false;\n this.fragments = [];\n this.encryptedFragments = [];\n this.dateRanges = {};\n this.url = baseUrl;\n }\n reloaded(previous) {\n if (!previous) {\n this.advanced = true;\n this.updated = true;\n return;\n }\n const partSnDiff = this.lastPartSn - previous.lastPartSn;\n const partIndexDiff = this.lastPartIndex - previous.lastPartIndex;\n this.updated = this.endSN !== previous.endSN || !!partIndexDiff || !!partSnDiff || !this.live;\n this.advanced = this.endSN > previous.endSN || partSnDiff > 0 || partSnDiff === 0 && partIndexDiff > 0;\n if (this.updated || this.advanced) {\n this.misses = Math.floor(previous.misses * 0.6);\n } else {\n this.misses = previous.misses + 1;\n }\n this.availabilityDelay = previous.availabilityDelay;\n }\n get hasProgramDateTime() {\n if (this.fragments.length) {\n return isFiniteNumber(this.fragments[this.fragments.length - 1].programDateTime);\n }\n return false;\n }\n get levelTargetDuration() {\n return this.averagetargetduration || this.targetduration || DEFAULT_TARGET_DURATION;\n }\n get drift() {\n const runTime = this.driftEndTime - this.driftStartTime;\n if (runTime > 0) {\n const runDuration = this.driftEnd - this.driftStart;\n return runDuration * 1000 / runTime;\n }\n return 1;\n }\n get edge() {\n return this.partEnd || this.fragmentEnd;\n }\n get partEnd() {\n var _this$partList;\n if ((_this$partList = this.partList) != null && _this$partList.length) {\n return this.partList[this.partList.length - 1].end;\n }\n return this.fragmentEnd;\n }\n get fragmentEnd() {\n var _this$fragments;\n if ((_this$fragments = this.fragments) != null && _this$fragments.length) {\n return this.fragments[this.fragments.length - 1].end;\n }\n return 0;\n }\n get age() {\n if (this.advancedDateTime) {\n return Math.max(Date.now() - this.advancedDateTime, 0) / 1000;\n }\n return 0;\n }\n get lastPartIndex() {\n var _this$partList2;\n if ((_this$partList2 = this.partList) != null && _this$partList2.length) {\n return this.partList[this.partList.length - 1].index;\n }\n return -1;\n }\n get lastPartSn() {\n var _this$partList3;\n if ((_this$partList3 = this.partList) != null && _this$partList3.length) {\n return this.partList[this.partList.length - 1].fragment.sn;\n }\n return this.endSN;\n }\n}\n\n// This file is inserted as a shim for modules which we do not want to include into the distro.\n// This replacement is done in the \"alias\" plugin of the rollup config.\n// Use a ES dedicated file as Rollup assigns an object in the output\n// For example: \"var KeySystemFormats = emptyEs.KeySystemFormats;\"\nvar emptyEs = {};\nvar Cues = /*@__PURE__*/getDefaultExportFromCjs(emptyEs);\n\nfunction sliceUint8(array, start, end) {\n // @ts-expect-error This polyfills IE11 usage of Uint8Array slice.\n // It always exists in the TypeScript definition so fails, but it fails at runtime on IE11.\n return Uint8Array.prototype.slice ? array.slice(start, end) : new Uint8Array(Array.prototype.slice.call(array, start, end));\n}\n\n// breaking up those two types in order to clarify what is happening in the decoding path.\n\n/**\n * Returns true if an ID3 header can be found at offset in data\n * @param data - The data to search\n * @param offset - The offset at which to start searching\n */\nconst isHeader$2 = (data, offset) => {\n /*\n * http://id3.org/id3v2.3.0\n * [0] = 'I'\n * [1] = 'D'\n * [2] = '3'\n * [3,4] = {Version}\n * [5] = {Flags}\n * [6-9] = {ID3 Size}\n *\n * An ID3v2 tag can be detected with the following pattern:\n * $49 44 33 yy yy xx zz zz zz zz\n * Where yy is less than $FF, xx is the 'flags' byte and zz is less than $80\n */\n if (offset + 10 <= data.length) {\n // look for 'ID3' identifier\n if (data[offset] === 0x49 && data[offset + 1] === 0x44 && data[offset + 2] === 0x33) {\n // check version is within range\n if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) {\n // check size is within range\n if (data[offset + 6] < 0x80 && data[offset + 7] < 0x80 && data[offset + 8] < 0x80 && data[offset + 9] < 0x80) {\n return true;\n }\n }\n }\n }\n return false;\n};\n\n/**\n * Returns true if an ID3 footer can be found at offset in data\n * @param data - The data to search\n * @param offset - The offset at which to start searching\n */\nconst isFooter = (data, offset) => {\n /*\n * The footer is a copy of the header, but with a different identifier\n */\n if (offset + 10 <= data.length) {\n // look for '3DI' identifier\n if (data[offset] === 0x33 && data[offset + 1] === 0x44 && data[offset + 2] === 0x49) {\n // check version is within range\n if (data[offset + 3] < 0xff && data[offset + 4] < 0xff) {\n // check size is within range\n if (data[offset + 6] < 0x80 && data[offset + 7] < 0x80 && data[offset + 8] < 0x80 && data[offset + 9] < 0x80) {\n return true;\n }\n }\n }\n }\n return false;\n};\n\n/**\n * Returns any adjacent ID3 tags found in data starting at offset, as one block of data\n * @param data - The data to search in\n * @param offset - The offset at which to start searching\n * @returns the block of data containing any ID3 tags found\n * or *undefined* if no header is found at the starting offset\n */\nconst getID3Data = (data, offset) => {\n const front = offset;\n let length = 0;\n while (isHeader$2(data, offset)) {\n // ID3 header is 10 bytes\n length += 10;\n const size = readSize(data, offset + 6);\n length += size;\n if (isFooter(data, offset + 10)) {\n // ID3 footer is 10 bytes\n length += 10;\n }\n offset += length;\n }\n if (length > 0) {\n return data.subarray(front, front + length);\n }\n return undefined;\n};\nconst readSize = (data, offset) => {\n let size = 0;\n size = (data[offset] & 0x7f) << 21;\n size |= (data[offset + 1] & 0x7f) << 14;\n size |= (data[offset + 2] & 0x7f) << 7;\n size |= data[offset + 3] & 0x7f;\n return size;\n};\nconst canParse$2 = (data, offset) => {\n return isHeader$2(data, offset) && readSize(data, offset + 6) + 10 <= data.length - offset;\n};\n\n/**\n * Searches for the Elementary Stream timestamp found in the ID3 data chunk\n * @param data - Block of data containing one or more ID3 tags\n */\nconst getTimeStamp = data => {\n const frames = getID3Frames(data);\n for (let i = 0; i < frames.length; i++) {\n const frame = frames[i];\n if (isTimeStampFrame(frame)) {\n return readTimeStamp(frame);\n }\n }\n return undefined;\n};\n\n/**\n * Returns true if the ID3 frame is an Elementary Stream timestamp frame\n */\nconst isTimeStampFrame = frame => {\n return frame && frame.key === 'PRIV' && frame.info === 'com.apple.streaming.transportStreamTimestamp';\n};\nconst getFrameData = data => {\n /*\n Frame ID $xx xx xx xx (four characters)\n Size $xx xx xx xx\n Flags $xx xx\n */\n const type = String.fromCharCode(data[0], data[1], data[2], data[3]);\n const size = readSize(data, 4);\n\n // skip frame id, size, and flags\n const offset = 10;\n return {\n type,\n size,\n data: data.subarray(offset, offset + size)\n };\n};\n\n/**\n * Returns an array of ID3 frames found in all the ID3 tags in the id3Data\n * @param id3Data - The ID3 data containing one or more ID3 tags\n */\nconst getID3Frames = id3Data => {\n let offset = 0;\n const frames = [];\n while (isHeader$2(id3Data, offset)) {\n const size = readSize(id3Data, offset + 6);\n // skip past ID3 header\n offset += 10;\n const end = offset + size;\n // loop through frames in the ID3 tag\n while (offset + 8 < end) {\n const frameData = getFrameData(id3Data.subarray(offset));\n const frame = decodeFrame(frameData);\n if (frame) {\n frames.push(frame);\n }\n\n // skip frame header and frame data\n offset += frameData.size + 10;\n }\n if (isFooter(id3Data, offset)) {\n offset += 10;\n }\n }\n return frames;\n};\nconst decodeFrame = frame => {\n if (frame.type === 'PRIV') {\n return decodePrivFrame(frame);\n } else if (frame.type[0] === 'W') {\n return decodeURLFrame(frame);\n }\n return decodeTextFrame(frame);\n};\nconst decodePrivFrame = frame => {\n /*\n Format: <text string>\\0<binary data>\n */\n if (frame.size < 2) {\n return undefined;\n }\n const owner = utf8ArrayToStr(frame.data, true);\n const privateData = new Uint8Array(frame.data.subarray(owner.length + 1));\n return {\n key: frame.type,\n info: owner,\n data: privateData.buffer\n };\n};\nconst decodeTextFrame = frame => {\n if (frame.size < 2) {\n return undefined;\n }\n if (frame.type === 'TXXX') {\n /*\n Format:\n [0] = {Text Encoding}\n [1-?] = {Description}\\0{Value}\n */\n let index = 1;\n const description = utf8ArrayToStr(frame.data.subarray(index), true);\n index += description.length + 1;\n const value = utf8ArrayToStr(frame.data.subarray(index));\n return {\n key: frame.type,\n info: description,\n data: value\n };\n }\n /*\n Format:\n [0] = {Text Encoding}\n [1-?] = {Value}\n */\n const text = utf8ArrayToStr(frame.data.subarray(1));\n return {\n key: frame.type,\n data: text\n };\n};\nconst decodeURLFrame = frame => {\n if (frame.type === 'WXXX') {\n /*\n Format:\n [0] = {Text Encoding}\n [1-?] = {Description}\\0{URL}\n */\n if (frame.size < 2) {\n return undefined;\n }\n let index = 1;\n const description = utf8ArrayToStr(frame.data.subarray(index), true);\n index += description.length + 1;\n const value = utf8ArrayToStr(frame.data.subarray(index));\n return {\n key: frame.type,\n info: description,\n data: value\n };\n }\n /*\n Format:\n [0-?] = {URL}\n */\n const url = utf8ArrayToStr(frame.data);\n return {\n key: frame.type,\n data: url\n };\n};\nconst readTimeStamp = timeStampFrame => {\n if (timeStampFrame.data.byteLength === 8) {\n const data = new Uint8Array(timeStampFrame.data);\n // timestamp is 33 bit expressed as a big-endian eight-octet number,\n // with the upper 31 bits set to zero.\n const pts33Bit = data[3] & 0x1;\n let timestamp = (data[4] << 23) + (data[5] << 15) + (data[6] << 7) + data[7];\n timestamp /= 45;\n if (pts33Bit) {\n timestamp += 47721858.84;\n } // 2^32 / 90\n\n return Math.round(timestamp);\n }\n return undefined;\n};\n\n// http://stackoverflow.com/questions/8936984/uint8array-to-string-in-javascript/22373197\n// http://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt\n/* utf.js - UTF-8 <=> UTF-16 convertion\n *\n * Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>\n * Version: 1.0\n * LastModified: Dec 25 1999\n * This library is free. You can redistribute it and/or modify it.\n */\nconst utf8ArrayToStr = (array, exitOnNull = false) => {\n const decoder = getTextDecoder();\n if (decoder) {\n const decoded = decoder.decode(array);\n if (exitOnNull) {\n // grab up to the first null\n const idx = decoded.indexOf('\\0');\n return idx !== -1 ? decoded.substring(0, idx) : decoded;\n }\n\n // remove any null characters\n return decoded.replace(/\\0/g, '');\n }\n const len = array.length;\n let c;\n let char2;\n let char3;\n let out = '';\n let i = 0;\n while (i < len) {\n c = array[i++];\n if (c === 0x00 && exitOnNull) {\n return out;\n } else if (c === 0x00 || c === 0x03) {\n // If the character is 3 (END_OF_TEXT) or 0 (NULL) then skip it\n continue;\n }\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c);\n break;\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++];\n out += String.fromCharCode((c & 0x1f) << 6 | char2 & 0x3f);\n break;\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++];\n char3 = array[i++];\n out += String.fromCharCode((c & 0x0f) << 12 | (char2 & 0x3f) << 6 | (char3 & 0x3f) << 0);\n break;\n }\n }\n return out;\n};\nlet decoder;\nfunction getTextDecoder() {\n // On Play Station 4, TextDecoder is defined but partially implemented.\n // Manual decoding option is preferable\n if (navigator.userAgent.includes('PlayStation 4')) {\n return;\n }\n if (!decoder && typeof self.TextDecoder !== 'undefined') {\n decoder = new self.TextDecoder('utf-8');\n }\n return decoder;\n}\n\n/**\n * hex dump helper class\n */\n\nconst Hex = {\n hexDump: function (array) {\n let str = '';\n for (let i = 0; i < array.length; i++) {\n let h = array[i].toString(16);\n if (h.length < 2) {\n h = '0' + h;\n }\n str += h;\n }\n return str;\n }\n};\n\nconst UINT32_MAX$1 = Math.pow(2, 32) - 1;\nconst push = [].push;\n\n// We are using fixed track IDs for driving the MP4 remuxer\n// instead of following the TS PIDs.\n// There is no reason not to do this and some browsers/SourceBuffer-demuxers\n// may not like if there are TrackID \"switches\"\n// See https://github.com/video-dev/hls.js/issues/1331\n// Here we are mapping our internal track types to constant MP4 track IDs\n// With MSE currently one can only have one track of each, and we are muxing\n// whatever video/audio rendition in them.\nconst RemuxerTrackIdConfig = {\n video: 1,\n audio: 2,\n id3: 3,\n text: 4\n};\nfunction bin2str(data) {\n return String.fromCharCode.apply(null, data);\n}\nfunction readUint16(buffer, offset) {\n const val = buffer[offset] << 8 | buffer[offset + 1];\n return val < 0 ? 65536 + val : val;\n}\nfunction readUint32(buffer, offset) {\n const val = readSint32(buffer, offset);\n return val < 0 ? 4294967296 + val : val;\n}\nfunction readUint64(buffer, offset) {\n let result = readUint32(buffer, offset);\n result *= Math.pow(2, 32);\n result += readUint32(buffer, offset + 4);\n return result;\n}\nfunction readSint32(buffer, offset) {\n return buffer[offset] << 24 | buffer[offset + 1] << 16 | buffer[offset + 2] << 8 | buffer[offset + 3];\n}\nfunction writeUint32(buffer, offset, value) {\n buffer[offset] = value >> 24;\n buffer[offset + 1] = value >> 16 & 0xff;\n buffer[offset + 2] = value >> 8 & 0xff;\n buffer[offset + 3] = value & 0xff;\n}\n\n// Find \"moof\" box\nfunction hasMoofData(data) {\n const end = data.byteLength;\n for (let i = 0; i < end;) {\n const size = readUint32(data, i);\n if (size > 8 && data[i + 4] === 0x6d && data[i + 5] === 0x6f && data[i + 6] === 0x6f && data[i + 7] === 0x66) {\n return true;\n }\n i = size > 1 ? i + size : end;\n }\n return false;\n}\n\n// Find the data for a box specified by its path\nfunction findBox(data, path) {\n const results = [];\n if (!path.length) {\n // short-circuit the search for empty paths\n return results;\n }\n const end = data.byteLength;\n for (let i = 0; i < end;) {\n const size = readUint32(data, i);\n const type = bin2str(data.subar