@oddin-gg/havik-player 2.16.8 → 2.16.10

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.
package/dist/index.js CHANGED
@@ -174,7 +174,7 @@ function ue(e, t) {
174
174
  t?.addEventListener("abort", a, { once: !0 });
175
175
  });
176
176
  }
177
- async function v(e, t, r) {
177
+ async function de(e, t, r) {
178
178
  let i = ae(t), a = Date.now(), s = i.timeoutMs == null ? Infinity : a + i.timeoutMs, c = 0, l;
179
179
  for (;;) {
180
180
  if (r?.aborted) throw new n("ABORTED", 0, "wait-for-live aborted");
@@ -200,21 +200,21 @@ async function v(e, t, r) {
200
200
  }
201
201
  //#endregion
202
202
  //#region src/core/resolve.ts
203
- async function y(e) {
203
+ async function v(e) {
204
204
  if (!e.matchUrn || typeof e.matchUrn != "string") throw new n("INVALID_URN", 0, "resolveStream: a non-empty matchUrn is required");
205
205
  let t = await p(d(e.baseUrl, `/v1/playback/${encodeURIComponent(e.matchUrn)}`), {
206
206
  credential: e.credential,
207
207
  signal: e.signal,
208
208
  apiHeaders: e.apiHeaders
209
209
  });
210
- if (!t.ok) throw await de(t);
211
- return me(await t.json(), e.matchUrn);
210
+ if (!t.ok) throw await fe(t);
211
+ return he(await t.json(), e.matchUrn);
212
212
  }
213
- function b(e) {
214
- let t = () => y(e);
215
- return e.waitForLive ? v(t, e.waitForLive, e.signal) : t();
213
+ function y(e) {
214
+ let t = () => v(e);
215
+ return e.waitForLive ? de(t, e.waitForLive, e.signal) : t();
216
216
  }
217
- async function de(e) {
217
+ async function fe(e) {
218
218
  let t = f(e.headers.get("retry-after")), i = e.headers.get("x-request-id") ?? e.headers.get("x-amzn-requestid") ?? void 0, a = e.statusText || `HTTP ${e.status}`, o, s;
219
219
  try {
220
220
  let t = await e.json();
@@ -230,7 +230,7 @@ async function de(e) {
230
230
  liveStartsAtMs: s
231
231
  });
232
232
  }
233
- var fe = /* @__PURE__ */ new Set([
233
+ var pe = /* @__PURE__ */ new Set([
234
234
  "matchUrn",
235
235
  "protocol",
236
236
  "drmEnabled",
@@ -241,7 +241,7 @@ var fe = /* @__PURE__ */ new Set([
241
241
  "expiresAt",
242
242
  "analytics"
243
243
  ]);
244
- function x(e, t) {
244
+ function b(e, t) {
245
245
  let r;
246
246
  try {
247
247
  r = new URL(t);
@@ -251,7 +251,7 @@ function x(e, t) {
251
251
  if (r.protocol !== "https:" && r.protocol !== "http:") throw new n("INTERNAL", 0, `playback ${e} has a disallowed scheme: ${r.protocol}`);
252
252
  return t;
253
253
  }
254
- function pe(e) {
254
+ function me(e) {
255
255
  if (e !== void 0) {
256
256
  if (typeof e == "string" && !e.endsWith("/")) try {
257
257
  let t = new URL(e);
@@ -260,41 +260,41 @@ function pe(e) {
260
260
  g(`server analytics.endpoint ${JSON.stringify(e)} ignored: not a bare https origin.`);
261
261
  }
262
262
  }
263
- function me(e, t) {
263
+ function he(e, t) {
264
264
  if (!e.manifestUrl) throw new n("INTERNAL", 0, "playback response is missing manifestUrl");
265
265
  let r = e.drmEnabled ?? !!e.drm, i = {
266
266
  matchUrn: e.matchUrn ?? t,
267
267
  protocol: "hls",
268
268
  drmEnabled: r,
269
- manifestUrl: x("manifestUrl", e.manifestUrl),
269
+ manifestUrl: b("manifestUrl", e.manifestUrl),
270
270
  serverTime: e.serverTime ?? ""
271
271
  };
272
272
  if (e.liveStartsAt && (i.liveStartsAt = e.liveStartsAt), typeof e.analytics?.sid == "string" && e.analytics.sid) {
273
273
  i.analytics = { sid: e.analytics.sid };
274
- let t = pe(e.analytics.endpoint);
274
+ let t = me(e.analytics.endpoint);
275
275
  t && (i.analytics.endpoint = t);
276
276
  }
277
277
  if (r && e.drm) {
278
278
  let t = {};
279
- e.drm.widevine?.licenseUrl && (t.widevine = { licenseUrl: x("widevine licenseUrl", e.drm.widevine.licenseUrl) }), e.drm.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && (t.fairplay = {
280
- licenseUrl: x("fairplay licenseUrl", e.drm.fairplay.licenseUrl),
281
- certificateUrl: x("fairplay certificateUrl", e.drm.fairplay.certificateUrl)
279
+ e.drm.widevine?.licenseUrl && (t.widevine = { licenseUrl: b("widevine licenseUrl", e.drm.widevine.licenseUrl) }), e.drm.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && (t.fairplay = {
280
+ licenseUrl: b("fairplay licenseUrl", e.drm.fairplay.licenseUrl),
281
+ certificateUrl: b("fairplay certificateUrl", e.drm.fairplay.certificateUrl)
282
282
  }), (t.widevine || t.fairplay) && (i.drm = t);
283
283
  }
284
284
  let a = {};
285
- for (let [t, n] of Object.entries(e)) fe.has(t) || (a[t] = n);
285
+ for (let [t, n] of Object.entries(e)) pe.has(t) || (a[t] = n);
286
286
  return Object.keys(a).length > 0 && (i.extensions = a), i;
287
287
  }
288
288
  //#endregion
289
289
  //#region src/core/fullscreen.ts
290
- function he(e) {
290
+ function ge(e) {
291
291
  return e.ownerDocument ?? document;
292
292
  }
293
- function ge(e) {
293
+ function x(e) {
294
294
  return e.fullscreenElement ?? e.webkitFullscreenElement ?? null;
295
295
  }
296
296
  function S(e, t) {
297
- let n = ge(he(e));
297
+ let n = x(ge(e));
298
298
  return n != null && (n === e || t != null && n === t) || e.webkitDisplayingFullscreen === !0;
299
299
  }
300
300
  async function C(e, t) {
@@ -310,7 +310,7 @@ async function w(e, t) {
310
310
  n.webkitExitFullscreen?.();
311
311
  return;
312
312
  }
313
- let r = he(e), i = ge(r);
313
+ let r = ge(e), i = x(r);
314
314
  i != null && (i === e || t != null && i === t) && (typeof r.exitFullscreen == "function" ? await r.exitFullscreen() : r.webkitExitFullscreen?.());
315
315
  }
316
316
  //#endregion
@@ -671,14 +671,14 @@ function I(e) {
671
671
  function L(e) {
672
672
  return (e ?? "").trim().toLowerCase();
673
673
  }
674
- var R = {
674
+ var je = {
675
675
  hevc: "hvc1.1.6.L93.90",
676
676
  dv: "dvh1.05.06",
677
677
  av1: "av01.0.05M.08",
678
678
  vp9: "vp09.00.10.08"
679
- }, je = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map();
680
- function Me(e) {
681
- let t = L(e), n = je.get(t);
679
+ }, Me = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
680
+ function Ne(e) {
681
+ let t = L(e), n = Me.get(t);
682
682
  if (n) return n;
683
683
  let r = {
684
684
  initDataTypes: ["cenc"],
@@ -696,23 +696,23 @@ function Me(e) {
696
696
  } catch {
697
697
  return !1;
698
698
  }
699
- })().then((e) => (z.set(t, e), e));
700
- return je.set(t, i), i;
699
+ })().then((e) => (R.set(t, e), e));
700
+ return Me.set(t, i), i;
701
701
  }
702
- function Ne() {
703
- if (j()) for (let e of Object.values(R)) Me(e);
702
+ function Pe() {
703
+ if (j()) for (let e of Object.values(je)) Ne(e);
704
704
  }
705
- function Pe(e) {
705
+ function Fe(e) {
706
706
  let t = I(e);
707
- if (t) return t === "avc" ? !0 : z.get(L(e)) ?? z.get(L(R[t]));
707
+ if (t) return t === "avc" ? !0 : R.get(L(e)) ?? R.get(L(je[t]));
708
708
  }
709
709
  //#endregion
710
710
  //#region src/core/drm/support.ts
711
- var Fe = 5e3, Ie = "video/mp4; codecs=\"avc1.42E01E\"", Le = "audio/mp4; codecs=\"mp4a.40.2\"", Re = {
711
+ var Ie = 5e3, Le = "video/mp4; codecs=\"avc1.42E01E\"", Re = "audio/mp4; codecs=\"mp4a.40.2\"", ze = {
712
712
  widevine: ["com.widevine.alpha"],
713
713
  fairplay: ["com.apple.fps"]
714
714
  };
715
- function ze(e) {
715
+ function Be(e) {
716
716
  return e === "fairplay" ? [{
717
717
  initDataTypes: [
718
718
  "sinf",
@@ -720,30 +720,30 @@ function ze(e) {
720
720
  "cenc"
721
721
  ],
722
722
  videoCapabilities: [{
723
- contentType: Ie,
723
+ contentType: Le,
724
724
  robustness: "",
725
725
  encryptionScheme: "cbcs"
726
726
  }],
727
727
  audioCapabilities: [{
728
- contentType: Le,
728
+ contentType: Re,
729
729
  robustness: "",
730
730
  encryptionScheme: "cbcs"
731
731
  }]
732
732
  }] : N("com.widevine.alpha", [{
733
733
  initDataTypes: ["cenc"],
734
734
  videoCapabilities: [{
735
- contentType: Ie,
735
+ contentType: Le,
736
736
  robustness: F.video,
737
737
  encryptionScheme: F.scheme
738
738
  }],
739
739
  audioCapabilities: [{
740
- contentType: Le,
740
+ contentType: Re,
741
741
  robustness: F.audio,
742
742
  encryptionScheme: F.scheme
743
743
  }]
744
744
  }]);
745
745
  }
746
- function Be(e, t) {
746
+ function Ve(e, t) {
747
747
  return new Promise((n, r) => {
748
748
  let i = setTimeout(() => r(/* @__PURE__ */ Error("probe-timeout")), t);
749
749
  e.then((e) => {
@@ -753,8 +753,8 @@ function Be(e, t) {
753
753
  });
754
754
  });
755
755
  }
756
- async function Ve(e = {}) {
757
- let t = e.systems ?? ["widevine", "fairplay"], n = e.timeoutMs ?? Fe, r = {};
756
+ async function He(e = {}) {
757
+ let t = e.systems ?? ["widevine", "fairplay"], n = e.timeoutMs ?? Ie, r = {};
758
758
  if (typeof window < "u" && window.isSecureContext === !1) return {
759
759
  verdict: "insecure-context",
760
760
  detail: r
@@ -766,7 +766,7 @@ async function Ve(e = {}) {
766
766
  };
767
767
  let a = !1, o = !1, s = Date.now() + n, c = () => Math.max(1, s - Date.now());
768
768
  for (let e of t) {
769
- let t = Re[e];
769
+ let t = ze[e];
770
770
  if (!t) {
771
771
  r[e] = "unknown system";
772
772
  continue;
@@ -777,7 +777,7 @@ async function Ve(e = {}) {
777
777
  break;
778
778
  }
779
779
  try {
780
- return await Be((await Be(i(n, ze(e)), c())).createMediaKeys(), c()), r[e] = `ok (${n})`, {
780
+ return await Ve((await Ve(i(n, Be(e)), c())).createMediaKeys(), c()), r[e] = `ok (${n})`, {
781
781
  verdict: "supported",
782
782
  system: e,
783
783
  detail: r
@@ -801,49 +801,49 @@ async function Ve(e = {}) {
801
801
  }
802
802
  //#endregion
803
803
  //#region src/core/manifest.ts
804
- var He = /^#EXT-X-(PART-INF|PART|PRELOAD-HINT)[:\s]/m;
805
- function Ue(e) {
806
- return He.test(e);
804
+ var Ue = /^#EXT-X-(PART-INF|PART|PRELOAD-HINT)[:\s]/m;
805
+ function We(e) {
806
+ return Ue.test(e);
807
807
  }
808
808
  //#endregion
809
809
  //#region src/core/env.ts
810
- var We = {
810
+ var Ge = {
811
811
  integration: "https://feed-dev.oddin-video.gg",
812
812
  production: "https://feed.oddin-video.gg"
813
813
  };
814
- function Ge(e) {
815
- let t = Object.prototype.hasOwnProperty.call(We, e) ? We[e] : void 0;
814
+ function Ke(e) {
815
+ let t = Object.prototype.hasOwnProperty.call(Ge, e) ? Ge[e] : void 0;
816
816
  if (!t) throw new n("INTERNAL", 0, `unknown env ${JSON.stringify(e)} — expected 'integration' or 'production'`);
817
817
  return t;
818
818
  }
819
819
  //#endregion
820
820
  //#region src/core/stats.ts
821
- var Ke = { droppedFrames: 0 };
822
- function qe(e) {
821
+ var qe = { droppedFrames: 0 };
822
+ function Je(e) {
823
823
  try {
824
824
  return new URL(e).host;
825
825
  } catch {
826
826
  return "";
827
827
  }
828
828
  }
829
- var Je = /\.(m3u8|ts|m4s|mp4|cmfv|cmfa)(\?|$)/i;
830
- function Ye(e) {
829
+ var Ye = /\.(m3u8|ts|m4s|mp4|cmfv|cmfa)(\?|$)/i;
830
+ function Xe(e) {
831
831
  if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return "";
832
832
  let t = "", n = -1, r = performance.getEntriesByType("resource");
833
- for (let i of r) if (!(i.startTime < e) && (i.initiatorType === "video" || i.initiatorType === "audio" || Je.test(i.name)) && i.startTime >= n) {
834
- let e = qe(i.name);
833
+ for (let i of r) if (!(i.startTime < e) && (i.initiatorType === "video" || i.initiatorType === "audio" || Ye.test(i.name)) && i.startTime >= n) {
834
+ let e = Je(i.name);
835
835
  e && (t = e, n = i.startTime);
836
836
  }
837
837
  return t;
838
838
  }
839
- function B(e) {
839
+ function z(e) {
840
840
  let t = e.getVideoPlaybackQuality?.();
841
841
  return {
842
842
  dropped: t?.droppedVideoFrames ?? 0,
843
843
  totalFrames: t?.totalVideoFrames ?? 0
844
844
  };
845
845
  }
846
- var Xe = class {
846
+ var B = class {
847
847
  video;
848
848
  baseFrames = 0;
849
849
  baseDropped = 0;
@@ -853,7 +853,7 @@ var Xe = class {
853
853
  this.video = e;
854
854
  }
855
855
  read() {
856
- let e = B(this.video);
856
+ let e = z(this.video);
857
857
  return e.totalFrames < this.lastFrames && (this.baseFrames += this.lastFrames), e.dropped < this.lastDropped && (this.baseDropped += this.lastDropped), this.lastFrames = e.totalFrames, this.lastDropped = e.dropped, {
858
858
  dropped: this.baseDropped + e.dropped,
859
859
  totalFrames: this.baseFrames + e.totalFrames
@@ -883,8 +883,8 @@ function Ze(e, t) {
883
883
  }
884
884
  //#endregion
885
885
  //#region src/core/engine/native.ts
886
- var Qe = 2e3, $e = 3, V = 500, et = 6e3, tt = .25, nt = 250, rt = .05;
887
- function it(e) {
886
+ var Qe = 2e3, $e = 3, V = 500, et = 6e3, tt = .25, nt = 250, rt = .05, it = 4;
887
+ function at(e) {
888
888
  try {
889
889
  let t = new TextDecoder("utf-8").decode(new Uint8Array(e));
890
890
  return /^skd:\/\/[0-9a-fA-F-]{36}:([0-9a-fA-F]{32})$/.exec(t)?.[1];
@@ -900,7 +900,7 @@ function U() {
900
900
  let e = "WebKitMediaKeys" in window || typeof HTMLMediaElement < "u" && "webkitSetMediaKeys" in HTMLMediaElement.prototype, t = typeof navigator < "u" && /Apple/i.test(navigator.vendor ?? "");
901
901
  return e || t;
902
902
  }
903
- function at() {
903
+ function ot() {
904
904
  if (typeof navigator > "u" || !U()) return !1;
905
905
  let e = navigator.userAgent ?? "";
906
906
  return /iPhone|iPad|iPod/.test(e) ? !0 : /Macintosh/.test(e) && typeof navigator.maxTouchPoints == "number" && navigator.maxTouchPoints > 1;
@@ -931,7 +931,7 @@ var W = class {
931
931
  frameCounter;
932
932
  detachFrames = null;
933
933
  constructor(e) {
934
- this.deps = e, this.frameCounter = new Xe(e.video), this.loadStarted = e.deferLoad !== !0, this.builtAt = typeof performance < "u" ? performance.now() : 0;
934
+ this.deps = e, this.frameCounter = new B(e.video), this.loadStarted = e.deferLoad !== !0, this.builtAt = typeof performance < "u" ? performance.now() : 0;
935
935
  }
936
936
  async load() {
937
937
  this.detachFrames ??= this.frameCounter.attach();
@@ -952,7 +952,7 @@ var W = class {
952
952
  type: "error",
953
953
  error: new n("INTERNAL", 0, "native HLS playback error"),
954
954
  fatal: !0
955
- }), this.onLoaded && e.addEventListener("loadedmetadata", this.onLoaded, { once: !0 }), e.addEventListener("error", this.onError), e.src = st(t.manifestUrl, t.analytics?.sid), e.load();
955
+ }), this.onLoaded && e.addEventListener("loadedmetadata", this.onLoaded, { once: !0 }), e.addEventListener("error", this.onError), e.src = ct(t.manifestUrl, t.analytics?.sid), e.load();
956
956
  }
957
957
  startLoad() {
958
958
  this.loadStarted || (this.loadStarted = !0, this.restorePreload());
@@ -974,7 +974,7 @@ var W = class {
974
974
  });
975
975
  this.onEncrypted = (n) => {
976
976
  let i = n;
977
- i.initData && !this.fairplayArmed && (this.fairplayArmed = !0, this.fairplayKeyIV = it(i.initData), (async () => {
977
+ i.initData && !this.fairplayArmed && (this.fairplayArmed = !0, this.fairplayKeyIV = at(i.initData), (async () => {
978
978
  try {
979
979
  let n = await (await navigator.requestMediaKeySystemAccess("com.apple.fps", [{
980
980
  initDataTypes: [i.initDataType],
@@ -1065,18 +1065,18 @@ var W = class {
1065
1065
  for (let n = 0; n < t.length; n += 1) t[n].mode = n === e ? "showing" : "disabled";
1066
1066
  }
1067
1067
  seekToLive() {
1068
- let e = this.deps.video;
1069
- e.seekable.length > 0 && (e.currentTime = e.seekable.end(e.seekable.length - 1));
1068
+ let e = this.deps.video, t = this.liveEnd();
1069
+ t == null || t <= e.currentTime || (e.currentTime = t);
1070
1070
  }
1071
1071
  getStats() {
1072
1072
  let e = this.deps.video, t = this.frameCounter.read(), n = {
1073
1073
  droppedFrames: t.dropped,
1074
1074
  decodedFrames: t.totalFrames
1075
1075
  };
1076
- if (this.cdnHost ||= Ye(this.builtAt), this.cdnHost && (n.cdnHost = this.cdnHost), this.deps.descriptor.drmEnabled && (n.keySystem = "fairplay"), e.duration === Infinity) {
1076
+ if (this.cdnHost ||= Xe(this.builtAt), this.cdnHost && (n.cdnHost = this.cdnHost), this.deps.descriptor.drmEnabled && (n.keySystem = "fairplay"), e.duration === Infinity) {
1077
1077
  n.isLive = !0;
1078
1078
  let t = this.liveEdgeEstimate(), r = t == null ? NaN : t - e.currentTime;
1079
- Number.isFinite(r) && (n.atLiveEdge = r <= 2, !e.paused && r >= 0 && (n.latencySeconds = r));
1079
+ Number.isFinite(r) && (n.atLiveEdge = r <= it, !e.paused && r >= 0 && (n.latencySeconds = r));
1080
1080
  } else Number.isFinite(e.duration) && e.duration > 0 && (n.isLive = !1);
1081
1081
  return n;
1082
1082
  }
@@ -1123,7 +1123,7 @@ var W = class {
1123
1123
  this.lastBufferedEnd = null, this.bufferedAdvancedAt = null;
1124
1124
  }, e.addEventListener("seeking", this.onEdgeReset), e.addEventListener("emptied", this.onEdgeReset), this.edgeTimer = setInterval(() => {
1125
1125
  if (e.duration !== Infinity) return;
1126
- let t = ot(e, e.currentTime);
1126
+ let t = st(e, e.currentTime);
1127
1127
  t != null && ((this.lastBufferedEnd == null || Math.abs(t - this.lastBufferedEnd) >= rt) && (this.bufferedAdvancedAt = G()), this.lastBufferedEnd = t);
1128
1128
  }, nt);
1129
1129
  }
@@ -1133,7 +1133,7 @@ var W = class {
1133
1133
  liveEdgeEstimate() {
1134
1134
  let e = this.deps.video;
1135
1135
  if (e.duration !== Infinity) return null;
1136
- let t = this.liveEnd(), n = ot(e, e.currentTime) ?? this.lastBufferedEnd;
1136
+ let t = this.liveEnd(), n = st(e, e.currentTime) ?? this.lastBufferedEnd;
1137
1137
  if (n != null) {
1138
1138
  let e = this.bufferedAdvancedAt, r = n + (e == null ? 0 : Math.max(0, (G() - e) / 1e3));
1139
1139
  (t == null || r > t) && (t = r);
@@ -1170,7 +1170,7 @@ var W = class {
1170
1170
  function G() {
1171
1171
  return typeof performance < "u" ? performance.now() : Date.now();
1172
1172
  }
1173
- function ot(e, t) {
1173
+ function st(e, t) {
1174
1174
  let n = e.buffered;
1175
1175
  if (!n || !Number.isFinite(t)) return null;
1176
1176
  for (let e = 0; e < n.length; e += 1) if (n.start(e) <= t + .1 && n.end(e) > t) {
@@ -1179,7 +1179,7 @@ function ot(e, t) {
1179
1179
  }
1180
1180
  return null;
1181
1181
  }
1182
- function st(e, t) {
1182
+ function ct(e, t) {
1183
1183
  return t ? `${e}${e.includes("?") ? "&" : "?"}CMCD=${encodeURIComponent(`sid="${t}"`)}` : e;
1184
1184
  }
1185
1185
  //#endregion
@@ -1196,8 +1196,8 @@ function K(e, t = Date.now()) {
1196
1196
  }
1197
1197
  //#endregion
1198
1198
  //#region src/core/engine/prefetch.ts
1199
- var ct = 15e3, lt = 5e3, ut = 6;
1200
- function dt(e) {
1199
+ var lt = 15e3, ut = 5e3, dt = 6;
1200
+ function ft(e) {
1201
1201
  try {
1202
1202
  let t = new URL(e);
1203
1203
  return t.searchParams.delete("CMCD"), t.toString();
@@ -1205,7 +1205,7 @@ function dt(e) {
1205
1205
  return e;
1206
1206
  }
1207
1207
  }
1208
- var ft = class {
1208
+ var pt = class {
1209
1209
  cmcd;
1210
1210
  entries = /* @__PURE__ */ new Map();
1211
1211
  keyed = /* @__PURE__ */ new Set();
@@ -1228,10 +1228,10 @@ var ft = class {
1228
1228
  }
1229
1229
  prefetch(e, t, n) {
1230
1230
  if (!this.isActive(t)) return;
1231
- let r = dt(e);
1231
+ let r = ft(e);
1232
1232
  if (this.entries.has(r)) return;
1233
1233
  let i = this.perTrack.get(t) ?? 0;
1234
- if (i >= ut) return;
1234
+ if (i >= dt) return;
1235
1235
  this.perTrack.set(t, i + 1);
1236
1236
  let a = new AbortController(), o = {
1237
1237
  started: performance.now(),
@@ -1245,10 +1245,10 @@ var ft = class {
1245
1245
  signal: a.signal
1246
1246
  }).then(async (e) => (o.first = performance.now(), e.ok ? e.arrayBuffer() : null)).catch(() => null), this.entries.set(r, o), this.stats.started += 1, setTimeout(() => {
1247
1247
  this.entries.get(r) === o && (this.entries.delete(r), a.abort(), this.stats.expired += 1);
1248
- }, ct);
1248
+ }, lt);
1249
1249
  }
1250
1250
  take(e) {
1251
- let t = dt(e), n = this.entries.get(t);
1251
+ let t = ft(e), n = this.entries.get(t);
1252
1252
  return n && this.entries.delete(t), n;
1253
1253
  }
1254
1254
  destroy() {
@@ -1268,13 +1268,13 @@ var ft = class {
1268
1268
  }
1269
1269
  }
1270
1270
  };
1271
- function pt(t) {
1271
+ function mt(t) {
1272
1272
  let n = e.DefaultConfig?.loader;
1273
1273
  if (typeof n != "function") return;
1274
1274
  class r extends n {
1275
1275
  served = !1;
1276
1276
  cancelled = !1;
1277
- stats = mt();
1277
+ stats = ht();
1278
1278
  load(e, n, r) {
1279
1279
  let i = e.rangeEnd ? void 0 : t.take(e.url);
1280
1280
  if (!i) {
@@ -1282,7 +1282,7 @@ function pt(t) {
1282
1282
  return;
1283
1283
  }
1284
1284
  this.served = !0;
1285
- let a = performance.now(), o = n?.loadPolicy?.maxTimeToFirstByteMs || lt, s = setTimeout(() => {
1285
+ let a = performance.now(), o = n?.loadPolicy?.maxTimeToFirstByteMs || ut, s = setTimeout(() => {
1286
1286
  !this.cancelled && this.served && (i.abort.abort(), t.stats.failed += 1, this.served = !1, super.load(e, n, r));
1287
1287
  }, o);
1288
1288
  i.bytes.then((o) => {
@@ -1309,7 +1309,7 @@ function pt(t) {
1309
1309
  }
1310
1310
  return r;
1311
1311
  }
1312
- function mt() {
1312
+ function ht() {
1313
1313
  return {
1314
1314
  aborted: !1,
1315
1315
  loaded: 0,
@@ -1333,10 +1333,10 @@ function mt() {
1333
1333
  }
1334
1334
  };
1335
1335
  }
1336
- function ht(e) {
1336
+ function gt(e) {
1337
1337
  return e === "audio" ? "audio" : "main";
1338
1338
  }
1339
- function gt(e, t) {
1339
+ function _t(e, t) {
1340
1340
  let n = [];
1341
1341
  t.initSegment?.url && !t.initSegment.data && n.push({
1342
1342
  url: t.initSegment.url,
@@ -1355,24 +1355,24 @@ function gt(e, t) {
1355
1355
  }
1356
1356
  //#endregion
1357
1357
  //#region src/core/engine/hls.ts
1358
- function _t() {
1358
+ function vt() {
1359
1359
  return e.isSupported();
1360
1360
  }
1361
- var vt = 3, yt = 5, bt = 3, xt = 1e4, St = 3e4, Ct = 12e3, wt = 3e3, Tt = .02, Et = 6e3, Dt = .5, Ot = 3, kt = .5, At = 1.1, jt = .25, Mt = 5e3, Nt = 4e3, Pt = 2, Ft = 5, It = 2, Lt = 2, Rt = 4, zt = 4, Bt = 2e3, Vt = 3e4, Ht = .2, Ut = 30, Wt = 2, Gt = 2, Kt = 9, qt = .5, Jt = 64;
1362
- function Yt(e) {
1361
+ var yt = 3, bt = 5, xt = 3, St = 1e4, Ct = 3e4, wt = 12e3, Tt = 3e3, Et = .02, Dt = 6e3, Ot = .5, kt = 3, At = .5, jt = 1.1, Mt = .25, Nt = 5e3, Pt = 4e3, Ft = 2, It = 5, Lt = 2, Rt = 2, zt = 4, Bt = 4, Vt = 2e3, Ht = 3e4, Ut = .2, Wt = 30, Gt = 2, Kt = 2, qt = 9, Jt = .5, Yt = 64;
1362
+ function Xt(e) {
1363
1363
  if (e.liveSyncDurationCount != null || e.liveMaxLatencyDurationCount != null) {
1364
1364
  delete e.liveSyncDuration, delete e.liveMaxLatencyDuration;
1365
1365
  return;
1366
1366
  }
1367
- e.liveSyncDuration ??= Gt;
1368
- let t = Math.max(12, e.liveSyncDuration + Kt);
1369
- (e.liveMaxLatencyDuration == null || e.liveMaxLatencyDuration <= e.liveSyncDuration) && (e.liveMaxLatencyDuration = t), Xt(e, e.liveSyncDuration);
1367
+ e.liveSyncDuration ??= Kt;
1368
+ let t = Math.max(12, e.liveSyncDuration + qt);
1369
+ (e.liveMaxLatencyDuration == null || e.liveMaxLatencyDuration <= e.liveSyncDuration) && (e.liveMaxLatencyDuration = t), Zt(e, e.liveSyncDuration);
1370
1370
  }
1371
- function Xt(e, t) {
1371
+ function Zt(e, t) {
1372
1372
  let n = (e, t, n) => Math.min(n, Math.max(t, e));
1373
1373
  e.maxStarvationDelay ??= n(t / 2, .5, 4), e.maxLoadingDelay ??= n(t, 1, 4), e.abrEwmaFastLive ??= n(t / 2, 1, 3);
1374
1374
  }
1375
- var Zt = class {
1375
+ var Qt = class {
1376
1376
  name = "hls";
1377
1377
  hls = null;
1378
1378
  deps;
@@ -1452,7 +1452,7 @@ var Zt = class {
1452
1452
  frameCounter;
1453
1453
  detachFrames = null;
1454
1454
  constructor(e) {
1455
- this.deps = e, this.frameCounter = new Xe(e.video), this.licenseUrl = e.descriptor.drm?.widevine?.licenseUrl, this.loadStarted = e.deferLoad !== !0;
1455
+ this.deps = e, this.frameCounter = new B(e.video), this.licenseUrl = e.descriptor.drm?.widevine?.licenseUrl, this.loadStarted = e.deferLoad !== !0;
1456
1456
  }
1457
1457
  async load() {
1458
1458
  this.detachFrames ??= this.frameCounter.attach();
@@ -1465,7 +1465,7 @@ var Zt = class {
1465
1465
  });
1466
1466
  return;
1467
1467
  }
1468
- e.drmEnabled && o && !this.deps.hlsConfig?.requestMediaKeySystemAccessFunc && (Ae(r), Ne()), this.startHls(), t !== !1 && typeof document < "u" && (this.onVisibility = () => {
1468
+ e.drmEnabled && o && !this.deps.hlsConfig?.requestMediaKeySystemAccessFunc && (Ae(r), Pe()), this.startHls(), t !== !1 && typeof document < "u" && (this.onVisibility = () => {
1469
1469
  let e = this.hls;
1470
1470
  if (document.visibilityState !== "visible" || !e) return;
1471
1471
  let t = e.liveSyncPosition;
@@ -1488,7 +1488,7 @@ var Zt = class {
1488
1488
  }
1489
1489
  this.loadSuspended = !0;
1490
1490
  }
1491
- }, Mt));
1491
+ }, Nt));
1492
1492
  }
1493
1493
  resumeLoading() {
1494
1494
  if (this.pauseSuspendTimer &&= (clearTimeout(this.pauseSuspendTimer), null), this.resetChaseWindow(), this.resetFrameDropWindow(), this.loadSuspended && (this.loadSuspended = !1, !this.stopped && this.hls)) {
@@ -1520,7 +1520,7 @@ var Zt = class {
1520
1520
  let t = e.liveSyncPosition;
1521
1521
  if (typeof t != "number" || !Number.isFinite(t)) return;
1522
1522
  let { video: n } = this.deps;
1523
- n.currentTime <= t + qt || (n.currentTime = t);
1523
+ n.currentTime <= t + Jt || (n.currentTime = t);
1524
1524
  }
1525
1525
  reanchorPartTimeline(e, t) {
1526
1526
  let { frag: n, part: r } = t;
@@ -1532,7 +1532,7 @@ var Zt = class {
1532
1532
  let o = n.sn, s = i.fragments.find((e) => e && e.sn === o) ?? (i.fragmentHint?.sn === o ? i.fragmentHint : void 0);
1533
1533
  if (!s) return;
1534
1534
  let c = a.startPTS - s.start;
1535
- if (!(!Number.isFinite(c) || Math.abs(c) < Tt)) {
1535
+ if (!(!Number.isFinite(c) || Math.abs(c) < Et)) {
1536
1536
  for (let e of i.fragments) e && e.setStart(e.start + c);
1537
1537
  i.fragmentHint?.setStart(i.fragmentHint.start + c), this.deps.debug === !0 && console.info(`havik-player: LL-HLS timeline re-anchored by ${c >= 0 ? "+" : ""}${c.toFixed(3)}s at sn ${n.sn} (level ${n.level})`);
1538
1538
  }
@@ -1571,7 +1571,7 @@ var Zt = class {
1571
1571
  return;
1572
1572
  }
1573
1573
  let l = this.hls, u, d = new Promise((e) => {
1574
- u = setTimeout(() => e(void 0), xt);
1574
+ u = setTimeout(() => e(void 0), St);
1575
1575
  });
1576
1576
  return Promise.race([c().catch(() => void 0), d]).finally(() => clearTimeout(u)).then((e) => {
1577
1577
  if (!this.hls || this.hls !== l) throw Error("havik-player: engine torn down during refresh");
@@ -1587,20 +1587,20 @@ var Zt = class {
1587
1587
  ...c
1588
1588
  };
1589
1589
  if (this.prefetch?.destroy(), this.prefetch = null, u && this.deps.mediaDuringKey !== !1 && !d.fLoader) {
1590
- let e = new ft({
1590
+ let e = new pt({
1591
1591
  sessionId: n.analytics?.sid,
1592
1592
  contentId: n.matchUrn
1593
- }), t = pt(e);
1593
+ }), t = mt(e);
1594
1594
  t && (this.prefetch = e, d.fLoader = t);
1595
1595
  }
1596
- Yt(d), this.catchUpRate = typeof d.maxLiveSyncPlaybackRate == "number" ? d.maxLiveSyncPlaybackRate : 1, this.catchUpEngaged = !1, this.catchUpRate > 1 && (d.maxLiveSyncPlaybackRate = 1), this.sizeCapManaged = d.capLevelToPlayerSize !== !0, this.fpsCapManaged = !(c && "capLevelOnFPSDrop" in c), this.loadStarted = d.autoStartLoad !== !1;
1596
+ Xt(d), this.catchUpRate = typeof d.maxLiveSyncPlaybackRate == "number" ? d.maxLiveSyncPlaybackRate : 1, this.catchUpEngaged = !1, this.catchUpRate > 1 && (d.maxLiveSyncPlaybackRate = 1), this.sizeCapManaged = d.capLevelToPlayerSize !== !0, this.fpsCapManaged = !(c && "capLevelOnFPSDrop" in c), this.loadStarted = d.autoStartLoad !== !1;
1597
1597
  let f = new e(d);
1598
1598
  if (this.hls = f, f.on(e.Events.FRAG_PARSED, (e, t) => this.reanchorPartTimeline(f, t)), f.on(e.Events.MANIFEST_PARSED, () => {
1599
1599
  this.mediaRecoveries = 0, this.networkRecoveries = 0, u && !this.deps.hlsConfig?.requestMediaKeySystemAccessFunc && this.dropLevelsWidevineCannotPlay(f), this.measureLadder(f), this.applySizeCap(), this.loadSuspended = !1, t.paused && this.schedulePauseSuspend(), l({ type: "ready" });
1600
1600
  }), f.on(e.Events.FRAG_BUFFERED, (e, t) => {
1601
1601
  t?.frag?.type === "main" && (this.kickKind !== "dead" && this.clearKick(), (this.mediaRecoveries > 0 || this.networkRecoveries > 0 || this.licenseRecoveries > 0 || this.starvationKicks > 0 || this.starvationRebuilds > 0) && !this.recoveryResetTimer && (this.recoveryResetTimer = setTimeout(() => {
1602
1602
  this.mediaRecoveries = 0, this.networkRecoveries = 0, this.licenseRecoveries = 0, this.starvationKicks = 0, this.starvationRebuilds = 0, this.recoveryResetTimer = null;
1603
- }, St)));
1603
+ }, Ct)));
1604
1604
  }), f.on(e.Events.FRAG_LOADING, (e, t) => {
1605
1605
  t?.frag?.type === "main" && (this.lastFragLoadingMs = Date.now());
1606
1606
  }), f.on(e.Events.FRAG_LOADED, (e, t) => {
@@ -1608,10 +1608,10 @@ var Zt = class {
1608
1608
  let n = t?.frag?.stats, r = n?.loaded;
1609
1609
  typeof r == "number" && (this.bytesLoaded += r), !this.reportedFirstBytes && typeof r == "number" && r > 0 && (this.reportedFirstBytes = !0, l({ type: "firstBytes" }));
1610
1610
  let i = n?.loading;
1611
- i && i.end > 0 && i.start > 0 && (this.requestCount += 1, this.requestTimesMs.push(Math.max(0, Math.round(i.end - i.start))), this.requestTimesMs.length > Jt && this.requestTimesMs.shift());
1611
+ i && i.end > 0 && i.start > 0 && (this.requestCount += 1, this.requestTimesMs.push(Math.max(0, Math.round(i.end - i.start))), this.requestTimesMs.length > Yt && this.requestTimesMs.shift());
1612
1612
  let a = t?.frag?.url;
1613
1613
  if (a) {
1614
- let e = qe(a);
1614
+ let e = Je(a);
1615
1615
  e && (this.cdnHost = e);
1616
1616
  }
1617
1617
  }), f.on(e.Events.LEVEL_LOADED, (e, t) => {
@@ -1625,15 +1625,15 @@ var Zt = class {
1625
1625
  }), f.on(e.Events.LEVEL_LOADED, (e, t) => this.trackEnd(t)), this.prefetch) {
1626
1626
  let t = this.prefetch;
1627
1627
  f.on(e.Events.KEY_LOADING, (e, n) => {
1628
- let r = n?.frag, i = ht(r?.type);
1629
- if (r && t.isActive(i)) for (let e of gt(f, r)) t.prefetch(e.url, i, e.kind);
1630
- }), f.on(e.Events.KEY_LOADED, (e, n) => t.keyUsable(ht(n?.frag?.type)));
1628
+ let r = n?.frag, i = gt(r?.type);
1629
+ if (r && t.isActive(i)) for (let e of _t(f, r)) t.prefetch(e.url, i, e.kind);
1630
+ }), f.on(e.Events.KEY_LOADED, (e, n) => t.keyUsable(gt(n?.frag?.type)));
1631
1631
  }
1632
1632
  f.on(e.Events.KEY_LOADED, () => {
1633
1633
  u && !this.reportedDrmReady && (this.reportedDrmReady = !0, l({ type: "drmReady" }));
1634
1634
  }), this.endWatchdog && clearInterval(this.endWatchdog), this.endWatchdog = setInterval(() => {
1635
1635
  this.checkEndStale(), this.checkStarvation(), this.updateCatchUpBand(), this.checkFutileChase(), this.checkFrameDrops();
1636
- }, wt), f.on(e.Events.LEVEL_SWITCHED, (e, t) => {
1636
+ }, Tt), f.on(e.Events.LEVEL_SWITCHED, (e, t) => {
1637
1637
  this.renditionSwitches += 1;
1638
1638
  let n = this.lastLevelIndex >= 0 ? f.levels[this.lastLevelIndex] : void 0, r = f.levels[t.level];
1639
1639
  n && r && r.bitrate !== n.bitrate && (r.bitrate > n.bitrate ? this.upshifts += 1 : this.downshifts += 1), this.lastLevelIndex = t.level, l({
@@ -1697,7 +1697,7 @@ var Zt = class {
1697
1697
  return;
1698
1698
  }
1699
1699
  this.capTimer && clearTimeout(this.capTimer);
1700
- let t = e > this.sizeCapLevel ? Bt : Vt;
1700
+ let t = e > this.sizeCapLevel ? Vt : Ht;
1701
1701
  this.capTimer = setTimeout(() => {
1702
1702
  this.capTimer = null, this.computeSizeCapTarget() === e ? this.applySizeCap() : this.onMediaResize();
1703
1703
  }, t);
@@ -1707,9 +1707,9 @@ var Zt = class {
1707
1707
  this.ladderHeights = t.length ? [...new Set(t)].sort((e, t) => e - t) : void 0, this.ladderTopBitrateKbps = e.levels.length ? Math.round(Math.max(...e.levels.map((e) => e.bitrate)) / 1e3) : 0;
1708
1708
  }
1709
1709
  dropLevelsWidevineCannotPlay(e) {
1710
- this.removeLevelsWhere(e, (e) => Pe(e) !== !0);
1710
+ this.removeLevelsWhere(e, (e) => Fe(e) !== !0);
1711
1711
  let t = new Set(e.levels.map((e) => e.videoCodec).filter((e) => !!e && I(e) !== "avc" && !!I(e)));
1712
- for (let n of t) Me(n).then((t) => {
1712
+ for (let n of t) Ne(n).then((t) => {
1713
1713
  t || this.hls !== e || this.removeLevelsWhere(e, (e) => e === n) && (this.measureLadder(e), this.applySizeCap());
1714
1714
  });
1715
1715
  }
@@ -1720,7 +1720,7 @@ var Zt = class {
1720
1720
  a && I(a) && t(a) && (r.push(n), i.add(a));
1721
1721
  }), !r.length) return !1;
1722
1722
  let a = [...i].join(", ");
1723
- if (!n.some((e, t) => r.includes(t) ? !1 : !I(e.videoCodec) || Pe(e.videoCodec) === !0)) return console.warn(`havik-player: every rendition is ${a}, which Widevine may not play on this browser; keeping them`), !1;
1723
+ if (!n.some((e, t) => r.includes(t) ? !1 : !I(e.videoCodec) || Fe(e.videoCodec) === !0)) return console.warn(`havik-player: every rendition is ${a}, which Widevine may not play on this browser; keeping them`), !1;
1724
1724
  for (let t = r.length - 1; t >= 0; --t) e.removeLevel(r[t]);
1725
1725
  return console.info(`havik-player: skipped ${r.length} rendition(s) Widevine cannot play on this browser (${a})`), !0;
1726
1726
  }
@@ -1818,7 +1818,7 @@ var Zt = class {
1818
1818
  return;
1819
1819
  }
1820
1820
  let e = Date.now() - this.lastAdvanceMs;
1821
- !this.chaseSuspended && e > Et && this.suspendChasing(), e > Ct && this.emitEnded("stalled");
1821
+ !this.chaseSuspended && e > Dt && this.suspendChasing(), e > wt && this.emitEnded("stalled");
1822
1822
  }
1823
1823
  resetStarvationWindow() {
1824
1824
  this.starvedTicks = 0, this.deadTicks = 0, this.mainFragsSinceTick = 0, this.recentMainFrags = [];
@@ -1833,7 +1833,7 @@ var Zt = class {
1833
1833
  this.resetStarvationWindow();
1834
1834
  return;
1835
1835
  }
1836
- let n = Date.now(), r = this.lastAdvanceMs !== 0 && n - this.lastAdvanceMs < Et, i = this.lastFragLoadingMs !== 0 && n - this.lastFragLoadingMs > Nt, a = t.readyState < HTMLMediaElement.HAVE_FUTURE_DATA && !t.paused, { totalFrames: o, dropped: s } = B(t), c = o - s, l = c !== this.starvedFrames;
1836
+ let n = Date.now(), r = this.lastAdvanceMs !== 0 && n - this.lastAdvanceMs < Dt, i = this.lastFragLoadingMs !== 0 && n - this.lastFragLoadingMs > Pt, a = t.readyState < HTMLMediaElement.HAVE_FUTURE_DATA && !t.paused, { totalFrames: o, dropped: s } = z(t), c = o - s, l = c !== this.starvedFrames;
1837
1837
  if (this.starvedFrames = c, !a || l) {
1838
1838
  (t.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA || l) && this.clearKick(), this.resetStarvationWindow();
1839
1839
  return;
@@ -1842,12 +1842,12 @@ var Zt = class {
1842
1842
  this.resetStarvationWindow();
1843
1843
  return;
1844
1844
  }
1845
- if (this.kickPending && (this.kickKind === "dead" || i) && (this.kickTicks += 1), this.starvedTicks = i ? this.starvedTicks + 1 : 0, this.deadTicks += 1, this.recentMainFrags.push(this.mainFragsSinceTick), this.mainFragsSinceTick = 0, this.recentMainFrags.length > Rt && this.recentMainFrags.shift(), this.clearRecoveryReset(), this.kickPending && this.kickTicks >= It && (this.clearKick(), this.starvationRebuilds < Lt)) {
1845
+ if (this.kickPending && (this.kickKind === "dead" || i) && (this.kickTicks += 1), this.starvedTicks = i ? this.starvedTicks + 1 : 0, this.deadTicks += 1, this.recentMainFrags.push(this.mainFragsSinceTick), this.mainFragsSinceTick = 0, this.recentMainFrags.length > zt && this.recentMainFrags.shift(), this.clearRecoveryReset(), this.kickPending && this.kickTicks >= Lt && (this.clearKick(), this.starvationRebuilds < Rt)) {
1846
1846
  this.starvationRebuilds += 1, this.resetStarvationWindow(), this.clearRecoveryReset(), console.warn("havik-player: restarting the load did not resume video (the wedge is in hls.js state that only a rebuild clears) — rebuilding the player"), this.rebuildInstance("starvation rebuild");
1847
1847
  return;
1848
1848
  }
1849
- let u = i && this.starvedTicks >= Pt, d = !i && this.deadTicks >= Rt && this.recentMainFrags.reduce((e, t) => e + t, 0) >= zt;
1850
- if ((u || d) && (this.resetStarvationWindow(), !(this.starvationKicks >= Ft))) {
1849
+ let u = i && this.starvedTicks >= Ft, d = !i && this.deadTicks >= zt && this.recentMainFrags.reduce((e, t) => e + t, 0) >= Bt;
1850
+ if ((u || d) && (this.resetStarvationWindow(), !(this.starvationKicks >= It))) {
1851
1851
  this.starvationKicks += 1, this.kickPending = !0, this.kickTicks = 0, this.kickKind = d ? "dead" : "quiet", this.clearRecoveryReset(), console.warn(d ? "havik-player: video starved while hls.js keeps loading media it never plays (dead pipeline at the live edge) — restarting the load" : "havik-player: video starved while the live playlist advances (wedged hls.js fragment pipeline) — restarting the load");
1852
1852
  try {
1853
1853
  e.stopLoad(), e.startLoad(-1);
@@ -1862,7 +1862,7 @@ var Zt = class {
1862
1862
  let t = e.latency, n = e.targetLatency;
1863
1863
  if (typeof t != "number" || typeof n != "number" || !Number.isFinite(t)) return;
1864
1864
  let r = t - n;
1865
- !this.catchUpEngaged && r > Dt ? this.catchUpEngaged = !0 : this.catchUpEngaged && r <= Dt && this.deps.video.playbackRate === 1 && (this.catchUpEngaged = !1);
1865
+ !this.catchUpEngaged && r > Ot ? this.catchUpEngaged = !0 : this.catchUpEngaged && r <= Ot && this.deps.video.playbackRate === 1 && (this.catchUpEngaged = !1);
1866
1866
  let i = this.catchUpEngaged ? this.catchUpRate : 1;
1867
1867
  e.config.maxLiveSyncPlaybackRate !== i && (e.config.maxLiveSyncPlaybackRate = i);
1868
1868
  }
@@ -1883,16 +1883,16 @@ var Zt = class {
1883
1883
  this.resetFrameDropWindow();
1884
1884
  return;
1885
1885
  }
1886
- let { totalFrames: n, dropped: r } = B(t), i = this.fpsLastFrames < 0, a = n - this.fpsLastFrames, o = r - this.fpsLastDropped;
1887
- if (this.fpsLastFrames = n, this.fpsLastDropped = r, i || a < Ut || o < 0) {
1886
+ let { totalFrames: n, dropped: r } = z(t), i = this.fpsLastFrames < 0, a = n - this.fpsLastFrames, o = r - this.fpsLastDropped;
1887
+ if (this.fpsLastFrames = n, this.fpsLastDropped = r, i || a < Wt || o < 0) {
1888
1888
  this.fpsBadTicks = 0;
1889
1889
  return;
1890
1890
  }
1891
- if (o <= Ht * a) {
1891
+ if (o <= Ut * a) {
1892
1892
  this.fpsBadTicks = 0;
1893
1893
  return;
1894
1894
  }
1895
- if (this.fpsBadTicks += 1, this.fpsBadTicks < Wt) return;
1895
+ if (this.fpsBadTicks += 1, this.fpsBadTicks < Gt) return;
1896
1896
  this.fpsBadTicks = 0;
1897
1897
  let s = e.levels, c = s[e.currentLevel];
1898
1898
  if (!c) return;
@@ -1909,20 +1909,20 @@ var Zt = class {
1909
1909
  return;
1910
1910
  }
1911
1911
  let n = e.latency, r = t.playbackRate, i = e.config.maxLiveSyncPlaybackRate;
1912
- if (!(!t.paused && typeof i == "number" && i > 1 && r >= Math.min(At, i) && r <= i && typeof n == "number" && Number.isFinite(n))) {
1912
+ if (!(!t.paused && typeof i == "number" && i > 1 && r >= Math.min(jt, i) && r <= i && typeof n == "number" && Number.isFinite(n))) {
1913
1913
  this.resetChaseWindow();
1914
1914
  return;
1915
1915
  }
1916
- if (this.chaseLatency < 0 || this.chaseLatency - n >= kt) {
1916
+ if (this.chaseLatency < 0 || this.chaseLatency - n >= At) {
1917
1917
  this.chaseLatency = n, this.chaseTicks = 0;
1918
1918
  return;
1919
1919
  }
1920
- if (this.chaseTicks += 1, this.chaseTicks < Ot) return;
1920
+ if (this.chaseTicks += 1, this.chaseTicks < kt) return;
1921
1921
  this.resetChaseWindow();
1922
1922
  let a = typeof e.config.liveMaxLatencyDuration == "number" ? e.config.liveMaxLatencyDuration : e.maxLatency;
1923
1923
  if (!(a > 1)) return;
1924
1924
  let o = typeof e.targetLatency == "number" ? e.targetLatency : 0, s = Math.min(n, a - 1);
1925
- s < o + jt || (console.warn(`havik-player: catch-up at ${r}x not gaining on the live edge (latency ${n.toFixed(1)}s); holding at ${s.toFixed(1)}s`), this.liveRetargets += 1, e.targetLatency = s);
1925
+ s < o + Mt || (console.warn(`havik-player: catch-up at ${r}x not gaining on the live edge (latency ${n.toFixed(1)}s); holding at ${s.toFixed(1)}s`), this.liveRetargets += 1, e.targetLatency = s);
1926
1926
  }
1927
1927
  suspendChasing() {
1928
1928
  let e = this.hls;
@@ -1967,7 +1967,7 @@ var Zt = class {
1967
1967
  scheduleLicenseRetry(t) {
1968
1968
  if (t.details !== e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED && t.details !== e.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) return !1;
1969
1969
  let n = t.response?.code ?? 0;
1970
- if (!(n === 0 || n === 408 || n === 429 || n >= 500) || this.licenseRecoveries >= bt) return !1;
1970
+ if (!(n === 0 || n === 408 || n === 429 || n >= 500) || this.licenseRecoveries >= xt) return !1;
1971
1971
  this.licenseRecoveries += 1;
1972
1972
  let r = Math.min(8e3, 500 * 2 ** (this.licenseRecoveries - 1));
1973
1973
  return this.licenseRetryTimer = setTimeout(() => {
@@ -1999,7 +1999,7 @@ var Zt = class {
1999
1999
  return;
2000
2000
  }
2001
2001
  if (t.type === e.ErrorTypes.NETWORK_ERROR) {
2002
- if (this.networkRecoveries < yt) {
2002
+ if (this.networkRecoveries < bt) {
2003
2003
  this.networkRecoveries += 1;
2004
2004
  let e = Math.min(8e3, 1e3 * 2 ** (this.networkRecoveries - 1));
2005
2005
  this.networkRetryTimer = setTimeout(() => {
@@ -2016,7 +2016,7 @@ var Zt = class {
2016
2016
  return;
2017
2017
  }
2018
2018
  if (t.type === e.ErrorTypes.MEDIA_ERROR) {
2019
- if (this.mediaRecoveries < vt) {
2019
+ if (this.mediaRecoveries < yt) {
2020
2020
  this.mediaRecoveries += 1, n.recoverMediaError();
2021
2021
  return;
2022
2022
  }
@@ -2040,19 +2040,19 @@ var Zt = class {
2040
2040
  let r = e.response?.code ?? 0, a = e.details ?? e.type, o = e.reason ?? e.error?.message ?? "";
2041
2041
  return new n(t === "DRM" ? i(r) : r === 401 ? "UNAUTHORIZED" : r === 403 ? "FORBIDDEN" : "INTERNAL", r, `${t} error: ${a}${o ? ` (${o})` : ""}`);
2042
2042
  }
2043
- }, Qt = 15e3, $t = 6e5, en = 3e5, tn = 100, q = 1, nn = 1e3, rn = 3e4, an = 1e3, on = {
2043
+ }, $t = 15e3, en = 6e5, tn = 3e5, nn = 100, q = 1, rn = 1e3, an = 3e4, on = 1e3, sn = {
2044
2044
  inline: "PRESENTATION_INLINE",
2045
2045
  fullscreen: "PRESENTATION_FULLSCREEN",
2046
2046
  pip: "PRESENTATION_PIP"
2047
- }, sn = {
2047
+ }, cn = {
2048
2048
  widevine: "KEY_SYSTEM_WIDEVINE",
2049
2049
  fairplay: "KEY_SYSTEM_FAIRPLAY",
2050
2050
  none: "KEY_SYSTEM_NONE"
2051
2051
  };
2052
- function cn(e, t) {
2052
+ function ln(e, t) {
2053
2053
  return e.length === 0 ? 0 : e[Math.min(e.length, Math.max(1, Math.ceil(t / 100 * e.length))) - 1] ?? 0;
2054
2054
  }
2055
- var ln = /* @__PURE__ */ new Set([
2055
+ var un = /* @__PURE__ */ new Set([
2056
2056
  "INVALID_URN",
2057
2057
  "NOT_FOUND",
2058
2058
  "GONE",
@@ -2072,7 +2072,7 @@ var ln = /* @__PURE__ */ new Set([
2072
2072
  ended: "PLAYER_STATE_ENDED",
2073
2073
  error: "PLAYER_STATE_ERROR"
2074
2074
  };
2075
- function un(e) {
2075
+ function dn(e) {
2076
2076
  try {
2077
2077
  let t = new URL(e), [n, ...r] = t.hostname.split(".");
2078
2078
  return !n || r.length === 0 || n !== "feed" && !n.startsWith("feed-") ? void 0 : (t.hostname = [n.replace(/^feed/, "beacons"), ...r].join("."), t.pathname = "", t.search = "", t.origin);
@@ -2080,8 +2080,8 @@ function un(e) {
2080
2080
  return;
2081
2081
  }
2082
2082
  }
2083
- var dn = (e, t) => e.replace(/\/$/, "").toLowerCase() === t.replace(/\/$/, "").toLowerCase(), fn = /* @__PURE__ */ new Set(), Y = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Set(), pn = (e) => `this page's Content-Security-Policy blocks QoE beacons. Add ${e} to connect-src; until then none are sent.`;
2084
- function mn(e) {
2083
+ var fn = (e, t) => e.replace(/\/$/, "").toLowerCase() === t.replace(/\/$/, "").toLowerCase(), pn = /* @__PURE__ */ new Set(), Y = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Set(), mn = (e) => `this page's Content-Security-Policy blocks QoE beacons. Add ${e} to connect-src; until then none are sent.`;
2084
+ function hn(e) {
2085
2085
  if (e.disposition !== "enforce" || e.effectiveDirective !== "connect-src") return;
2086
2086
  let t;
2087
2087
  try {
@@ -2090,19 +2090,19 @@ function mn(e) {
2090
2090
  } catch {
2091
2091
  return;
2092
2092
  }
2093
- if (fn.has(t) && !Y.has(t)) {
2094
- Y.add(t), g(pn(new URL(t).origin));
2093
+ if (pn.has(t) && !Y.has(t)) {
2094
+ Y.add(t), g(mn(new URL(t).origin));
2095
2095
  for (let e of X) e.noteCspBlocked();
2096
2096
  }
2097
2097
  }
2098
- function hn(e, t) {
2098
+ function Z(e, t) {
2099
2099
  return g(t, e), { disabledReason: t };
2100
2100
  }
2101
2101
  function gn(e, t, n) {
2102
- if (n) return t && !dn(t, n) && g(`analytics.endpoint "${t}" ignored; the server named "${n}".`), { endpoint: n };
2102
+ if (n) return t && !fn(t, n) && g(`analytics.endpoint "${t}" ignored; the server named "${n}".`), { endpoint: n };
2103
2103
  if (t) return { endpoint: t };
2104
- if (t !== void 0) return hn("empty-endpoint", "analytics is disabled: no QoE beacons will be sent. analytics.endpoint was supplied but empty. Pass a real beacons origin, analytics: { endpoint: 'https://beacons[-dev].<domain>' }, or omit the option to derive it from baseUrl (or analytics: false to opt out).");
2105
- let r = un(e);
2104
+ if (t !== void 0) return Z("empty-endpoint", "analytics is disabled: no QoE beacons will be sent. analytics.endpoint was supplied but empty. Pass a real beacons origin, analytics: { endpoint: 'https://beacons[-dev].<domain>' }, or omit the option to derive it from baseUrl (or analytics: false to opt out).");
2105
+ let r = dn(e);
2106
2106
  if (r) return { endpoint: r };
2107
2107
  let i;
2108
2108
  try {
@@ -2110,7 +2110,7 @@ function gn(e, t, n) {
2110
2110
  } catch {
2111
2111
  i = e;
2112
2112
  }
2113
- return hn(i, `analytics is disabled: no QoE beacons will be sent. The beacons endpoint cannot be derived from the baseUrl host "${i}" — the convention is feed[-dev].<domain> → beacons[-dev].<domain>. Pass an explicit endpoint, analytics: { endpoint: 'https://beacons[-dev].<domain>' }, to createPlayer (or analytics: false to opt out deliberately).`);
2113
+ return Z(i, `analytics is disabled: no QoE beacons will be sent. The beacons endpoint cannot be derived from the baseUrl host "${i}" — the convention is feed[-dev].<domain> → beacons[-dev].<domain>. Pass an explicit endpoint, analytics: { endpoint: 'https://beacons[-dev].<domain>' }, to createPlayer (or analytics: false to opt out deliberately).`);
2114
2114
  }
2115
2115
  var _n = class {
2116
2116
  opts;
@@ -2194,8 +2194,8 @@ var _n = class {
2194
2194
  constructor(e) {
2195
2195
  this.opts = {
2196
2196
  ...e,
2197
- heartbeatMs: e.heartbeatMs ?? Qt,
2198
- idleMs: e.idleMs ?? $t
2197
+ heartbeatMs: e.heartbeatMs ?? $t,
2198
+ idleMs: e.idleMs ?? en
2199
2199
  }, this.url = `${e.endpoint.replace(/\/$/, "")}/v1/beacons`;
2200
2200
  try {
2201
2201
  let e = new URL(this.url);
@@ -2212,11 +2212,11 @@ var _n = class {
2212
2212
  sdkVersion: this.opts.sdkVersion,
2213
2213
  ...this.opts.environment
2214
2214
  };
2215
- this.pendingStart = e, this.enqueue({ sessionStart: e }), this.firstFlushTimer = setTimeout(() => this.flush(), nn), this.lastTickMs = this.now(), this.timer = setInterval(() => this.heartbeat(), this.opts.heartbeatMs), typeof window < "u" && window.addEventListener("pagehide", this.onPagehide), typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), document.addEventListener("freeze", this.onFreeze), document.addEventListener("resume", this.onResume), this.cspKey && fn.add(this.cspKey), document.addEventListener("securitypolicyviolation", mn), X.add(this), this.noteCspBlocked(), this.onVisibility());
2215
+ this.pendingStart = e, this.enqueue({ sessionStart: e }), this.firstFlushTimer = setTimeout(() => this.flush(), rn), this.lastTickMs = this.now(), this.timer = setInterval(() => this.heartbeat(), this.opts.heartbeatMs), typeof window < "u" && window.addEventListener("pagehide", this.onPagehide), typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), document.addEventListener("freeze", this.onFreeze), document.addEventListener("resume", this.onResume), this.cspKey && pn.add(this.cspKey), document.addEventListener("securitypolicyviolation", hn), X.add(this), this.noteCspBlocked(), this.onVisibility());
2216
2216
  }
2217
2217
  checkSuspension(e) {
2218
2218
  if (this.endedFlag || !this.opts.idleMs) return !1;
2219
- let t = Math.max(this.opts.idleMs, en);
2219
+ let t = Math.max(this.opts.idleMs, tn);
2220
2220
  return this.lastTickMs > 0 && e - this.lastTickMs >= t ? (this.endIdle(this.lastTickMs), !0) : (this.lastTickMs = e, !1);
2221
2221
  }
2222
2222
  syncIdle(e) {
@@ -2239,12 +2239,12 @@ var _n = class {
2239
2239
  let a = {
2240
2240
  fromState: J[e] ?? "PLAYER_STATE_UNSPECIFIED",
2241
2241
  toState: J[t] ?? "PLAYER_STATE_UNSPECIFIED",
2242
- presentation: on[this.presentation]
2242
+ presentation: sn[this.presentation]
2243
2243
  }, o = this.causeOf(e, t, i);
2244
2244
  o && (a.cause = o), n > 0 && (a.positionMs = Math.round(n)), r && (a.renditionHeight = r), this.enqueue({ stateChange: a });
2245
2245
  }
2246
2246
  seekInduced(e) {
2247
- return this.lastSeekMs >= 0 && e - this.lastSeekMs < an;
2247
+ return this.lastSeekMs >= 0 && e - this.lastSeekMs < on;
2248
2248
  }
2249
2249
  causeOf(e, t, n) {
2250
2250
  if (t === "error") return "TRANSITION_CAUSE_ERROR";
@@ -2318,7 +2318,7 @@ var _n = class {
2318
2318
  let r = n ?? "";
2319
2319
  if (r !== "") return /^fragLoad/i.test(r) ? this.sawFirstBytes ? "ERROR_STAGE_SEGMENT" : "ERROR_STAGE_FIRST_SEGMENT" : /^(manifest|level|audioTrack|subtitleTrack)/i.test(r) ? "ERROR_STAGE_MANIFEST" : /key|licen[cs]e/i.test(r) ? "ERROR_STAGE_DRM" : /parsing|append|buffer|remux|decrypt|media/i.test(r) ? "ERROR_STAGE_DECODE" : "ERROR_STAGE_OTHER";
2320
2320
  if (e === "DRM_CLIENT") return "ERROR_STAGE_DRM";
2321
- if (ln.has(e)) return "ERROR_STAGE_RESOLVE";
2321
+ if (un.has(e)) return "ERROR_STAGE_RESOLVE";
2322
2322
  let i = t ?? "";
2323
2323
  return /frag|segment/i.test(i) ? this.sawFirstBytes ? "ERROR_STAGE_SEGMENT" : "ERROR_STAGE_FIRST_SEGMENT" : /manifest|level|playlist/i.test(i) ? "ERROR_STAGE_MANIFEST" : /key|licen[cs]e/i.test(i) ? "ERROR_STAGE_DRM" : /buffer|decode|media|append/i.test(i) ? "ERROR_STAGE_DECODE" : "ERROR_STAGE_OTHER";
2324
2324
  }
@@ -2365,14 +2365,14 @@ var _n = class {
2365
2365
  if (this.lastRequestCount = g, _ > 0) {
2366
2366
  o.requestCountDelta = _;
2367
2367
  let e = t.requestTimesMs ?? [], n = e.slice(Math.max(0, e.length - _)).sort((e, t) => e - t);
2368
- n.length > 0 && (o.requestTimeP50Ms = cn(n, 50), o.requestTimeP95Ms = cn(n, 95));
2368
+ n.length > 0 && (o.requestTimeP50Ms = ln(n, 50), o.requestTimeP95Ms = ln(n, 95));
2369
2369
  }
2370
2370
  typeof t.latencySeconds == "number" && typeof t.targetLatencySeconds == "number" && (o.driftMs = Math.round((t.latencySeconds - t.targetLatencySeconds) * 1e3)), typeof t.playbackRate == "number" && t.playbackRate > 0 && (o.playbackRate = t.playbackRate), t.qualityPinned === !0 && (o.qualityPinned = !0), t.cdnHost && (o.cdnHost = t.cdnHost), this.maybeEmitMediaInfo(t), this.enqueue({ heartbeat: o }), this.flush(), s > 0 && this.noteFirstBytes();
2371
2371
  }
2372
2372
  maybeEmitMediaInfo(e) {
2373
2373
  if (!(e.videoCodec ?? e.keySystem ?? e.ladderHeights)) return;
2374
2374
  let t = {};
2375
- e.videoCodec && (t.videoCodec = e.videoCodec), e.audioCodec && (t.audioCodec = e.audioCodec), e.keySystem && (t.keySystem = sn[e.keySystem]), e.drmSecurityLevel && (t.drmSecurityLevel = e.drmSecurityLevel), e.ladderHeights?.length && (t.ladderHeights = e.ladderHeights), e.ladderTopBitrateKbps && (t.ladderTopBitrateKbps = e.ladderTopBitrateKbps), e.lowLatency && (t.lowLatency = !0);
2375
+ e.videoCodec && (t.videoCodec = e.videoCodec), e.audioCodec && (t.audioCodec = e.audioCodec), e.keySystem && (t.keySystem = cn[e.keySystem]), e.drmSecurityLevel && (t.drmSecurityLevel = e.drmSecurityLevel), e.ladderHeights?.length && (t.ladderHeights = e.ladderHeights), e.ladderTopBitrateKbps && (t.ladderTopBitrateKbps = e.ladderTopBitrateKbps), e.lowLatency && (t.lowLatency = !0);
2376
2376
  let n = JSON.stringify(t);
2377
2377
  n !== this.mediaInfoSignature && (this.mediaInfoSignature = n, this.enqueue({ mediaInfo: t }));
2378
2378
  }
@@ -2392,7 +2392,7 @@ var _n = class {
2392
2392
  let c = r?.positionMs ?? 0;
2393
2393
  c > 0 && (i.exitPositionMs = Math.round(c)), this.activeTotalMs > 0 && (i.activeWatchTimeMs = Math.round(this.activeTotalMs)), this.mutedTotalMs > 0 && (i.mutedTimeMs = Math.round(this.mutedTotalMs));
2394
2394
  let l = e !== "END_REASON_ENDED";
2395
- l && this.lastStallMs > 0 && n - this.lastStallMs <= rn && (i.abandonAfterStallMs = Math.max(q, Math.round(n - this.lastStallMs))), l && this.lastErrorMs > 0 && n - this.lastErrorMs <= rn && (i.abandonAfterErrorMs = Math.max(q, Math.round(n - this.lastErrorMs))), this.fullscreenTotalMs > 0 && (i.fullscreenTimeMs = Math.round(this.fullscreenTotalMs)), this.pipTotalMs > 0 && (i.pipTimeMs = Math.round(this.pipTotalMs)), this.volumeChanges > 0 && (i.volumeChanges = this.volumeChanges), this.muteChanges > 0 && (i.muteChanges = this.muteChanges);
2395
+ l && this.lastStallMs > 0 && n - this.lastStallMs <= an && (i.abandonAfterStallMs = Math.max(q, Math.round(n - this.lastStallMs))), l && this.lastErrorMs > 0 && n - this.lastErrorMs <= an && (i.abandonAfterErrorMs = Math.max(q, Math.round(n - this.lastErrorMs))), this.fullscreenTotalMs > 0 && (i.fullscreenTimeMs = Math.round(this.fullscreenTotalMs)), this.pipTotalMs > 0 && (i.pipTimeMs = Math.round(this.pipTotalMs)), this.volumeChanges > 0 && (i.volumeChanges = this.volumeChanges), this.muteChanges > 0 && (i.muteChanges = this.muteChanges);
2396
2396
  let u = r?.decodedFrames ?? this.lastDecoded;
2397
2397
  u > 0 && (i.decodedFramesTotal = u), e === "END_REASON_STOPPED" && this.startupTimeMs === 0 && this.lastErrorStage === null && (e = "END_REASON_ABORTED", i.reason = e), this.startupTimeMs === 0 && e !== "END_REASON_ABORTED" && (i.failedStage = this.lastErrorStage ?? (this.manifestLoadMs === 0 ? "ERROR_STAGE_MANIFEST" : this.firstFragLoadMs === 0 ? "ERROR_STAGE_FIRST_SEGMENT" : "ERROR_STAGE_OTHER")), this.pending.push(this.wrap({ sessionEnd: i })), this.flush(e === "END_REASON_PAGEHIDE");
2398
2398
  }
@@ -2412,13 +2412,13 @@ var _n = class {
2412
2412
  };
2413
2413
  }
2414
2414
  noteCspBlocked() {
2415
- this.cspBlockedNoted || this.endedFlag || !this.cspBlocked() || (this.cspBlockedNoted = !0, this.opts.onBlocked?.(pn(new URL(this.url).origin)));
2415
+ this.cspBlockedNoted || this.endedFlag || !this.cspBlocked() || (this.cspBlockedNoted = !0, this.opts.onBlocked?.(mn(new URL(this.url).origin)));
2416
2416
  }
2417
2417
  cspBlocked() {
2418
2418
  return !!this.cspKey && Y.has(this.cspKey);
2419
2419
  }
2420
2420
  enqueue(e) {
2421
- if (!this.cspBlocked()) for (this.pending.push(this.wrap(e)); this.pending.length > tn;) {
2421
+ if (!this.cspBlocked()) for (this.pending.push(this.wrap(e)); this.pending.length > nn;) {
2422
2422
  let e = this.pending.findIndex((e) => e.heartbeat || e.stateChange);
2423
2423
  this.pending.splice(e >= 0 ? e : 0, 1);
2424
2424
  }
@@ -2518,7 +2518,7 @@ async function Sn() {
2518
2518
  }
2519
2519
  //#endregion
2520
2520
  //#region src/core/version.ts
2521
- var Cn = "2.16.8", wn = {
2521
+ var Cn = "2.16.10", wn = {
2522
2522
  accent: "#E1B600",
2523
2523
  accentText: "#1B1C23",
2524
2524
  background: "#0e0f13",
@@ -2573,7 +2573,7 @@ var jn = {
2573
2573
  liveDot: "<circle cx=\"12\" cy=\"12\" r=\"6\"/>",
2574
2574
  retry: "<path d=\"M17.65 6.35A8 8 0 1 0 19.73 13h-2.08A6 6 0 1 1 12 6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z\"/>"
2575
2575
  };
2576
- function Z(e) {
2576
+ function Q(e) {
2577
2577
  return `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="currentColor">${jn[e]}</svg>`;
2578
2578
  }
2579
2579
  //#endregion
@@ -2644,12 +2644,12 @@ var In = class {
2644
2644
  "aria-label": r,
2645
2645
  title: r
2646
2646
  });
2647
- return i.innerHTML = Z(n), i;
2647
+ return i.innerHTML = Q(n), i;
2648
2648
  };
2649
2649
  this.overlay = t("div", "havik-overlay"), this.center = t("button", "havik-center", {
2650
2650
  type: "button",
2651
2651
  "aria-label": "Play"
2652
- }), this.center.innerHTML = Z("play"), this.spinner = t("div", "havik-spinner"), this.spinner.style.display = "none", this.overlay.append(this.center, this.spinner), this.gradient = t("div", "havik-gradient"), this.bar = t("div", "havik-bar"), this.seek = t("div", "havik-seek", {
2652
+ }), this.center.innerHTML = Q("play"), this.spinner = t("div", "havik-spinner"), this.spinner.style.display = "none", this.overlay.append(this.center, this.spinner), this.gradient = t("div", "havik-gradient"), this.bar = t("div", "havik-bar"), this.seek = t("div", "havik-seek", {
2653
2653
  role: "slider",
2654
2654
  "aria-label": "Seek",
2655
2655
  "aria-valuemin": "0",
@@ -2667,7 +2667,7 @@ var In = class {
2667
2667
  "aria-label": "Volume"
2668
2668
  });
2669
2669
  let a = t("div", "havik-vol");
2670
- a.append(this.muteBtn, this.volSlider), this.live = t("div", "havik-live"), this.live.innerHTML = Z("liveDot");
2670
+ a.append(this.muteBtn, this.volSlider), this.live = t("div", "havik-live"), this.live.innerHTML = Q("liveDot");
2671
2671
  let o = this.doc.createElement("span");
2672
2672
  o.textContent = "LIVE", this.liveGo = t("button", "havik-live__go", { type: "button" }), this.liveGo.textContent = "Go live", this.live.append(o, this.liveGo), this.time = t("div", "havik-time"), this.time.textContent = "0:00", this.time.style.display = "none";
2673
2673
  let s = t("div", "havik-spacer");
@@ -2751,12 +2751,12 @@ var In = class {
2751
2751
  }
2752
2752
  if (e === "preplay") {
2753
2753
  let e = this.doc.createElement("button");
2754
- e.type = "button", e.className = "havik-status__btn havik-status__btn--play", e.setAttribute("aria-label", "Play"), e.innerHTML = Z("play"), e.addEventListener("click", () => void this.player.play()), n.append(e);
2754
+ e.type = "button", e.className = "havik-status__btn havik-status__btn--play", e.setAttribute("aria-label", "Play"), e.innerHTML = Q("play"), e.addEventListener("click", () => void this.player.play()), n.append(e);
2755
2755
  } else {
2756
2756
  let r = this.doc.createElement("div");
2757
2757
  if (r.className = "havik-status__msg", r.textContent = t ?? "", n.append(r), e === "error" && this.lastError && !Pn.has(this.lastError.code)) {
2758
2758
  let e = this.doc.createElement("button");
2759
- e.type = "button", e.className = "havik-status__btn", e.innerHTML = `${Z("retry")}<span>Retry</span>`, e.addEventListener("click", () => void this.player.retry()), n.append(e);
2759
+ e.type = "button", e.className = "havik-status__btn", e.innerHTML = `${Q("retry")}<span>Retry</span>`, e.addEventListener("click", () => void this.player.retry()), n.append(e);
2760
2760
  }
2761
2761
  }
2762
2762
  this.root.append(n), this.statusBox = n, this.show();
@@ -2939,7 +2939,7 @@ var In = class {
2939
2939
  }
2940
2940
  }
2941
2941
  setIcon(e, t) {
2942
- e.innerHTML = Z(t);
2942
+ e.innerHTML = Q(t);
2943
2943
  }
2944
2944
  destroy() {
2945
2945
  this.hideTimer && clearTimeout(this.hideTimer), this.tapTimer && clearTimeout(this.tapTimer);
@@ -2972,25 +2972,25 @@ function Bn(e) {
2972
2972
  }
2973
2973
  //#endregion
2974
2974
  //#region src/managed/index.ts
2975
- var Vn = 6e3, Q = 45e3, Hn = 2e3, Un = 3, Wn = 2e3, Gn = 48e4, Kn = "keySystemLicenseRequestFailed";
2976
- function qn(e) {
2975
+ var Vn = 6e3, Hn = 45e3, Un = 2e3, Wn = 3, Gn = 2e3, Kn = 48e4, qn = "keySystemLicenseRequestFailed";
2976
+ function Jn(e) {
2977
2977
  if (e.env !== void 0 && e.baseUrl !== void 0) throw new n("INTERNAL", 0, `createPlayer: pass env OR baseUrl, not both (got env=${JSON.stringify(e.env)} and baseUrl=${JSON.stringify(e.baseUrl)})`);
2978
- if (e.env !== void 0) return Ge(e.env);
2978
+ if (e.env !== void 0) return Ke(e.env);
2979
2979
  if (!e.baseUrl) throw new n("INTERNAL", 0, "createPlayer: env or baseUrl is required (env: 'integration' | 'production')");
2980
2980
  return e.baseUrl;
2981
2981
  }
2982
- async function Jn(e) {
2982
+ async function Yn(e) {
2983
2983
  if (!e.video || typeof e.video.play != "function") throw new n("INTERNAL", 0, "createPlayer: opts.video must be an HTMLVideoElement");
2984
- let t = qn(e);
2984
+ let t = Jn(e);
2985
2985
  if (!e.matchUrn) throw new n("INVALID_URN", 0, "createPlayer: matchUrn is required");
2986
2986
  if (!e.credential) throw new n("INTERNAL", 0, "createPlayer: credential is required");
2987
- let r = new Yn({
2987
+ let r = new Xn({
2988
2988
  ...e,
2989
2989
  baseUrl: t
2990
2990
  });
2991
2991
  return await r.start(), r;
2992
2992
  }
2993
- var Yn = class {
2993
+ var Xn = class {
2994
2994
  opts;
2995
2995
  abort = new AbortController();
2996
2996
  listeners = {};
@@ -3037,7 +3037,7 @@ var Yn = class {
3037
3037
  this.opts.muted && (this.opts.video.muted = !0), this.opts.poster && (this.opts.video.poster = this.opts.poster), this.mountControls(), this.attachPipListeners(), this.setState("loading");
3038
3038
  let e = ++this.loadGen, t = this.resolveOptions();
3039
3039
  try {
3040
- let n = await y(t);
3040
+ let n = await v(t);
3041
3041
  if (await this.onResolved(n, e), e === this.loadGen && this._state === "error" && this._lastError) {
3042
3042
  let e = this._lastError;
3043
3043
  throw this.destroy(), e;
@@ -3064,7 +3064,7 @@ var Yn = class {
3064
3064
  r ? this.armWithSse(e, r, t, n) : this.beginArmingByPolling(e);
3065
3065
  }
3066
3066
  beginArmingByPolling(e) {
3067
- b({
3067
+ y({
3068
3068
  ...this.resolveOptions(),
3069
3069
  signal: this.abort.signal,
3070
3070
  waitForLive: this.buildWaitConfig(e)
@@ -3081,7 +3081,7 @@ var Yn = class {
3081
3081
  setTimeout(() => {
3082
3082
  a || this.destroyed || e !== this.loadGen || this.emit("waiting", {
3083
3083
  phase: i ? "unavailable" : "tooEarly",
3084
- retryInMs: Q,
3084
+ retryInMs: Hn,
3085
3085
  attempt: 1,
3086
3086
  elapsedMs: 0,
3087
3087
  ...!i && f !== void 0 && f > Date.now() ? { ttkMs: f - Date.now() } : {}
@@ -3098,7 +3098,7 @@ var Yn = class {
3098
3098
  }
3099
3099
  }
3100
3100
  }, h = () => {
3101
- a || s || p() || (s = !0, b({
3101
+ a || s || p() || (s = !0, y({
3102
3102
  ...this.resolveOptions(),
3103
3103
  signal: c.signal,
3104
3104
  waitForLive: this.buildWaitConfig(e)
@@ -3106,7 +3106,7 @@ var Yn = class {
3106
3106
  a || p() || c.signal.aborted || (a = !0, this.closeArming(), this.fail(e instanceof n ? e : new n("INTERNAL", 0, String(e))));
3107
3107
  }));
3108
3108
  }, g = () => {
3109
- a || p() || y(this.resolveOptions()).then((e) => m(e)).catch((e) => {
3109
+ a || p() || v(this.resolveOptions()).then((e) => m(e)).catch((e) => {
3110
3110
  if (!(a || p())) {
3111
3111
  if (e instanceof n && o(e.code)) {
3112
3112
  h();
@@ -3124,9 +3124,9 @@ var Yn = class {
3124
3124
  eventsBaseUrl: t,
3125
3125
  matchUrn: this.opts.matchUrn,
3126
3126
  credential: this.opts.credential,
3127
- onAlive: () => _(Q),
3127
+ onAlive: () => _(Hn),
3128
3128
  onState: (e) => {
3129
- a || p() || (e.state === "live" || e.state === "gone") && setTimeout(g, Math.random() * Hn);
3129
+ a || p() || (e.state === "live" || e.state === "gone") && setTimeout(g, Math.random() * Un);
3130
3130
  },
3131
3131
  onError: () => h()
3132
3132
  });
@@ -3190,7 +3190,7 @@ var Yn = class {
3190
3190
  this.destroyed || r !== this.loadGen || this.emit("warning", new n("INTERNAL", 0, e));
3191
3191
  }, 0),
3192
3192
  sample: () => {
3193
- let e = this.engine?.getStats() ?? Ke, t = c.buffered.length ? Math.max(0, c.buffered.end(c.buffered.length - 1) - c.currentTime) : 0;
3193
+ let e = this.engine?.getStats() ?? qe, t = c.buffered.length ? Math.max(0, c.buffered.end(c.buffered.length - 1) - c.currentTime) : 0;
3194
3194
  return {
3195
3195
  ...e,
3196
3196
  bufferedMs: Math.round(t * 1e3),
@@ -3231,9 +3231,9 @@ var Yn = class {
3231
3231
  freshLicenseUrl: () => this.refreshLicense()
3232
3232
  }, o = this.opts.engine ?? "auto";
3233
3233
  if (o === "native") return new W(a);
3234
- if (o === "hls") return new Zt(a);
3235
- if (e.drmEnabled && e.drm?.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && H(this.opts.video) && U() || !e.drmEnabled && at() && H(this.opts.video)) return new W(a);
3236
- if (_t()) return new Zt(a);
3234
+ if (o === "hls") return new Qt(a);
3235
+ if (e.drmEnabled && e.drm?.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && H(this.opts.video) && U() || !e.drmEnabled && ot() && H(this.opts.video)) return new W(a);
3236
+ if (vt()) return new Qt(a);
3237
3237
  if (H(this.opts.video)) return new W(a);
3238
3238
  throw new n("INTERNAL", 0, "no supported HLS playback engine in this browser");
3239
3239
  }
@@ -3296,7 +3296,7 @@ var Yn = class {
3296
3296
  r = 0, i = !1;
3297
3297
  },
3298
3298
  onError: () => {
3299
- this.destroyed || e !== this.loadGen || i || this.endedHandled || (r += 1, r >= Un && (i = !0, this.emit("warning", new n("NETWORK", 0, `live-state events unreachable at ${t} after ${r} attempts — end-of-stream detection degraded to the HLS staleness watchdog. Check the events host, the api-key's allowed origins, and CSP connect-src.`))));
3299
+ this.destroyed || e !== this.loadGen || i || this.endedHandled || (r += 1, r >= Wn && (i = !0, this.emit("warning", new n("NETWORK", 0, `live-state events unreachable at ${t} after ${r} attempts — end-of-stream detection degraded to the HLS staleness watchdog. Check the events host, the api-key's allowed origins, and CSP connect-src.`))));
3300
3300
  }
3301
3301
  });
3302
3302
  }
@@ -3318,7 +3318,7 @@ var Yn = class {
3318
3318
  scheduleRejoin(e) {
3319
3319
  this.rejoinEnabled() && !this.rejoinTimer && (this.rejoinTimer = setTimeout(() => {
3320
3320
  this.rejoinTimer = null, !(this.destroyed || e !== this.loadGen || this._state !== "ended") && this.rejoin();
3321
- }, Math.random() * Hn));
3321
+ }, Math.random() * Un));
3322
3322
  }
3323
3323
  cancelRejoin() {
3324
3324
  this.rejoinTimer &&= (clearTimeout(this.rejoinTimer), null);
@@ -3373,7 +3373,7 @@ var Yn = class {
3373
3373
  }
3374
3374
  startStats() {
3375
3375
  this.stopStats();
3376
- let e = Math.max(500, this.opts.statsIntervalMs ?? Wn);
3376
+ let e = Math.max(500, this.opts.statsIntervalMs ?? Gn);
3377
3377
  this.statsTimer = setInterval(() => {
3378
3378
  if (!this.engine) return;
3379
3379
  let e = this.engine.getStats();
@@ -3384,14 +3384,14 @@ var Yn = class {
3384
3384
  this.statsTimer && clearInterval(this.statsTimer), this.statsTimer = void 0;
3385
3385
  }
3386
3386
  isStaleLicenseDenial(e) {
3387
- return this.staleLicenseReloaded || this.opts.hlsConfig?.licenseXhrSetup || this._state === "ended" || this._state === "error" || e.detail !== Kn || e.error.httpStatus !== 403 ? !1 : K(this._descriptor?.drm?.widevine?.licenseUrl);
3387
+ return this.staleLicenseReloaded || this.opts.hlsConfig?.licenseXhrSetup || this._state === "ended" || this._state === "error" || e.detail !== qn || e.error.httpStatus !== 403 ? !1 : K(this._descriptor?.drm?.widevine?.licenseUrl);
3388
3388
  }
3389
3389
  scheduleLicenseRefresh() {
3390
3390
  if (this.stopRefresh(), !this._descriptor?.drmEnabled) return;
3391
3391
  typeof document < "u" && this.engine?.name === "hls" && (this.onRefocus = () => {
3392
3392
  document.visibilityState !== "visible" || this.destroyed || K(this._descriptor?.drm?.widevine?.licenseUrl) && this.refreshLicense();
3393
3393
  }, document.addEventListener("visibilitychange", this.onRefocus));
3394
- let e = this.opts.licenseRefreshMs ?? Gn;
3394
+ let e = this.opts.licenseRefreshMs ?? Kn;
3395
3395
  e && (this.refreshTimer = setInterval(() => void this.refreshLicense(), e));
3396
3396
  }
3397
3397
  stopRefresh() {
@@ -3403,7 +3403,7 @@ var Yn = class {
3403
3403
  if (this.refreshInFlight?.engine === e) return this.refreshInFlight.promise;
3404
3404
  let t = (async () => {
3405
3405
  try {
3406
- let t = await y(this.resolveOptions());
3406
+ let t = await v(this.resolveOptions());
3407
3407
  if (this.destroyed || this.engine !== e) return;
3408
3408
  let n = t.drm?.widevine?.licenseUrl, r = t.drm?.fairplay?.licenseUrl;
3409
3409
  return (n || r) && (e.setLicenseUrls({
@@ -3447,7 +3447,7 @@ var Yn = class {
3447
3447
  this.destroyed || (this.opts.video.volume = Math.min(1, Math.max(0, e)));
3448
3448
  }
3449
3449
  getStats() {
3450
- return this.engine?.getStats() ?? Ke;
3450
+ return this.engine?.getStats() ?? qe;
3451
3451
  }
3452
3452
  getQualityLevels() {
3453
3453
  return this.engine?.getQualityLevels() ?? [];
@@ -3499,7 +3499,7 @@ var Yn = class {
3499
3499
  let e = ++this.loadGen;
3500
3500
  this.teardownPlayback();
3501
3501
  try {
3502
- let t = await b({
3502
+ let t = await y({
3503
3503
  ...this.resolveOptions(),
3504
3504
  waitForLive: this.opts.waitForLive ? this.buildWaitConfig(e) : void 0
3505
3505
  });
@@ -3557,7 +3557,7 @@ function $(e) {
3557
3557
  }
3558
3558
  //#endregion
3559
3559
  //#region src/embed/host.ts
3560
- function Xn(e) {
3560
+ function Zn(e) {
3561
3561
  if (!e.container || typeof e.container.appendChild != "function") throw Error("mountEmbed: opts.container must be a DOM element");
3562
3562
  if (!e.src) throw Error("mountEmbed: opts.src is required");
3563
3563
  if (!e.baseUrl || !e.matchUrn) throw Error("mountEmbed: opts.baseUrl and opts.matchUrn are required");
@@ -3616,15 +3616,15 @@ function Xn(e) {
3616
3616
  }
3617
3617
  //#endregion
3618
3618
  //#region src/embed/page.ts
3619
- var Zn = /^[A-Za-z0-9:_.-]{1,128}$/;
3620
- function Qn(e) {
3619
+ var Qn = /^[A-Za-z0-9:_.-]{1,128}$/;
3620
+ function $n(e) {
3621
3621
  if (typeof e == "boolean") return e;
3622
3622
  if (typeof e == "object" && e) {
3623
3623
  let t = e.endpoint;
3624
3624
  return typeof t == "string" ? { endpoint: t } : {};
3625
3625
  }
3626
3626
  }
3627
- function $n() {
3627
+ function er() {
3628
3628
  let e = window.HAVIK_EMBED_CONFIG;
3629
3629
  if (e) return {
3630
3630
  baseUrl: e.baseUrl ?? "",
@@ -3634,7 +3634,7 @@ function $n() {
3634
3634
  autoplay: e.autoplay ?? !0,
3635
3635
  muted: e.muted ?? !0,
3636
3636
  waitForLive: e.waitForLive ?? !0,
3637
- analytics: Qn(e.analytics)
3637
+ analytics: $n(e.analytics)
3638
3638
  };
3639
3639
  let t = new URLSearchParams(location.search);
3640
3640
  return {
@@ -3647,9 +3647,9 @@ function $n() {
3647
3647
  waitForLive: !0
3648
3648
  };
3649
3649
  }
3650
- async function er() {
3651
- let e = $n();
3652
- nr();
3650
+ async function tr() {
3651
+ let e = er();
3652
+ rr();
3653
3653
  let t = document.createElement("video");
3654
3654
  t.setAttribute("playsinline", ""), t.muted = e.muted ?? !0, t.style.cssText = "width:100%;height:100%;object-fit:contain;background:#000;aspect-ratio:auto", document.body.appendChild(t);
3655
3655
  let r = e.parentOrigin && e.parentOrigin !== "null" ? e.parentOrigin : null;
@@ -3704,12 +3704,12 @@ async function er() {
3704
3704
  code: e.code,
3705
3705
  message: e.message
3706
3706
  })), e.on("autoplayblocked", () => {
3707
- i({ type: "oddin:autoplayblocked" }), tr(t, e);
3707
+ i({ type: "oddin:autoplayblocked" }), nr(t, e);
3708
3708
  });
3709
3709
  }, s = async (r) => {
3710
3710
  a?.destroy(), a = null;
3711
3711
  try {
3712
- let n = await Jn({
3712
+ let n = await Yn({
3713
3713
  video: t,
3714
3714
  baseUrl: e.baseUrl,
3715
3715
  matchUrn: r,
@@ -3771,7 +3771,7 @@ async function er() {
3771
3771
  a?.retry();
3772
3772
  break;
3773
3773
  case "oddin:load":
3774
- typeof e.matchUrn == "string" && Zn.test(e.matchUrn) && s(e.matchUrn);
3774
+ typeof e.matchUrn == "string" && Qn.test(e.matchUrn) && s(e.matchUrn);
3775
3775
  break;
3776
3776
  case "oddin:destroy": c();
3777
3777
  }
@@ -3783,18 +3783,18 @@ async function er() {
3783
3783
  protocol: 1
3784
3784
  });
3785
3785
  }
3786
- function tr(e, t) {
3786
+ function nr(e, t) {
3787
3787
  if (document.getElementById("havik-tap")) return;
3788
3788
  let n = document.createElement("button");
3789
3789
  n.id = "havik-tap", n.textContent = "▶ Tap to play", n.style.cssText = "position:fixed;inset:0;width:100%;height:100%;border:0;background:rgba(0,0,0,.55);color:#fff;font:600 18px system-ui,sans-serif;cursor:pointer;z-index:9", n.addEventListener("click", () => {
3790
3790
  n.remove(), t.play();
3791
3791
  }), document.body.appendChild(n);
3792
3792
  }
3793
- function nr() {
3793
+ function rr() {
3794
3794
  let e = document.createElement("style");
3795
3795
  e.textContent = "html,body{margin:0;height:100%;background:#000;overflow:hidden}body{display:flex}", document.head.appendChild(e);
3796
3796
  }
3797
3797
  //#endregion
3798
- export { wn as ODDIN_THEME, n as PlaybackError, En as applyTheme, Ge as baseUrlForEnv, er as bootEmbed, Te as clearDeviceId, Jn as createPlayer, E as deriveEventsBaseUrl, Ve as detectDrmSupport, C as enterVideoFullscreen, w as exitVideoFullscreen, _e as fetchCatalog, ye as fetchTournament, xe as flattenMatches, k as getDeviceId, Ue as isLowLatencyManifest, $ as isOddinMessage, De as licenseRequestHeaders, Xn as mountEmbed, v as pollToLive, b as resolveStream, T as subscribeLiveState, S as videoFullscreenActive, Ce as watchStatus };
3798
+ export { wn as ODDIN_THEME, n as PlaybackError, En as applyTheme, Ke as baseUrlForEnv, tr as bootEmbed, Te as clearDeviceId, Yn as createPlayer, E as deriveEventsBaseUrl, He as detectDrmSupport, C as enterVideoFullscreen, w as exitVideoFullscreen, _e as fetchCatalog, ye as fetchTournament, xe as flattenMatches, k as getDeviceId, We as isLowLatencyManifest, $ as isOddinMessage, De as licenseRequestHeaders, Zn as mountEmbed, de as pollToLive, y as resolveStream, T as subscribeLiveState, S as videoFullscreenActive, Ce as watchStatus };
3799
3799
 
3800
3800
  //# sourceMappingURL=index.js.map