UNPKG

vue3-video-play

Version:
1,404 lines (1,403 loc) 565 kB
import { computed as je, openBlock as z, createElementBlock as j, normalizeClass as Ye, normalizeStyle as qe, ref as $e, onUnmounted as Ki, createElementVNode as P, toDisplayString as re, unref as He, defineComponent as gt, withDirectives as Te, createVNode as te, createTextVNode as ke, vShow as xe, useCssVars as Ds, nextTick as Vi, pushScopeId as Mt, popScopeId as Nt, getCurrentInstance as Hr, createCommentVNode as he, reactive as bt, withModifiers as Wr, watch as Hi, onMounted as Wi, Transition as ms, withCtx as ps, Fragment as Dt, renderList as _t, useAttrs as Yr, mergeProps as qr, createBlock as zr, withKeys as rt } from "vue"; function jr(a, e, t) { var s = t || {}, i = s.noTrailing, r = i === void 0 ? !1 : i, n = s.noLeading, o = n === void 0 ? !1 : n, l = s.debounceMode, c = l === void 0 ? void 0 : l, d, h = !1, u = 0; function f() { d && clearTimeout(d); } function g(y) { var T = y || {}, E = T.upcomingOnly, x = E === void 0 ? !1 : E; f(), h = !x; } function p() { for (var y = arguments.length, T = new Array(y), E = 0; E < y; E++) T[E] = arguments[E]; var x = this, A = Date.now() - u; if (h) return; function S() { u = Date.now(), e.apply(x, T); } function _() { d = void 0; } !o && c && !d && S(), f(), c === void 0 && A > a ? o ? (u = Date.now(), r || (d = setTimeout(c ? _ : S, a))) : S() : r !== !0 && (d = setTimeout(c ? _ : S, c === void 0 ? a - A : a)); } return p.cancel = g, p; } function Ws(a, e, t) { var s = t || {}, i = s.atBegin, r = i === void 0 ? !1 : i; return jr(a, e, { debounceMode: r !== !1 }); } function Xr(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var Yi = { exports: {} }; (function(a, e) { (function(t) { var s = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, i = /^(?=([^\/?#]*))\1([^]*)$/, r = /(?:\/|^)\.(?=\/)/g, n = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g, o = { // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or // // E.g // With opts.alwaysNormalize = false (default, spec compliant) // http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g // With opts.alwaysNormalize = true (not spec compliant) // http://a.com/b/cd + /e/f/../g => http://a.com/e/g buildAbsoluteURL: function(l, c, d) { if (d = d || {}, l = l.trim(), c = c.trim(), !c) { if (!d.alwaysNormalize) return l; var h = o.parseURL(l); if (!h) throw new Error("Error trying to parse base URL."); return h.path = o.normalizePath( h.path ), o.buildURLFromParts(h); } var u = o.parseURL(c); if (!u) throw new Error("Error trying to parse relative URL."); if (u.scheme) return d.alwaysNormalize ? (u.path = o.normalizePath(u.path), o.buildURLFromParts(u)) : c; var f = o.parseURL(l); if (!f) throw new Error("Error trying to parse base URL."); if (!f.netLoc && f.path && f.path[0] !== "/") { var g = i.exec(f.path); f.netLoc = g[1], f.path = g[2]; } f.netLoc && !f.path && (f.path = "/"); var p = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: f.scheme, netLoc: u.netLoc, path: null, params: u.params, query: u.query, fragment: u.fragment }; if (!u.netLoc && (p.netLoc = f.netLoc, u.path[0] !== "/")) if (!u.path) p.path = f.path, u.params || (p.params = f.params, u.query || (p.query = f.query)); else { var y = f.path, T = y.substring(0, y.lastIndexOf("/") + 1) + u.path; p.path = o.normalizePath(T); } return p.path === null && (p.path = d.alwaysNormalize ? o.normalizePath(u.path) : u.path), o.buildURLFromParts(p); }, parseURL: function(l) { var c = s.exec(l); return c ? { scheme: c[1] || "", netLoc: c[2] || "", path: c[3] || "", params: c[4] || "", query: c[5] || "", fragment: c[6] || "" } : null; }, normalizePath: function(l) { for (l = l.split("").reverse().join("").replace(r, ""); l.length !== (l = l.replace(n, "")).length; ) ; return l.split("").reverse().join(""); }, buildURLFromParts: function(l) { return l.scheme + l.netLoc + l.path + l.params + l.query + l.fragment; } }; a.exports = o; })(); })(Yi); var _s = Yi.exports; function Ys(a, e) { var t = Object.keys(a); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(a); e && (s = s.filter(function(i) { return Object.getOwnPropertyDescriptor(a, i).enumerable; })), t.push.apply(t, s); } return t; } function me(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e] != null ? arguments[e] : {}; e % 2 ? Ys(Object(t), !0).forEach(function(s) { Qr(a, s, t[s]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(t)) : Ys(Object(t)).forEach(function(s) { Object.defineProperty(a, s, Object.getOwnPropertyDescriptor(t, s)); }); } return a; } function Qr(a, e, t) { return e = Zr(e), e in a ? Object.defineProperty(a, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : a[e] = t, a; } function ne() { return ne = Object.assign ? Object.assign.bind() : function(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && (a[s] = t[s]); } return a; }, ne.apply(this, arguments); } function Jr(a, e) { if (typeof a != "object" || a === null) return a; var t = a[Symbol.toPrimitive]; if (t !== void 0) { var s = t.call(a, e || "default"); if (typeof s != "object") return s; throw new TypeError("@@toPrimitive must return a primitive value."); } return (e === "string" ? String : Number)(a); } function Zr(a) { var e = Jr(a, "string"); return typeof e == "symbol" ? e : String(e); } const B = Number.isFinite || function(a) { return typeof a == "number" && isFinite(a); }; let m = /* @__PURE__ */ function(a) { return a.MEDIA_ATTACHING = "hlsMediaAttaching", a.MEDIA_ATTACHED = "hlsMediaAttached", a.MEDIA_DETACHING = "hlsMediaDetaching", a.MEDIA_DETACHED = "hlsMediaDetached", a.BUFFER_RESET = "hlsBufferReset", a.BUFFER_CODECS = "hlsBufferCodecs", a.BUFFER_CREATED = "hlsBufferCreated", a.BUFFER_APPENDING = "hlsBufferAppending", a.BUFFER_APPENDED = "hlsBufferAppended", a.BUFFER_EOS = "hlsBufferEos", a.BUFFER_FLUSHING = "hlsBufferFlushing", a.BUFFER_FLUSHED = "hlsBufferFlushed", a.MANIFEST_LOADING = "hlsManifestLoading", a.MANIFEST_LOADED = "hlsManifestLoaded", a.MANIFEST_PARSED = "hlsManifestParsed", a.LEVEL_SWITCHING = "hlsLevelSwitching", a.LEVEL_SWITCHED = "hlsLevelSwitched", a.LEVEL_LOADING = "hlsLevelLoading", a.LEVEL_LOADED = "hlsLevelLoaded", a.LEVEL_UPDATED = "hlsLevelUpdated", a.LEVEL_PTS_UPDATED = "hlsLevelPtsUpdated", a.LEVELS_UPDATED = "hlsLevelsUpdated", a.AUDIO_TRACKS_UPDATED = "hlsAudioTracksUpdated", a.AUDIO_TRACK_SWITCHING = "hlsAudioTrackSwitching", a.AUDIO_TRACK_SWITCHED = "hlsAudioTrackSwitched", a.AUDIO_TRACK_LOADING = "hlsAudioTrackLoading", a.AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded", a.SUBTITLE_TRACKS_UPDATED = "hlsSubtitleTracksUpdated", a.SUBTITLE_TRACKS_CLEARED = "hlsSubtitleTracksCleared", a.SUBTITLE_TRACK_SWITCH = "hlsSubtitleTrackSwitch", a.SUBTITLE_TRACK_LOADING = "hlsSubtitleTrackLoading", a.SUBTITLE_TRACK_LOADED = "hlsSubtitleTrackLoaded", a.SUBTITLE_FRAG_PROCESSED = "hlsSubtitleFragProcessed", a.CUES_PARSED = "hlsCuesParsed", a.NON_NATIVE_TEXT_TRACKS_FOUND = "hlsNonNativeTextTracksFound", a.INIT_PTS_FOUND = "hlsInitPtsFound", a.FRAG_LOADING = "hlsFragLoading", a.FRAG_LOAD_EMERGENCY_ABORTED = "hlsFragLoadEmergencyAborted", a.FRAG_LOADED = "hlsFragLoaded", a.FRAG_DECRYPTED = "hlsFragDecrypted", a.FRAG_PARSING_INIT_SEGMENT = "hlsFragParsingInitSegment", a.FRAG_PARSING_USERDATA = "hlsFragParsingUserdata", a.FRAG_PARSING_METADATA = "hlsFragParsingMetadata", a.FRAG_PARSED = "hlsFragParsed", a.FRAG_BUFFERED = "hlsFragBuffered", a.FRAG_CHANGED = "hlsFragChanged", a.FPS_DROP = "hlsFpsDrop", a.FPS_DROP_LEVEL_CAPPING = "hlsFpsDropLevelCapping", a.ERROR = "hlsError", a.DESTROYING = "hlsDestroying", a.KEY_LOADING = "hlsKeyLoading", a.KEY_LOADED = "hlsKeyLoaded", a.LIVE_BACK_BUFFER_REACHED = "hlsLiveBackBufferReached", a.BACK_BUFFER_REACHED = "hlsBackBufferReached", a; }({}), G = /* @__PURE__ */ function(a) { return a.NETWORK_ERROR = "networkError", a.MEDIA_ERROR = "mediaError", a.KEY_SYSTEM_ERROR = "keySystemError", a.MUX_ERROR = "muxError", a.OTHER_ERROR = "otherError", a; }({}), I = /* @__PURE__ */ function(a) { return a.KEY_SYSTEM_NO_KEYS = "keySystemNoKeys", a.KEY_SYSTEM_NO_ACCESS = "keySystemNoAccess", a.KEY_SYSTEM_NO_SESSION = "keySystemNoSession", a.KEY_SYSTEM_NO_CONFIGURED_LICENSE = "keySystemNoConfiguredLicense", a.KEY_SYSTEM_LICENSE_REQUEST_FAILED = "keySystemLicenseRequestFailed", a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED = "keySystemServerCertificateRequestFailed", a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED = "keySystemServerCertificateUpdateFailed", a.KEY_SYSTEM_SESSION_UPDATE_FAILED = "keySystemSessionUpdateFailed", a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED = "keySystemStatusOutputRestricted", a.KEY_SYSTEM_STATUS_INTERNAL_ERROR = "keySystemStatusInternalError", a.MANIFEST_LOAD_ERROR = "manifestLoadError", a.MANIFEST_LOAD_TIMEOUT = "manifestLoadTimeOut", a.MANIFEST_PARSING_ERROR = "manifestParsingError", a.MANIFEST_INCOMPATIBLE_CODECS_ERROR = "manifestIncompatibleCodecsError", a.LEVEL_EMPTY_ERROR = "levelEmptyError", a.LEVEL_LOAD_ERROR = "levelLoadError", a.LEVEL_LOAD_TIMEOUT = "levelLoadTimeOut", a.LEVEL_PARSING_ERROR = "levelParsingError", a.LEVEL_SWITCH_ERROR = "levelSwitchError", a.AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError", a.AUDIO_TRACK_LOAD_TIMEOUT = "audioTrackLoadTimeOut", a.SUBTITLE_LOAD_ERROR = "subtitleTrackLoadError", a.SUBTITLE_TRACK_LOAD_TIMEOUT = "subtitleTrackLoadTimeOut", a.FRAG_LOAD_ERROR = "fragLoadError", a.FRAG_LOAD_TIMEOUT = "fragLoadTimeOut", a.FRAG_DECRYPT_ERROR = "fragDecryptError", a.FRAG_PARSING_ERROR = "fragParsingError", a.FRAG_GAP = "fragGap", a.REMUX_ALLOC_ERROR = "remuxAllocError", a.KEY_LOAD_ERROR = "keyLoadError", a.KEY_LOAD_TIMEOUT = "keyLoadTimeOut", a.BUFFER_ADD_CODEC_ERROR = "bufferAddCodecError", a.BUFFER_INCOMPATIBLE_CODECS_ERROR = "bufferIncompatibleCodecsError", a.BUFFER_APPEND_ERROR = "bufferAppendError", a.BUFFER_APPENDING_ERROR = "bufferAppendingError", a.BUFFER_STALLED_ERROR = "bufferStalledError", a.BUFFER_FULL_ERROR = "bufferFullError", a.BUFFER_SEEK_OVER_HOLE = "bufferSeekOverHole", a.BUFFER_NUDGE_ON_STALL = "bufferNudgeOnStall", a.INTERNAL_EXCEPTION = "internalException", a.INTERNAL_ABORTED = "aborted", a.UNKNOWN = "unknown", a; }({}); const We = function() { }, ys = { trace: We, debug: We, log: We, warn: We, info: We, error: We }; let lt = ys; function en(a) { const e = self.console[a]; return e ? e.bind(self.console, `[${a}] >`) : We; } function tn(a, ...e) { e.forEach(function(t) { lt[t] = a[t] ? a[t].bind(a) : en(t); }); } function sn(a, e) { if (self.console && a === !0 || typeof a == "object") { tn( a, // Remove out from list here to hard-disable a log-level // 'trace', "debug", "log", "info", "warn", "error" ); try { lt.log(`Debug logs enabled for "${e}" in hls.js version 1.4.12`); } catch { lt = ys; } } else lt = ys; } const v = lt, rn = /^(\d+)x(\d+)$/, qs = /(.+?)=(".*?"|.*?)(?:,|$)/g; class se { constructor(e) { typeof e == "string" && (e = se.parseAttrList(e)); for (const t in e) e.hasOwnProperty(t) && (t.substring(0, 2) === "X-" && (this.clientAttrs = this.clientAttrs || [], this.clientAttrs.push(t)), this[t] = e[t]); } decimalInteger(e) { const t = parseInt(this[e], 10); return t > Number.MAX_SAFE_INTEGER ? 1 / 0 : t; } hexadecimalInteger(e) { if (this[e]) { let t = (this[e] || "0x").slice(2); t = (t.length & 1 ? "0" : "") + t; const s = new Uint8Array(t.length / 2); for (let i = 0; i < t.length / 2; i++) s[i] = parseInt(t.slice(i * 2, i * 2 + 2), 16); return s; } else return null; } hexadecimalIntegerAsNumber(e) { const t = parseInt(this[e], 16); return t > Number.MAX_SAFE_INTEGER ? 1 / 0 : t; } decimalFloatingPoint(e) { return parseFloat(this[e]); } optionalFloat(e, t) { const s = this[e]; return s ? parseFloat(s) : t; } enumeratedString(e) { return this[e]; } bool(e) { return this[e] === "YES"; } decimalResolution(e) { const t = rn.exec(this[e]); if (t !== null) return { width: parseInt(t[1], 10), height: parseInt(t[2], 10) }; } static parseAttrList(e) { let t; const s = {}, i = '"'; for (qs.lastIndex = 0; (t = qs.exec(e)) !== null; ) { let r = t[2]; r.indexOf(i) === 0 && r.lastIndexOf(i) === r.length - 1 && (r = r.slice(1, -1)); const n = t[1].trim(); s[n] = r; } return s; } } function nn(a) { return a !== "ID" && a !== "CLASS" && a !== "START-DATE" && a !== "DURATION" && a !== "END-DATE" && a !== "END-ON-NEXT"; } function an(a) { return a === "SCTE35-OUT" || a === "SCTE35-IN"; } class qi { constructor(e, t) { if (this.attr = void 0, this._startDate = void 0, this._endDate = void 0, this._badValueForSameId = void 0, t) { const s = t.attr; for (const i in s) if (Object.prototype.hasOwnProperty.call(e, i) && e[i] !== s[i]) { v.warn(`DATERANGE tag attribute: "${i}" does not match for tags with ID: "${e.ID}"`), this._badValueForSameId = i; break; } e = ne(new se({}), s, e); } if (this.attr = e, this._startDate = new Date(e["START-DATE"]), "END-DATE" in this.attr) { const s = new Date(this.attr["END-DATE"]); B(s.getTime()) && (this._endDate = s); } } get id() { return this.attr.ID; } get class() { return this.attr.CLASS; } get startDate() { return this._startDate; } get endDate() { if (this._endDate) return this._endDate; const e = this.duration; return e !== null ? new Date(this._startDate.getTime() + e * 1e3) : null; } get duration() { if ("DURATION" in this.attr) { const e = this.attr.decimalFloatingPoint("DURATION"); if (B(e)) return e; } else if (this._endDate) return (this._endDate.getTime() - this._startDate.getTime()) / 1e3; return null; } get plannedDuration() { return "PLANNED-DURATION" in this.attr ? this.attr.decimalFloatingPoint("PLANNED-DURATION") : null; } get endOnNext() { return this.attr.bool("END-ON-NEXT"); } get isValid() { return !!this.id && !this._badValueForSameId && B(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class); } } class Ut { constructor() { this.aborted = !1, this.loaded = 0, this.retry = 0, this.total = 0, this.chunkCount = 0, this.bwEstimate = 0, this.loading = { start: 0, first: 0, end: 0 }, this.parsing = { start: 0, end: 0 }, this.buffering = { start: 0, first: 0, end: 0 }; } } var X = { AUDIO: "audio", VIDEO: "video", AUDIOVIDEO: "audiovideo" }; class zi { // baseurl is the URL to the playlist // relurl is the portion of the URL that comes from inside the playlist. // Holds the types of data this fragment supports constructor(e) { this._byteRange = null, this._url = null, this.baseurl = void 0, this.relurl = void 0, this.elementaryStreams = { [X.AUDIO]: null, [X.VIDEO]: null, [X.AUDIOVIDEO]: null }, this.baseurl = e; } // setByteRange converts a EXT-X-BYTERANGE attribute into a two element array setByteRange(e, t) { const s = e.split("@", 2), i = []; s.length === 1 ? i[0] = t ? t.byteRangeEndOffset : 0 : i[0] = parseInt(s[1]), i[1] = parseInt(s[0]) + i[0], this._byteRange = i; } get byteRange() { return this._byteRange ? this._byteRange : []; } get byteRangeStartOffset() { return this.byteRange[0]; } get byteRangeEndOffset() { return this.byteRange[1]; } get url() { return !this._url && this.baseurl && this.relurl && (this._url = _s.buildAbsoluteURL(this.baseurl, this.relurl, { alwaysNormalize: !0 })), this._url || ""; } set url(e) { this._url = e; } } class Ht extends zi { // EXTINF has to be present for a m3u8 to be considered valid // sn notates the sequence number for a segment, and if set to a string can be 'initSegment' // levelkeys are the EXT-X-KEY tags that apply to this segment for decryption // core difference from the private field _decryptdata is the lack of the initialized IV // _decryptdata will set the IV for this segment based on the segment number in the fragment // A string representing the fragment type // A reference to the loader. Set while the fragment is loading, and removed afterwards. Used to abort fragment loading // A reference to the key loader. Set while the key is loading, and removed afterwards. Used to abort key loading // The level/track index to which the fragment belongs // The continuity counter of the fragment // The starting Presentation Time Stamp (PTS) of the fragment. Set after transmux complete. // The ending Presentation Time Stamp (PTS) of the fragment. Set after transmux complete. // The starting Decode Time Stamp (DTS) of the fragment. Set after transmux complete. // The ending Decode Time Stamp (DTS) of the fragment. Set after transmux complete. // The start time of the fragment, as listed in the manifest. Updated after transmux complete. // Set by `updateFragPTSDTS` in level-helper // The maximum starting Presentation Time Stamp (audio/video PTS) of the fragment. Set after transmux complete. // The minimum ending Presentation Time Stamp (audio/video PTS) of the fragment. Set after transmux complete. // Load/parse timing information // A flag indicating whether the segment was downloaded in order to test bitrate, and was not buffered // #EXTINF segment title // The Media Initialization Section for this segment // Fragment is the last fragment in the media playlist // Fragment is marked by an EXT-X-GAP tag indicating that it does not contain media data and should not be loaded constructor(e, t) { super(t), this._decryptdata = null, this.rawProgramDateTime = null, this.programDateTime = null, this.tagList = [], this.duration = 0, this.sn = 0, this.levelkeys = void 0, this.type = void 0, this.loader = null, this.keyLoader = null, this.level = -1, this.cc = 0, this.startPTS = void 0, this.endPTS = void 0, this.startDTS = void 0, this.endDTS = void 0, this.start = 0, this.deltaPTS = void 0, this.maxStartPTS = void 0, this.minEndPTS = void 0, this.stats = new Ut(), this.urlId = 0, this.data = void 0, this.bitrateTest = !1, this.title = null, this.initSegment = null, this.endList = void 0, this.gap = void 0, this.type = e; } get decryptdata() { const { levelkeys: e } = this; if (!e && !this._decryptdata) return null; if (!this._decryptdata && this.levelkeys && !this.levelkeys.NONE) { const t = this.levelkeys.identity; if (t) this._decryptdata = t.getDecryptData(this.sn); else { const s = Object.keys(this.levelkeys); if (s.length === 1) return this._decryptdata = this.levelkeys[s[0]].getDecryptData(this.sn); } } return this._decryptdata; } get end() { return this.start + this.duration; } get endProgramDateTime() { if (this.programDateTime === null || !B(this.programDateTime)) return null; const e = B(this.duration) ? this.duration : 0; return this.programDateTime + e * 1e3; } get encrypted() { var e; if ((e = this._decryptdata) != null && e.encrypted) return !0; if (this.levelkeys) { const t = Object.keys(this.levelkeys), s = t.length; if (s > 1 || s === 1 && this.levelkeys[t[0]].encrypted) return !0; } return !1; } setKeyFormat(e) { if (this.levelkeys) { const t = this.levelkeys[e]; t && !this._decryptdata && (this._decryptdata = t.getDecryptData(this.sn)); } } abortRequests() { var e, t; (e = this.loader) == null || e.abort(), (t = this.keyLoader) == null || t.abort(); } setElementaryStreamInfo(e, t, s, i, r, n = !1) { const { elementaryStreams: o } = this, l = o[e]; if (!l) { o[e] = { startPTS: t, endPTS: s, startDTS: i, endDTS: r, partial: n }; return; } l.startPTS = Math.min(l.startPTS, t), l.endPTS = Math.max(l.endPTS, s), l.startDTS = Math.min(l.startDTS, i), l.endDTS = Math.max(l.endDTS, r); } clearElementaryStreamInfo() { const { elementaryStreams: e } = this; e[X.AUDIO] = null, e[X.VIDEO] = null, e[X.AUDIOVIDEO] = null; } } class on extends zi { constructor(e, t, s, i, r) { super(s), this.fragOffset = 0, this.duration = 0, this.gap = !1, this.independent = !1, this.relurl = void 0, this.fragment = void 0, this.index = void 0, this.stats = new Ut(), this.duration = e.decimalFloatingPoint("DURATION"), this.gap = e.bool("GAP"), this.independent = e.bool("INDEPENDENT"), this.relurl = e.enumeratedString("URI"), this.fragment = t, this.index = i; const n = e.enumeratedString("BYTERANGE"); n && this.setByteRange(n, r), r && (this.fragOffset = r.fragOffset + r.duration); } get start() { return this.fragment.start + this.fragOffset; } get end() { return this.start + this.duration; } get loaded() { const { elementaryStreams: e } = this; return !!(e.audio || e.video || e.audiovideo); } } const ln = 10; class cn { // Manifest reload synchronization constructor(e) { this.PTSKnown = !1, this.alignedSliding = !1, this.averagetargetduration = void 0, this.endCC = 0, this.endSN = 0, this.fragments = void 0, this.fragmentHint = void 0, this.partList = null, this.dateRanges = void 0, this.live = !0, this.ageHeader = 0, this.advancedDateTime = void 0, this.updated = !0, this.advanced = !0, this.availabilityDelay = void 0, this.misses = 0, this.startCC = 0, this.startSN = 0, this.startTimeOffset = null, this.targetduration = 0, this.totalduration = 0, this.type = null, this.url = void 0, this.m3u8 = "", this.version = null, this.canBlockReload = !1, this.canSkipUntil = 0, this.canSkipDateRanges = !1, this.skippedSegments = 0, this.recentlyRemovedDateranges = void 0, this.partHoldBack = 0, this.holdBack = 0, this.partTarget = 0, this.preloadHint = void 0, this.renditionReports = void 0, this.tuneInGoal = 0, this.deltaUpdateFailed = void 0, this.driftStartTime = 0, this.driftEndTime = 0, this.driftStart = 0, this.driftEnd = 0, this.encryptedFragments = void 0, this.playlistParsingError = null, this.variableList = null, this.hasVariableRefs = !1, this.fragments = [], this.encryptedFragments = [], this.dateRanges = {}, this.url = e; } reloaded(e) { if (!e) { this.advanced = !0, this.updated = !0; return; } const t = this.lastPartSn - e.lastPartSn, s = this.lastPartIndex - e.lastPartIndex; this.updated = this.endSN !== e.endSN || !!s || !!t || !this.live, this.advanced = this.endSN > e.endSN || t > 0 || t === 0 && s > 0, this.updated || this.advanced ? this.misses = Math.floor(e.misses * 0.6) : this.misses = e.misses + 1, this.availabilityDelay = e.availabilityDelay; } get hasProgramDateTime() { return this.fragments.length ? B(this.fragments[this.fragments.length - 1].programDateTime) : !1; } get levelTargetDuration() { return this.averagetargetduration || this.targetduration || ln; } get drift() { const e = this.driftEndTime - this.driftStartTime; return e > 0 ? (this.driftEnd - this.driftStart) * 1e3 / e : 1; } get edge() { return this.partEnd || this.fragmentEnd; } get partEnd() { var e; return (e = this.partList) != null && e.length ? this.partList[this.partList.length - 1].end : this.fragmentEnd; } get fragmentEnd() { var e; return (e = this.fragments) != null && e.length ? this.fragments[this.fragments.length - 1].end : 0; } get age() { return this.advancedDateTime ? Math.max(Date.now() - this.advancedDateTime, 0) / 1e3 : 0; } get lastPartIndex() { var e; return (e = this.partList) != null && e.length ? this.partList[this.partList.length - 1].index : -1; } get lastPartSn() { var e; return (e = this.partList) != null && e.length ? this.partList[this.partList.length - 1].fragment.sn : this.endSN; } } function Cs(a) { return Uint8Array.from(atob(a), (e) => e.charCodeAt(0)); } function dn(a) { const e = ji(a).subarray(0, 16), t = new Uint8Array(16); return t.set(e, 16 - e.length), t; } function hn(a) { const e = function(s, i, r) { const n = s[i]; s[i] = s[r], s[r] = n; }; e(a, 0, 3), e(a, 1, 2), e(a, 4, 5), e(a, 6, 7); } function un(a) { const e = a.split(":"); let t = null; if (e[0] === "data" && e.length === 2) { const s = e[1].split(";"), i = s[s.length - 1].split(","); if (i.length === 2) { const r = i[0] === "base64", n = i[1]; r ? (s.splice(-1, 1), t = Cs(n)) : t = dn(n); } } return t; } function ji(a) { return Uint8Array.from(unescape(encodeURIComponent(a)), (e) => e.charCodeAt(0)); } var ie = { CLEARKEY: "org.w3.clearkey", FAIRPLAY: "com.apple.fps", PLAYREADY: "com.microsoft.playready", WIDEVINE: "com.widevine.alpha" }, ge = { CLEARKEY: "org.w3.clearkey", FAIRPLAY: "com.apple.streamingkeydelivery", PLAYREADY: "com.microsoft.playready", WIDEVINE: "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" }; function zs(a) { switch (a) { case ge.FAIRPLAY: return ie.FAIRPLAY; case ge.PLAYREADY: return ie.PLAYREADY; case ge.WIDEVINE: return ie.WIDEVINE; case ge.CLEARKEY: return ie.CLEARKEY; } } var Xi = { WIDEVINE: "edef8ba979d64acea3c827dcd51d21ed" }; function fn(a) { if (a === Xi.WIDEVINE) return ie.WIDEVINE; } function js(a) { switch (a) { case ie.FAIRPLAY: return ge.FAIRPLAY; case ie.PLAYREADY: return ge.PLAYREADY; case ie.WIDEVINE: return ge.WIDEVINE; case ie.CLEARKEY: return ge.CLEARKEY; } } function Wt(a) { const { drmSystems: e, widevineLicenseUrl: t } = a, s = e ? [ie.FAIRPLAY, ie.WIDEVINE, ie.PLAYREADY, ie.CLEARKEY].filter((i) => !!e[i]) : []; return !s[ie.WIDEVINE] && t && s.push(ie.WIDEVINE), s; } const Qi = function() { return typeof self < "u" && self.navigator && self.navigator.requestMediaKeySystemAccess ? self.navigator.requestMediaKeySystemAccess.bind(self.navigator) : null; }(); function gn(a, e, t, s) { let i; switch (a) { case ie.FAIRPLAY: i = ["cenc", "sinf"]; break; case ie.WIDEVINE: case ie.PLAYREADY: i = ["cenc"]; break; case ie.CLEARKEY: i = ["cenc", "keyids"]; break; default: throw new Error(`Unknown key-system: ${a}`); } return mn(i, e, t, s); } function mn(a, e, t, s) { return [{ initDataTypes: a, persistentState: s.persistentState || "not-allowed", distinctiveIdentifier: s.distinctiveIdentifier || "not-allowed", sessionTypes: s.sessionTypes || [s.sessionType || "temporary"], audioCapabilities: e.map((r) => ({ contentType: `audio/mp4; codecs="${r}"`, robustness: s.audioRobustness || "", encryptionScheme: s.audioEncryptionScheme || null })), videoCapabilities: t.map((r) => ({ contentType: `video/mp4; codecs="${r}"`, robustness: s.videoRobustness || "", encryptionScheme: s.videoEncryptionScheme || null })) }]; } function Xe(a, e, t) { return Uint8Array.prototype.slice ? a.slice(e, t) : new Uint8Array(Array.prototype.slice.call(a, e, t)); } const ks = (a, e) => e + 10 <= a.length && a[e] === 73 && a[e + 1] === 68 && a[e + 2] === 51 && a[e + 3] < 255 && a[e + 4] < 255 && a[e + 6] < 128 && a[e + 7] < 128 && a[e + 8] < 128 && a[e + 9] < 128, Ji = (a, e) => e + 10 <= a.length && a[e] === 51 && a[e + 1] === 68 && a[e + 2] === 73 && a[e + 3] < 255 && a[e + 4] < 255 && a[e + 6] < 128 && a[e + 7] < 128 && a[e + 8] < 128 && a[e + 9] < 128, Ct = (a, e) => { const t = e; let s = 0; for (; ks(a, e); ) { s += 10; const i = Bt(a, e + 6); s += i, Ji(a, e + 10) && (s += 10), e += s; } if (s > 0) return a.subarray(t, t + s); }, Bt = (a, e) => { let t = 0; return t = (a[e] & 127) << 21, t |= (a[e + 1] & 127) << 14, t |= (a[e + 2] & 127) << 7, t |= a[e + 3] & 127, t; }, pn = (a, e) => ks(a, e) && Bt(a, e + 6) + 10 <= a.length - e, yn = (a) => { const e = er(a); for (let t = 0; t < e.length; t++) { const s = e[t]; if (Zi(s)) return Ln(s); } }, Zi = (a) => a && a.key === "PRIV" && a.info === "com.apple.streaming.transportStreamTimestamp", Tn = (a) => { const e = String.fromCharCode(a[0], a[1], a[2], a[3]), t = Bt(a, 4), s = 10; return { type: e, size: t, data: a.subarray(s, s + t) }; }, er = (a) => { let e = 0; const t = []; for (; ks(a, e); ) { const s = Bt(a, e + 6); e += 10; const i = e + s; for (; e + 8 < i; ) { const r = Tn(a.subarray(e)), n = xn(r); n && t.push(n), e += r.size + 10; } Ji(a, e) && (e += 10); } return t; }, xn = (a) => a.type === "PRIV" ? En(a) : a.type[0] === "W" ? Sn(a) : vn(a), En = (a) => { if (a.size < 2) return; const e = we(a.data, !0), t = new Uint8Array(a.data.subarray(e.length + 1)); return { key: a.type, info: e, data: t.buffer }; }, vn = (a) => { if (a.size < 2) return; if (a.type === "TXXX") { let t = 1; const s = we(a.data.subarray(t), !0); t += s.length + 1; const i = we(a.data.subarray(t)); return { key: a.type, info: s, data: i }; } const e = we(a.data.subarray(1)); return { key: a.type, data: e }; }, Sn = (a) => { if (a.type === "WXXX") { if (a.size < 2) return; let t = 1; const s = we(a.data.subarray(t), !0); t += s.length + 1; const i = we(a.data.subarray(t)); return { key: a.type, info: s, data: i }; } const e = we(a.data); return { key: a.type, data: e }; }, Ln = (a) => { if (a.data.byteLength === 8) { const e = new Uint8Array(a.data), t = e[3] & 1; let s = (e[4] << 23) + (e[5] << 15) + (e[6] << 7) + e[7]; return s /= 45, t && (s += 4772185884e-2), Math.round(s); } }, we = (a, e = !1) => { const t = An(); if (t) { const c = t.decode(a); if (e) { const d = c.indexOf("\0"); return d !== -1 ? c.substring(0, d) : c; } return c.replace(/\0/g, ""); } const s = a.length; let i, r, n, o = "", l = 0; for (; l < s; ) { if (i = a[l++], i === 0 && e) return o; if (i === 0 || i === 3) continue; switch (i >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: o += String.fromCharCode(i); break; case 12: case 13: r = a[l++], o += String.fromCharCode((i & 31) << 6 | r & 63); break; case 14: r = a[l++], n = a[l++], o += String.fromCharCode((i & 15) << 12 | (r & 63) << 6 | (n & 63) << 0); break; } } return o; }; let Yt; function An() { return !Yt && typeof self.TextDecoder < "u" && (Yt = new self.TextDecoder("utf-8")), Yt; } const De = { hexDump: function(a) { let e = ""; for (let t = 0; t < a.length; t++) { let s = a[t].toString(16); s.length < 2 && (s = "0" + s), e += s; } return e; } }, kt = Math.pow(2, 32) - 1, In = [].push, tr = { video: 1, audio: 2, id3: 3, text: 4 }; function le(a) { return String.fromCharCode.apply(null, a); } function sr(a, e) { const t = a[e] << 8 | a[e + 1]; return t < 0 ? 65536 + t : t; } function V(a, e) { const t = ir(a, e); return t < 0 ? 4294967296 + t : t; } function ir(a, e) { return a[e] << 24 | a[e + 1] << 16 | a[e + 2] << 8 | a[e + 3]; } function qt(a, e, t) { a[e] = t >> 24, a[e + 1] = t >> 16 & 255, a[e + 2] = t >> 8 & 255, a[e + 3] = t & 255; } function H(a, e) { const t = []; if (!e.length) return t; const s = a.byteLength; for (let i = 0; i < s; ) { const r = V(a, i), n = le(a.subarray(i + 4, i + 8)), o = r > 1 ? i + r : s; if (n === e[0]) if (e.length === 1) t.push(a.subarray(i + 8, o)); else { const l = H(a.subarray(i + 8, o), e.slice(1)); l.length && In.apply(t, l); } i = o; } return t; } function Rn(a) { const e = [], t = a[0]; let s = 8; const i = V(a, s); s += 4; const r = 0, n = 0; t === 0 ? s += 8 : s += 16, s += 2; let o = a.length + n; const l = sr(a, s); s += 2; for (let c = 0; c < l; c++) { let d = s; const h = V(a, d); d += 4; const u = h & 2147483647; if ((h & 2147483648) >>> 31 === 1) return v.warn("SIDX has hierarchical references (not supported)"), null; const g = V(a, d); d += 4, e.push({ referenceSize: u, subsegmentDuration: g, // unscaled info: { duration: g / i, start: o, end: o + u - 1 } }), o += u, d += 4, s = d; } return { earliestPresentationTime: r, timescale: i, version: t, referencesCount: l, references: e }; } function rr(a) { const e = [], t = H(a, ["moov", "trak"]); for (let i = 0; i < t.length; i++) { const r = t[i], n = H(r, ["tkhd"])[0]; if (n) { let o = n[0], l = o === 0 ? 12 : 20; const c = V(n, l), d = H(r, ["mdia", "mdhd"])[0]; if (d) { o = d[0], l = o === 0 ? 12 : 20; const h = V(d, l), u = H(r, ["mdia", "hdlr"])[0]; if (u) { const f = le(u.subarray(8, 12)), g = { soun: X.AUDIO, vide: X.VIDEO }[f]; if (g) { const p = H(r, ["mdia", "minf", "stbl", "stsd"])[0]; let y; p && (y = le(p.subarray(12, 16))), e[c] = { timescale: h, type: g }, e[g] = { timescale: h, id: c, codec: y }; } } } } } return H(a, ["moov", "mvex", "trex"]).forEach((i) => { const r = V(i, 4), n = e[r]; n && (n.default = { duration: V(i, 12), flags: V(i, 20) }); }), e; } function bn(a, e) { if (!a || !e) return a; const t = e.keyId; return t && e.isCommonEncryption && H(a, ["moov", "trak"]).forEach((i) => { const n = H(i, ["mdia", "minf", "stbl", "stsd"])[0].subarray(8); let o = H(n, ["enca"]); const l = o.length > 0; l || (o = H(n, ["encv"])), o.forEach((c) => { const d = l ? c.subarray(28) : c.subarray(78); H(d, ["sinf"]).forEach((u) => { const f = nr(u); if (f) { const g = f.subarray(8, 24); g.some((p) => p !== 0) || (v.log(`[eme] Patching keyId in 'enc${l ? "a" : "v"}>sinf>>tenc' box: ${De.hexDump(g)} -> ${De.hexDump(t)}`), f.set(t, 8)); } }); }); }), a; } function nr(a) { const e = H(a, ["schm"])[0]; if (e) { const t = le(e.subarray(4, 8)); if (t === "cbcs" || t === "cenc") return H(a, ["schi", "tenc"])[0]; } return v.error("[eme] missing 'schm' box"), null; } function Dn(a, e) { return H(e, ["moof", "traf"]).reduce((t, s) => { const i = H(s, ["tfdt"])[0], r = i[0], n = H(s, ["tfhd"]).reduce((o, l) => { const c = V(l, 4), d = a[c]; if (d) { let h = V(i, 4); if (r === 1) { if (h === kt) return v.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"), o; h *= kt + 1, h += V(i, 8); } const u = d.timescale || 9e4, f = h / u; if (isFinite(f) && (o === null || f < o)) return f; } return o; }, null); return n !== null && isFinite(n) && (t === null || n < t) ? n : t; }, null); } function _n(a, e) { let t = 0, s = 0, i = 0; const r = H(a, ["moof", "traf"]); for (let n = 0; n < r.length; n++) { const o = r[n], l = H(o, ["tfhd"])[0], c = V(l, 4), d = e[c]; if (!d) continue; const h = d.default, u = V(l, 0) | (h == null ? void 0 : h.flags); let f = h == null ? void 0 : h.duration; u & 8 && (u & 2 ? f = V(l, 12) : f = V(l, 8)); const g = d.timescale || 9e4, p = H(o, ["trun"]); for (let y = 0; y < p.length; y++) { if (t = Cn(p[y]), !t && f) { const T = V(p[y], 4); t = f * T; } d.type === X.VIDEO ? s += t / g : d.type === X.AUDIO && (i += t / g); } } if (s === 0 && i === 0) { let n = 0; const o = H(a, ["sidx"]); for (let l = 0; l < o.length; l++) { const c = Rn(o[l]); c != null && c.references && (n += c.references.reduce((d, h) => d + h.info.duration || 0, 0)); } return n; } return s || i; } function Cn(a) { const e = V(a, 0); let t = 8; e & 1 && (t += 4), e & 4 && (t += 4); let s = 0; const i = V(a, 4); for (let r = 0; r < i; r++) { if (e & 256) { const n = V(a, t); s += n, t += 4; } e & 512 && (t += 4), e & 1024 && (t += 4), e & 2048 && (t += 4); } return s; } function kn(a, e, t) { H(e, ["moof", "traf"]).forEach((s) => { H(s, ["tfhd"]).forEach((i) => { const r = V(i, 4), n = a[r]; if (!n) return; const o = n.timescale || 9e4; H(s, ["tfdt"]).forEach((l) => { const c = l[0]; let d = V(l, 4); if (c === 0) d -= t * o, d = Math.max(d, 0), qt(l, 4, d); else { d *= Math.pow(2, 32), d += V(l, 8), d -= t * o, d = Math.max(d, 0); const h = Math.floor(d / (kt + 1)), u = Math.floor(d % (kt + 1)); qt(l, 4, h), qt(l, 8, u); } }); }); }); } function wn(a) { const e = { valid: null, remainder: null }, t = H(a, ["moof"]); if (t) { if (t.length < 2) return e.remainder = a, e; } else return e; const s = t[t.length - 1]; return e.valid = Xe(a, 0, s.byteOffset - 8), e.remainder = Xe(a, s.byteOffset - 8), e; } function Qe(a, e) { const t = new Uint8Array(a.length + e.length); return t.set(a), t.set(e, a.length), t; } function Xs(a, e) { const t = [], s = e.samples, i = e.timescale, r = e.id; let n = !1; return H(s, ["moof"]).map((l) => { const c = l.byteOffset - 8; H(l, ["traf"]).map((h) => { const u = H(h, ["tfdt"]).map((f) => { const g = f[0]; let p = V(f, 4); return g === 1 && (p *= Math.pow(2, 32), p += V(f, 8)), p / i; })[0]; return u !== void 0 && (a = u), H(h, ["tfhd"]).map((f) => { const g = V(f, 4), p = V(f, 0) & 16777215, y = (p & 1) !== 0, T = (p & 2) !== 0, E = (p & 8) !== 0; let x = 0; const A = (p & 16) !== 0; let S = 0; const _ = (p & 32) !== 0; let b = 8; g === r && (y && (b += 8), T && (b += 4), E && (x = V(f, b), b += 4), A && (S = V(f, b), b += 4), _ && (b += 4), e.type === "video" && (n = Pn(e.codec)), H(h, ["trun"]).map((C) => { const w = C[0], R = V(C, 0) & 16777215, U = (R & 1) !== 0; let O = 0; const Y = (R & 4) !== 0, oe = (R & 256) !== 0; let Q = 0; const Z = (R & 512) !== 0; let J = 0; const M = (R & 1024) !== 0, $ = (R & 2048) !== 0; let k = 0; const F = V(C, 4); let N = 8; U && (O = V(C, N), N += 4), Y && (N += 4); let q = O + c; for (let pe = 0; pe < F; pe++) { if (oe ? (Q = V(C, N), N += 4) : Q = x, Z ? (J = V(C, N), N += 4) : J = S, M && (N += 4), $ && (w === 0 ? k = V(C, N) : k = ir(C, N), N += 4), e.type === X.VIDEO) { let Ae = 0; for (; Ae < J; ) { const Ee = V(s, q); if (q += 4, Fn(n, s[q])) { const Ke = s.subarray(q, q + Ee); ar(Ke, n ? 2 : 1, a + k / i, t); } q += Ee, Ae += Ee + 4; } } a += Q / i; } })); }); }); }), t; } function Pn(a) { if (!a) return !1; const e = a.indexOf("."), t = e < 0 ? a : a.substring(0, e); return t === "hvc1" || t === "hev1" || // Dolby Vision t === "dvh1" || t === "dvhe"; } function Fn(a, e) { if (a) { const t = e >> 1 & 63; return t === 39 || t === 40; } else return (e & 31) === 6; } function ar(a, e, t, s) { const i = or(a); let r = 0; r += e; let n = 0, o = 0, l = !1, c = 0; for (; r < i.length; ) { n = 0; do { if (r >= i.length) break; c = i[r++], n += c; } while (c === 255); o = 0; do { if (r >= i.length) break; c = i[r++], o += c; } while (c === 255); const d = i.length - r; if (!l && n === 4 && r < i.length) { if (l = !0, i[r++] === 181) { const u = sr(i, r); if (r += 2, u === 49) { const f = V(i, r); if (r += 4, f === 1195456820) { const g = i[r++]; if (g === 3) { const p = i[r++], y = 31 & p, T = 64 & p, E = T ? 2 + y * 3 : 0, x = new Uint8Array(E); if (T) { x[0] = p; for (let A = 1; A < E; A++) x[A] = i[r++]; } s.push({ type: g, payloadType: n, pts: t, bytes: x }); } } } } } else if (n === 5 && o < d) { if (l = !0, o > 16) { const h = []; for (let g = 0; g < 16; g++) { const p = i[r++].toString(16); h.push(p.length == 1 ? "0" + p : p), (g === 3 || g === 5 || g === 7 || g === 9) && h.push("-"); } const u = o - 16, f = new Uint8Array(u); for (let g = 0; g < u; g++) f[g] = i[r++]; s.push({ payloadType: n, pts: t, uuid: h.join(""), userData: we(f), userDataBytes: f }); } } else if (o < d) r += o; else if (o > d) break; } } function or(a) { const e = a.byteLength, t = []; let s = 1; for (; s < e - 2; ) a[s] === 0 && a[s + 1] === 0 && a[s + 2] === 3 ? (t.push(s + 2), s += 2) : s++; if (t.length === 0) return a; const i = e - t.length, r = new Uint8Array(i); let n = 0; for (s = 0; s < i; n++, s++) n === t[0] && (n++, t.shift()), r[s] = a[n]; return r; } function On(a) { const e = a[0]; let t = "", s = "", i = 0, r = 0, n = 0, o = 0, l = 0, c = 0; if (e === 0) { for (; le(a.subarray(c, c + 1)) !== "\0"; ) t += le(a.subarray(c, c + 1)), c += 1; for (t += le(a.subarray(c, c + 1)), c += 1; le(a.subarray(c, c + 1)) !== "\0"; ) s += le(a.subarray(c, c + 1)), c += 1; s += le(a.subarray(c, c + 1)), c += 1, i = V(a, 12), r = V(a, 16), o = V(a, 20), l = V(a, 24), c = 28; } else if (e === 1) { c += 4, i = V(a, c), c += 4; const h = V(a, c); c += 4; const u = V(a, c); for (c += 4, n = 2 ** 32 * h + u, Number.isSafeInteger(n) || (n = Number.MAX_SAFE_INTEGER, v.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")), o = V(a, c), c += 4, l = V(a, c), c += 4; le(a.subarray(c, c + 1)) !== "\0"; ) t += le(a.subarray(c, c + 1)), c += 1; for (t += le(a.subarray(c, c + 1)), c += 1; le(a.subarray(c, c + 1)) !== "\0"; ) s += le(a.subarray(c, c + 1)), c += 1; s += le(a.subarray(c, c + 1)), c += 1; } const d = a.subarray(c, a.byteLength); return { schemeIdUri: t, value: s, timeScale: i, presentationTime: n, presentationTimeDelta: r, eventDuration: o, id: l, payload: d }; } function Mn(a, ...e) { const t = e.length; let s = 8, i = t; for (; i--; ) s += e[i].byteLength; const r = new Uint8Array(s); for (r[0] = s >> 24 & 255, r[1] = s >> 16 & 255, r[2] = s >> 8 & 255, r[3] = s & 255, r.set(a, 4), i = 0, s = 8; i < t; i++) r.set(e[i], s), s += e[i].byteLength; return r; } function Nn(a, e, t) { if (a.byteLength !== 16) throw new RangeError("Invalid system id"); let s, i; if (e) { s = 1, i = new Uint8Array(e.length * 16); for (let o = 0; o < e.length; o++) { const l = e[o]; if (l.byteLength !== 16) throw new RangeError("Invalid key"); i.set(l, o * 16); } } else s = 0, i = new Uint8Array(); let r; s > 0 ? (r = new Uint8Array(4), e.length > 0 && new DataView(r.buffer).setUint32(0, e.length, !1)) : r = new Uint8Array(); const n = new Uint8Array(4); return t && t.byteLength > 0 && new DataView(n.buffer).setUint32(0, t.byteLength, !1), Mn( [112, 115, 115, 104], new Uint8Array([ s, 0, 0, 0 // Flags ]), a, // 16 bytes r, i, n, t || new Uint8Array() ); } function Un(a) { if (!(a instanceof ArrayBuffer) || a.byteLength < 32) return null; const e = { version: 0, systemId: "", kids: null, data: null }, t = new DataView(a), s = t.getUint32(0); if (a.byteLength !== s && s > 44 || t.getUint32(4) !== 1886614376 || (e.version = t.getUint32(8) >>> 24, e.version > 1)) return null; e.systemId = De.hexDump(new Uint8Array(a, 12, 16)); const r = t.getUint32(28); if (e.version === 0) { if (s - 32 < r) return null; e.data = new Uint8Array(a, 32, r); } else if (e.version === 1) { e.kids = []; for (let n = 0; n < r; n++) e.kids.push(new Uint8Array(a, 32 + n * 16, 16)); } return e; } let pt = {}; class ht { static clearKeyUriToKeyIdMap() { pt = {}; } constructor(e, t, s, i = [1], r = null) { this.uri = void 0, this.method = void 0, this.keyFormat = void 0, this.keyFormatVersions = void 0, this.encrypted = void 0, this.isCommonEncryption = void 0, this.iv = null, this.key = null, this.keyId = null, this.pssh = null, this.method = e, this.uri = t, this.keyFormat = s, this.keyFormatVersions = i, this.iv = r, this.encrypted = e ? e !== "NONE" : !1, this.isCommonEncryption = this.encrypted && e !== "AES-128"; } isSupported() { if (this.method) { if (this.method === "AES-128" || this.method === "NONE") return !0; if (this.keyFormat === "identity") return this.method === "SAMPLE-AES"; switch (this.keyFormat) { case ge.FAIRPLAY: case ge.WIDEVINE: case ge.PLAYREADY: case ge.CLEARKEY: return ["ISO-23001-7", "SAMPLE-AES", "SAMPLE-AES-CENC", "SAMPLE-AES-CTR"].indexOf(this.method) !== -1; } } return !1; } getDecryptData(e) { if (!this.encrypted || !this.uri) return null; if (this.method === "AES-128" && this.uri && !this.iv) { typeof e != "number" && (this.method === "AES-128" && !this.iv && v.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`), e = 0); const s = Bn(e); return new ht(this.method, this.uri, "identity", this.keyFormatVersions, s); } const t = un(this.uri); if (t) switch (this.keyFormat) { case ge.WIDEVINE: this.pssh = t, t.length >= 22 && (this.keyId = t.subarray(t.length - 22, t.length - 6)); break; case ge.PLAYREADY: { const s = new Uint8Array([154, 4, 240, 121, 152, 64, 66, 134, 171, 146, 230, 91, 224, 136, 95, 149]); this.pssh = Nn(s, null, t); const i = new Uint16Array(t.buffer, t.byteOffset, t.byteLength / 2), r = String.fromCharCode.apply(null, Array.from(i)), n = r.substring(r.indexOf("<"), r.length), c = new DOMParser().parseFromString(n, "text/xml").getElementsByTagName("KID")[0]; if (c) { const d = c.childNodes[0] ? c.childNodes[0].nodeValue : c.getAttribute("VALUE"); if (d) { const h = Cs(d).subarray(0, 16); hn(h), this.keyId = h; } } break; } default: { let s = t.subarray(0, 16); if (s.length !== 16) { const i = new Uint8Array(16); i.set(s, 16 - s.length), s = i; } this.keyId = s; break; } } if (!this.keyId || this.keyId.byteLength !== 16) { let s = pt[this.uri]; if (!s) { const i = Object.keys(pt).length % Number.MAX_SAFE_INTEGER; s = new Uint8Array(16), new DataView(s.buffer, 12, 4).setUint32(0, i), pt[this.uri] = s; } this.keyId = s; } return this; } } function Bn(a) { const e = new Uint8Array(16); for (let t = 12; t < 16; t++) e[t] = a >> 8 * (15 - t) & 255; return e; } const lr = /\{\$([a-zA-Z0-9-_]+)\}/g; function Qs(a) { return lr.test(a); } function fe(a, e, t) { if (a.variableList !== null || a.hasVariableRefs) for (let s = t.length; s--; ) { const i = t[s], r = e[i]; r && (e[i] = Ts(a, r)); } } function Ts(a, e) { if (a.variableList !== null || a.hasVariableRefs) { const t = a.variableList; return e.replace(lr, (s) => {