UNPKG

@hakit/components

Version:
1,474 lines 420 kB
function Ti(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var Si = { exports: {} }; (function(a, e) { (function(t) { var i = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, s = /^(?=([^\/?#]*))\1([^]*)$/, n = /(?:\/|^)\.(?=\/)/g, r = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/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, d, u) { if (u = u || {}, l = l.trim(), d = d.trim(), !d) { if (!u.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 c = o.parseURL(d); if (!c) throw new Error("Error trying to parse relative URL."); if (c.scheme) return u.alwaysNormalize ? (c.path = o.normalizePath(c.path), o.buildURLFromParts(c)) : d; 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 m = s.exec(f.path); f.netLoc = m[1], f.path = m[2]; } f.netLoc && !f.path && (f.path = "/"); var g = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: f.scheme, netLoc: c.netLoc, path: null, params: c.params, query: c.query, fragment: c.fragment }; if (!c.netLoc && (g.netLoc = f.netLoc, c.path[0] !== "/")) if (!c.path) g.path = f.path, c.params || (g.params = f.params, c.query || (g.query = f.query)); else { var p = f.path, y = p.substring(0, p.lastIndexOf("/") + 1) + c.path; g.path = o.normalizePath(y); } return g.path === null && (g.path = u.alwaysNormalize ? o.normalizePath(c.path) : c.path), o.buildURLFromParts(g); }, parseURL: function(l) { var d = i.exec(l); return d ? { scheme: d[1] || "", netLoc: d[2] || "", path: d[3] || "", params: d[4] || "", query: d[5] || "", fragment: d[6] || "" } : null; }, normalizePath: function(l) { for (l = l.split("").reverse().join("").replace(n, ""); l.length !== (l = l.replace(r, "")).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; })(); })(Si); var Rt = Si.exports; function Ft(a, e) { var t = Object.keys(a); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(a); e && (i = i.filter(function(s) { return Object.getOwnPropertyDescriptor(a, s).enumerable; })), t.push.apply(t, i); } return t; } function oe(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e] != null ? arguments[e] : {}; e % 2 ? Ft(Object(t), !0).forEach(function(i) { us(a, i, t[i]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(t)) : Ft(Object(t)).forEach(function(i) { Object.defineProperty(a, i, Object.getOwnPropertyDescriptor(t, i)); }); } return a; } function ls(a, e) { if (typeof a != "object" || !a) return a; var t = a[Symbol.toPrimitive]; if (t !== void 0) { var i = t.call(a, e || "default"); if (typeof i != "object") return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return (e === "string" ? String : Number)(a); } function ds(a) { var e = ls(a, "string"); return typeof e == "symbol" ? e : String(e); } function us(a, e, t) { return e = ds(e), e in a ? Object.defineProperty(a, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : a[e] = t, a; } function ae() { return ae = Object.assign ? Object.assign.bind() : function(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (a[i] = t[i]); } return a; }, ae.apply(this, arguments); } const k = Number.isFinite || function(a) { return typeof a == "number" && isFinite(a); }, hs = Number.isSafeInteger || function(a) { return typeof a == "number" && Math.abs(a) <= cs; }, cs = Number.MAX_SAFE_INTEGER || 9007199254740991; let x = /* @__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.MAX_AUTO_LEVEL_UPDATED = "hlsMaxAutoLevelUpdated", 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.STEERING_MANIFEST_LOADED = "hlsSteeringManifestLoaded", a; }({}), K = /* @__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; }({}), R = /* @__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 Le = function() { }, yt = { trace: Le, debug: Le, log: Le, warn: Le, info: Le, error: Le }; let Fe = yt; function fs(a) { const e = self.console[a]; return e ? e.bind(self.console, `[${a}] >`) : Le; } function ms(a, ...e) { e.forEach(function(t) { Fe[t] = a[t] ? a[t].bind(a) : fs(t); }); } function gs(a, e) { if (typeof console == "object" && a === !0 || typeof a == "object") { ms( a, // Remove out from list here to hard-disable a log-level // 'trace', "debug", "log", "info", "warn", "error" ); try { Fe.log(`Debug logs enabled for "${e}" in hls.js version 1.5.18`); } catch { Fe = yt; } } else Fe = yt; } const L = Fe, ps = /^(\d+)x(\d+)$/, Ot = /(.+?)=(".*?"|.*?)(?:,|$)/g; class Z { constructor(e) { typeof e == "string" && (e = Z.parseAttrList(e)), ae(this, e); } get clientAttrs() { return Object.keys(this).filter((e) => e.substring(0, 2) === "X-"); } 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 i = new Uint8Array(t.length / 2); for (let s = 0; s < t.length / 2; s++) i[s] = parseInt(t.slice(s * 2, s * 2 + 2), 16); return i; } 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 i = this[e]; return i ? parseFloat(i) : t; } enumeratedString(e) { return this[e]; } bool(e) { return this[e] === "YES"; } decimalResolution(e) { const t = ps.exec(this[e]); if (t !== null) return { width: parseInt(t[1], 10), height: parseInt(t[2], 10) }; } static parseAttrList(e) { let t; const i = {}, s = '"'; for (Ot.lastIndex = 0; (t = Ot.exec(e)) !== null; ) { let n = t[2]; n.indexOf(s) === 0 && n.lastIndexOf(s) === n.length - 1 && (n = n.slice(1, -1)); const r = t[1].trim(); i[r] = n; } return i; } } function xs(a) { return a !== "ID" && a !== "CLASS" && a !== "START-DATE" && a !== "DURATION" && a !== "END-DATE" && a !== "END-ON-NEXT"; } function ys(a) { return a === "SCTE35-OUT" || a === "SCTE35-IN"; } class Li { constructor(e, t) { if (this.attr = void 0, this._startDate = void 0, this._endDate = void 0, this._badValueForSameId = void 0, t) { const i = t.attr; for (const s in i) if (Object.prototype.hasOwnProperty.call(e, s) && e[s] !== i[s]) { L.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`), this._badValueForSameId = s; break; } e = ae(new Z({}), i, e); } if (this.attr = e, this._startDate = new Date(e["START-DATE"]), "END-DATE" in this.attr) { const i = new Date(this.attr["END-DATE"]); k(i.getTime()) && (this._endDate = i); } } 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 (k(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 && k(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class); } } class et { 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 Q = { AUDIO: "audio", VIDEO: "video", AUDIOVIDEO: "audiovideo" }; class vi { constructor(e) { this._byteRange = null, this._url = null, this.baseurl = void 0, this.relurl = void 0, this.elementaryStreams = { [Q.AUDIO]: null, [Q.VIDEO]: null, [Q.AUDIOVIDEO]: null }, this.baseurl = e; } // setByteRange converts a EXT-X-BYTERANGE attribute into a two element array setByteRange(e, t) { const i = e.split("@", 2); let s; i.length === 1 ? s = t?.byteRangeEndOffset || 0 : s = parseInt(i[1]), this._byteRange = [s, parseInt(i[0]) + s]; } 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 = Rt.buildAbsoluteURL(this.baseurl, this.relurl, { alwaysNormalize: !0 })), this._url || ""; } set url(e) { this._url = e; } } class st extends vi { 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 et(), this.data = void 0, this.bitrateTest = !1, this.title = null, this.initSegment = null, this.endList = void 0, this.gap = void 0, this.urlId = 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 i = Object.keys(this.levelkeys); if (i.length === 1) return this._decryptdata = this.levelkeys[i[0]].getDecryptData(this.sn); } } return this._decryptdata; } get end() { return this.start + this.duration; } get endProgramDateTime() { if (this.programDateTime === null || !k(this.programDateTime)) return null; const e = k(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), i = t.length; if (i > 1 || i === 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, i, s, n, r = !1) { const { elementaryStreams: o } = this, l = o[e]; if (!l) { o[e] = { startPTS: t, endPTS: i, startDTS: s, endDTS: n, partial: r }; return; } l.startPTS = Math.min(l.startPTS, t), l.endPTS = Math.max(l.endPTS, i), l.startDTS = Math.min(l.startDTS, s), l.endDTS = Math.max(l.endDTS, n); } clearElementaryStreamInfo() { const { elementaryStreams: e } = this; e[Q.AUDIO] = null, e[Q.VIDEO] = null, e[Q.AUDIOVIDEO] = null; } } class Es extends vi { constructor(e, t, i, s, n) { super(i), 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 et(), 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 = s; const r = e.enumeratedString("BYTERANGE"); r && this.setByteRange(r, n), n && (this.fragOffset = n.fragOffset + n.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 Ts = 10; class Ss { 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, i = this.lastPartIndex - e.lastPartIndex; this.updated = this.endSN !== e.endSN || !!i || !!t || !this.live, this.advanced = this.endSN > e.endSN || t > 0 || t === 0 && i > 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 ? k(this.fragments[this.fragments.length - 1].programDateTime) : !1; } get levelTargetDuration() { return this.averagetargetduration || this.targetduration || Ts; } 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; } } var Oe = {}, Ls = /* @__PURE__ */ Ti(Oe); function ve(a, e, t) { return Uint8Array.prototype.slice ? a.slice(e, t) : new Uint8Array(Array.prototype.slice.call(a, e, t)); } const bt = (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, Ai = (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, Ke = (a, e) => { const t = e; let i = 0; for (; bt(a, e); ) { i += 10; const s = tt(a, e + 6); i += s, Ai(a, e + 10) && (i += 10), e += i; } if (i > 0) return a.subarray(t, t + i); }, tt = (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; }, vs = (a, e) => bt(a, e) && tt(a, e + 6) + 10 <= a.length - e, Ri = (a) => { const e = Ii(a); for (let t = 0; t < e.length; t++) { const i = e[t]; if (bi(i)) return Cs(i); } }, bi = (a) => a && a.key === "PRIV" && a.info === "com.apple.streaming.transportStreamTimestamp", As = (a) => { const e = String.fromCharCode(a[0], a[1], a[2], a[3]), t = tt(a, 4), i = 10; return { type: e, size: t, data: a.subarray(i, i + t) }; }, Ii = (a) => { let e = 0; const t = []; for (; bt(a, e); ) { const i = tt(a, e + 6); e += 10; const s = e + i; for (; e + 8 < s; ) { const n = As(a.subarray(e)), r = Rs(n); r && t.push(r), e += n.size + 10; } Ai(a, e) && (e += 10); } return t; }, Rs = (a) => a.type === "PRIV" ? bs(a) : a.type[0] === "W" ? Ds(a) : Is(a), bs = (a) => { if (a.size < 2) return; const e = Se(a.data, !0), t = new Uint8Array(a.data.subarray(e.length + 1)); return { key: a.type, info: e, data: t.buffer }; }, Is = (a) => { if (a.size < 2) return; if (a.type === "TXXX") { let t = 1; const i = Se(a.data.subarray(t), !0); t += i.length + 1; const s = Se(a.data.subarray(t)); return { key: a.type, info: i, data: s }; } const e = Se(a.data.subarray(1)); return { key: a.type, data: e }; }, Ds = (a) => { if (a.type === "WXXX") { if (a.size < 2) return; let t = 1; const i = Se(a.data.subarray(t), !0); t += i.length + 1; const s = Se(a.data.subarray(t)); return { key: a.type, info: i, data: s }; } const e = Se(a.data); return { key: a.type, data: e }; }, Cs = (a) => { if (a.data.byteLength === 8) { const e = new Uint8Array(a.data), t = e[3] & 1; let i = (e[4] << 23) + (e[5] << 15) + (e[6] << 7) + e[7]; return i /= 45, t && (i += 4772185884e-2), Math.round(i); } }, Se = (a, e = !1) => { const t = _s(); if (t) { const d = t.decode(a); if (e) { const u = d.indexOf("\0"); return u !== -1 ? d.substring(0, u) : d; } return d.replace(/\0/g, ""); } const i = a.length; let s, n, r, o = "", l = 0; for (; l < i; ) { if (s = a[l++], s === 0 && e) return o; if (s === 0 || s === 3) continue; switch (s >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: o += String.fromCharCode(s); break; case 12: case 13: n = a[l++], o += String.fromCharCode((s & 31) << 6 | n & 63); break; case 14: n = a[l++], r = a[l++], o += String.fromCharCode((s & 15) << 12 | (n & 63) << 6 | (r & 63) << 0); break; } } return o; }; let nt; function _s() { if (!navigator.userAgent.includes("PlayStation 4")) return !nt && typeof self.TextDecoder < "u" && (nt = new self.TextDecoder("utf-8")), nt; } const kt = { hexDump: function(a) { let e = ""; for (let t = 0; t < a.length; t++) { let i = a[t].toString(16); i.length < 2 && (i = "0" + i), e += i; } return e; } }, We = Math.pow(2, 32) - 1, ws = [].push, Di = { video: 1, audio: 2, id3: 3, text: 4 }; function te(a) { return String.fromCharCode.apply(null, a); } function Ci(a, e) { const t = a[e] << 8 | a[e + 1]; return t < 0 ? 65536 + t : t; } function N(a, e) { const t = _i(a, e); return t < 0 ? 4294967296 + t : t; } function Mt(a, e) { let t = N(a, e); return t *= Math.pow(2, 32), t += N(a, e + 4), t; } function _i(a, e) { return a[e] << 24 | a[e + 1] << 16 | a[e + 2] << 8 | a[e + 3]; } function rt(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 Ps(a) { const e = a.byteLength; for (let t = 0; t < e; ) { const i = N(a, t); if (i > 8 && a[t + 4] === 109 && a[t + 5] === 111 && a[t + 6] === 111 && a[t + 7] === 102) return !0; t = i > 1 ? t + i : e; } return !1; } function G(a, e) { const t = []; if (!e.length) return t; const i = a.byteLength; for (let s = 0; s < i; ) { const n = N(a, s), r = te(a.subarray(s + 4, s + 8)), o = n > 1 ? s + n : i; if (r === e[0]) if (e.length === 1) t.push(a.subarray(s + 8, o)); else { const l = G(a.subarray(s + 8, o), e.slice(1)); l.length && ws.apply(t, l); } s = o; } return t; } function Fs(a) { const e = [], t = a[0]; let i = 8; const s = N(a, i); i += 4; let n = 0, r = 0; t === 0 ? (n = N(a, i), r = N(a, i + 4), i += 8) : (n = Mt(a, i), r = Mt(a, i + 8), i += 16), i += 2; let o = a.length + r; const l = Ci(a, i); i += 2; for (let d = 0; d < l; d++) { let u = i; const h = N(a, u); u += 4; const c = h & 2147483647; if ((h & 2147483648) >>> 31 === 1) return L.warn("SIDX has hierarchical references (not supported)"), null; const m = N(a, u); u += 4, e.push({ referenceSize: c, subsegmentDuration: m, // unscaled info: { duration: m / s, start: o, end: o + c - 1 } }), o += c, u += 4, i = u; } return { earliestPresentationTime: n, timescale: s, version: t, referencesCount: l, references: e }; } function wi(a) { const e = [], t = G(a, ["moov", "trak"]); for (let s = 0; s < t.length; s++) { const n = t[s], r = G(n, ["tkhd"])[0]; if (r) { let o = r[0]; const l = N(r, o === 0 ? 12 : 20), d = G(n, ["mdia", "mdhd"])[0]; if (d) { o = d[0]; const u = N(d, o === 0 ? 12 : 20), h = G(n, ["mdia", "hdlr"])[0]; if (h) { const c = te(h.subarray(8, 12)), f = { soun: Q.AUDIO, vide: Q.VIDEO }[c]; if (f) { const m = G(n, ["mdia", "minf", "stbl", "stsd"])[0], g = Os(m); e[l] = { timescale: u, type: f }, e[f] = oe({ timescale: u, id: l }, g); } } } } } return G(a, ["moov", "mvex", "trex"]).forEach((s) => { const n = N(s, 4), r = e[n]; r && (r.default = { duration: N(s, 12), flags: N(s, 20) }); }), e; } function Os(a) { const e = a.subarray(8), t = e.subarray(86), i = te(e.subarray(4, 8)); let s = i; const n = i === "enca" || i === "encv"; if (n) { const o = G(e, [i])[0].subarray(i === "enca" ? 28 : 78); G(o, ["sinf"]).forEach((d) => { const u = G(d, ["schm"])[0]; if (u) { const h = te(u.subarray(4, 8)); if (h === "cbcs" || h === "cenc") { const c = G(d, ["frma"])[0]; c && (s = te(c)); } } }); } switch (s) { case "avc1": case "avc2": case "avc3": case "avc4": { const r = G(t, ["avcC"])[0]; s += "." + ke(r[1]) + ke(r[2]) + ke(r[3]); break; } case "mp4a": { const r = G(e, [i])[0], o = G(r.subarray(28), ["esds"])[0]; if (o && o.length > 12) { let l = 4; if (o[l++] !== 3) break; l = at(o, l), l += 2; const d = o[l++]; if (d & 128 && (l += 2), d & 64 && (l += o[l++]), o[l++] !== 4) break; l = at(o, l); const u = o[l++]; if (u === 64) s += "." + ke(u); else break; if (l += 12, o[l++] !== 5) break; l = at(o, l); const h = o[l++]; let c = (h & 248) >> 3; c === 31 && (c += 1 + ((h & 7) << 3) + ((o[l] & 224) >> 5)), s += "." + c; } break; } case "hvc1": case "hev1": { const r = G(t, ["hvcC"])[0], o = r[1], l = ["", "A", "B", "C"][o >> 6], d = o & 31, u = N(r, 2), h = (o & 32) >> 5 ? "H" : "L", c = r[12], f = r.subarray(6, 12); s += "." + l + d, s += "." + u.toString(16).toUpperCase(), s += "." + h + c; let m = ""; for (let g = f.length; g--; ) { const p = f[g]; (p || m) && (m = "." + p.toString(16).toUpperCase() + m); } s += m; break; } case "dvh1": case "dvhe": { const r = G(t, ["dvcC"])[0], o = r[2] >> 1 & 127, l = r[2] << 5 & 32 | r[3] >> 3 & 31; s += "." + fe(o) + "." + fe(l); break; } case "vp09": { const r = G(t, ["vpcC"])[0], o = r[4], l = r[5], d = r[6] >> 4 & 15; s += "." + fe(o) + "." + fe(l) + "." + fe(d); break; } case "av01": { const r = G(t, ["av1C"])[0], o = r[1] >>> 5, l = r[1] & 31, d = r[2] >>> 7 ? "H" : "M", u = (r[2] & 64) >> 6, h = (r[2] & 32) >> 5, c = o === 2 && u ? h ? 12 : 10 : u ? 10 : 8, f = (r[2] & 16) >> 4, m = (r[2] & 8) >> 3, g = (r[2] & 4) >> 2, p = r[2] & 3; s += "." + o + "." + fe(l) + d + "." + fe(c) + "." + f + "." + m + g + p + "." + fe(1) + "." + fe(1) + "." + fe(1) + "." + 0; break; } } return { codec: s, encrypted: n }; } function at(a, e) { const t = e + 5; for (; a[e++] & 128 && e < t; ) ; return e; } function ke(a) { return ("0" + a.toString(16).toUpperCase()).slice(-2); } function fe(a) { return (a < 10 ? "0" : "") + a; } function ks(a, e) { if (!a || !e) return a; const t = e.keyId; return t && e.isCommonEncryption && G(a, ["moov", "trak"]).forEach((s) => { const r = G(s, ["mdia", "minf", "stbl", "stsd"])[0].subarray(8); let o = G(r, ["enca"]); const l = o.length > 0; l || (o = G(r, ["encv"])), o.forEach((d) => { const u = l ? d.subarray(28) : d.subarray(78); G(u, ["sinf"]).forEach((c) => { const f = Ms(c); if (f) { const m = f.subarray(8, 24); m.some((g) => g !== 0) || (L.log(`[eme] Patching keyId in 'enc${l ? "a" : "v"}>sinf>>tenc' box: ${kt.hexDump(m)} -> ${kt.hexDump(t)}`), f.set(t, 8)); } }); }); }), a; } function Ms(a) { const e = G(a, ["schm"])[0]; if (e) { const t = te(e.subarray(4, 8)); if (t === "cbcs" || t === "cenc") return G(a, ["schi", "tenc"])[0]; } return null; } function Ns(a, e) { return G(e, ["moof", "traf"]).reduce((t, i) => { const s = G(i, ["tfdt"])[0], n = s[0], r = G(i, ["tfhd"]).reduce((o, l) => { const d = N(l, 4), u = a[d]; if (u) { let h = N(s, 4); if (n === 1) { if (h === We) return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"), o; h *= We + 1, h += N(s, 8); } const c = u.timescale || 9e4, f = h / c; if (k(f) && (o === null || f < o)) return f; } return o; }, null); return r !== null && k(r) && (t === null || r < t) ? r : t; }, null); } function Bs(a, e) { let t = 0, i = 0, s = 0; const n = G(a, ["moof", "traf"]); for (let r = 0; r < n.length; r++) { const o = n[r], l = G(o, ["tfhd"])[0], d = N(l, 4), u = e[d]; if (!u) continue; const h = u.default, c = N(l, 0) | h?.flags; let f = h?.duration; c & 8 && (c & 2 ? f = N(l, 12) : f = N(l, 8)); const m = u.timescale || 9e4, g = G(o, ["trun"]); for (let p = 0; p < g.length; p++) { if (t = Us(g[p]), !t && f) { const y = N(g[p], 4); t = f * y; } u.type === Q.VIDEO ? i += t / m : u.type === Q.AUDIO && (s += t / m); } } if (i === 0 && s === 0) { let r = 1 / 0, o = 0, l = 0; const d = G(a, ["sidx"]); for (let u = 0; u < d.length; u++) { const h = Fs(d[u]); if (h != null && h.references) { r = Math.min(r, h.earliestPresentationTime / h.timescale); const c = h.references.reduce((f, m) => f + m.info.duration || 0, 0); o = Math.max(o, c + h.earliestPresentationTime / h.timescale), l = o - r; } } if (l && k(l)) return l; } return i || s; } function Us(a) { const e = N(a, 0); let t = 8; e & 1 && (t += 4), e & 4 && (t += 4); let i = 0; const s = N(a, 4); for (let n = 0; n < s; n++) { if (e & 256) { const r = N(a, t); i += r, t += 4; } e & 512 && (t += 4), e & 1024 && (t += 4), e & 2048 && (t += 4); } return i; } function $s(a, e, t) { G(e, ["moof", "traf"]).forEach((i) => { G(i, ["tfhd"]).forEach((s) => { const n = N(s, 4), r = a[n]; if (!r) return; const o = r.timescale || 9e4; G(i, ["tfdt"]).forEach((l) => { const d = l[0], u = t * o; if (u) { let h = N(l, 4); if (d === 0) h -= u, h = Math.max(h, 0), rt(l, 4, h); else { h *= Math.pow(2, 32), h += N(l, 8), h -= u, h = Math.max(h, 0); const c = Math.floor(h / (We + 1)), f = Math.floor(h % (We + 1)); rt(l, 4, c), rt(l, 8, f); } } }); }); }); } function Gs(a) { const e = { valid: null, remainder: null }, t = G(a, ["moof"]); if (t.length < 2) return e.remainder = a, e; const i = t[t.length - 1]; return e.valid = ve(a, 0, i.byteOffset - 8), e.remainder = ve(a, i.byteOffset - 8), e; } function ce(a, e) { const t = new Uint8Array(a.length + e.length); return t.set(a), t.set(e, a.length), t; } function Nt(a, e) { const t = [], i = e.samples, s = e.timescale, n = e.id; let r = !1; return G(i, ["moof"]).map((l) => { const d = l.byteOffset - 8; G(l, ["traf"]).map((h) => { const c = G(h, ["tfdt"]).map((f) => { const m = f[0]; let g = N(f, 4); return m === 1 && (g *= Math.pow(2, 32), g += N(f, 8)), g / s; })[0]; return c !== void 0 && (a = c), G(h, ["tfhd"]).map((f) => { const m = N(f, 4), g = N(f, 0) & 16777215, p = (g & 1) !== 0, y = (g & 2) !== 0, v = (g & 8) !== 0; let E = 0; const b = (g & 16) !== 0; let S = 0; const I = (g & 32) !== 0; let A = 8; m === n && (p && (A += 8), y && (A += 4), v && (E = N(f, A), A += 4), b && (S = N(f, A), A += 4), I && (A += 4), e.type === "video" && (r = Vs(e.codec)), G(h, ["trun"]).map((D) => { const P = D[0], _ = N(D, 0) & 16777215, C = (_ & 1) !== 0; let $ = 0; const M = (_ & 4) !== 0, U = (_ & 256) !== 0; let B = 0; const V = (_ & 512) !== 0; let W = 0; const X = (_ & 1024) !== 0, O = (_ & 2048) !== 0; let F = 0; const Y = N(D, 4); let H = 8; C && ($ = N(D, H), H += 4), M && (H += 4); let z = $ + d; for (let se = 0; se < Y; se++) { if (U ? (B = N(D, H), H += 4) : B = E, V ? (W = N(D, H), H += 4) : W = S, X && (H += 4), O && (P === 0 ? F = N(D, H) : F = _i(D, H), H += 4), e.type === Q.VIDEO) { let le = 0; for (; le < W; ) { const ne = N(i, z); if (z += 4, Hs(r, i[z])) { const Re = i.subarray(z, z + ne); Pi(Re, r ? 2 : 1, a + F / s, t); } z += ne, le += ne + 4; } } a += B / s; } })); }); }); }), t; } function Vs(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 Hs(a, e) { if (a) { const t = e >> 1 & 63; return t === 39 || t === 40; } else return (e & 31) === 6; } function Pi(a, e, t, i) { const s = Fi(a); let n = 0; n += e; let r = 0, o = 0, l = 0; for (; n < s.length; ) { r = 0; do { if (n >= s.length) break; l = s[n++], r += l; } while (l === 255); o = 0; do { if (n >= s.length) break; l = s[n++], o += l; } while (l === 255); const d = s.length - n; let u = n; if (o < d) n += o; else if (o > d) { L.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`); break; } if (r === 4) { if (s[u++] === 181) { const c = Ci(s, u); if (u += 2, c === 49) { const f = N(s, u); if (u += 4, f === 1195456820) { const m = s[u++]; if (m === 3) { const g = s[u++], p = 31 & g, y = 64 & g, v = y ? 2 + p * 3 : 0, E = new Uint8Array(v); if (y) { E[0] = g; for (let b = 1; b < v; b++) E[b] = s[u++]; } i.push({ type: m, payloadType: r, pts: t, bytes: E }); } } } } } else if (r === 5 && o > 16) { const h = []; for (let m = 0; m < 16; m++) { const g = s[u++].toString(16); h.push(g.length == 1 ? "0" + g : g), (m === 3 || m === 5 || m === 7 || m === 9) && h.push("-"); } const c = o - 16, f = new Uint8Array(c); for (let m = 0; m < c; m++) f[m] = s[u++]; i.push({ payloadType: r, pts: t, uuid: h.join(""), userData: Se(f), userDataBytes: f }); } } } function Fi(a) { const e = a.byteLength, t = []; let i = 1; for (; i < e - 2; ) a[i] === 0 && a[i + 1] === 0 && a[i + 2] === 3 ? (t.push(i + 2), i += 2) : i++; if (t.length === 0) return a; const s = e - t.length, n = new Uint8Array(s); let r = 0; for (i = 0; i < s; r++, i++) r === t[0] && (r++, t.shift()), n[i] = a[r]; return n; } function Ks(a) { const e = a[0]; let t = "", i = "", s = 0, n = 0, r = 0, o = 0, l = 0, d = 0; if (e === 0) { for (; te(a.subarray(d, d + 1)) !== "\0"; ) t += te(a.subarray(d, d + 1)), d += 1; for (t += te(a.subarray(d, d + 1)), d += 1; te(a.subarray(d, d + 1)) !== "\0"; ) i += te(a.subarray(d, d + 1)), d += 1; i += te(a.subarray(d, d + 1)), d += 1, s = N(a, 12), n = N(a, 16), o = N(a, 20), l = N(a, 24), d = 28; } else if (e === 1) { d += 4, s = N(a, d), d += 4; const h = N(a, d); d += 4; const c = N(a, d); for (d += 4, r = 2 ** 32 * h + c, hs(r) || (r = Number.MAX_SAFE_INTEGER, L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")), o = N(a, d), d += 4, l = N(a, d), d += 4; te(a.subarray(d, d + 1)) !== "\0"; ) t += te(a.subarray(d, d + 1)), d += 1; for (t += te(a.subarray(d, d + 1)), d += 1; te(a.subarray(d, d + 1)) !== "\0"; ) i += te(a.subarray(d, d + 1)), d += 1; i += te(a.subarray(d, d + 1)), d += 1; } const u = a.subarray(d, a.byteLength); return { schemeIdUri: t, value: i, timeScale: s, presentationTime: r, presentationTimeDelta: n, eventDuration: o, id: l, payload: u }; } class It { static clearKeyUriToKeyIdMap() { } constructor(e, t, i, s = [1], n = 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 = i, this.keyFormatVersions = s, this.iv = n, 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"; } 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 && L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`), e = 0); const t = Ws(e); return new It(this.method, this.uri, "identity", this.keyFormatVersions, t); } return this; } } function Ws(a) { const e = new Uint8Array(16); for (let t = 12; t < 16; t++) e[t] = a >> 8 * (15 - t) & 255; return e; } function Ae(a = !0) { return typeof self > "u" ? void 0 : (a || !self.MediaSource) && self.ManagedMediaSource || self.MediaSource || self.WebKitMediaSource; } function Ys(a) { return typeof self < "u" && a === self.ManagedMediaSource; } const Ye = { audio: { a3ds: 1, "ac-3": 0.95, "ac-4": 1, alac: 0.9, alaw: 1, dra1: 1, "dts+": 1, "dts-": 1, dtsc: 1, dtse: 1, dtsh: 1, "ec-3": 0.9, enca: 1, fLaC: 0.9, // MP4-RA listed codec entry for FLAC flac: 0.9, // legacy browser codec name for FLAC FLAC: 0.9, // some manifests may list "FLAC" with Apple's tools g719: 1, g726: 1, m4ae: 1, mha1: 1, mha2: 1, mhm1: 1, mhm2: 1, mlpa: 1, mp4a: 1, "raw ": 1, Opus: 1, opus: 1, // browsers expect this to be lowercase despite MP4RA says 'Opus' samr: 1, sawb: 1, sawp: 1, sevc: 1, sqcp: 1, ssmv: 1, twos: 1, ulaw: 1 }, video: { avc1: 1, avc2: 1, avc3: 1, avc4: 1, avcp: 1, av01: 0.8, drac: 1, dva1: 1, dvav: 1, dvh1: 0.7, dvhe: 0.7, encv: 1, hev1: 0.75, hvc1: 0.75, mjp2: 1, mp4v: 1, mvc1: 1, mvc2: 1, mvc3: 1, mvc4: 1, resv: 1, rv60: 1, s263: 1, svc1: 1, svc2: 1, "vc-1": 1, vp08: 1, vp09: 0.9 }, text: { stpp: 1, wvtt: 1 } }; function js(a, e) { const t = Ye[e]; return !!t && !!t[a.slice(0, 4)]; } function ot(a, e, t = !0) { return !a.split(",").some((i) => !Oi(i, e, t)); } function Oi(a, e, t = !0) { var i; const s = Ae(t); return (i = s?.isTypeSupported(Et(a, e))) != null ? i : !1; } function Et(a, e) { return `${e}/mp4;codecs="${a}"`; } function Bt(a) { if (a) { const e = a.substring(0, 4); return Ye.video[e]; } return 2; } function je(a) { return a.split(",").reduce((e, t) => { const i = Ye.video[t]; return i ? (i * 2 + e) / (e ? 3 : 2) : (Ye.audio[t] + e) / (e ? 2 : 1); }, 0); } const lt = {}; function qs(a, e = !0) { if (lt[a]) return lt[a]; const t = { flac: ["flac", "fLaC", "FLAC"], opus: ["opus", "Opus"] }[a]; for (let i = 0; i < t.length; i++) if (Oi(t[i], "audio", e)) return lt[a] = t[i], t[i]; return a; } const zs = /flac|opus/i; function qe(a, e = !0) { return a.replace(zs, (t) => qs(t.toLowerCase(), e)); } function Ut(a, e) { return a && a !== "mp4a" ? a : e && e.split(",")[0]; } function Xs(a) { const e = a.split(","); for (let t = 0; t < e.length; t++) { const i = e[t].split("."); if (i.length > 2) { let s = i.shift() + "."; s += parseInt(i.shift()).toString(16), s += ("000" + parseInt(i.shift()).toString(16)).slice(-4), e[t] = s; } } return e.join(","); } const $t = /#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g, Gt = /#EXT-X-MEDIA:(.*)/g, Qs = /^#EXT(?:INF|-X-TARGETDURATION):/m, Vt = new RegExp([ /#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source, // duration (#EXTINF:<duration>,<title>), group 1 => duration, group 2 => title /(?!#) *(\S[^\r\n]*)/.source, // segment URI, group 3 => the URI (note newline is not eaten) /#EXT-X-BYTERANGE:*(.+)/.source, // next segment's byterange, group 4 => range spec (x@y) /#EXT-X-PROGRAM-DATE-TIME:(.+)/.source, // next segment's program date/time group 5 => the datetime spec /#.*/.source // All other non-segment oriented tags will match with all groups empty ].join("|"), "g"), Js = new RegExp([/#(EXTM3U)/.source, /#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source, /#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source, /#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source, /(#)([^:]*):(.*)/.source, /(#)(.*)(?:.*)\r?\n?/.source].join("|")); class ge { static findGroup(e, t) { for (let i = 0; i < e.length; i++) { const s = e[i]; if (s.id === t) return s; } } static resolve(e, t) { return Rt.buildAbsoluteURL(t, e, { alwaysNormalize: !0 }); } static isMediaPlaylist(e) { return Qs.test(e); } static parseMasterPlaylist(e, t) { const s = { contentSteering: null, levels: [], playlistParsingError: null, sessionData: null, sessionKeys: null, startTimeOffset: null, variableList: null, hasVariableRefs: !1 }, n = []; $t.lastIndex = 0; let r; for (; (r = $t.exec(e)) != null; ) if (r[1]) { var o; const d = new Z(r[1]), u = r[2], h = { attrs: d, bitrate: d.decimalInteger("BANDWIDTH") || d.decimalInteger("AVERAGE-BANDWIDTH"), name: d.NAME, url: ge.resolve(u, t) }, c = d.decimalResolution("RESOLUTION"); c && (h.width = c.width, h.height = c.height), Zs(d.CODECS, h), (o = h.unknownCodecs) != null && o.length || n.push(h), s.levels.push(h); } else if (r[3]) { const d = r[3], u = r[4]; switch (d) { case "SESSION-DATA": { const h = new Z(u), c = h["DATA-ID"]; c && (s.sessionData === null && (s.sessionData = {}), s.sessionData[c] = h); break; } case "SESSION-KEY": { const h = Ht(u, t); h.encrypted && h.isSupported() ? (s.sessionKeys === null && (s.sessionKeys = []), s.sessionKeys.push(h)) : L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`); break; } case "DEFINE": break; case "CONTENT-STEERING": { const h = new Z(u); s.contentSteering = { uri: ge.resolve(h["SERVER-URI"], t), pathwayId: h["PATHWAY-ID"] || "." }; break; } case "START": { s.startTimeOffset = Kt(u); break; } } } const l = n.length > 0 && n.length < s.levels.length; return s.levels = l ? n : s.levels, s.levels.length === 0 && (s.playlistParsingError = new Error("no levels found in manifest")), s; } static parseMasterPlaylistMedia(e, t, i) { let s; const n = {}, r = i.levels, o = { AUDIO: r.map((d) => ({ id: d.attrs.AUDIO, audioCodec: d.audioCodec })), SUBTITLES: r.map((d) => ({ id: d.attrs.SUBTITLES, textCodec: d.textCodec })), "CLOSED-CAPTIONS": [] }; let l = 0; for (Gt.lastIndex = 0; (s = Gt.exec(e)) !== null; ) { const d = new Z(s[1]), u = d.TYPE; if (u) { const h = o[u], c = n[u] || []; n[u] = c; const f = d.LANGUAGE, m = d["ASSOC-LANGUAGE"], g = d.CHANNELS, p = d.CHARACTERISTICS, y = d["INSTREAM-ID"], v = { attrs: d, bitrate: 0, id: l++, groupId: d["GROUP-ID"] || "", name: d.NAME || f || "", type: u, default: d.bool("DEFAULT"), autoselect: d.bool("AUTOSELECT"), forced: d.bool("FORCED"), lang: f, url: d.URI ? ge.resolve(d.URI, t) : "" };