UNPKG

@asicupv/paella-video-plugins

Version:
1,484 lines 581 kB
function zr(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var $i = { 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, h) { if (h = h || {}, l = l.trim(), c = c.trim(), !c) { if (!h.alwaysNormalize) return l; var u = o.parseURL(l); if (!u) throw new Error("Error trying to parse base URL."); return u.path = o.normalizePath( u.path ), o.buildURLFromParts(u); } var d = o.parseURL(c); if (!d) throw new Error("Error trying to parse relative URL."); if (d.scheme) return h.alwaysNormalize ? (d.path = o.normalizePath(d.path), o.buildURLFromParts(d)) : c; var g = o.parseURL(l); if (!g) throw new Error("Error trying to parse base URL."); if (!g.netLoc && g.path && g.path[0] !== "/") { var f = i.exec(g.path); g.netLoc = f[1], g.path = f[2]; } g.netLoc && !g.path && (g.path = "/"); var m = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: g.scheme, netLoc: d.netLoc, path: null, params: d.params, query: d.query, fragment: d.fragment }; if (!d.netLoc && (m.netLoc = g.netLoc, d.path[0] !== "/")) if (!d.path) m.path = g.path, d.params || (m.params = g.params, d.query || (m.query = g.query)); else { var T = g.path, E = T.substring(0, T.lastIndexOf("/") + 1) + d.path; m.path = o.normalizePath(E); } return m.path === null && (m.path = h.alwaysNormalize ? o.normalizePath(d.path) : d.path), o.buildURLFromParts(m); }, 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; })(); })($i); var vs = $i.exports; function $s(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 oe(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e] != null ? arguments[e] : {}; e % 2 ? $s(Object(t), !0).forEach(function(s) { Jr(a, s, t[s]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(t)) : $s(Object(t)).forEach(function(s) { Object.defineProperty(a, s, Object.getOwnPropertyDescriptor(t, s)); }); } return a; } function Xr(a, e) { if (typeof a != "object" || !a) return a; var t = a[Symbol.toPrimitive]; if (t !== void 0) { var s = t.call(a, e); if (typeof s != "object") return s; throw new TypeError("@@toPrimitive must return a primitive value."); } return (e === "string" ? String : Number)(a); } function Qr(a) { var e = Xr(a, "string"); return typeof e == "symbol" ? e : String(e); } function Jr(a, e, t) { return e = Qr(e), e in a ? Object.defineProperty(a, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : a[e] = t, a; } function se() { return se = 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; }, se.apply(this, arguments); } const O = Number.isFinite || function(a) { return typeof a == "number" && isFinite(a); }, Zr = Number.isSafeInteger || function(a) { return typeof a == "number" && Math.abs(a) <= en; }, en = Number.MAX_SAFE_INTEGER || 9007199254740991; let p = /* @__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; }({}), $ = /* @__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; }({}), L = /* @__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 Fe = function() { }, os = { trace: Fe, debug: Fe, log: Fe, warn: Fe, info: Fe, error: Fe }; let Je = os; function tn(a) { const e = self.console[a]; return e ? e.bind(self.console, `[${a}] >`) : Fe; } function sn(a, ...e) { e.forEach(function(t) { Je[t] = a[t] ? a[t].bind(a) : tn(t); }); } function rn(a, e) { if (typeof console == "object" && a === !0 || typeof a == "object") { sn( a, // Remove out from list here to hard-disable a log-level // 'trace', "debug", "log", "info", "warn", "error" ); try { Je.log(`Debug logs enabled for "${e}" in hls.js version 1.5.20`); } catch { Je = os; } } else Je = os; } const v = Je, nn = /^(\d+)x(\d+)$/, Gs = /(.+?)=(".*?"|.*?)(?:,|$)/g; class ee { constructor(e) { typeof e == "string" && (e = ee.parseAttrList(e)), se(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 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 = nn.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 (Gs.lastIndex = 0; (t = Gs.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 an(a) { return a !== "ID" && a !== "CLASS" && a !== "START-DATE" && a !== "DURATION" && a !== "END-DATE" && a !== "END-ON-NEXT"; } function on(a) { return a === "SCTE35-OUT" || a === "SCTE35-IN"; } class Gi { 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 = se(new ee({}), 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"]); O(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 (O(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 && O(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class); } } class Ot { 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 Ki { 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 s = e.split("@", 2); let i; s.length === 1 ? i = (t == null ? void 0 : t.byteRangeEndOffset) || 0 : i = parseInt(s[1]), this._byteRange = [i, parseInt(s[0]) + 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 = vs.buildAbsoluteURL(this.baseurl, this.relurl, { alwaysNormalize: !0 })), this._url || ""; } set url(e) { this._url = e; } } class Ut extends Ki { 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 Ot(), 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 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 || !O(this.programDateTime)) return null; const e = O(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[Q.AUDIO] = null, e[Q.VIDEO] = null, e[Q.AUDIOVIDEO] = null; } } class ln extends Ki { 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 Ot(), 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 cn = 10; class hn { 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 ? O(this.fragments[this.fragments.length - 1].programDateTime) : !1; } get levelTargetDuration() { return this.averagetargetduration || this.targetduration || cn; } 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 As(a) { return Uint8Array.from(atob(a), (e) => e.charCodeAt(0)); } function un(a) { const e = ls(a).subarray(0, 16), t = new Uint8Array(16); return t.set(e, 16 - e.length), t; } function dn(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 fn(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 = As(n)) : t = un(n); } } return t; } function ls(a) { return Uint8Array.from(unescape(encodeURIComponent(a)), (e) => e.charCodeAt(0)); } const qe = typeof self < "u" ? self : void 0; var z = { CLEARKEY: "org.w3.clearkey", FAIRPLAY: "com.apple.fps", PLAYREADY: "com.microsoft.playready", WIDEVINE: "com.widevine.alpha" }, de = { CLEARKEY: "org.w3.clearkey", FAIRPLAY: "com.apple.streamingkeydelivery", PLAYREADY: "com.microsoft.playready", WIDEVINE: "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" }; function Bt(a) { switch (a) { case de.FAIRPLAY: return z.FAIRPLAY; case de.PLAYREADY: return z.PLAYREADY; case de.WIDEVINE: return z.WIDEVINE; case de.CLEARKEY: return z.CLEARKEY; } } var it = { CENC: "1077efecc0b24d02ace33c1e52e2fb4b", CLEARKEY: "e2719d58a985b3c9781ab030af78d30e", PLAYREADY: "9a04f07998404286ab92e65be0885f95", WIDEVINE: "edef8ba979d64acea3c827dcd51d21ed" }; function $t(a) { if (a === it.WIDEVINE) return z.WIDEVINE; if (a === it.PLAYREADY) return z.PLAYREADY; if (a === it.CENC || a === it.CLEARKEY) return z.CLEARKEY; } function Gt(a) { switch (a) { case z.FAIRPLAY: return de.FAIRPLAY; case z.PLAYREADY: return de.PLAYREADY; case z.WIDEVINE: return de.WIDEVINE; case z.CLEARKEY: return de.CLEARKEY; } } function rt(a) { const { drmSystems: e, widevineLicenseUrl: t } = a, s = e ? [z.FAIRPLAY, z.WIDEVINE, z.PLAYREADY, z.CLEARKEY].filter((i) => !!e[i]) : []; return !s[z.WIDEVINE] && t && s.push(z.WIDEVINE), s; } const Vi = function(a) { return qe != null && (a = qe.navigator) != null && a.requestMediaKeySystemAccess ? self.navigator.requestMediaKeySystemAccess.bind(self.navigator) : null; }(); function gn(a, e, t, s) { let i; switch (a) { case z.FAIRPLAY: i = ["cenc", "sinf"]; break; case z.WIDEVINE: case z.PLAYREADY: i = ["cenc"]; break; case z.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 || "optional", distinctiveIdentifier: s.distinctiveIdentifier || "optional", 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 Hi(a) { const e = new Uint16Array(a.buffer, a.byteOffset, a.byteLength / 2), t = String.fromCharCode.apply(null, Array.from(e)), s = t.substring(t.indexOf("<"), t.length), n = new DOMParser().parseFromString(s, "text/xml").getElementsByTagName("KID")[0]; if (n) { const o = n.childNodes[0] ? n.childNodes[0].nodeValue : n.getAttribute("VALUE"); if (o) { const l = As(o).subarray(0, 16); return dn(l), l; } } return null; } function Ne(a, e, t) { return Uint8Array.prototype.slice ? a.slice(e, t) : new Uint8Array(Array.prototype.slice.call(a, e, t)); } const Ls = (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, Wi = (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, Ze = (a, e) => { const t = e; let s = 0; for (; Ls(a, e); ) { s += 10; const i = Mt(a, e + 6); s += i, Wi(a, e + 10) && (s += 10), e += s; } if (s > 0) return a.subarray(t, t + s); }, Mt = (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) => Ls(a, e) && Mt(a, e + 6) + 10 <= a.length - e, Rs = (a) => { const e = qi(a); for (let t = 0; t < e.length; t++) { const s = e[t]; if (Yi(s)) return vn(s); } }, Yi = (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 = Mt(a, 4), s = 10; return { type: e, size: t, data: a.subarray(s, s + t) }; }, qi = (a) => { let e = 0; const t = []; for (; Ls(a, e); ) { const s = Mt(a, e + 6); e += 10; const i = e + s; for (; e + 8 < i; ) { const r = Tn(a.subarray(e)), n = En(r); n && t.push(n), e += r.size + 10; } Wi(a, e) && (e += 10); } return t; }, En = (a) => a.type === "PRIV" ? yn(a) : a.type[0] === "W" ? Sn(a) : xn(a), yn = (a) => { if (a.size < 2) return; const e = Re(a.data, !0), t = new Uint8Array(a.data.subarray(e.length + 1)); return { key: a.type, info: e, data: t.buffer }; }, xn = (a) => { if (a.size < 2) return; if (a.type === "TXXX") { let t = 1; const s = Re(a.data.subarray(t), !0); t += s.length + 1; const i = Re(a.data.subarray(t)); return { key: a.type, info: s, data: i }; } const e = Re(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 = Re(a.data.subarray(t), !0); t += s.length + 1; const i = Re(a.data.subarray(t)); return { key: a.type, info: s, data: i }; } const e = Re(a.data); return { key: a.type, data: e }; }, vn = (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); } }, Re = (a, e = !1) => { const t = An(); if (t) { const c = t.decode(a); if (e) { const h = c.indexOf("\0"); return h !== -1 ? c.substring(0, h) : 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 Kt; function An() { if (!navigator.userAgent.includes("PlayStation 4")) return !Kt && typeof self.TextDecoder < "u" && (Kt = new self.TextDecoder("utf-8")), Kt; } const Se = { 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; } }, Lt = Math.pow(2, 32) - 1, Ln = [].push, ji = { video: 1, audio: 2, id3: 3, text: 4 }; function ie(a) { return String.fromCharCode.apply(null, a); } function zi(a, e) { const t = a[e] << 8 | a[e + 1]; return t < 0 ? 65536 + t : t; } function N(a, e) { const t = Xi(a, e); return t < 0 ? 4294967296 + t : t; } function Ks(a, e) { let t = N(a, e); return t *= Math.pow(2, 32), t += N(a, e + 4), t; } function Xi(a, e) { return a[e] << 24 | a[e + 1] << 16 | a[e + 2] << 8 | a[e + 3]; } function Vt(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 Rn(a) { const e = a.byteLength; for (let t = 0; t < e; ) { const s = N(a, t); if (s > 8 && a[t + 4] === 109 && a[t + 5] === 111 && a[t + 6] === 111 && a[t + 7] === 102) return !0; t = s > 1 ? t + s : e; } return !1; } function H(a, e) { const t = []; if (!e.length) return t; const s = a.byteLength; for (let i = 0; i < s; ) { const r = N(a, i), n = ie(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 && Ln.apply(t, l); } i = o; } return t; } function In(a) { const e = [], t = a[0]; let s = 8; const i = N(a, s); s += 4; let r = 0, n = 0; t === 0 ? (r = N(a, s), n = N(a, s + 4), s += 8) : (r = Ks(a, s), n = Ks(a, s + 8), s += 16), s += 2; let o = a.length + n; const l = zi(a, s); s += 2; for (let c = 0; c < l; c++) { let h = s; const u = N(a, h); h += 4; const d = u & 2147483647; if ((u & 2147483648) >>> 31 === 1) return v.warn("SIDX has hierarchical references (not supported)"), null; const f = N(a, h); h += 4, e.push({ referenceSize: d, subsegmentDuration: f, // unscaled info: { duration: f / i, start: o, end: o + d - 1 } }), o += d, h += 4, s = h; } return { earliestPresentationTime: r, timescale: i, version: t, referencesCount: l, references: e }; } function Qi(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]; const l = N(n, o === 0 ? 12 : 20), c = H(r, ["mdia", "mdhd"])[0]; if (c) { o = c[0]; const h = N(c, o === 0 ? 12 : 20), u = H(r, ["mdia", "hdlr"])[0]; if (u) { const d = ie(u.subarray(8, 12)), g = { soun: Q.AUDIO, vide: Q.VIDEO }[d]; if (g) { const f = H(r, ["mdia", "minf", "stbl", "stsd"])[0], m = bn(f); e[l] = { timescale: h, type: g }, e[g] = oe({ timescale: h, id: l }, m); } } } } } return H(a, ["moov", "mvex", "trex"]).forEach((i) => { const r = N(i, 4), n = e[r]; n && (n.default = { duration: N(i, 12), flags: N(i, 20) }); }), e; } function bn(a) { const e = a.subarray(8), t = e.subarray(86), s = ie(e.subarray(4, 8)); let i = s; const r = s === "enca" || s === "encv"; if (r) { const o = H(e, [s])[0].subarray(s === "enca" ? 28 : 78); H(o, ["sinf"]).forEach((c) => { const h = H(c, ["schm"])[0]; if (h) { const u = ie(h.subarray(4, 8)); if (u === "cbcs" || u === "cenc") { const d = H(c, ["frma"])[0]; d && (i = ie(d)); } } }); } switch (i) { case "avc1": case "avc2": case "avc3": case "avc4": { const n = H(t, ["avcC"])[0]; i += "." + nt(n[1]) + nt(n[2]) + nt(n[3]); break; } case "mp4a": { const n = H(e, [s])[0], o = H(n.subarray(28), ["esds"])[0]; if (o && o.length > 12) { let l = 4; if (o[l++] !== 3) break; l = Ht(o, l), l += 2; const c = o[l++]; if (c & 128 && (l += 2), c & 64 && (l += o[l++]), o[l++] !== 4) break; l = Ht(o, l); const h = o[l++]; if (h === 64) i += "." + nt(h); else break; if (l += 12, o[l++] !== 5) break; l = Ht(o, l); const u = o[l++]; let d = (u & 248) >> 3; d === 31 && (d += 1 + ((u & 7) << 3) + ((o[l] & 224) >> 5)), i += "." + d; } break; } case "hvc1": case "hev1": { const n = H(t, ["hvcC"])[0], o = n[1], l = ["", "A", "B", "C"][o >> 6], c = o & 31, h = N(n, 2), u = (o & 32) >> 5 ? "H" : "L", d = n[12], g = n.subarray(6, 12); i += "." + l + c, i += "." + h.toString(16).toUpperCase(), i += "." + u + d; let f = ""; for (let m = g.length; m--; ) { const T = g[m]; (T || f) && (f = "." + T.toString(16).toUpperCase() + f); } i += f; break; } case "dvh1": case "dvhe": { const n = H(t, ["dvcC"])[0], o = n[2] >> 1 & 127, l = n[2] << 5 & 32 | n[3] >> 3 & 31; i += "." + xe(o) + "." + xe(l); break; } case "vp09": { const n = H(t, ["vpcC"])[0], o = n[4], l = n[5], c = n[6] >> 4 & 15; i += "." + xe(o) + "." + xe(l) + "." + xe(c); break; } case "av01": { const n = H(t, ["av1C"])[0], o = n[1] >>> 5, l = n[1] & 31, c = n[2] >>> 7 ? "H" : "M", h = (n[2] & 64) >> 6, u = (n[2] & 32) >> 5, d = o === 2 && h ? u ? 12 : 10 : h ? 10 : 8, g = (n[2] & 16) >> 4, f = (n[2] & 8) >> 3, m = (n[2] & 4) >> 2, T = n[2] & 3; i += "." + o + "." + xe(l) + c + "." + xe(d) + "." + g + "." + f + m + T + "." + xe(1) + "." + xe(1) + "." + xe(1) + "." + 0; break; } } return { codec: i, encrypted: r }; } function Ht(a, e) { const t = e + 5; for (; a[e++] & 128 && e < t; ) ; return e; } function nt(a) { return ("0" + a.toString(16).toUpperCase()).slice(-2); } function xe(a) { return (a < 10 ? "0" : "") + a; } function Dn(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 h = l ? c.subarray(28) : c.subarray(78); H(h, ["sinf"]).forEach((d) => { const g = Ji(d); if (g) { const f = g.subarray(8, 24); f.some((m) => m !== 0) || (v.log(`[eme] Patching keyId in 'enc${l ? "a" : "v"}>sinf>>tenc' box: ${Se.hexDump(f)} -> ${Se.hexDump(t)}`), g.set(t, 8)); } }); }); }), a; } function Ji(a) { const e = H(a, ["schm"])[0]; if (e) { const t = ie(e.subarray(4, 8)); if (t === "cbcs" || t === "cenc") return H(a, ["schi", "tenc"])[0]; } return null; } function Cn(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 = N(l, 4), h = a[c]; if (h) { let u = N(i, 4); if (r === 1) { if (u === Lt) return v.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"), o; u *= Lt + 1, u += N(i, 8); } const d = h.timescale || 9e4, g = u / d; if (O(g) && (o === null || g < o)) return g; } return o; }, null); return n !== null && O(n) && (t === null || n < t) ? n : t; }, null); } function kn(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 = N(l, 4), h = e[c]; if (!h) continue; const u = h.default, d = N(l, 0) | (u == null ? void 0 : u.flags); let g = u == null ? void 0 : u.duration; d & 8 && (d & 2 ? g = N(l, 12) : g = N(l, 8)); const f = h.timescale || 9e4, m = H(o, ["trun"]); for (let T = 0; T < m.length; T++) { if (t = wn(m[T]), !t && g) { const E = N(m[T], 4); t = g * E; } h.type === Q.VIDEO ? s += t / f : h.type === Q.AUDIO && (i += t / f); } } if (s === 0 && i === 0) { let n = 1 / 0, o = 0, l = 0; const c = H(a, ["sidx"]); for (let h = 0; h < c.length; h++) { const u = In(c[h]); if (u != null && u.references) { n = Math.min(n, u.earliestPresentationTime / u.timescale); const d = u.references.reduce((g, f) => g + f.info.duration || 0, 0); o = Math.max(o, d + u.earliestPresentationTime / u.timescale), l = o - n; } } if (l && O(l)) return l; } return s || i; } function wn(a) { const e = N(a, 0); let t = 8; e & 1 && (t += 4), e & 4 && (t += 4); let s = 0; const i = N(a, 4); for (let r = 0; r < i; r++) { if (e & 256) { const n = N(a, t); s += n, t += 4; } e & 512 && (t += 4), e & 1024 && (t += 4), e & 2048 && (t += 4); } return s; } function _n(a, e, t) { H(e, ["moof", "traf"]).forEach((s) => { H(s, ["tfhd"]).forEach((i) => { const r = N(i, 4), n = a[r]; if (!n) return; const o = n.timescale || 9e4; H(s, ["tfdt"]).forEach((l) => { const c = l[0], h = t * o; if (h) { let u = N(l, 4); if (c === 0) u -= h, u = Math.max(u, 0), Vt(l, 4, u); else { u *= Math.pow(2, 32), u += N(l, 8), u -= h, u = Math.max(u, 0); const d = Math.floor(u / (Lt + 1)), g = Math.floor(u % (Lt + 1)); Vt(l, 4, d), Vt(l, 8, g); } } }); }); }); } function Pn(a) { const e = { valid: null, remainder: null }, t = H(a, ["moof"]); if (t.length < 2) return e.remainder = a, e; const s = t[t.length - 1]; return e.valid = Ne(a, 0, s.byteOffset - 8), e.remainder = Ne(a, s.byteOffset - 8), e; } function pe(a, e) { const t = new Uint8Array(a.length + e.length); return t.set(a), t.set(e, a.length), t; } function Vs(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((u) => { const d = H(u, ["tfdt"]).map((g) => { const f = g[0]; let m = N(g, 4); return f === 1 && (m *= Math.pow(2, 32), m += N(g, 8)), m / i; })[0]; return d !== void 0 && (a = d), H(u, ["tfhd"]).map((g) => { const f = N(g, 4), m = N(g, 0) & 16777215, T = (m & 1) !== 0, E = (m & 2) !== 0, x = (m & 8) !== 0; let y = 0; const I = (m & 16) !== 0; let S = 0; const D = (m & 32) !== 0; let R = 8; f === r && (T && (R += 8), E && (R += 4), x && (y = N(g, R), R += 4), I && (S = N(g, R), R += 4), D && (R += 4), e.type === "video" && (n = Fn(e.codec)), H(u, ["trun"]).map((k) => { const _ = k[0], b = N(k, 0) & 16777215, w = (b & 1) !== 0; let V = 0; const P = (b & 4) !== 0, K = (b & 256) !== 0; let G = 0; const B = (b & 512) !== 0; let q = 0; const J = (b & 1024) !== 0, M = (b & 2048) !== 0; let F = 0; const j = N(k, 4); let W = 8; w && (V = N(k, W), W += 4), P && (W += 4); let X = V + c; for (let te = 0; te < j; te++) { if (K ? (G = N(k, W), W += 4) : G = y, B ? (q = N(k, W), W += 4) : q = S, J && (W += 4), M && (_ === 0 ? F = N(k, W) : F = Xi(k, W), W += 4), e.type === Q.VIDEO) { let re = 0; for (; re < q; ) { const le = N(s, X); if (X += 4, On(n, s[X])) { const fe = s.subarray(X, X + le); Zi(fe, n ? 2 : 1, a + F / i, t); } X += le, re += le + 4; } } a += G / i; } })); }); }); }), t; } function Fn(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 On(a, e) { if (a) { const t = e >> 1 & 63; return t === 39 || t === 40; } else return (e & 31) === 6; } function Zi(a, e, t, s) { const i = er(a); let r = 0; r += e; let n = 0, o = 0, l = 0; for (; r < i.length; ) { n = 0; do { if (r >= i.length) break; l = i[r++], n += l; } while (l === 255); o = 0; do { if (r >= i.length) break; l = i[r++], o += l; } while (l === 255); const c = i.length - r; let h = r; if (o < c) r += o; else if (o > c) { v.error(`Malformed SEI payload. ${o} is too small, only ${c} bytes left to parse.`); break; } if (n === 4) { if (i[h++] === 181) { const d = zi(i, h); if (h += 2, d === 49) { const g = N(i, h); if (h += 4, g === 1195456820) { const f = i[h++]; if (f === 3) { const m = i[h++], T = 31 & m, E = 64 & m, x = E ? 2 + T * 3 : 0, y = new Uint8Array(x); if (E) { y[0] = m; for (let I = 1; I < x; I++) y[I] = i[h++]; } s.push({ type: f, payloadType: n, pts: t, bytes: y }); } } } } } else if (n === 5 && o > 16) { const u = []; for (let f = 0; f < 16; f++) { const m = i[h++].toString(16); u.push(m.length == 1 ? "0" + m : m), (f === 3 || f === 5 || f === 7 || f === 9) && u.push("-"); } const d = o - 16, g = new Uint8Array(d); for (let f = 0; f < d; f++) g[f] = i[h++]; s.push({ payloadType: n, pts: t, uuid: u.join(""), userData: Re(g), userDataBytes: g }); } } } function er(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 Mn(a) { const e = a[0]; let t = "", s = "", i = 0, r = 0, n = 0, o = 0, l = 0, c = 0; if (e === 0) { for (; ie(a.subarray(c, c + 1)) !== "\0"; ) t += ie(a.subarray(c, c + 1)), c += 1; for (t += ie(a.subarray(c, c + 1)), c += 1; ie(a.subarray(c, c + 1)) !== "\0"; ) s += ie(a.subarray(c, c + 1)), c += 1; s += ie(a.subarray(c, c + 1)), c += 1, i = N(a, 12), r = N(a, 16), o = N(a, 20), l = N(a, 24), c = 28; } else if (e === 1) { c += 4, i = N(a, c), c += 4; const u = N(a, c); c += 4; const d = N(a, c); for (c += 4, n = 2 ** 32 * u + d, Zr(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 = N(a, c), c += 4, l = N(a, c), c += 4; ie(a.subarray(c, c + 1)) !== "\0"; ) t += ie(a.subarray(c, c + 1)), c += 1; for (t += ie(a.subarray(c, c + 1)), c += 1; ie(a.subarray(c, c + 1)) !== "\0"; ) s += ie(a.subarray(c, c + 1)), c += 1; s += ie(a.subarray(c, c + 1)), c += 1; } const h = a.subarray(c, a.byteLength); return { schemeIdUri: t, value: s, timeScale: i, presentationTime: n, presentationTimeDelta: r, eventDuration: o, id: l, payload: h }; } function Nn(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 Un(a, e, t) { if (a.byteLength !== 16) throw new RangeError("Invalid system id"); let s, i; 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), Nn( [112, 115, 115, 104], new Uint8Array([ s, 0, 0, 0 // Flags ]), a, // 16 bytes r, i, n, t || new Uint8Array() ); } function Bn(a) { const e = []; if (a instanceof ArrayBuffer) { const t = a.byteLength; let s = 0; for (; s + 32 < t; ) { const i = new DataView(a, s), r = $n(i); e.push(r), s += r.size; } } return e; } function $n(a) { const e = a.getUint32(0), t = a.byteOffset, s = a.byteLength; if (s < e) return { offset: t, size: s }; if (a.getUint32(4) !== 1886614376) return { offset: t, size: e }; const r = a.getUint32(8) >>> 24; if (r !== 0 && r !== 1) return { offset: t, size: e }; const n = a.buffer, o = Se.hexDump(new Uint8Array(n, t + 12, 16)), l = a.getUint32(28); let c = null, h = null; if (r === 0) { if (e - 32 < l || l < 22) return { offset: t, size: e }; h = new Uint8Array(n, t + 32, l); } else if (r === 1) { if (!l || s < t + 32 + l * 16 + 16) return { offset: t, size: e }; c = []; for (let u = 0; u < l; u++) c.push(new Uint8Array(n, t + 32 + u * 16, 16)); } return { version: r, systemId: o, kids: c, data: h, offset: t, size: e }; } let at = {}; class et { static clearKeyUriToKeyIdMap() { at = {}; } 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 de.FAIRPLAY: case de.WIDEVINE: case de.PLAYREADY: case de.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 = Gn(e); return new et(this.method, this.uri, "identity", this.keyFormatVersions, s); } const t = fn(this.uri); if (t) switch (this.keyFormat) { case de.WIDEVINE: this.pssh = t, t.length >= 22 && (this.keyId = t.subarray(t.length - 22, t.length - 6)); break; case de.PLAYREADY: { const s = new Uint8Array([154, 4, 240, 121, 152, 64, 66, 134, 171, 146, 230, 91, 224, 136, 95, 149]); this.pssh = Un(s, null, t), this.keyId = Hi(t); 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 = at[this.uri]; if (!s) { const i = Object.keys(at).length % Number.MAX_SAFE_INTEGER; s = new Uint8Array(16), new DataView(s.buffer, 12, 4).setUint32(0, i), at[this.uri] = s; } this.keyId = s; } return this; } } function Gn(a) { const e = new Uint8Array(16); for (let t = 12; t < 16; t++) e[t] = a >> 8 * (15 - t) & 255; return e; } const tr = /\{\$([a-zA-Z0-9-_]+)\}/g; functio