UNPKG

vvpf

Version:

hls.js player component for Vue3

1,507 lines 765 kB
import { computed as pt, openBlock as re, createElementBlock as oe, normalizeClass as ft, normalizeStyle as gt, ref as rt, onUnmounted as xn, createElementVNode as B, toDisplayString as fe, unref as dt, defineComponent as zt, withDirectives as Re, createVNode as ce, createTextVNode as Ge, vShow as be, useCssVars as Di, nextTick as An, getCurrentInstance as Xa, createCommentVNode as ve, reactive as Es, withModifiers as Qa, watch as Ln, onMounted as In, Transition as li, withCtx as ci, Fragment as Ts, renderList as vs, useAttrs as Za, mergeProps as Ja, createBlock as eo, withKeys as wt } from "vue"; function to(a, e, t) { var s = t || {}, i = s.noTrailing, r = i === void 0 ? !1 : i, n = s.noLeading, o = n === void 0 ? !1 : n, c = s.debounceMode, l = c === void 0 ? void 0 : c, u, d = !1, h = 0; function f() { u && clearTimeout(u); } function g(p) { var E = p || {}, v = E.upcomingOnly, T = v === void 0 ? !1 : v; f(), d = !T; } function y() { for (var p = arguments.length, E = new Array(p), v = 0; v < p; v++) E[v] = arguments[v]; var T = this, S = Date.now() - h; if (d) return; function x() { h = Date.now(), e.apply(T, E); } function _() { u = void 0; } !o && l && !u && x(), f(), l === void 0 && S > a ? o ? (h = Date.now(), r || (u = setTimeout(l ? _ : x, a))) : x() : r !== !0 && (u = setTimeout(l ? _ : x, l === void 0 ? a - S : a)); } return y.cancel = g, y; } function rr(a, e, t) { var s = t || {}, i = s.atBegin, r = i === void 0 ? !1 : i; return to(a, e, { debounceMode: r !== !1 }); } const N = Number.isFinite || function(a) { return typeof a == "number" && isFinite(a); }, so = Number.isSafeInteger || function(a) { return typeof a == "number" && Math.abs(a) <= io; }, io = Number.MAX_SAFE_INTEGER || 9007199254740991; let H = /* @__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.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR = "keySystemDestroyMediaKeysError", a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR = "keySystemDestroyCloseSessionError", a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR = "keySystemDestroyRemoveSessionError", 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.ASSET_LIST_LOAD_ERROR = "assetListLoadError", a.ASSET_LIST_LOAD_TIMEOUT = "assetListLoadTimeout", a.ASSET_LIST_PARSING_ERROR = "assetListParsingError", a.INTERSTITIAL_ASSET_ITEM_ERROR = "interstitialAssetItemError", a.INTERNAL_EXCEPTION = "internalException", a.INTERNAL_ABORTED = "aborted", a.ATTACH_MEDIA_ERROR = "attachMediaError", a.UNKNOWN = "unknown", a; }({}), m = /* @__PURE__ */ function(a) { return a.MEDIA_ATTACHING = "hlsMediaAttaching", a.MEDIA_ATTACHED = "hlsMediaAttached", a.MEDIA_DETACHING = "hlsMediaDetaching", a.MEDIA_DETACHED = "hlsMediaDetached", a.MEDIA_ENDED = "hlsMediaEnded", a.STALL_RESOLVED = "hlsStallResolved", 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.BUFFERED_TO_END = "hlsBufferedToEnd", 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.AUDIO_TRACK_UPDATED = "hlsAudioTrackUpdated", 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_TRACK_UPDATED = "hlsSubtitleTrackUpdated", 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.ASSET_LIST_LOADING = "hlsAssetListLoading", a.ASSET_LIST_LOADED = "hlsAssetListLoaded", a.INTERSTITIALS_UPDATED = "hlsInterstitialsUpdated", a.INTERSTITIALS_BUFFERED_TO_BOUNDARY = "hlsInterstitialsBufferedToBoundary", a.INTERSTITIAL_ASSET_PLAYER_CREATED = "hlsInterstitialAssetPlayerCreated", a.INTERSTITIAL_STARTED = "hlsInterstitialStarted", a.INTERSTITIAL_ASSET_STARTED = "hlsInterstitialAssetStarted", a.INTERSTITIAL_ASSET_ENDED = "hlsInterstitialAssetEnded", a.INTERSTITIAL_ASSET_ERROR = "hlsInterstitialAssetError", a.INTERSTITIAL_ENDED = "hlsInterstitialEnded", a.INTERSTITIALS_PRIMARY_RESUMED = "hlsInterstitialsPrimaryResumed", a.PLAYOUT_LIMIT_REACHED = "hlsPlayoutLimitReached", a.EVENT_CUE_ENTER = "hlsEventCueEnter", a; }({}); var Q = { MANIFEST: "manifest", LEVEL: "level", AUDIO_TRACK: "audioTrack", SUBTITLE_TRACK: "subtitleTrack" }, G = { MAIN: "main", AUDIO: "audio", SUBTITLE: "subtitle" }; class vt { // About half of the estimated value will be from the last |halfLife| samples by weight. constructor(e, t = 0, s = 0) { this.halfLife = void 0, this.alpha_ = void 0, this.estimate_ = void 0, this.totalWeight_ = void 0, this.halfLife = e, this.alpha_ = e ? Math.exp(Math.log(0.5) / e) : 0, this.estimate_ = t, this.totalWeight_ = s; } sample(e, t) { const s = Math.pow(this.alpha_, e); this.estimate_ = t * (1 - s) + s * this.estimate_, this.totalWeight_ += e; } getTotalWeight() { return this.totalWeight_; } getEstimate() { if (this.alpha_) { const e = 1 - Math.pow(this.alpha_, this.totalWeight_); if (e) return this.estimate_ / e; } return this.estimate_; } } class ro { constructor(e, t, s, i = 100) { this.defaultEstimate_ = void 0, this.minWeight_ = void 0, this.minDelayMs_ = void 0, this.slow_ = void 0, this.fast_ = void 0, this.defaultTTFB_ = void 0, this.ttfb_ = void 0, this.defaultEstimate_ = s, this.minWeight_ = 1e-3, this.minDelayMs_ = 50, this.slow_ = new vt(e), this.fast_ = new vt(t), this.defaultTTFB_ = i, this.ttfb_ = new vt(e); } update(e, t) { const { slow_: s, fast_: i, ttfb_: r } = this; s.halfLife !== e && (this.slow_ = new vt(e, s.getEstimate(), s.getTotalWeight())), i.halfLife !== t && (this.fast_ = new vt(t, i.getEstimate(), i.getTotalWeight())), r.halfLife !== e && (this.ttfb_ = new vt(e, r.getEstimate(), r.getTotalWeight())); } sample(e, t) { e = Math.max(e, this.minDelayMs_); const s = 8 * t, i = e / 1e3, r = s / i; this.fast_.sample(i, r), this.slow_.sample(i, r); } sampleTTFB(e) { const t = e / 1e3, s = Math.sqrt(2) * Math.exp(-Math.pow(t, 2) / 2); this.ttfb_.sample(s, Math.max(e, 5)); } canEstimate() { return this.fast_.getTotalWeight() >= this.minWeight_; } getEstimate() { return this.canEstimate() ? Math.min(this.fast_.getEstimate(), this.slow_.getEstimate()) : this.defaultEstimate_; } getEstimateTTFB() { return this.ttfb_.getTotalWeight() >= this.minWeight_ ? this.ttfb_.getEstimate() : this.defaultTTFB_; } get defaultEstimate() { return this.defaultEstimate_; } destroy() { } } function no(a, e, t) { return (e = oo(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 s in t) ({}).hasOwnProperty.call(t, s) && (a[s] = t[s]); } return a; }, ae.apply(null, arguments); } function nr(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 se(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e] != null ? arguments[e] : {}; e % 2 ? nr(Object(t), !0).forEach(function(s) { no(a, s, t[s]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(t)) : nr(Object(t)).forEach(function(s) { Object.defineProperty(a, s, Object.getOwnPropertyDescriptor(t, s)); }); } return a; } function ao(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 oo(a) { var e = ao(a, "string"); return typeof e == "symbol" ? e : e + ""; } class Ze { constructor(e, t) { this.trace = void 0, this.debug = void 0, this.log = void 0, this.warn = void 0, this.info = void 0, this.error = void 0; const s = `[${e}]:`; this.trace = st, this.debug = t.debug.bind(null, s), this.log = t.log.bind(null, s), this.warn = t.warn.bind(null, s), this.info = t.info.bind(null, s), this.error = t.error.bind(null, s); } } const st = function() { }, lo = { trace: st, debug: st, log: st, warn: st, info: st, error: st }; function ui() { return ae({}, lo); } function co(a, e) { const t = self.console[a]; return t ? t.bind(self.console, `${e ? "[" + e + "] " : ""}[${a}] >`) : st; } function ar(a, e, t) { return e[a] ? e[a].bind(e) : co(a, t); } const di = ui(); function uo(a, e, t) { const s = ui(); if (typeof console == "object" && a === !0 || typeof a == "object") { const i = [ // Remove out from list here to hard-disable a log-level // 'trace', "debug", "log", "info", "warn", "error" ]; i.forEach((r) => { s[r] = ar(r, a, t); }); try { s.log(`Debug logs enabled for "${e}" in hls.js version 1.6.2`); } catch { return ui(); } i.forEach((r) => { di[r] = ar(r, a); }); } else ae(di, s); return s; } const Z = di; function nt(a = !0) { return typeof self > "u" ? void 0 : (a || !self.MediaSource) && self.ManagedMediaSource || self.MediaSource || self.WebKitMediaSource; } function ho(a) { return typeof self < "u" && a === self.ManagedMediaSource; } function Rn(a, e) { const t = Object.keys(a), s = Object.keys(e), i = t.length, r = s.length; return !i || !r || i === r && !t.some((n) => s.indexOf(n) === -1); } function _e(a, e = !1) { if (typeof TextDecoder < "u") { const l = new TextDecoder("utf-8").decode(a); if (e) { const u = l.indexOf("\0"); return u !== -1 ? l.substring(0, u) : l; } return l.replace(/\0/g, ""); } const t = a.length; let s, i, r, n = "", o = 0; for (; o < t; ) { if (s = a[o++], s === 0 && e) return n; 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: n += String.fromCharCode(s); break; case 12: case 13: i = a[o++], n += String.fromCharCode((s & 31) << 6 | i & 63); break; case 14: i = a[o++], r = a[o++], n += String.fromCharCode((s & 15) << 12 | (i & 63) << 6 | (r & 63) << 0); break; } } return n; } const Be = { 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; } }; function fo(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var Ms = { exports: {} }, or; function go() { return or || (or = 1, 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(c, l, u) { if (u = u || {}, c = c.trim(), l = l.trim(), !l) { if (!u.alwaysNormalize) return c; var d = o.parseURL(c); if (!d) throw new Error("Error trying to parse base URL."); return d.path = o.normalizePath( d.path ), o.buildURLFromParts(d); } var h = o.parseURL(l); if (!h) throw new Error("Error trying to parse relative URL."); if (h.scheme) return u.alwaysNormalize ? (h.path = o.normalizePath(h.path), o.buildURLFromParts(h)) : l; var f = o.parseURL(c); 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 y = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: f.scheme, netLoc: h.netLoc, path: null, params: h.params, query: h.query, fragment: h.fragment }; if (!h.netLoc && (y.netLoc = f.netLoc, h.path[0] !== "/")) if (!h.path) y.path = f.path, h.params || (y.params = f.params, h.query || (y.query = f.query)); else { var p = f.path, E = p.substring(0, p.lastIndexOf("/") + 1) + h.path; y.path = o.normalizePath(E); } return y.path === null && (y.path = u.alwaysNormalize ? o.normalizePath(h.path) : h.path), o.buildURLFromParts(y); }, parseURL: function(c) { var l = s.exec(c); return l ? { scheme: l[1] || "", netLoc: l[2] || "", path: l[3] || "", params: l[4] || "", query: l[5] || "", fragment: l[6] || "" } : null; }, normalizePath: function(c) { for (c = c.split("").reverse().join("").replace(r, ""); c.length !== (c = c.replace(n, "")).length; ) ; return c.split("").reverse().join(""); }, buildURLFromParts: function(c) { return c.scheme + c.netLoc + c.path + c.params + c.query + c.fragment; } }; a.exports = o; })(); }(Ms)), Ms.exports; } var Ci = go(); class Pi { 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 ne = { AUDIO: "audio", VIDEO: "video", AUDIOVIDEO: "audiovideo" }; class bn { constructor(e) { this._byteRange = null, this._url = null, this._stats = null, this._streams = null, this.base = void 0, this.relurl = void 0, typeof e == "string" && (e = { url: e }), this.base = e, po(this, "stats"); } // 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 baseurl() { return this.base.url; } get byteRange() { return this._byteRange === null ? [] : this._byteRange; } get byteRangeStartOffset() { return this.byteRange[0]; } get byteRangeEndOffset() { return this.byteRange[1]; } get elementaryStreams() { return this._streams === null && (this._streams = { [ne.AUDIO]: null, [ne.VIDEO]: null, [ne.AUDIOVIDEO]: null }), this._streams; } set elementaryStreams(e) { this._streams = e; } get hasStats() { return this._stats !== null; } get hasStreams() { return this._streams !== null; } get stats() { return this._stats === null && (this._stats = new Pi()), this._stats; } set stats(e) { this._stats = e; } get url() { return !this._url && this.baseurl && this.relurl && (this._url = Ci.buildAbsoluteURL(this.baseurl, this.relurl, { alwaysNormalize: !0 })), this._url || ""; } set url(e) { this._url = e; } clearElementaryStreamInfo() { const { elementaryStreams: e } = this; e[ne.AUDIO] = null, e[ne.VIDEO] = null, e[ne.AUDIOVIDEO] = null; } } function pe(a) { return a.sn !== "initSegment"; } class Ns extends bn { constructor(e, t) { super(t), this._decryptdata = null, this._programDateTime = null, this._ref = null, this._bitrate = void 0, this.rawProgramDateTime = 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.playlistOffset = 0, this.deltaPTS = void 0, this.maxStartPTS = void 0, this.minEndPTS = void 0, 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 byteLength() { if (this.hasStats) { const e = this.stats.total; if (e) return e; } if (this.byteRange) { const e = this.byteRange[0], t = this.byteRange[1]; if (N(e) && N(t)) return t - e; } return null; } get bitrate() { return this.byteLength ? this.byteLength * 8 / this.duration : this._bitrate ? this._bitrate : null; } set bitrate(e) { this._bitrate = 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) return null; const e = N(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; } get programDateTime() { return this._programDateTime === null && this.rawProgramDateTime && (this.programDateTime = Date.parse(this.rawProgramDateTime)), this._programDateTime; } set programDateTime(e) { if (!N(e)) { this._programDateTime = this.rawProgramDateTime = null; return; } this._programDateTime = e; } get ref() { return pe(this) ? (this._ref || (this._ref = { base: this.base, start: this.start, duration: this.duration, sn: this.sn, programDateTime: this.programDateTime }), this._ref) : null; } addStart(e) { this.setStart(this.start + e); } setStart(e) { this.start = e, this._ref && (this._ref.start = e); } setDuration(e) { this.duration = e, this._ref && (this._ref.duration = e); } 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, c = o[e]; if (!c) { o[e] = { startPTS: t, endPTS: s, startDTS: i, endDTS: r, partial: n }; return; } c.startPTS = Math.min(c.startPTS, t), c.endPTS = Math.max(c.endPTS, s), c.startDTS = Math.min(c.startDTS, i), c.endDTS = Math.max(c.endDTS, r); } } class mo extends bn { 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.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); } } function _n(a, e) { const t = Object.getPrototypeOf(a); if (t) { const s = Object.getOwnPropertyDescriptor(t, e); return s || _n(t, e); } } function po(a, e) { const t = _n(a, e); t && (t.enumerable = !0, Object.defineProperty(a, e, t)); } const Ss = Math.pow(2, 32) - 1, yo = [].push, Dn = { video: 1, audio: 2, id3: 3, text: 4 }; function he(a) { return String.fromCharCode.apply(null, a); } function Cn(a, e) { const t = a[e] << 8 | a[e + 1]; return t < 0 ? 65536 + t : t; } function Y(a, e) { const t = Pn(a, e); return t < 0 ? 4294967296 + t : t; } function lr(a, e) { let t = Y(a, e); return t *= Math.pow(2, 32), t += Y(a, e + 4), t; } function Pn(a, e) { return a[e] << 24 | a[e + 1] << 16 | a[e + 2] << 8 | a[e + 3]; } function Bs(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 Eo(a) { const e = a.byteLength; for (let t = 0; t < e; ) { const s = Y(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 j(a, e) { const t = []; if (!e.length) return t; const s = a.byteLength; for (let i = 0; i < s; ) { const r = Y(a, i), n = he(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 c = j(a.subarray(i + 8, o), e.slice(1)); c.length && yo.apply(t, c); } i = o; } return t; } function To(a) { const e = [], t = a[0]; let s = 8; const i = Y(a, s); s += 4; let r = 0, n = 0; t === 0 ? (r = Y(a, s), n = Y(a, s + 4), s += 8) : (r = lr(a, s), n = lr(a, s + 8), s += 16), s += 2; let o = a.length + n; const c = Cn(a, s); s += 2; for (let l = 0; l < c; l++) { let u = s; const d = Y(a, u); u += 4; const h = d & 2147483647; if ((d & 2147483648) >>> 31 === 1) return Z.warn("SIDX has hierarchical references (not supported)"), null; const g = Y(a, u); u += 4, e.push({ referenceSize: h, subsegmentDuration: g, // unscaled info: { duration: g / i, start: o, end: o + h - 1 } }), o += h, u += 4, s = u; } return { earliestPresentationTime: r, timescale: i, version: t, referencesCount: c, references: e }; } function kn(a) { const e = [], t = j(a, ["moov", "trak"]); for (let i = 0; i < t.length; i++) { const r = t[i], n = j(r, ["tkhd"])[0]; if (n) { let o = n[0]; const c = Y(n, o === 0 ? 12 : 20), l = j(r, ["mdia", "mdhd"])[0]; if (l) { o = l[0]; const u = Y(l, o === 0 ? 12 : 20), d = j(r, ["mdia", "hdlr"])[0]; if (d) { const h = he(d.subarray(8, 12)), f = { soun: ne.AUDIO, vide: ne.VIDEO }[h], g = j(r, ["mdia", "minf", "stbl", "stsd"])[0], y = vo(g); f ? (e[c] = { timescale: u, type: f, stsd: y }, e[f] = se({ timescale: u, id: c }, y)) : e[c] = { timescale: u, type: h, stsd: y }; } } } } return j(a, ["moov", "mvex", "trex"]).forEach((i) => { const r = Y(i, 4), n = e[r]; n && (n.default = { duration: Y(i, 12), flags: Y(i, 20) }); }), e; } function vo(a) { const e = a.subarray(8), t = e.subarray(8 + 78), s = he(e.subarray(4, 8)); let i = s, r; const n = s === "enca" || s === "encv"; if (n) { const l = j(e, [s])[0].subarray(s === "enca" ? 28 : 78); j(l, ["sinf"]).forEach((d) => { const h = j(d, ["schm"])[0]; if (h) { const f = he(h.subarray(4, 8)); if (f === "cbcs" || f === "cenc") { const g = j(d, ["frma"])[0]; g && (i = he(g)); } } }); } const o = i; switch (i) { case "avc1": case "avc2": case "avc3": case "avc4": { const c = j(t, ["avcC"])[0]; c && c.length > 3 && (i += "." + Zt(c[1]) + Zt(c[2]) + Zt(c[3]), r = Qt(o === "avc1" ? "dva1" : "dvav", t)); break; } case "mp4a": { const c = j(e, [s])[0], l = j(c.subarray(28), ["esds"])[0]; if (l && l.length > 7) { let u = 4; if (l[u++] !== 3) break; u = Us(l, u), u += 2; const d = l[u++]; if (d & 128 && (u += 2), d & 64 && (u += l[u++]), l[u++] !== 4) break; u = Us(l, u); const h = l[u++]; if (h === 64) i += "." + Zt(h); else break; if (u += 12, l[u++] !== 5) break; u = Us(l, u); const f = l[u++]; let g = (f & 248) >> 3; g === 31 && (g += 1 + ((f & 7) << 3) + ((l[u] & 224) >> 5)), i += "." + g; } break; } case "hvc1": case "hev1": { const c = j(t, ["hvcC"])[0]; if (c && c.length > 12) { const l = c[1], u = ["", "A", "B", "C"][l >> 6], d = l & 31, h = Y(c, 2), f = (l & 32) >> 5 ? "H" : "L", g = c[12], y = c.subarray(6, 12); i += "." + u + d, i += "." + h.toString(16).toUpperCase(), i += "." + f + g; let p = ""; for (let E = y.length; E--; ) { const v = y[E]; (v || p) && (p = "." + v.toString(16).toUpperCase() + p); } i += p; } r = Qt(o == "hev1" ? "dvhe" : "dvh1", t); break; } case "dvh1": case "dvhe": case "dvav": case "dva1": case "dav1": { i = Qt(i, t) || i; break; } case "vp09": { const c = j(t, ["vpcC"])[0]; if (c && c.length > 6) { const l = c[4], u = c[5], d = c[6] >> 4 & 15; i += "." + Ne(l) + "." + Ne(u) + "." + Ne(d); } break; } case "av01": { const c = j(t, ["av1C"])[0]; if (c && c.length > 2) { const l = c[1] >>> 5, u = c[1] & 31, d = c[2] >>> 7 ? "H" : "M", h = (c[2] & 64) >> 6, f = (c[2] & 32) >> 5, g = l === 2 && h ? f ? 12 : 10 : h ? 10 : 8, y = (c[2] & 16) >> 4, p = (c[2] & 8) >> 3, E = (c[2] & 4) >> 2, v = c[2] & 3, T = 1, S = 1, x = 1, _ = 0; i += "." + l + "." + Ne(u) + d + "." + Ne(g) + "." + y + "." + p + E + v + "." + Ne(T) + "." + Ne(S) + "." + Ne(x) + "." + _, r = Qt("dav1", t); } break; } } return { codec: i, encrypted: n, supplemental: r }; } function Qt(a, e) { const t = j(e, ["dvvC"]), s = t.length ? t[0] : j(e, ["dvcC"])[0]; if (s) { const i = s[2] >> 1 & 127, r = s[2] << 5 & 32 | s[3] >> 3 & 31; return a + "." + Ne(i) + "." + Ne(r); } } function Us(a, e) { const t = e + 5; for (; a[e++] & 128 && e < t; ) ; return e; } function Zt(a) { return ("0" + a.toString(16).toUpperCase()).slice(-2); } function Ne(a) { return (a < 10 ? "0" : "") + a; } function So(a, e) { if (!a || !e) return a; const t = e.keyId; return t && e.isCommonEncryption && j(a, ["moov", "trak"]).forEach((i) => { const n = j(i, ["mdia", "minf", "stbl", "stsd"])[0].subarray(8); let o = j(n, ["enca"]); const c = o.length > 0; c || (o = j(n, ["encv"])), o.forEach((l) => { const u = c ? l.subarray(28) : l.subarray(78); j(u, ["sinf"]).forEach((h) => { const f = wn(h); if (f) { const g = f.subarray(8, 24); g.some((y) => y !== 0) || (Z.log(`[eme] Patching keyId in 'enc${c ? "a" : "v"}>sinf>>tenc' box: ${Be.hexDump(g)} -> ${Be.hexDump(t)}`), f.set(t, 8)); } }); }); }), a; } function wn(a) { const e = j(a, ["schm"])[0]; if (e) { const t = he(e.subarray(4, 8)); if (t === "cbcs" || t === "cenc") return j(a, ["schi", "tenc"])[0]; } return null; } function xo(a, e) { return j(e, ["moof", "traf"]).reduce((t, s) => { const i = j(s, ["tfdt"])[0], r = i[0], n = j(s, ["tfhd"]).reduce((o, c) => { const l = Y(c, 4), u = a[l]; if (u) { let d = Y(i, 4); if (r === 1) { if (d === Ss) return Z.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"), o; d *= Ss + 1, d += Y(i, 8); } const h = u.timescale || 9e4, f = d / h; if (N(f) && (o === null || f < o)) return f; } return o; }, null); return n !== null && N(n) && (t === null || n < t) ? n : t; }, null); } function Ao(a, e) { let t = 0, s = 0, i = 0; const r = j(a, ["moof", "traf"]); for (let n = 0; n < r.length; n++) { const o = r[n], c = j(o, ["tfhd"])[0], l = Y(c, 4), u = e[l]; if (!u) continue; const d = u.default, h = Y(c, 0) | (d == null ? void 0 : d.flags); let f = d == null ? void 0 : d.duration; h & 8 && (h & 2 ? f = Y(c, 12) : f = Y(c, 8)); const g = u.timescale || 9e4, y = j(o, ["trun"]); for (let p = 0; p < y.length; p++) { if (t = Lo(y[p]), !t && f) { const E = Y(y[p], 4); t = f * E; } u.type === ne.VIDEO ? s += t / g : u.type === ne.AUDIO && (i += t / g); } } if (s === 0 && i === 0) { let n = 1 / 0, o = 0, c = 0; const l = j(a, ["sidx"]); for (let u = 0; u < l.length; u++) { const d = To(l[u]); if (d != null && d.references) { n = Math.min(n, d.earliestPresentationTime / d.timescale); const h = d.references.reduce((f, g) => f + g.info.duration || 0, 0); o = Math.max(o, h + d.earliestPresentationTime / d.timescale), c = o - n; } } if (c && N(c)) return c; } return s || i; } function Lo(a) { const e = Y(a, 0); let t = 8; e & 1 && (t += 4), e & 4 && (t += 4); let s = 0; const i = Y(a, 4); for (let r = 0; r < i; r++) { if (e & 256) { const n = Y(a, t); s += n, t += 4; } e & 512 && (t += 4), e & 1024 && (t += 4), e & 2048 && (t += 4); } return s; } function Io(a, e, t) { j(e, ["moof", "traf"]).forEach((s) => { j(s, ["tfhd"]).forEach((i) => { const r = Y(i, 4), n = a[r]; if (!n) return; const o = n.timescale || 9e4; j(s, ["tfdt"]).forEach((c) => { const l = c[0], u = t * o; if (u) { let d = Y(c, 4); if (l === 0) d -= u, d = Math.max(d, 0), Bs(c, 4, d); else { d *= Math.pow(2, 32), d += Y(c, 8), d -= u, d = Math.max(d, 0); const h = Math.floor(d / (Ss + 1)), f = Math.floor(d % (Ss + 1)); Bs(c, 4, h), Bs(c, 8, f); } } }); }); }); } function Ro(a) { const e = { valid: null, remainder: null }, t = j(a, ["moof"]); if (t.length < 2) return e.remainder = a, e; const s = t[t.length - 1]; return e.valid = a.slice(0, s.byteOffset - 8), e.remainder = a.slice(s.byteOffset - 8), e; } function ke(a, e) { const t = new Uint8Array(a.length + e.length); return t.set(a), t.set(e, a.length), t; } function cr(a, e) { const t = [], s = e.samples, i = e.timescale, r = e.id; let n = !1; return j(s, ["moof"]).map((c) => { const l = c.byteOffset - 8; j(c, ["traf"]).map((d) => { const h = j(d, ["tfdt"]).map((f) => { const g = f[0]; let y = Y(f, 4); return g === 1 && (y *= Math.pow(2, 32), y += Y(f, 8)), y / i; })[0]; return h !== void 0 && (a = h), j(d, ["tfhd"]).map((f) => { const g = Y(f, 4), y = Y(f, 0) & 16777215, p = (y & 1) !== 0, E = (y & 2) !== 0, v = (y & 8) !== 0; let T = 0; const S = (y & 16) !== 0; let x = 0; const _ = (y & 32) !== 0; let A = 8; g === r && (p && (A += 8), E && (A += 4), v && (T = Y(f, A), A += 4), S && (x = Y(f, A), A += 4), _ && (A += 4), e.type === "video" && (n = ks(e.codec)), j(d, ["trun"]).map((b) => { const C = b[0], L = Y(b, 0) & 16777215, w = (L & 1) !== 0; let F = 0; const X = (L & 4) !== 0, W = (L & 256) !== 0; let K = 0; const U = (L & 512) !== 0; let V = 0; const $ = (L & 1024) !== 0, O = (L & 2048) !== 0; let D = 0; const k = Y(b, 4); let M = 8; w && (F = Y(b, M), M += 4), X && (M += 4); let q = F + l; for (let J = 0; J < k; J++) { if (W ? (K = Y(b, M), M += 4) : K = T, U ? (V = Y(b, M), M += 4) : V = x, $ && (M += 4), O && (C === 0 ? D = Y(b, M) : D = Pn(b, M), M += 4), e.type === ne.VIDEO) { let te = 0; for (; te < V; ) { const le = Y(s, q); if (q += 4, bo(n, s[q])) { const Te = s.subarray(q, q + le); ki(Te, n ? 2 : 1, a + D / i, t); } q += le, te += le + 4; } } a += K / i; } })); }); }); }), t; } function ks(a) { if (!a) return !1; const e = a.substring(0, 4); return e === "hvc1" || e === "hev1" || // Dolby Vision e === "dvh1" || e === "dvhe"; } function bo(a, e) { if (a) { const t = e >> 1 & 63; return t === 39 || t === 40; } else return (e & 31) === 6; } function ki(a, e, t, s) { const i = On(a); let r = 0; r += e; let n = 0, o = 0, 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 l = i.length - r; let u = r; if (o < l) r += o; else if (o > l) { Z.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`); break; } if (n === 4) { if (i[u++] === 181) { const h = Cn(i, u); if (u += 2, h === 49) { const f = Y(i, u); if (u += 4, f === 1195456820) { const g = i[u++]; if (g === 3) { const y = i[u++], p = 31 & y, E = 64 & y, v = E ? 2 + p * 3 : 0, T = new Uint8Array(v); if (E) { T[0] = y; for (let S = 1; S < v; S++) T[S] = i[u++]; } s.push({ type: g, payloadType: n, pts: t, bytes: T }); } } } } } else if (n === 5 && o > 16) { const d = []; for (let g = 0; g < 16; g++) { const y = i[u++].toString(16); d.push(y.length == 1 ? "0" + y : y), (g === 3 || g === 5 || g === 7 || g === 9) && d.push("-"); } const h = o - 16, f = new Uint8Array(h); for (let g = 0; g < h; g++) f[g] = i[u++]; s.push({ payloadType: n, pts: t, uuid: d.join(""), userData: _e(f), userDataBytes: f }); } } } function On(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 _o(a) { const e = a[0]; let t = "", s = "", i = 0, r = 0, n = 0, o = 0, c = 0, l = 0; if (e === 0) { for (; he(a.subarray(l, l + 1)) !== "\0"; ) t += he(a.subarray(l, l + 1)), l += 1; for (t += he(a.subarray(l, l + 1)), l += 1; he(a.subarray(l, l + 1)) !== "\0"; ) s += he(a.subarray(l, l + 1)), l += 1; s += he(a.subarray(l, l + 1)), l += 1, i = Y(a, 12), r = Y(a, 16), o = Y(a, 20), c = Y(a, 24), l = 28; } else if (e === 1) { l += 4, i = Y(a, l), l += 4; const d = Y(a, l); l += 4; const h = Y(a, l); for (l += 4, n = 2 ** 32 * d + h, so(n) || (n = Number.MAX_SAFE_INTEGER, Z.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")), o = Y(a, l), l += 4, c = Y(a, l), l += 4; he(a.subarray(l, l + 1)) !== "\0"; ) t += he(a.subarray(l, l + 1)), l += 1; for (t += he(a.subarray(l, l + 1)), l += 1; he(a.subarray(l, l + 1)) !== "\0"; ) s += he(a.subarray(l, l + 1)), l += 1; s += he(a.subarray(l, l + 1)), l += 1; } const u = a.subarray(l, a.byteLength); return { schemeIdUri: t, value: s, timeScale: i, presentationTime: n, presentationTimeDelta: r, eventDuration: o, id: c, payload: u }; } function Do(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 Co(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), Do( [112, 115, 115, 104], new Uint8Array([ s, 0, 0, 0 // Flags ]), a, // 16 bytes r, i, n, t || new Uint8Array() ); } function Po(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 = ko(i); e.push(r), s += r.size; } } return e; } function ko(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 = Be.hexDump(new Uint8Array(n, t + 12, 16)), c = a.getUint32(28); let l = null, u = null; if (r === 0) { if (e - 32 < c || c < 22) return { offset: t, size: e }; u = new Uint8Array(n, t + 32, c); } else if (r === 1) { if (!c || s < t + 32 + c * 16 + 16) return { offset: t, size: e }; l = []; for (let d = 0; d < c; d++) l.push(new Uint8Array(n, t + 32 + d * 16, 16)); } return { version: r, systemId: o, kids: l, data: u, offset: t, size: e }; } const Fn = () => /\(Windows.+Firefox\//i.test(navigator.userAgent), _t = { 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, dav1: 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 Mn(a, e) { const t = _t[e]; return !!t && !!t[a.slice(0, 4)]; } function hi(a, e, t = !0) { return !a.split(",").some((s) => !Nn(s, e, t)); } function Nn(a, e, t = !0) { var s; const i = nt(t); return (s = i == null ? void 0 : i.isTypeSupported(Gt(a, e))) != null ? s : !1; } function Gt(a, e) { return `${e}/mp4;codecs=${a}`; } function ur(a) { if (a) { const e = a.substring(0, 4); return _t.video[e]; } return 2; } function xs(a) { const e = Fn(); return a.split(",").reduce((t, s) => { const r = e && ks(s) ? 9 : _t.video[s]; return r ? (r * 2 + t) / (t ? 3 : 2) : (_t.audio[s] + t) / (t ? 2 : 1); }, 0); } const $s = {}; function wo(a, e = !0) { if ($s[a]) return $s[a]; const t = { // Idealy fLaC and Opus would be first (spec-compliant) but // some browsers will report that fLaC is supported then fail. // see: https://bugs.chromium.org/p/chromium/issues/detail?id=1422728 flac: ["flac", "fLaC", "FLAC"], opus: ["opus", "Opus"], // Replace audio codec info if browser does not support mp4a.40.34, // and demuxer can fallback to 'audio/mpeg' or 'audio/mp4;codecs="mp3"' "mp4a.40.34": ["mp3"] }[a]; for (let i = 0; i < t.length; i++) { var s; if (Nn(t[i], "audio", e)) return $s[a] = t[i], t[i]; if (t[i] === "mp3" && (s = nt(e)) != null && s.isTypeSupported("audio/mpeg")) return ""; } return a; } const Oo = /flac|opus|mp4a\.40\.34/i; function As(a, e = !0) { return a.replace(Oo, (t) => wo(t.toLowerCase(), e)); } function Fo(a, e) { const t = []; if (a) { const s = a.split(","); for (let i = 0; i < s.length; i++) Mn(s[i], "video") || t.push(s[i]); } return e && t.push(e), t.join(","); } function ds(a, e) { if (a && (a.length > 4 || ["ac-3", "ec-3", "alac", "fLaC", "Opus"].indexOf(a) !== -1)) return a; if (e) { const t = e.split(","); if (t.length > 1) { if (a) { for (let s = t.length; s--; ) if (t[s].substring(0, 4) === a.substring(0, 4)) return t[s]; } return t[0]; } } return e || a; } function Mo(a) { const e = a.split(","); for (let t = 0; t < e.length; t++) { const s = e[t].split("."); if (s.length > 2) { let i = s.shift() + "."; i += parseInt(s.shift()).toString(16), i += ("000" + parseInt(s.shift()).toString(16)).slice(-4), e[t] = i; } } return e.join(","); } function No(a) { if (a.startsWith("av01.")) { const e = a.split("."), t = ["0", "111", "01", "01", "01", "0"]; for (let s = e.length; s > 4 && s < 10; s++) e[s] = t[s - 4]; return e.join("."); } return a; } function dr(a) { const e = nt(a) || { isTypeSupported: () => !1 }; return { mpeg: e.isTypeSupported("audio/mpeg"), mp3: e.isTypeSupported('audio/mp4; codecs="mp3"'), ac3: e.isTypeSupported('audio/mp4; codecs="ac-3"') }; } function Bn(a) { return a.replace(/^.+codecs=["']?([^"']+).*$/, "$1"); } const Un = { supported: !0, configurations: [], decodingInfoResults: [{ supported: !0, powerEfficient: !0, smooth: !0 }] }; function $n(a, e) { return { supported: !1, configurations: e, decodingInfoResults: [{ supported: !1, smooth: !1, powerEfficient: !1 }], error: a }; } const hr = {}; function Bo(a, e, t, s, i, r) { const n = a.audioCodec ? a.audioGroups : null, o = r == null ? void 0 : r.audioCodec, c = r == null ? void 0 : r.channels, l = c ? parseInt(c) : o ? 1 / 0 : 2; let u = null; if (n != null && n.length) try { n.length === 1 && n[0] ? u = e.groups[n[0]].channels : u = n.reduce((d, h) => { if (h) { const f = e.groups[h]; if (!f) throw new Error(`Audio track group ${h} not found`); Object.keys(f.channels).forEach((g) => { d[g] = (d[g] || 0) + f.channels[g]; }); } return d; }, { 2: 0 }); } catch { return !0; } return a.videoCodec !== void 0 && (a.width > 1920 && a.height > 1088 || a.height > 1920 && a.width > 1088 || a.frameRate > Math.max(s, 30) || a.videoRange !== "SDR" && a.videoRange !== t || a.bitrate > Math.max(i, 8e6)) || !!u && N(l) && Object.keys(u).some((d) => parseInt(d) > l); } function Gn(a, e, t) { const s = a.videoCodec, i = a.audioCodec; if (!s && !i || !t) return Promise.resolve(Un); const r = []; if (s) { const n = { width: a.width, height: a.height, bitrate: Math.ceil(Math.max(a.bitrate * 0.9, a.averageBitrate)), // Assume a framerate of 30fps since MediaCapabilities will not accept Level default of 0. framerate: a.frameRate || 30 }, o = a.videoRange; o !== "SDR" && (n.transferFunction = o.toLowerCase()); const c = s.split(","), l = navigator.userAgent; if (c.some((u) => ks(u)) && Fn()) return Promise.resolve($n(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (${l})`), r)); r.push.apply(r, c.map((u) => ({ type: "media-source", video: se(se({}, n), {}, { contentType: Gt(No(u),