@eluvio/elv-player-js 2.0.50 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,13 @@ const F = Number.isFinite || function(a) {
3
3
  }, ha = Number.isSafeInteger || function(a) {
4
4
  return typeof a == "number" && Math.abs(a) <= ua;
5
5
  }, ua = Number.MAX_SAFE_INTEGER || 9007199254740991;
6
- let U = /* @__PURE__ */ function(a) {
6
+ let U = /* @__PURE__ */ (function(a) {
7
7
  return a.NETWORK_ERROR = "networkError", a.MEDIA_ERROR = "mediaError", a.KEY_SYSTEM_ERROR = "keySystemError", a.MUX_ERROR = "muxError", a.OTHER_ERROR = "otherError", a;
8
- }({}), R = /* @__PURE__ */ function(a) {
8
+ })({}), R = /* @__PURE__ */ (function(a) {
9
9
  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;
10
- }({}), m = /* @__PURE__ */ function(a) {
10
+ })({}), m = /* @__PURE__ */ (function(a) {
11
11
  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;
12
- }({});
12
+ })({});
13
13
  var z = {
14
14
  MANIFEST: "manifest",
15
15
  LEVEL: "level",
@@ -247,7 +247,7 @@ function Sa(a) {
247
247
  }
248
248
  var us = { exports: {} }, Di;
249
249
  function va() {
250
- return Di || (Di = 1, function(a, e) {
250
+ return Di || (Di = 1, (function(a, e) {
251
251
  (function(t) {
252
252
  var s = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, i = /^(?=([^\/?#]*))\1([^]*)$/, r = /(?:\/|^)\.(?=\/)/g, n = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g, o = {
253
253
  // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or //
@@ -321,7 +321,7 @@ function va() {
321
321
  };
322
322
  a.exports = o;
323
323
  })();
324
- }(us)), us.exports;
324
+ })(us)), us.exports;
325
325
  }
326
326
  var Js = va();
327
327
  class ei {
@@ -355,7 +355,7 @@ class Gr {
355
355
  setByteRange(e, t) {
356
356
  const s = e.split("@", 2);
357
357
  let i;
358
- s.length === 1 ? i = (t == null ? void 0 : t.byteRangeEndOffset) || 0 : i = parseInt(s[1]), this._byteRange = [i, parseInt(s[0]) + i];
358
+ s.length === 1 ? i = t?.byteRangeEndOffset || 0 : i = parseInt(s[1]), this._byteRange = [i, parseInt(s[0]) + i];
359
359
  }
360
360
  get baseurl() {
361
361
  return this.base.url;
@@ -854,8 +854,8 @@ function Ca(a, e) {
854
854
  const o = r[n], c = W(o, ["tfhd"])[0], l = K(c, 4), h = e[l];
855
855
  if (!h)
856
856
  continue;
857
- const u = h.default, d = K(c, 0) | (u == null ? void 0 : u.flags);
858
- let g = u == null ? void 0 : u.duration;
857
+ const u = h.default, d = K(c, 0) | u?.flags;
858
+ let g = u?.duration;
859
859
  d & 8 && (d & 2 ? g = K(c, 12) : g = K(c, 8));
860
860
  const f = h.timescale || 9e4, p = W(o, ["trun"]);
861
861
  for (let E = 0; E < p.length; E++) {
@@ -1294,7 +1294,7 @@ function Ns(a, e, t = !0) {
1294
1294
  function Qr(a, e, t = !0) {
1295
1295
  var s;
1296
1296
  const i = We(t);
1297
- return (s = i == null ? void 0 : i.isTypeSupported(St(a, e))) != null ? s : !1;
1297
+ return (s = i?.isTypeSupported(St(a, e))) != null ? s : !1;
1298
1298
  }
1299
1299
  function St(a, e) {
1300
1300
  return `${e}/mp4;codecs=${a}`;
@@ -1421,7 +1421,7 @@ function en(a, e) {
1421
1421
  }
1422
1422
  const Oi = {};
1423
1423
  function Ya(a, e, t, s, i, r) {
1424
- 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;
1424
+ const n = a.audioCodec ? a.audioGroups : null, o = r?.audioCodec, c = r?.channels, l = c ? parseInt(c) : o ? 1 / 0 : 2;
1425
1425
  let h = null;
1426
1426
  if (n != null && n.length)
1427
1427
  try {
@@ -1656,7 +1656,7 @@ const Qa = (a) => {
1656
1656
  };
1657
1657
  }, ae = (a, e) => JSON.stringify(a, Qa(e));
1658
1658
  function Za(a, e, t, s, i) {
1659
- const r = Object.keys(a), n = s == null ? void 0 : s.channels, o = s == null ? void 0 : s.audioCodec, c = i == null ? void 0 : i.videoCodec, l = n && parseInt(n) === 2;
1659
+ const r = Object.keys(a), n = s?.channels, o = s?.audioCodec, c = i?.videoCodec, l = n && parseInt(n) === 2;
1660
1660
  let h = !1, u = !1, d = 1 / 0, g = 1 / 0, f = 1 / 0, p = 1 / 0, E = 0, y = [];
1661
1661
  const {
1662
1662
  preferHDR: S,
@@ -1882,7 +1882,7 @@ class io extends $e {
1882
1882
  const X = A ? h.loaded * 1e3 / O : 0, V = T / 1e3, $ = X ? (P - h.loaded) / X : P * 8 / b + V;
1883
1883
  if ($ <= x)
1884
1884
  return;
1885
- const M = X ? X * 8 : b, G = ((s = (t == null ? void 0 : t.details) || this.hls.latestLevelDetails) == null ? void 0 : s.live) === !0, B = this.hls.config.abrBandWidthUpFactor;
1885
+ const M = X ? X * 8 : b, G = ((s = t?.details || this.hls.latestLevelDetails) == null ? void 0 : s.live) === !0, B = this.hls.config.abrBandWidthUpFactor;
1886
1886
  let k = Number.POSITIVE_INFINITY, w;
1887
1887
  for (w = f - 1; w > g; w--) {
1888
1888
  const Z = D[w].maxBitrate, ee = !D[w].details || G;
@@ -2098,7 +2098,7 @@ class io extends $e {
2098
2098
  if (this.rebufferNotice !== g && (this.rebufferNotice = g, this.info(`${l ? "rebuffering expected" : "buffer is empty"}, optimal quality level ${g}`)), g > -1)
2099
2099
  return g;
2100
2100
  const f = s.levels[n], p = s.loadLevelObj;
2101
- return p && (f == null ? void 0 : f.bitrate) < p.bitrate ? n : s.loadLevel;
2101
+ return p && f?.bitrate < p.bitrate ? n : s.loadLevel;
2102
2102
  }
2103
2103
  getStarvationDelay() {
2104
2104
  const e = this.hls, t = e.media;
@@ -2124,7 +2124,7 @@ class io extends $e {
2124
2124
  if (f.length === 1)
2125
2125
  return 0;
2126
2126
  const S = f[u], T = !!((c = this.hls.latestLevelDetails) != null && c.live), v = E === -1 || h === -1;
2127
- let x, _ = "SDR", A = (S == null ? void 0 : S.frameRate) || 0;
2127
+ let x, _ = "SDR", A = S?.frameRate || 0;
2128
2128
  const {
2129
2129
  audioPreference: b,
2130
2130
  videoPreference: D
@@ -2143,7 +2143,7 @@ class io extends $e {
2143
2143
  } = G;
2144
2144
  P = H, x = B, _ = j ? k[k.length - 1] : k[0], A = w, e = Math.max(e, Y), this.log(`picked start tier ${ae(G)}`);
2145
2145
  } else
2146
- x = S == null ? void 0 : S.codecSet, _ = S == null ? void 0 : S.videoRange;
2146
+ x = S?.codecSet, _ = S?.videoRange;
2147
2147
  const O = g ? g.duration : d ? d.duration : 0, X = this.bwEstimator.getEstimateTTFB() / 1e3, V = [];
2148
2148
  for (let M = s; M >= t; M--) {
2149
2149
  var $;
@@ -2152,7 +2152,7 @@ class io extends $e {
2152
2152
  continue;
2153
2153
  if (y.useMediaCapabilities && !G.supportedResult && !G.supportedPromise) {
2154
2154
  const ee = navigator.mediaCapabilities;
2155
- typeof (ee == null ? void 0 : ee.decodingInfo) == "function" && (Ya(G, L, _, A, e, b) || os(G.videoCodec)) ? (G.supportedPromise = tn(G, L, ee), G.supportedPromise.then((ne) => {
2155
+ typeof ee?.decodingInfo == "function" && (Ya(G, L, _, A, e, b) || os(G.videoCodec)) ? (G.supportedPromise = tn(G, L, ee), G.supportedPromise.then((ne) => {
2156
2156
  if (!this.hls)
2157
2157
  return;
2158
2158
  G.supportedResult = ne;
@@ -2164,7 +2164,7 @@ class io extends $e {
2164
2164
  V.push(M);
2165
2165
  continue;
2166
2166
  }
2167
- const k = G.details, w = (g ? k == null ? void 0 : k.partTarget : k == null ? void 0 : k.averagetargetduration) || O;
2167
+ const k = G.details, w = (g ? k?.partTarget : k?.averagetargetduration) || O;
2168
2168
  let Y;
2169
2169
  B ? Y = o * e : Y = n * e;
2170
2170
  const H = O && i >= O * 2 && r === 0 ? G.averageBitrate : G.maxBitrate, j = this.getTimeToLoadFrag(X, Y, H * w, k === void 0);
@@ -2315,7 +2315,7 @@ function Ki(a) {
2315
2315
  function ss(a, e, t, s) {
2316
2316
  if (!a)
2317
2317
  return !1;
2318
- const i = s == null ? void 0 : s.code, r = e < a.maxNumRetry && (lo(i) || !!t);
2318
+ const i = s?.code, r = e < a.maxNumRetry && (lo(i) || !!t);
2319
2319
  return a.shouldRetry ? a.shouldRetry(a, e, t, s, r) : r;
2320
2320
  }
2321
2321
  function lo(a) {
@@ -2323,16 +2323,13 @@ function lo(a) {
2323
2323
  }
2324
2324
  var fe = {
2325
2325
  DoNothing: 0,
2326
- SendEndCallback: 1,
2327
2326
  SendAlternateToPenaltyBox: 2,
2328
2327
  RemoveAlternatePermanently: 3,
2329
- InsertDiscontinuity: 4,
2330
2328
  RetryRequest: 5
2331
2329
  }, Re = {
2332
2330
  None: 0,
2333
2331
  MoveAllAlternatesMatchingHost: 1,
2334
- MoveAllAlternatesMatchingHDCP: 2,
2335
- SwitchToSDR: 4
2332
+ MoveAllAlternatesMatchingHDCP: 2
2336
2333
  };
2337
2334
  class co extends $e {
2338
2335
  constructor(e) {
@@ -2355,7 +2352,7 @@ class co extends $e {
2355
2352
  this.playlistError = 0;
2356
2353
  }
2357
2354
  getVariantLevelIndex(e) {
2358
- return (e == null ? void 0 : e.type) === N.MAIN ? e.level : this.hls.loadLevel;
2355
+ return e?.type === N.MAIN ? e.level : this.hls.loadLevel;
2359
2356
  }
2360
2357
  onManifestLoading() {
2361
2358
  this.playlistError = 0, this.penalizedRenditions = {};
@@ -2380,6 +2377,7 @@ class co extends $e {
2380
2377
  t.errorAction = xt();
2381
2378
  return;
2382
2379
  }
2380
+ // falls through
2383
2381
  case R.FRAG_GAP:
2384
2382
  case R.FRAG_DECRYPT_ERROR: {
2385
2383
  t.errorAction = this.getFragRetryOrSwitchAction(t), t.errorAction.action = fe.SendAlternateToPenaltyBox;
@@ -2395,7 +2393,7 @@ class co extends $e {
2395
2393
  return;
2396
2394
  case R.LEVEL_LOAD_ERROR:
2397
2395
  case R.LEVEL_LOAD_TIMEOUT:
2398
- typeof (r == null ? void 0 : r.level) == "number" && (t.errorAction = this.getPlaylistRetryOrSwitchAction(t, r.level));
2396
+ typeof r?.level == "number" && (t.errorAction = this.getPlaylistRetryOrSwitchAction(t, r.level));
2399
2397
  return;
2400
2398
  case R.AUDIO_TRACK_LOAD_ERROR:
2401
2399
  case R.AUDIO_TRACK_LOAD_TIMEOUT:
@@ -2411,7 +2409,7 @@ class co extends $e {
2411
2409
  return;
2412
2410
  case R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:
2413
2411
  {
2414
- const l = i.loadLevelObj, h = l == null ? void 0 : l.attrs["HDCP-LEVEL"];
2412
+ const l = i.loadLevelObj, h = l?.attrs["HDCP-LEVEL"];
2415
2413
  h ? t.errorAction = {
2416
2414
  action: fe.SendAlternateToPenaltyBox,
2417
2415
  flags: Re.MoveAllAlternatesMatchingHDCP,
@@ -2635,7 +2633,7 @@ class ho {
2635
2633
  } = this, r = Object.keys(i);
2636
2634
  for (let n = r.length; n--; ) {
2637
2635
  const o = i[r[n]];
2638
- if ((o == null ? void 0 : o.body.type) === t && (!s || o.buffered)) {
2636
+ if (o?.body.type === t && (!s || o.buffered)) {
2639
2637
  const c = o.body;
2640
2638
  if (c.start <= e && e <= c.end)
2641
2639
  return c;
@@ -2650,7 +2648,7 @@ class ho {
2650
2648
  */
2651
2649
  detectEvictedFragments(e, t, s, i, r) {
2652
2650
  this.timeRanges && (this.timeRanges[e] = t);
2653
- const n = (i == null ? void 0 : i.fragment.sn) || -1;
2651
+ const n = i?.fragment.sn || -1;
2654
2652
  Object.keys(this.fragments).forEach((o) => {
2655
2653
  const c = this.fragments[o];
2656
2654
  if (!c || n >= c.body.sn)
@@ -2811,7 +2809,7 @@ class ho {
2811
2809
  return s.length > 0;
2812
2810
  for (let i = s.length; i--; ) {
2813
2811
  const r = t[s[i]];
2814
- if ((r == null ? void 0 : r.body.type) === e)
2812
+ if (r?.body.type === e)
2815
2813
  return !0;
2816
2814
  }
2817
2815
  return !1;
@@ -3461,7 +3459,7 @@ function Us(a, e) {
3461
3459
  if (a.variableList !== null || a.hasVariableRefs) {
3462
3460
  const t = a.variableList;
3463
3461
  return e.replace(an, (s) => {
3464
- const i = s.substring(2, s.length - 1), r = t == null ? void 0 : t[i];
3462
+ const i = s.substring(2, s.length - 1), r = t?.[i];
3465
3463
  return r === void 0 ? (a.playlistParsingError || (a.playlistParsingError = new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)), s) : r;
3466
3464
  });
3467
3465
  }
@@ -3548,11 +3546,11 @@ class oe {
3548
3546
  }
3549
3547
  static parseAttrList(e, t) {
3550
3548
  let s;
3551
- const i = {}, r = '"';
3549
+ const i = {};
3552
3550
  for (Xi.lastIndex = 0; (s = Xi.exec(e)) !== null; ) {
3553
3551
  const n = s[1].trim();
3554
3552
  let o = s[2];
3555
- const c = o.indexOf(r) === 0 && o.lastIndexOf(r) === o.length - 1;
3553
+ const c = o.indexOf('"') === 0 && o.lastIndexOf('"') === o.length - 1;
3556
3554
  let l = !1;
3557
3555
  if (c)
3558
3556
  o = o.slice(1, -1);
@@ -3571,6 +3569,7 @@ class oe {
3571
3569
  case "CLOSED-CAPTIONS":
3572
3570
  if (o === "NONE")
3573
3571
  break;
3572
+ // falls through
3574
3573
  case "ALLOWED-CPC":
3575
3574
  case "CLASS":
3576
3575
  case "ASSOC-LANGUAGE":
@@ -3620,7 +3619,7 @@ function Lo(a) {
3620
3619
  class on {
3621
3620
  constructor(e, t, s = 0) {
3622
3621
  var i;
3623
- if (this.attr = void 0, this.tagAnchor = void 0, this.tagOrder = void 0, this._startDate = void 0, this._endDate = void 0, this._dateAtEnd = void 0, this._cue = void 0, this._badValueForSameId = void 0, this.tagAnchor = (t == null ? void 0 : t.tagAnchor) || null, this.tagOrder = (i = t == null ? void 0 : t.tagOrder) != null ? i : s, t) {
3622
+ if (this.attr = void 0, this.tagAnchor = void 0, this.tagOrder = void 0, this._startDate = void 0, this._endDate = void 0, this._dateAtEnd = void 0, this._cue = void 0, this._badValueForSameId = void 0, this.tagAnchor = t?.tagAnchor || null, this.tagOrder = (i = t?.tagOrder) != null ? i : s, t) {
3624
3623
  const r = t.attr;
3625
3624
  for (const n in r)
3626
3625
  if (Object.prototype.hasOwnProperty.call(e, n) && e[n] !== r[n]) {
@@ -3630,7 +3629,7 @@ class on {
3630
3629
  e = re(new oe({}), r, e);
3631
3630
  }
3632
3631
  if (this.attr = e, t ? (this._startDate = t._startDate, this._cue = t._cue, this._endDate = t._endDate, this._dateAtEnd = t._dateAtEnd) : this._startDate = new Date(e["START-DATE"]), "END-DATE" in this.attr) {
3633
- const r = (t == null ? void 0 : t.endDate) || new Date(this.attr["END-DATE"]);
3632
+ const r = t?.endDate || new Date(this.attr["END-DATE"]);
3634
3633
  F(r.getTime()) && (this._endDate = r);
3635
3634
  }
3636
3635
  }
@@ -3856,9 +3855,9 @@ function Ot(a) {
3856
3855
  } = a, s = e ? [se.FAIRPLAY, se.WIDEVINE, se.PLAYREADY, se.CLEARKEY].filter((i) => !!e[i]) : [];
3857
3856
  return !s[se.WIDEVINE] && t && s.push(se.WIDEVINE), s;
3858
3857
  }
3859
- const ln = function(a) {
3858
+ const ln = (function(a) {
3860
3859
  return is != null && (a = is.navigator) != null && a.requestMediaKeySystemAccess ? self.navigator.requestMediaKeySystemAccess.bind(self.navigator) : null;
3861
- }();
3860
+ })();
3862
3861
  function Co(a, e, t, s) {
3863
3862
  let i;
3864
3863
  switch (a) {
@@ -4782,7 +4781,7 @@ class li extends nn {
4782
4781
  }
4783
4782
  "payload" in r && (this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`), this.hls.trigger(m.FRAG_LOADED, r)), this._handleFragmentLoadComplete(r);
4784
4783
  }).catch((r) => {
4785
- this.state === C.STOPPED || this.state === C.ERROR || (this.warn(`Frag error: ${(r == null ? void 0 : r.message) || r}`), this.resetFragmentLoading(e));
4784
+ this.state === C.STOPPED || this.state === C.ERROR || (this.warn(`Frag error: ${r?.message || r}`), this.resetFragmentLoading(e));
4786
4785
  });
4787
4786
  }
4788
4787
  clearTrackerIfNeeded(e) {
@@ -4814,7 +4813,7 @@ class li extends nn {
4814
4813
  }
4815
4814
  waitForLive(e) {
4816
4815
  const t = e.details;
4817
- return (t == null ? void 0 : t.live) && t.type !== "EVENT" && (this.levelLastLoaded !== e || t.expired);
4816
+ return t?.live && t.type !== "EVENT" && (this.levelLastLoaded !== e || t.expired);
4818
4817
  }
4819
4818
  flushMainBuffer(e, t, s = null) {
4820
4819
  if (!(e - t))
@@ -4828,7 +4827,7 @@ class li extends nn {
4828
4827
  }
4829
4828
  _loadInitSegment(e, t) {
4830
4829
  this._doFragLoad(e, t).then((s) => {
4831
- const i = s == null ? void 0 : s.frag;
4830
+ const i = s?.frag;
4832
4831
  if (!i || this.fragContextChanged(i) || !this.levels)
4833
4832
  throw new Error("init load aborted");
4834
4833
  return s;
@@ -4916,7 +4915,7 @@ class li extends nn {
4916
4915
  _doFragLoad(e, t, s = null, i) {
4917
4916
  var r;
4918
4917
  this.fragCurrent = e;
4919
- const n = t == null ? void 0 : t.details;
4918
+ const n = t?.details;
4920
4919
  if (!this.levels || !n)
4921
4920
  throw new Error(`frag load aborted, missing level${n ? "" : " detail"}s`);
4922
4921
  let o = null;
@@ -4929,7 +4928,7 @@ class li extends nn {
4929
4928
  const c = this.fragPrevious;
4930
4929
  if (ue(e) && (!c || e.sn !== c.sn)) {
4931
4930
  const u = this.shouldLoadParts(t.details, e.end);
4932
- u !== this.loadingParts && (this.log(`LL-Part loading ${u ? "ON" : "OFF"} loading sn ${c == null ? void 0 : c.sn}->${e.sn}`), this.loadingParts = u);
4931
+ u !== this.loadingParts && (this.log(`LL-Part loading ${u ? "ON" : "OFF"} loading sn ${c?.sn}->${e.sn}`), this.loadingParts = u);
4933
4932
  }
4934
4933
  if (s = Math.max(e.start, s || 0), this.loadingParts && ue(e)) {
4935
4934
  const u = n.partList;
@@ -4956,7 +4955,7 @@ class li extends nn {
4956
4955
  this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e, !1)}) cc: ${e.cc} ${n ? "[" + n.startSN + "-" + n.endSN + "]" : ""}, target: ${parseFloat(s.toFixed(3))}`), F(e.sn) && !this.bitrateTest && (this.nextLoadPosition = e.start + e.duration), this.state = C.FRAG_LOADING;
4957
4956
  const l = this.config.progressive;
4958
4957
  let h;
4959
- return l && o ? h = o.then((u) => !u || this.fragContextChanged(u == null ? void 0 : u.frag) ? null : this.fragmentLoader.load(e, i)).catch((u) => this.handleFragLoadError(u)) : h = Promise.all([this.fragmentLoader.load(e, l ? i : void 0), o]).then(([u]) => (!l && u && i && i(u), u)).catch((u) => this.handleFragLoadError(u)), this.hls.trigger(m.FRAG_LOADING, {
4958
+ return l && o ? h = o.then((u) => !u || this.fragContextChanged(u?.frag) ? null : this.fragmentLoader.load(e, i)).catch((u) => this.handleFragLoadError(u)) : h = Promise.all([this.fragmentLoader.load(e, l ? i : void 0), o]).then(([u]) => (!l && u && i && i(u), u)).catch((u) => this.handleFragLoadError(u)), this.hls.trigger(m.FRAG_LOADING, {
4960
4959
  frag: e,
4961
4960
  targetBufferTime: s
4962
4961
  }), this.fragCurrent === null ? Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")) : h;
@@ -5174,16 +5173,16 @@ class li extends nn {
5174
5173
  if (!e)
5175
5174
  return e;
5176
5175
  if (lr(this.hls.config) && e.type !== N.SUBTITLE) {
5177
- const s = this.hls.interstitialsManager, i = s == null ? void 0 : s.bufferingItem;
5176
+ const s = this.hls.interstitialsManager, i = s?.bufferingItem;
5178
5177
  if (i) {
5179
5178
  const n = i.event;
5180
5179
  if (n) {
5181
5180
  if (n.appendInPlace || Math.abs(e.start - i.start) > 1 || i.start === 0)
5182
5181
  return null;
5183
- } else if (e.end <= i.start && (t == null ? void 0 : t.live) === !1 || e.start > i.end && i.nextEvent && (i.nextEvent.appendInPlace || e.start - i.end > 1))
5182
+ } else if (e.end <= i.start && t?.live === !1 || e.start > i.end && i.nextEvent && (i.nextEvent.appendInPlace || e.start - i.end > 1))
5184
5183
  return null;
5185
5184
  }
5186
- const r = s == null ? void 0 : s.playerQueue;
5185
+ const r = s?.playerQueue;
5187
5186
  if (r)
5188
5187
  for (let n = r.length; n--; ) {
5189
5188
  const o = r[n].interstitial;
@@ -5348,7 +5347,7 @@ class li extends nn {
5348
5347
  reduceLengthAndFlushBuffer(e) {
5349
5348
  if (this.state === C.PARSING || this.state === C.PARSED) {
5350
5349
  const t = e.frag, s = e.parent, i = this.getFwdBufferInfo(this.mediaBuffer, s), r = i && i.len > 0.5;
5351
- r && this.reduceMaxBufferLength(i.len, (t == null ? void 0 : t.duration) || 10);
5350
+ r && this.reduceMaxBufferLength(i.len, t?.duration || 10);
5352
5351
  const n = !r;
5353
5352
  return n && this.warn(`Buffer full error while media.currentTime is not buffered, flush ${s} buffer`), t && (this.fragmentTracker.removeFragment(t), this.nextLoadPosition = t.start), this.resetLoadingState(), n;
5354
5353
  }
@@ -5485,7 +5484,7 @@ function Yo(a, e) {
5485
5484
  }
5486
5485
  var vs = { exports: {} }, cr;
5487
5486
  function Wo() {
5488
- return cr || (cr = 1, function(a) {
5487
+ return cr || (cr = 1, (function(a) {
5489
5488
  var e = Object.prototype.hasOwnProperty, t = "~";
5490
5489
  function s() {
5491
5490
  }
@@ -5588,7 +5587,7 @@ function Wo() {
5588
5587
  var h;
5589
5588
  return l ? (h = t ? t + l : l, this._events[h] && n(this, h)) : (this._events = new s(), this._eventsCount = 0), this;
5590
5589
  }, o.prototype.off = o.prototype.removeListener, o.prototype.addListener = o.prototype.on, o.prefixed = t, o.EventEmitter = o, a.exports = o;
5591
- }(vs)), vs.exports;
5590
+ })(vs)), vs.exports;
5592
5591
  }
5593
5592
  var qo = Wo(), ci = /* @__PURE__ */ Sa(qo);
5594
5593
  const Lt = "1.6.0", ut = {};
@@ -5941,9 +5940,9 @@ function di(a) {
5941
5940
  return yl(s);
5942
5941
  }
5943
5942
  }
5944
- let ye = /* @__PURE__ */ function(a) {
5943
+ let ye = /* @__PURE__ */ (function(a) {
5945
5944
  return a.audioId3 = "org.id3", a.dateRange = "com.apple.quicktime.HLS", a.emsg = "https://aomedia.org/emsg/ID3", a.misbklv = "urn:misb:KLV:bin:1910.1", a;
5946
- }({});
5945
+ })({});
5947
5946
  function Ce(a = "", e = 9e4) {
5948
5947
  return {
5949
5948
  type: a,
@@ -6169,7 +6168,7 @@ class Il extends fi {
6169
6168
  if (!e)
6170
6169
  return !1;
6171
6170
  const s = It(e, 0);
6172
- let i = (s == null ? void 0 : s.length) || 0;
6171
+ let i = s?.length || 0;
6173
6172
  if (Pn(e, i))
6174
6173
  return !1;
6175
6174
  for (let r = e.length; i < r; i++)
@@ -6278,7 +6277,7 @@ class bl extends fi {
6278
6277
  if (!e)
6279
6278
  return !1;
6280
6279
  const t = It(e, 0);
6281
- let s = (t == null ? void 0 : t.length) || 0;
6280
+ let s = t?.length || 0;
6282
6281
  if (t && e[s] === 11 && e[s + 1] === 119 && di(t) !== void 0 && // check the bsid to confirm ac-3 or ec-3 (not mp3)
6283
6282
  kn(e, s) <= 16)
6284
6283
  return !1;
@@ -6589,7 +6588,7 @@ class yt {
6589
6588
  skipLZ() {
6590
6589
  let e;
6591
6590
  for (e = 0; e < this.bitsAvailable; ++e)
6592
- if (this.word & 2147483648 >>> e)
6591
+ if ((this.word & 2147483648 >>> e) !== 0)
6593
6592
  return this.word <<= e, this.bitsAvailable -= e, e;
6594
6593
  return this.loadWord(), e + this.skipLZ();
6595
6594
  }
@@ -6636,6 +6635,7 @@ class ur extends On {
6636
6635
  s.data = null, n && r.length && !e.audFound && (this.pushAccessUnit(n, e), n = this.VideoSample = this.createVideoSample(!1, s.pts, s.dts)), r.forEach((l) => {
6637
6636
  var h, u;
6638
6637
  switch (l.type) {
6638
+ // NDR
6639
6639
  case 1: {
6640
6640
  let p = !1;
6641
6641
  o = !0;
@@ -6654,6 +6654,7 @@ class ur extends On {
6654
6654
  case 5:
6655
6655
  o = !0, (h = n) != null && h.frame && !n.key && (this.pushAccessUnit(n, e), n = this.VideoSample = null), n || (n = this.VideoSample = this.createVideoSample(!0, s.pts, s.dts)), n.key = !0, n.frame = !0;
6656
6656
  break;
6657
+ // SEI
6657
6658
  case 6: {
6658
6659
  o = !0, ti(l.data, 1, s.pts, t.samples);
6659
6660
  break;
@@ -6674,12 +6675,15 @@ class ur extends On {
6674
6675
  }
6675
6676
  break;
6676
6677
  }
6678
+ // PPS
6677
6679
  case 8:
6678
6680
  o = !0, e.pps = [l.data];
6679
6681
  break;
6682
+ // AUD
6680
6683
  case 9:
6681
6684
  o = !0, e.audFound = !0, (u = n) != null && u.frame && (this.pushAccessUnit(n, e), n = null), n || (n = this.VideoSample = this.createVideoSample(!1, s.pts, s.dts));
6682
6685
  break;
6686
+ // Filler Data
6683
6687
  case 12:
6684
6688
  o = !0;
6685
6689
  break;
@@ -6811,6 +6815,7 @@ class dr extends On {
6811
6815
  s.data = null, n && r.length && !e.audFound && (this.pushAccessUnit(n, e), n = this.VideoSample = this.createVideoSample(!1, s.pts, s.dts)), r.forEach((l) => {
6812
6816
  var h, u;
6813
6817
  switch (l.type) {
6818
+ // NON-IDR, NON RANDOM ACCESS SLICE
6814
6819
  case 0:
6815
6820
  case 1:
6816
6821
  case 2:
@@ -6823,6 +6828,7 @@ class dr extends On {
6823
6828
  case 9:
6824
6829
  n || (n = this.VideoSample = this.createVideoSample(!1, s.pts, s.dts)), n.frame = !0, o = !0;
6825
6830
  break;
6831
+ // CRA, BLA (random access picture)
6826
6832
  case 16:
6827
6833
  case 17:
6828
6834
  case 18:
@@ -6833,10 +6839,12 @@ class dr extends On {
6833
6839
  }
6834
6840
  n || (n = this.VideoSample = this.createVideoSample(!0, s.pts, s.dts)), n.key = !0, n.frame = !0;
6835
6841
  break;
6842
+ // IDR
6836
6843
  case 19:
6837
6844
  case 20:
6838
6845
  o = !0, (h = n) != null && h.frame && !n.key && (this.pushAccessUnit(n, e), n = this.VideoSample = null), n || (n = this.VideoSample = this.createVideoSample(!0, s.pts, s.dts)), n.key = !0, n.frame = !0;
6839
6846
  break;
6847
+ // SEI
6840
6848
  case 39:
6841
6849
  o = !0, ti(
6842
6850
  l.data,
@@ -6846,9 +6854,11 @@ class dr extends On {
6846
6854
  t.samples
6847
6855
  );
6848
6856
  break;
6857
+ // VPS
6849
6858
  case 32:
6850
6859
  o = !0, e.vps || (typeof e.params != "object" && (e.params = {}), e.params = re(e.params, this.readVPS(l.data)), this.initVPS = l.data), e.vps = [l.data];
6851
6860
  break;
6861
+ // SPS
6852
6862
  case 33:
6853
6863
  if (o = !0, c = !0, e.vps !== void 0 && e.vps[0] !== this.initVPS && e.sps !== void 0 && !this.matchSPS(e.sps[0], l.data) && (this.initVPS = e.vps[0], e.sps = e.pps = void 0), !e.sps) {
6854
6864
  const g = this.readSPS(l.data);
@@ -6858,6 +6868,7 @@ class dr extends On {
6858
6868
  }
6859
6869
  this.pushParameterSet(e.sps, l.data, e.vps), n || (n = this.VideoSample = this.createVideoSample(!0, s.pts, s.dts)), n.key = !0;
6860
6870
  break;
6871
+ // PPS
6861
6872
  case 34:
6862
6873
  if (o = !0, typeof e.params == "object") {
6863
6874
  if (!e.pps) {
@@ -6869,6 +6880,7 @@ class dr extends On {
6869
6880
  this.pushParameterSet(e.pps, l.data, e.vps);
6870
6881
  }
6871
6882
  break;
6883
+ // ACCESS UNIT DELIMITER
6872
6884
  case 35:
6873
6885
  o = !0, e.audFound = !0, (u = n) != null && u.frame && (this.pushAccessUnit(n, e), n = null), n || (n = this.VideoSample = this.createVideoSample(!1, s.pts, s.dts));
6874
6886
  break;
@@ -7384,9 +7396,11 @@ function kl(a, e, t, s, i, r) {
7384
7396
  As("ADTS AAC", r);
7385
7397
  break;
7386
7398
  }
7399
+ /* falls through */
7387
7400
  case 15:
7388
7401
  n.audioPid === -1 && (n.audioPid = h);
7389
7402
  break;
7403
+ // Packetized metadata (ID3)
7390
7404
  case 21:
7391
7405
  n.id3Pid === -1 && (n.id3Pid = h);
7392
7406
  break;
@@ -7395,9 +7409,12 @@ function kl(a, e, t, s, i, r) {
7395
7409
  As("H.264", r);
7396
7410
  break;
7397
7411
  }
7412
+ /* falls through */
7398
7413
  case 27:
7399
7414
  n.videoPid === -1 && (n.videoPid = h);
7400
7415
  break;
7416
+ // ISO/IEC 11172-3 (MPEG-1 audio)
7417
+ // or ISO/IEC 13818-3 (MPEG-2 halved sample rate audio)
7401
7418
  case 3:
7402
7419
  case 4:
7403
7420
  !t.mpeg && !t.mp3 ? r.log("MPEG audio found, not supported in this browser") : n.audioPid === -1 && (n.audioPid = h, n.segmentAudioCodec = "mp3");
@@ -7407,6 +7424,7 @@ function kl(a, e, t, s, i, r) {
7407
7424
  As("AC-3", r);
7408
7425
  break;
7409
7426
  }
7427
+ /* falls through */
7410
7428
  case 129:
7411
7429
  t.ac3 ? n.audioPid === -1 && (n.audioPid = h, n.segmentAudioCodec = "ac3") : r.log("AC-3 audio found, not supported in this browser");
7412
7430
  break;
@@ -7425,6 +7443,8 @@ function kl(a, e, t, s, i, r) {
7425
7443
  }
7426
7444
  break;
7427
7445
  case 194:
7446
+ // SAMPLE-AES EC3
7447
+ /* falls through */
7428
7448
  case 135:
7429
7449
  return Hs(i, new Error("Unsupported EC-3 in M2TS found"), void 0, r), n;
7430
7450
  case 36:
@@ -7510,6 +7530,7 @@ class wl {
7510
7530
  if (t === 6)
7511
7531
  return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 0, 178, 0, 32, 8, 224]);
7512
7532
  break;
7533
+ // handle HE-AAC below (mp4a.40.5 / mp4a.40.29)
7513
7534
  default:
7514
7535
  if (t === 1)
7515
7536
  return new Uint8Array([1, 64, 34, 128, 163, 78, 230, 128, 186, 8, 0, 0, 0, 28, 6, 241, 193, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]);
@@ -9223,7 +9244,7 @@ function Kl(a, e, t, s) {
9223
9244
  return Math.abs(r - t) > i;
9224
9245
  }
9225
9246
  function gr(a, e) {
9226
- const t = a == null ? void 0 : a.codec;
9247
+ const t = a?.codec;
9227
9248
  return t && t.length > 4 ? t : e === ie.AUDIO ? t === "ec-3" || t === "ac-3" || t === "alac" ? t : t === "fLaC" || t === "Opus" ? Zt(t, !1) : (Q.warn(`Unhandled audio codec "${t}" in mp4 MAP`), t || "mp4a") : (Q.warn(`Unhandled video codec "${t}" in mp4 MAP`), t || "avc1");
9228
9249
  }
9229
9250
  let Be;
@@ -9436,7 +9457,7 @@ class mr {
9436
9457
  }
9437
9458
  function Vl(a, e) {
9438
9459
  let t = null;
9439
- return a.byteLength > 0 && (e == null ? void 0 : e.key) != null && e.iv !== null && e.method != null && (t = e), t;
9460
+ return a.byteLength > 0 && e?.key != null && e.iv !== null && e.method != null && (t = e), t;
9440
9461
  }
9441
9462
  const Is = (a) => ({
9442
9463
  remuxResult: {},
@@ -9476,6 +9497,7 @@ class Bn {
9476
9497
  this.onFlush(l.data);
9477
9498
  break;
9478
9499
  }
9500
+ // pass logs from the worker thread to the main logger
9479
9501
  case "workerLog": {
9480
9502
  h.logger[l.data.logType] && h.logger[l.data.logType](l.data.message);
9481
9503
  break;
@@ -9566,7 +9588,7 @@ class Bn {
9566
9588
  const {
9567
9589
  instanceNo: g,
9568
9590
  transmuxer: f
9569
- } = this, p = n ? n.start : r.start, E = r.decryptdata, y = this.frag, S = !(y && r.cc === y.cc), T = !(y && l.level === y.level), v = y ? l.sn - y.sn : -1, x = this.part ? l.part - this.part.index : -1, _ = v === 0 && l.id > 1 && l.id === (y == null ? void 0 : y.stats.chunkCount), A = !T && (v === 1 || v === 0 && (x === 1 || _ && x <= 0)), b = self.performance.now();
9591
+ } = this, p = n ? n.start : r.start, E = r.decryptdata, y = this.frag, S = !(y && r.cc === y.cc), T = !(y && l.level === y.level), v = y ? l.sn - y.sn : -1, x = this.part ? l.part - this.part.index : -1, _ = v === 0 && l.id > 1 && l.id === y?.stats.chunkCount, A = !T && (v === 1 || v === 0 && (x === 1 || _ && x <= 0)), b = self.performance.now();
9570
9592
  (T || v || r.stats.parsing.start === 0) && (r.stats.parsing.start = b), n && (x || !A) && (n.stats.parsing.start = b);
9571
9593
  const D = !(y && ((u = r.initSegment) == null ? void 0 : u.url) === ((d = y.initSegment) == null ? void 0 : d.url)), L = new Yl(S, A, c, T, p, D);
9572
9594
  if (!A || S || D) {
@@ -9715,7 +9737,7 @@ class Wl extends li {
9715
9737
  const {
9716
9738
  levels: t,
9717
9739
  trackId: s
9718
- } = this, i = t == null ? void 0 : t[s], r = i == null ? void 0 : i.details;
9740
+ } = this, i = t?.[s], r = i?.details;
9719
9741
  if (r && !this.waitForLive(i)) {
9720
9742
  if (this.waitForCdnTuneIn(r))
9721
9743
  break;
@@ -9731,7 +9753,7 @@ class Wl extends li {
9731
9753
  levels: i,
9732
9754
  trackId: r
9733
9755
  } = this;
9734
- this.log("RetryDate reached, switch back to IDLE state"), this.resetStartWhenNotLoaded((i == null ? void 0 : i[r]) || null), this.state = C.IDLE;
9756
+ this.log("RetryDate reached, switch back to IDLE state"), this.resetStartWhenNotLoaded(i?.[r] || null), this.state = C.IDLE;
9735
9757
  }
9736
9758
  break;
9737
9759
  }
@@ -10166,7 +10188,7 @@ class pi extends $e {
10166
10188
  this.canLoad = !1, this.clearTimer();
10167
10189
  }
10168
10190
  switchParams(e, t, s) {
10169
- const i = t == null ? void 0 : t.renditionReports;
10191
+ const i = t?.renditionReports;
10170
10192
  if (i) {
10171
10193
  let r = -1;
10172
10194
  for (let n = 0; n < i.length; n++) {
@@ -10183,8 +10205,8 @@ class pi extends $e {
10183
10205
  } else c === e.substring(0, c.length) && (r = n);
10184
10206
  }
10185
10207
  if (r !== -1) {
10186
- const n = i[r], o = parseInt(n["LAST-MSN"]) || (t == null ? void 0 : t.lastPartSn);
10187
- let c = parseInt(n["LAST-PART"]) || (t == null ? void 0 : t.lastPartIndex);
10208
+ const n = i[r], o = parseInt(n["LAST-MSN"]) || t?.lastPartSn;
10209
+ let c = parseInt(n["LAST-PART"]) || t?.lastPartIndex;
10188
10210
  if (this.hls.config.lowLatencyMode) {
10189
10211
  const h = Math.min(t.age - t.partTarget, t.targetduration);
10190
10212
  c >= 0 && h > t.partTarget && (c += 1);
@@ -10375,7 +10397,7 @@ class ql extends pi {
10375
10397
  details: r
10376
10398
  } = t, n = this.tracksInGroup[s];
10377
10399
  if (!n || n.groupId !== i) {
10378
- this.warn(`Audio track with id:${s} and group:${i} not found in active group ${n == null ? void 0 : n.groupId}`);
10400
+ this.warn(`Audio track with id:${s} and group:${i} not found in active group ${n?.groupId}`);
10379
10401
  return;
10380
10402
  }
10381
10403
  const o = n.details;
@@ -10393,7 +10415,7 @@ class ql extends pi {
10393
10415
  return;
10394
10416
  const s = t.audioGroups || null, i = this.groupIds;
10395
10417
  let r = this.currentTrack;
10396
- if (!s || (i == null ? void 0 : i.length) !== (s == null ? void 0 : s.length) || s != null && s.some((o) => (i == null ? void 0 : i.indexOf(o)) === -1)) {
10418
+ if (!s || i?.length !== s?.length || s != null && s.some((o) => i?.indexOf(o) === -1)) {
10397
10419
  this.groupIds = s, this.trackId = -1, this.currentTrack = null;
10398
10420
  const o = this.tracks.filter((d) => !s || s.indexOf(d.groupId) !== -1);
10399
10421
  if (o.length)
@@ -10418,7 +10440,7 @@ class ql extends pi {
10418
10440
  const h = {
10419
10441
  audioTracks: o
10420
10442
  };
10421
- this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${s == null ? void 0 : s.join(",")}`), this.hls.trigger(m.AUDIO_TRACKS_UPDATED, h);
10443
+ this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${s?.join(",")}`), this.hls.trigger(m.AUDIO_TRACKS_UPDATED, h);
10422
10444
  const u = this.trackId;
10423
10445
  if (l !== -1 && u === -1)
10424
10446
  this.setAudioTrack(l);
@@ -10488,7 +10510,7 @@ class ql extends pi {
10488
10510
  const s = this.currentTrack, i = t[e], r = i.details && !i.details.live;
10489
10511
  if (e === this.trackId && i === s && r || (this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`), this.trackId = e, this.currentTrack = i, this.hls.trigger(m.AUDIO_TRACK_SWITCHING, te({}, i)), r))
10490
10512
  return;
10491
- const n = this.switchParams(i.url, s == null ? void 0 : s.details, i.details);
10513
+ const n = this.switchParams(i.url, s?.details, i.details);
10492
10514
  this.loadPlaylist(n);
10493
10515
  }
10494
10516
  findTrackId(e) {
@@ -10539,8 +10561,8 @@ class ql extends pi {
10539
10561
  }
10540
10562
  loadingPlaylist(e, t) {
10541
10563
  super.loadingPlaylist(e, t);
10542
- const s = e.id, i = e.groupId, r = this.getUrlWithDirectives(e.url, t), n = e.details, o = n == null ? void 0 : n.age;
10543
- this.log(`Loading audio-track ${s} "${e.name}" lang:${e.lang} group:${i}${(t == null ? void 0 : t.msn) !== void 0 ? " at sn " + t.msn + " part " + t.part : ""}${o && n.live ? " age " + o.toFixed(1) + (n.type && " " + n.type || "") : ""} ${r}`), this.hls.trigger(m.AUDIO_TRACK_LOADING, {
10564
+ const s = e.id, i = e.groupId, r = this.getUrlWithDirectives(e.url, t), n = e.details, o = n?.age;
10565
+ this.log(`Loading audio-track ${s} "${e.name}" lang:${e.lang} group:${i}${t?.msn !== void 0 ? " at sn " + t.msn + " part " + t.part : ""}${o && n.live ? " age " + o.toFixed(1) + (n.type && " " + n.type || "") : ""} ${r}`), this.hls.trigger(m.AUDIO_TRACK_LOADING, {
10544
10566
  url: r,
10545
10567
  id: s,
10546
10568
  groupId: i,
@@ -10650,7 +10672,7 @@ ${this.list("audiovideo")}}`;
10650
10672
  }
10651
10673
  listSbInfo(e) {
10652
10674
  var t;
10653
- const s = (t = this.tracks) == null ? void 0 : t[e], i = s == null ? void 0 : s.buffer;
10675
+ const s = (t = this.tracks) == null ? void 0 : t[e], i = s?.buffer;
10654
10676
  return i ? `SourceBuffer${i.updating ? " updating" : ""}${s.ended ? " ended" : ""}${s.ending ? " ending" : ""}` : "none";
10655
10677
  }
10656
10678
  listOps(e) {
@@ -10794,7 +10816,7 @@ class zl extends $e {
10794
10816
  required tracks: ${ae(s, (c, l) => c === "initSegment" ? void 0 : l)};
10795
10817
  transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i, s)) {
10796
10818
  t.mediaSource = null, t.tracks = void 0;
10797
- const c = e.currentTime, l = this.details, h = Math.max(c, (l == null ? void 0 : l.fragments[0].start) || 0);
10819
+ const c = e.currentTime, l = this.details, h = Math.max(c, l?.fragments[0].start || 0);
10798
10820
  if (h - c > 1) {
10799
10821
  this.log(`attachTransferred: waiting for playback to reach new tracks start time ${c} -> ${h}`);
10800
10822
  return;
@@ -10900,7 +10922,7 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
10900
10922
  supplemental: y
10901
10923
  } = u;
10902
10924
  let S = s[o];
10903
- const T = (c = this.transferData) == null || (l = c.tracks) == null ? void 0 : l[o], v = T != null && T.buffer ? T : S, x = (v == null ? void 0 : v.pendingCodec) || (v == null ? void 0 : v.codec), _ = v == null ? void 0 : v.levelCodec;
10925
+ const T = (c = this.transferData) == null || (l = c.tracks) == null ? void 0 : l[o], v = T != null && T.buffer ? T : S, x = v?.pendingCodec || v?.codec, _ = v?.levelCodec;
10904
10926
  S || (S = s[o] = {
10905
10927
  buffer: void 0,
10906
10928
  listeners: [],
@@ -10911,7 +10933,7 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
10911
10933
  metadata: E,
10912
10934
  id: d
10913
10935
  });
10914
- const A = Vt(x, _), b = A == null ? void 0 : A.replace(yr, "$1");
10936
+ const A = Vt(x, _), b = A?.replace(yr, "$1");
10915
10937
  let D = Vt(g, f);
10916
10938
  const L = (h = D) == null ? void 0 : h.replace(yr, "$1");
10917
10939
  D && A && b !== L && (o.slice(0, 5) === "audio" && (D = Zt(D, this.appendSource)), this.log(`switching codec ${x} to ${D}`), D !== (S.pendingCodec || S.codec) && (S.pendingCodec = D), S.container = p, this.appendChangeType(o, p, D));
@@ -10997,8 +11019,8 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
10997
11019
  g.start === 0 && (g.start = d), f && f.start === 0 && (f.start = d);
10998
11020
  const p = s.audio;
10999
11021
  let E = !1;
11000
- r === "audio" && (p == null ? void 0 : p.container) === "audio/mpeg" && (E = !this.lastMpegAudioChunk || l.id === 1 || this.lastMpegAudioChunk.sn !== l.sn, this.lastMpegAudioChunk = l);
11001
- const y = this.tracks.video, S = y == null ? void 0 : y.buffer;
11022
+ r === "audio" && p?.container === "audio/mpeg" && (E = !this.lastMpegAudioChunk || l.id === 1 || this.lastMpegAudioChunk.sn !== l.sn, this.lastMpegAudioChunk = l);
11023
+ const y = this.tracks.video, S = y?.buffer;
11002
11024
  if (S && u !== "initSegment") {
11003
11025
  const x = c || o, _ = this.blockedAudioAppend;
11004
11026
  if (r === "audio" && n !== "main" && !this.blockedAudioAppend) {
@@ -11260,7 +11282,7 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
11260
11282
  details: t,
11261
11283
  mediaSource: s
11262
11284
  } = this;
11263
- if (!t || !this.media || (s == null ? void 0 : s.readyState) !== "open")
11285
+ if (!t || !this.media || s?.readyState !== "open")
11264
11286
  return null;
11265
11287
  const i = t.edge;
11266
11288
  if (t.live && this.hls.config.liveDurationInfinity) {
@@ -11407,7 +11429,7 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
11407
11429
  get mediaSrc() {
11408
11430
  var e, t;
11409
11431
  const s = ((e = this.media) == null || (t = e.querySelector) == null ? void 0 : t.call(e, "source")) || this.media;
11410
- return s == null ? void 0 : s.src;
11432
+ return s?.src;
11411
11433
  }
11412
11434
  onSBUpdateStart(e) {
11413
11435
  const t = this.currentOp(e);
@@ -11440,7 +11462,7 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
11440
11462
  const {
11441
11463
  media: i,
11442
11464
  mediaSource: r
11443
- } = this, n = this.tracks[e], o = n == null ? void 0 : n.buffer;
11465
+ } = this, n = this.tracks[e], o = n?.buffer;
11444
11466
  if (!i || !r || !o) {
11445
11467
  this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`), this.shiftAndExecuteNext(e);
11446
11468
  return;
@@ -11450,7 +11472,7 @@ transfer tracks: ${ae(i, (c, l) => c === "initSegment" ? void 0 : l)}}`), !$r(i,
11450
11472
  }
11451
11473
  // This method must result in an updateend event; if append is not called, onSBUpdateEnd must be called manually
11452
11474
  appendExecutor(e, t) {
11453
- const s = this.tracks[t], i = s == null ? void 0 : s.buffer;
11475
+ const s = this.tracks[t], i = s?.buffer;
11454
11476
  if (!i)
11455
11477
  throw new Xl(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);
11456
11478
  s.ending = !1, s.ended = !1, i.appendBuffer(e);
@@ -11852,7 +11874,7 @@ function Ic(a, e = {
11852
11874
  }) {
11853
11875
  if (typeof a != "object")
11854
11876
  throw Oe(a, ac);
11855
- const t = a instanceof Map ? a.entries() : Object.entries(a), s = e != null && e.whitespace ? " " : "";
11877
+ const t = a instanceof Map ? a.entries() : Object.entries(a), s = e?.whitespace ? " " : "";
11856
11878
  return Array.from(t).map(([i, r]) => {
11857
11879
  r instanceof dt || (r = new dt(r));
11858
11880
  let n = qs(i);
@@ -11868,7 +11890,7 @@ function bc(a) {
11868
11890
  function _c(a) {
11869
11891
  return typeof a == "number" ? F(a) : a != null && a !== "" && a !== !1;
11870
11892
  }
11871
- const qt = (a) => Math.round(a), Dc = (a, e) => (e != null && e.baseUrl && (a = ll(a, e.baseUrl)), encodeURIComponent(a)), Bt = (a) => qt(a / 100) * 100, Cc = {
11893
+ const qt = (a) => Math.round(a), Dc = (a, e) => (e?.baseUrl && (a = ll(a, e.baseUrl)), encodeURIComponent(a)), Bt = (a) => qt(a / 100) * 100, Cc = {
11872
11894
  /**
11873
11895
  * Bitrate (kbps) rounded integer
11874
11896
  */
@@ -11906,9 +11928,9 @@ function Pc(a, e) {
11906
11928
  const t = {};
11907
11929
  if (a == null || typeof a != "object")
11908
11930
  return t;
11909
- const s = Object.keys(a).sort(), i = re({}, Cc, e == null ? void 0 : e.formatters), r = e == null ? void 0 : e.filter;
11931
+ const s = Object.keys(a).sort(), i = re({}, Cc, e?.formatters), r = e?.filter;
11910
11932
  return s.forEach((n) => {
11911
- if (r != null && r(n))
11933
+ if (r?.(n))
11912
11934
  return;
11913
11935
  let o = a[n];
11914
11936
  const c = i[n];
@@ -11924,7 +11946,7 @@ function kc(a, e = {}) {
11924
11946
  const t = {};
11925
11947
  if (!a)
11926
11948
  return t;
11927
- const s = Object.entries(a), i = Object.entries(nc).concat(Object.entries((e == null ? void 0 : e.customHeaderMap) || {})), r = s.reduce((n, o) => {
11949
+ const s = Object.entries(a), i = Object.entries(nc).concat(Object.entries(e?.customHeaderMap || {})), r = s.reduce((n, o) => {
11928
11950
  var c, l;
11929
11951
  const [h, u] = o, d = ((c = i.find((g) => g[1].includes(h))) === null || c === void 0 ? void 0 : c[0]) || pt.REQUEST;
11930
11952
  return (l = n[d]) !== null && l !== void 0 || (n[d] = {}), n[d][h] = u, n;
@@ -12222,7 +12244,7 @@ class Uc extends $e {
12222
12244
  const {
12223
12245
  errorAction: s
12224
12246
  } = t;
12225
- if ((s == null ? void 0 : s.action) === fe.SendAlternateToPenaltyBox && s.flags === Re.MoveAllAlternatesMatchingHost) {
12247
+ if (s?.action === fe.SendAlternateToPenaltyBox && s.flags === Re.MoveAllAlternatesMatchingHost) {
12226
12248
  const i = this.levels;
12227
12249
  let r = this._pathwayPriority, n = this.pathwayId;
12228
12250
  if (t.context) {
@@ -12345,7 +12367,7 @@ class Uc extends $e {
12345
12367
  onSuccess: (h, u, d, g) => {
12346
12368
  this.log(`Loaded steering manifest: "${i}"`);
12347
12369
  const f = h.data;
12348
- if ((f == null ? void 0 : f.VERSION) !== 1) {
12370
+ if (f?.VERSION !== 1) {
12349
12371
  this.log(`Steering VERSION ${f.VERSION} not supported!`);
12350
12372
  return;
12351
12373
  }
@@ -12377,7 +12399,7 @@ class Uc extends $e {
12377
12399
  let f = this.timeToLoad * 1e3;
12378
12400
  if (h.code === 429) {
12379
12401
  const p = this.loader;
12380
- if (typeof (p == null ? void 0 : p.getResponseHeader) == "function") {
12402
+ if (typeof p?.getResponseHeader == "function") {
12381
12403
  const E = p.getResponseHeader("Retry-After");
12382
12404
  E && (f = parseFloat(E) * 1e3);
12383
12405
  }
@@ -12420,7 +12442,7 @@ function Yn(a, e, t, s) {
12420
12442
  [t]: n
12421
12443
  } = s;
12422
12444
  let o;
12423
- e && (o = n == null ? void 0 : n[e], o && (a = o));
12445
+ e && (o = n?.[e], o && (a = o));
12424
12446
  const c = new self.URL(a);
12425
12447
  return i && !o && (c.host = i), r && Object.keys(r).sort().forEach((l) => {
12426
12448
  l && c.searchParams.set(l, r[l]);
@@ -12592,7 +12614,7 @@ class lt extends $e {
12592
12614
  }
12593
12615
  getMediaKeysPromise(e, t, s) {
12594
12616
  const i = Co(e, t, s, this.config.drmSystemOptions), r = this.keySystemAccessPromises[e];
12595
- let n = r == null ? void 0 : r.keySystemAccess;
12617
+ let n = r?.keySystemAccess;
12596
12618
  if (!n) {
12597
12619
  this.log(`Requesting encrypted media "${e}" key-system access with config: ${ae(i)}`), n = this.requestMediaKeySystemAccess(e, i);
12598
12620
  const o = this.keySystemAccessPromises[e] = {
@@ -12844,7 +12866,7 @@ class lt extends $e {
12844
12866
  setMediaKeysServerCertificate(e, t, s) {
12845
12867
  return new Promise((i, r) => {
12846
12868
  e.setServerCertificate(s).then((n) => {
12847
- this.log(`setServerCertificate ${n ? "success" : "not supported by CDM"} (${s == null ? void 0 : s.byteLength}) on "${t}"`), i(e);
12869
+ this.log(`setServerCertificate ${n ? "success" : "not supported by CDM"} (${s?.byteLength}) on "${t}"`), i(e);
12848
12870
  }).catch((n) => {
12849
12871
  r(new ve({
12850
12872
  type: U.KEY_SYSTEM_ERROR,
@@ -12879,7 +12901,7 @@ class lt extends $e {
12879
12901
  g && f && e.setRequestHeader(g, f);
12880
12902
  }
12881
12903
  }
12882
- const c = i.querySelector("Challenge"), l = c == null ? void 0 : c.textContent;
12904
+ const c = i.querySelector("Challenge"), l = c?.textContent;
12883
12905
  if (!l)
12884
12906
  throw new Error("Cannot find <Challenge> in key message");
12885
12907
  return $s(atob(l));
@@ -13237,7 +13259,7 @@ class Vc extends pi {
13237
13259
  details: r
13238
13260
  } = t, n = this.tracksInGroup[s];
13239
13261
  if (!n || n.groupId !== i) {
13240
- this.warn(`Subtitle track with id:${s} and group:${i} not found in active group ${n == null ? void 0 : n.groupId}`);
13262
+ this.warn(`Subtitle track with id:${s} and group:${i} not found in active group ${n?.groupId}`);
13241
13263
  return;
13242
13264
  }
13243
13265
  const o = n.details;
@@ -13255,7 +13277,7 @@ class Vc extends pi {
13255
13277
  return;
13256
13278
  const s = t.subtitleGroups || null, i = this.groupIds;
13257
13279
  let r = this.currentTrack;
13258
- if (!s || (i == null ? void 0 : i.length) !== (s == null ? void 0 : s.length) || s != null && s.some((n) => (i == null ? void 0 : i.indexOf(n)) === -1)) {
13280
+ if (!s || i?.length !== s?.length || s != null && s.some((n) => i?.indexOf(n) === -1)) {
13259
13281
  this.groupIds = s, this.trackId = -1, this.currentTrack = null;
13260
13282
  const n = this.tracks.filter((h) => !s || s.indexOf(h.groupId) !== -1);
13261
13283
  if (n.length)
@@ -13281,7 +13303,7 @@ class Vc extends pi {
13281
13303
  const l = {
13282
13304
  subtitleTracks: n
13283
13305
  };
13284
- this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${s == null ? void 0 : s.join(",")}" group-id`), this.hls.trigger(m.SUBTITLE_TRACKS_UPDATED, l), c !== -1 && this.trackId === -1 && this.setSubtitleTrack(c);
13306
+ this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${s?.join(",")}" group-id`), this.hls.trigger(m.SUBTITLE_TRACKS_UPDATED, l), c !== -1 && this.trackId === -1 && this.setSubtitleTrack(c);
13285
13307
  }
13286
13308
  }
13287
13309
  findTrackId(e) {
@@ -13364,8 +13386,8 @@ class Vc extends pi {
13364
13386
  }
13365
13387
  loadingPlaylist(e, t) {
13366
13388
  super.loadingPlaylist(e, t);
13367
- const s = e.id, i = e.groupId, r = this.getUrlWithDirectives(e.url, t), n = e.details, o = n == null ? void 0 : n.age;
13368
- this.log(`Loading subtitle ${s} "${e.name}" lang:${e.lang} group:${i}${(t == null ? void 0 : t.msn) !== void 0 ? " at sn " + t.msn + " part " + t.part : ""}${o && n.live ? " age " + o.toFixed(1) + (n.type && " " + n.type || "") : ""} ${r}`), this.hls.trigger(m.SUBTITLE_TRACK_LOADING, {
13389
+ const s = e.id, i = e.groupId, r = this.getUrlWithDirectives(e.url, t), n = e.details, o = n?.age;
13390
+ this.log(`Loading subtitle ${s} "${e.name}" lang:${e.lang} group:${i}${t?.msn !== void 0 ? " at sn " + t.msn + " part " + t.part : ""}${o && n.live ? " age " + o.toFixed(1) + (n.type && " " + n.type || "") : ""} ${r}`), this.hls.trigger(m.SUBTITLE_TRACK_LOADING, {
13369
13391
  url: r,
13370
13392
  id: s,
13371
13393
  groupId: i,
@@ -13433,7 +13455,7 @@ class Vc extends pi {
13433
13455
  type: l,
13434
13456
  url: h
13435
13457
  });
13436
- const u = this.switchParams(i.url, s == null ? void 0 : s.details, i.details);
13458
+ const u = this.switchParams(i.url, s?.details, i.details);
13437
13459
  this.loadPlaylist(u);
13438
13460
  }
13439
13461
  }
@@ -13444,9 +13466,9 @@ function Tt(a) {
13444
13466
  return (e >>> 0).toString();
13445
13467
  }
13446
13468
  const ct = 0.025;
13447
- let as = /* @__PURE__ */ function(a) {
13469
+ let as = /* @__PURE__ */ (function(a) {
13448
13470
  return a[a.Point = 0] = "Point", a[a.Range = 1] = "Range", a;
13449
- }({});
13471
+ })({});
13450
13472
  function Hc(a, e, t) {
13451
13473
  return `${a.identifier}-${t + 1}-${Tt(e)}`;
13452
13474
  }
@@ -13841,7 +13863,7 @@ class jc extends $e {
13841
13863
  const s = this.events || [];
13842
13864
  if (s.length || t.length || this.length < 2) {
13843
13865
  const i = this.items, r = this.parseSchedule(s, e);
13844
- (t.length || (i == null ? void 0 : i.length) !== r.length || r.some((o, c) => Math.abs(o.playout.start - i[c].playout.start) > 5e-3 || Math.abs(o.playout.end - i[c].playout.end) > 5e-3)) && (this.items = r, this.onScheduleUpdate(t, i));
13866
+ (t.length || i?.length !== r.length || r.some((o, c) => Math.abs(o.playout.start - i[c].playout.start) > 5e-3 || Math.abs(o.playout.end - i[c].playout.end) > 5e-3)) && (this.items = r, this.onScheduleUpdate(t, i));
13845
13867
  }
13846
13868
  }
13847
13869
  parseDateRanges(e, t, s) {
@@ -13862,7 +13884,7 @@ class jc extends $e {
13862
13884
  this.resolveOffsets(e, t);
13863
13885
  let c = 0, l = 0;
13864
13886
  if (e.forEach((h, u) => {
13865
- const d = h.cue.pre, g = h.cue.post, f = e[u - 1] || null, p = h.appendInPlace, E = g ? r : h.startOffset, y = h.duration, S = h.timelineOccupancy === as.Range ? y : 0, T = h.resumptionOffset, v = (f == null ? void 0 : f.startTime) === E, x = E + h.cumulativeDuration;
13887
+ const d = h.cue.pre, g = h.cue.post, f = e[u - 1] || null, p = h.appendInPlace, E = g ? r : h.startOffset, y = h.duration, S = h.timelineOccupancy === as.Range ? y : 0, T = h.resumptionOffset, v = f?.startTime === E, x = E + h.cumulativeDuration;
13866
13888
  let _ = p ? x + y : E + T;
13867
13889
  if (d || !g && E <= 0) {
13868
13890
  const b = l;
@@ -14043,7 +14065,7 @@ class Xc {
14043
14065
  maxRetryDelay: 0
14044
14066
  }, u = {
14045
14067
  onSuccess: (d, g, f, p) => {
14046
- const E = d.data, y = E == null ? void 0 : E.ASSETS;
14068
+ const E = d.data, y = E?.ASSETS;
14047
14069
  if (!Array.isArray(y)) {
14048
14070
  const S = this.assignAssetListError(e, R.ASSET_LIST_PARSING_ERROR, new Error("Invalid interstitial asset list"), f.url, g, p);
14049
14071
  this.hls.trigger(m.ERROR, S);
@@ -14088,7 +14110,7 @@ function we(a, e, t) {
14088
14110
  a.removeEventListener(e, t);
14089
14111
  }
14090
14112
  function Ir(a) {
14091
- a == null || a.play().catch(() => {
14113
+ a?.play().catch(() => {
14092
14114
  });
14093
14115
  }
14094
14116
  class zc extends $e {
@@ -14266,7 +14288,7 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
14266
14288
  if (y) {
14267
14289
  if (d === "playout" || y.timelineOccupancy !== as.Point) {
14268
14290
  const S = s(g);
14269
- (S == null ? void 0 : S.interstitial) === y && (E += S.assetItem.startOffset + S[p]);
14291
+ S?.interstitial === y && (E += S.assetItem.startOffset + S[p]);
14270
14292
  }
14271
14293
  } else {
14272
14294
  const S = f === "bufferedPos" ? n() : e[f];
@@ -14297,9 +14319,9 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
14297
14319
  if (p != null && (g = p.event) != null && g.restrictions.skip)
14298
14320
  return;
14299
14321
  e.log(`seek to ${u} "${d}"`);
14300
- const E = e.effectivePlayingItem, y = e.schedule.findItemIndexAtTime(u, d), S = (f = e.schedule.items) == null ? void 0 : f[y], T = e.getBufferingPlayer(), v = T == null ? void 0 : T.interstitial, x = v == null ? void 0 : v.appendInPlace, _ = E && e.itemsMatch(E, S);
14322
+ const E = e.effectivePlayingItem, y = e.schedule.findItemIndexAtTime(u, d), S = (f = e.schedule.items) == null ? void 0 : f[y], T = e.getBufferingPlayer(), v = T?.interstitial, x = v?.appendInPlace, _ = E && e.itemsMatch(E, S);
14301
14323
  if (E && (x || _)) {
14302
- const b = s(e.playingAsset), D = (b == null ? void 0 : b.media) || e.primaryMedia;
14324
+ const b = s(e.playingAsset), D = b?.media || e.primaryMedia;
14303
14325
  if (D) {
14304
14326
  const L = d === "primary" ? D.currentTime : i(E, d, e.playingAsset, "timelinePos", "currentTime"), P = u - L, O = (x ? L : D.currentTime) + P;
14305
14327
  if (O >= 0 && (!b || x || O <= b.duration)) {
@@ -14316,7 +14338,7 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
14316
14338
  }
14317
14339
  const D = !e.isInterstitial(S);
14318
14340
  if ((!e.isInterstitial(E) || E.event.appendInPlace) && (D || S.event.appendInPlace)) {
14319
- const L = e.media || (x ? T == null ? void 0 : T.media : null);
14341
+ const L = e.media || (x ? T?.media : null);
14320
14342
  L && (L.currentTime = b);
14321
14343
  } else if (E) {
14322
14344
  const L = e.findItemIndex(E);
@@ -14453,7 +14475,7 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
14453
14475
  }
14454
14476
  },
14455
14477
  skip: () => {
14456
- const u = e.effectivePlayingItem, d = u == null ? void 0 : u.event;
14478
+ const u = e.effectivePlayingItem, d = u?.event;
14457
14479
  if (d && !d.restrictions.skip) {
14458
14480
  const g = e.findItemIndex(u);
14459
14481
  if (d.appendInPlace) {
@@ -14616,7 +14638,7 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
14616
14638
  const i = e >= 0 ? s[e] : null, r = this.playingItem, n = this.playingLastItem;
14617
14639
  if (this.isInterstitial(r)) {
14618
14640
  var o;
14619
- const l = r.event, h = this.playingAsset, u = h == null ? void 0 : h.identifier, d = u ? this.getAssetPlayer(u) : null;
14641
+ const l = r.event, h = this.playingAsset, u = h?.identifier, d = u ? this.getAssetPlayer(u) : null;
14620
14642
  if (d && u && (!this.eventItemsMatch(r, i) || t !== void 0 && u !== ((o = l.assetList) == null ? void 0 : o[t].identifier))) {
14621
14643
  var c;
14622
14644
  const g = l.findAssetIndex(h);
@@ -15170,9 +15192,9 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
15170
15192
  if (h === e)
15171
15193
  return;
15172
15194
  const u = r.appendInPlace;
15173
- if (u && (h == null ? void 0 : h.interstitial.appendInPlace) === !1)
15195
+ if (u && h?.interstitial.appendInPlace === !1)
15174
15196
  return;
15175
- const d = (h == null ? void 0 : h.tracks) || ((i = this.detachedData) == null ? void 0 : i.tracks) || this.requiredTracks;
15197
+ const d = h?.tracks || ((i = this.detachedData) == null ? void 0 : i.tracks) || this.requiredTracks;
15176
15198
  if (u && n !== this.playingAsset) {
15177
15199
  if (!e.tracks)
15178
15200
  return;
@@ -15241,7 +15263,7 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
15241
15263
  const E = parseFloat(f.DURATION);
15242
15264
  this.createAsset(i, p, l, o + l, E, f.URI), l += E;
15243
15265
  }), i.duration = l, this.log(`Loaded asset-list with duration: ${l} (was: ${c}) ${i}`);
15244
- const h = this.waitingItem, u = (h == null ? void 0 : h.event.identifier) === r;
15266
+ const h = this.waitingItem, u = h?.event.identifier === r;
15245
15267
  this.updateSchedule();
15246
15268
  const d = (s = this.bufferingItem) == null ? void 0 : s.event;
15247
15269
  if (u) {
@@ -15255,7 +15277,7 @@ Schedule: ${c.map((g) => Ve(g))}`), h.length && this.log(`Removed events ${h}`),
15255
15277
  this.setBufferingItem(p);
15256
15278
  }
15257
15279
  this.setSchedulePosition(f);
15258
- } else if ((d == null ? void 0 : d.identifier) === r && d.appendInPlace) {
15280
+ } else if (d?.identifier === r && d.appendInPlace) {
15259
15281
  const f = i.assetList[0], p = this.getAssetPlayer(f.identifier), E = this.primaryMedia;
15260
15282
  f && p && E && this.bufferAssetPlayer(p, E);
15261
15283
  }
@@ -15359,7 +15381,7 @@ class Qc extends li {
15359
15381
  // If something goes wrong, proceed to next frag, if we were processing one.
15360
15382
  onError(e, t) {
15361
15383
  const s = t.frag;
15362
- (s == null ? void 0 : s.type) === N.SUBTITLE && (t.details === R.FRAG_GAP && this.fragmentTracker.fragBuffered(s, !0), this.fragCurrent && this.fragCurrent.abortRequests(), this.state !== C.STOPPED && (this.state = C.IDLE));
15384
+ s?.type === N.SUBTITLE && (t.details === R.FRAG_GAP && this.fragmentTracker.fragBuffered(s, !0), this.fragCurrent && this.fragCurrent.abortRequests(), this.state !== C.STOPPED && (this.state = C.IDLE));
15363
15385
  }
15364
15386
  // Got all new subtitle levels.
15365
15387
  onSubtitleTracksUpdated(e, {
@@ -15460,7 +15482,7 @@ class Qc extends li {
15460
15482
  const {
15461
15483
  currentTrackId: e,
15462
15484
  levels: t
15463
- } = this, s = t == null ? void 0 : t[e];
15485
+ } = this, s = t?.[e];
15464
15486
  if (!s || !t.length || !s.details || this.waitForLive(s))
15465
15487
  return;
15466
15488
  const {
@@ -16254,7 +16276,7 @@ function ch() {
16254
16276
  b: null
16255
16277
  };
16256
16278
  }
16257
- var Ti = function() {
16279
+ var Ti = (function() {
16258
16280
  if (is != null && is.VTTCue)
16259
16281
  return self.VTTCue;
16260
16282
  const a = ["", "lr", "rl"], e = ["start", "middle", "end", "left", "right"];
@@ -16410,7 +16432,7 @@ var Ti = function() {
16410
16432
  return n.prototype.getCueAsHTML = function() {
16411
16433
  return self.WebVTT.convertCueToDOMTree(self, this.text);
16412
16434
  }, n;
16413
- }();
16435
+ })();
16414
16436
  class hh {
16415
16437
  decode(e, t) {
16416
16438
  if (!e)
@@ -16590,6 +16612,8 @@ class fh {
16590
16612
  t.cue.id = r;
16591
16613
  continue;
16592
16614
  }
16615
+ // Process line as start of a cue.
16616
+ /* falls through */
16593
16617
  case "CUE":
16594
16618
  if (!t.cue) {
16595
16619
  t.state = "BADCUE";
@@ -16645,7 +16669,7 @@ const gh = /\r\n|\n\r|\n|\r/g, Ds = function(e, t, s = 0) {
16645
16669
  const s = parseInt(e.slice(-6, -4)), i = parseInt(e.slice(-9, -7)), r = e.length > 9 ? parseInt(e.substring(0, e.indexOf(":"))) : 0;
16646
16670
  if (!F(t) || !F(s) || !F(i) || !F(r))
16647
16671
  throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);
16648
- return t += 1e3 * s, t += 60 * 1e3 * i, t += 60 * 60 * 1e3 * r, t;
16672
+ return t += 1e3 * s, t += 60 * 1e3 * i, t += 3600 * 1e3 * r, t;
16649
16673
  };
16650
16674
  function Si(a, e, t) {
16651
16675
  return Tt(a.toString()) + Tt(e.toString()) + Tt(t);
@@ -17056,7 +17080,7 @@ class Ah {
17056
17080
  }
17057
17081
  closedCaptionsForLevel(e) {
17058
17082
  const t = this.hls.levels[e.level];
17059
- return t == null ? void 0 : t.attrs["CLOSED-CAPTIONS"];
17083
+ return t?.attrs["CLOSED-CAPTIONS"];
17060
17084
  }
17061
17085
  onFragLoading(e, t) {
17062
17086
  if (this.enabled && t.frag.type === N.MAIN) {
@@ -17521,7 +17545,7 @@ class ra {
17521
17545
  context: t,
17522
17546
  stats: s
17523
17547
  } = this;
17524
- this.retryDelay = ii(e, s.retry), s.retry++, Q.warn(`${status ? "HTTP Status " + status : "Timeout"} while loading ${t == null ? void 0 : t.url}, retrying ${s.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`), this.abortInternal(), this.loader = null, self.clearTimeout(this.retryTimeout), this.retryTimeout = self.setTimeout(this.loadInternal.bind(this), this.retryDelay);
17548
+ this.retryDelay = ii(e, s.retry), s.retry++, Q.warn(`${status ? "HTTP Status " + status : "Timeout"} while loading ${t?.url}, retrying ${s.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`), this.abortInternal(), this.loader = null, self.clearTimeout(this.retryTimeout), this.retryTimeout = self.setTimeout(this.loadInternal.bind(this), this.retryDelay);
17525
17549
  }
17526
17550
  loadprogress(e) {
17527
17551
  const t = this.stats;
@@ -18009,7 +18033,7 @@ class Vh extends nn {
18009
18033
  const T = y - o;
18010
18034
  if (!c && (T >= E || S) && this.hls) {
18011
18035
  var v;
18012
- if (((v = this.mediaSource) == null ? void 0 : v.readyState) === "ended" && !(p != null && p.live) && Math.abs(e - ((p == null ? void 0 : p.edge) || 0)) < 1) {
18036
+ if (((v = this.mediaSource) == null ? void 0 : v.readyState) === "ended" && !(p != null && p.live) && Math.abs(e - (p?.edge || 0)) < 1) {
18013
18037
  if (this.ended)
18014
18038
  return;
18015
18039
  this.ended = e || 1, this.hls.trigger(m.MEDIA_ENDED, {
@@ -18179,7 +18203,7 @@ class Vh extends nn {
18179
18203
  hls: t,
18180
18204
  media: s,
18181
18205
  nudgeRetry: i
18182
- } = this, r = t == null ? void 0 : t.config;
18206
+ } = this, r = t?.config;
18183
18207
  if (!s || !r)
18184
18208
  return 0;
18185
18209
  const n = s.currentTime;
@@ -18408,13 +18432,13 @@ class Wh {
18408
18432
  n = this.dateRangeCuesAppended = {};
18409
18433
  }
18410
18434
  const c = e.fragments[e.fragments.length - 1];
18411
- if (r.length === 0 || !F(c == null ? void 0 : c.programDateTime))
18435
+ if (r.length === 0 || !F(c?.programDateTime))
18412
18436
  return;
18413
18437
  this.id3Track || (this.id3Track = this.createTrack(this.media));
18414
18438
  const l = Zs();
18415
18439
  for (let h = 0; h < r.length; h++) {
18416
- const u = r[h], d = i[u], g = d.startTime, f = n[u], p = (f == null ? void 0 : f.cues) || {};
18417
- let E = (f == null ? void 0 : f.durationKnown) || !1, y = Kt;
18440
+ const u = r[h], d = i[u], g = d.startTime, f = n[u], p = f?.cues || {};
18441
+ let E = f?.durationKnown || !1, y = Kt;
18418
18442
  const {
18419
18443
  duration: S,
18420
18444
  endDate: T
@@ -18833,7 +18857,7 @@ class jh extends pi {
18833
18857
  this.hls.trigger(m.LEVEL_SWITCHING, c);
18834
18858
  const l = n.details;
18835
18859
  if (!l || l.live) {
18836
- const h = this.switchParams(n.uri, i == null ? void 0 : i.details, l);
18860
+ const h = this.switchParams(n.uri, i?.details, l);
18837
18861
  this.loadPlaylist(h);
18838
18862
  }
18839
18863
  }
@@ -18912,8 +18936,8 @@ class jh extends pi {
18912
18936
  }
18913
18937
  loadingPlaylist(e, t) {
18914
18938
  super.loadingPlaylist(e, t);
18915
- const s = this.getUrlWithDirectives(e.uri, t), i = this.currentLevelIndex, r = e.attrs["PATHWAY-ID"], n = e.details, o = n == null ? void 0 : n.age;
18916
- this.log(`Loading level index ${i}${(t == null ? void 0 : t.msn) !== void 0 ? " at sn " + t.msn + " part " + t.part : ""}${r ? " Pathway " + r : ""}${o && n.live ? " age " + o.toFixed(1) + (n.type && " " + n.type || "") : ""} ${s}`), this.hls.trigger(m.LEVEL_LOADING, {
18939
+ const s = this.getUrlWithDirectives(e.uri, t), i = this.currentLevelIndex, r = e.attrs["PATHWAY-ID"], n = e.details, o = n?.age;
18940
+ this.log(`Loading level index ${i}${t?.msn !== void 0 ? " at sn " + t.msn + " part " + t.part : ""}${r ? " Pathway " + r : ""}${o && n.live ? " age " + o.toFixed(1) + (n.type && " " + n.type || "") : ""} ${s}`), this.hls.trigger(m.LEVEL_LOADING, {
18917
18941
  url: s,
18918
18942
  level: i,
18919
18943
  levelInfo: e,
@@ -18980,7 +19004,7 @@ function Xh() {
18980
19004
  if (!aa())
18981
19005
  return !1;
18982
19006
  const a = We();
18983
- return typeof (a == null ? void 0 : a.isTypeSupported) == "function" && (["avc1.42E01E,mp4a.40.2", "av01.0.01M.08", "vp09.00.50.08"].some((e) => a.isTypeSupported(St(e, "video"))) || ["mp4a.40.2", "fLaC"].some((e) => a.isTypeSupported(St(e, "audio"))));
19007
+ return typeof a?.isTypeSupported == "function" && (["avc1.42E01E,mp4a.40.2", "av01.0.01M.08", "vp09.00.50.08"].some((e) => a.isTypeSupported(St(e, "video"))) || ["mp4a.40.2", "fLaC"].some((e) => a.isTypeSupported(St(e, "audio"))));
18984
19008
  }
18985
19009
  function zh() {
18986
19010
  var a;
@@ -19044,7 +19068,7 @@ class Zh extends li {
19044
19068
  const {
19045
19069
  levels: t,
19046
19070
  level: s
19047
- } = this, i = t == null ? void 0 : t[s], r = i == null ? void 0 : i.details;
19071
+ } = this, i = t?.[s], r = i?.details;
19048
19072
  if (r && (!r.live || this.levelLastLoaded === i && !this.waitForLive(i))) {
19049
19073
  if (this.waitForCdnTuneIn(r))
19050
19074
  break;
@@ -19064,7 +19088,7 @@ class Zh extends li {
19064
19088
  const {
19065
19089
  levels: i,
19066
19090
  level: r
19067
- } = this, n = i == null ? void 0 : i[r];
19091
+ } = this, n = i?.[r];
19068
19092
  this.resetStartWhenNotLoaded(n || null), this.state = C.IDLE;
19069
19093
  }
19070
19094
  }
@@ -19434,7 +19458,7 @@ class Zh extends li {
19434
19458
  const i = this.timelineOffset;
19435
19459
  i && s && (s += i);
19436
19460
  const r = this.getLevelDetails(), n = q.getBuffered(e), o = n.length ? n.start(0) : 0, c = o - s, l = Math.max(this.config.maxBufferHole, this.config.maxFragLookUpTolerance);
19437
- c > 0 && (c < l || this.loadingParts && c < 2 * ((r == null ? void 0 : r.partTarget) || 0)) && (this.log(`adjusting start position by ${c} to match buffer start`), s += c, this.startPosition = s), t < s && (this.log(`seek to target start position ${s} from current time ${t} buffer start ${o}`), e.currentTime = s);
19461
+ c > 0 && (c < l || this.loadingParts && c < 2 * (r?.partTarget || 0)) && (this.log(`adjusting start position by ${c} to match buffer start`), s += c, this.startPosition = s), t < s && (this.log(`seek to target start position ${s} from current time ${t} buffer start ${o}`), e.currentTime = s);
19438
19462
  }
19439
19463
  }
19440
19464
  _getAudioCodec(e) {
@@ -19445,7 +19469,7 @@ class Zh extends li {
19445
19469
  e.bitrateTest = !0, this._doFragLoad(e, t).then((s) => {
19446
19470
  const {
19447
19471
  hls: i
19448
- } = this, r = s == null ? void 0 : s.frag;
19472
+ } = this, r = s?.frag;
19449
19473
  if (!r || this.fragContextChanged(r))
19450
19474
  return;
19451
19475
  t.fragmentError = 0, this.state = C.IDLE, this.startFragRequested = !1, this.bitrateTest = !1;
@@ -19589,7 +19613,7 @@ class Zh extends li {
19589
19613
  if (n) {
19590
19614
  n.levelCodec = e.videoCodec, n.id = N.MAIN;
19591
19615
  const l = n.codec;
19592
- if ((l == null ? void 0 : l.length) === 4)
19616
+ if (l?.length === 4)
19593
19617
  switch (l) {
19594
19618
  case "hvc1":
19595
19619
  case "hev1":
@@ -19631,7 +19655,7 @@ class Zh extends li {
19631
19655
  const {
19632
19656
  levels: e,
19633
19657
  level: t
19634
- } = this, s = e == null ? void 0 : e[t];
19658
+ } = this, s = e?.[t];
19635
19659
  return s ? this.getMaxBufferLength(s.maxBitrate) : this.config.maxBufferLength;
19636
19660
  }
19637
19661
  backtrack(e) {
@@ -20200,7 +20224,7 @@ class eu {
20200
20224
  stats: r
20201
20225
  };
20202
20226
  if (i) {
20203
- const d = (t == null ? void 0 : t.url) || e.url;
20227
+ const d = t?.url || e.url;
20204
20228
  u.response = te({
20205
20229
  url: d,
20206
20230
  data: void 0
@@ -20563,7 +20587,7 @@ class Ze {
20563
20587
  */
20564
20588
  recoverMediaError() {
20565
20589
  this.logger.log("recoverMediaError");
20566
- const e = this._media, t = e == null ? void 0 : e.currentTime;
20590
+ const e = this._media, t = e?.currentTime;
20567
20591
  this.detachMedia(), e && (this.attachMedia(e), t && this.startLoad(t));
20568
20592
  }
20569
20593
  removeLevel(e) {