@vindral/web-sdk 4.1.4-4-g5b507b07 → 4.1.4-6-g7bc4e5ae

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/legacy.es.js CHANGED
@@ -120,22 +120,40 @@ var xA = (i, A, t) => {
120
120
  };
121
121
  return B();
122
122
  };
123
- const vQ = (i) => {
124
- switch (i) {
125
- case "h264":
126
- case "av1":
127
- return "video";
128
- case "aac":
129
- case "opus":
130
- case "mp3":
131
- return "audio";
132
- case "webvtt":
133
- return "text";
134
- default:
135
- throw new Error("Unknown codec");
136
- }
123
+ const Sr = "_buffering_1ccif_1", mr = "_hidden_1ccif_25", tQ = {
124
+ buffering: Sr,
125
+ "buffering-fullscreen": "_buffering-fullscreen_1ccif_16",
126
+ hidden: mr,
127
+ "buffering-indicator": "_buffering-indicator_1ccif_31"
137
128
  };
138
- class En {
129
+ class At {
130
+ constructor(A) {
131
+ I(this, "attach", (A) => {
132
+ this.detach(), A.appendChild(this.element);
133
+ });
134
+ I(this, "attachBefore", (A, t) => {
135
+ this.detach(), A.insertBefore(this.element, t);
136
+ });
137
+ I(this, "detach", () => this.element.remove());
138
+ this.element = A;
139
+ }
140
+ }
141
+ const hQ = tQ.hidden, yr = tQ.buffering, En = tQ["buffering-fullscreen"], fr = tQ["buffering-indicator"];
142
+ class Da extends At {
143
+ constructor() {
144
+ super(document.createElement("div"));
145
+ I(this, "indicator", document.createElement("div"));
146
+ I(this, "isHidden", () => this.element.classList.contains(hQ));
147
+ I(this, "setHidden", (t) => t ? this.hide() : this.show());
148
+ I(this, "hide", () => this.element.classList.add(hQ));
149
+ I(this, "show", () => this.element.classList.remove(hQ));
150
+ I(this, "fullscreen", (t) => {
151
+ t ? this.element.classList.add(En) : this.element.classList.remove(En);
152
+ });
153
+ this.element.className = yr, this.indicator.className = fr, this.element.appendChild(this.indicator);
154
+ }
155
+ }
156
+ class rn {
139
157
  constructor(A) {
140
158
  I(this, "maxSize", 0);
141
159
  I(this, "size", 0);
@@ -169,10 +187,6 @@ class En {
169
187
  return this._borrowedBuffers;
170
188
  }
171
189
  }
172
- function lA(i, A) {
173
- if (!i)
174
- throw new Error(A);
175
- }
176
190
  const q = () => {
177
191
  };
178
192
  class j {
@@ -243,11 +257,11 @@ class uA {
243
257
  }
244
258
  }
245
259
  function Yo(i) {
246
- const A = new tQ(i);
260
+ const A = new eQ(i);
247
261
  return [A, A];
248
262
  }
249
263
  var Mt, AI, It, Vg;
250
- class tQ {
264
+ class eQ {
251
265
  constructor(A) {
252
266
  /// The internal queue
253
267
  n(this, Mt);
@@ -313,11 +327,9 @@ class tQ {
313
327
  }
314
328
  }
315
329
  Mt = new WeakMap(), AI = new WeakMap(), It = new WeakMap(), Vg = new WeakMap();
316
- function Da(i) {
317
- const A = atob(i), t = new Uint8Array(A.length);
318
- for (let e = 0; e < A.length; e++)
319
- t[e] = A.charCodeAt(e);
320
- return t.buffer;
330
+ function lA(i, A) {
331
+ if (!i)
332
+ throw new Error(A);
321
333
  }
322
334
  function M(i) {
323
335
  return typeof BigInt == "function" ? BigInt(i) : i;
@@ -355,7 +367,6 @@ class Sa {
355
367
  return t - 1;
356
368
  });
357
369
  // Safety: We assume that base has enough elements
358
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
359
370
  I(this, "getBit", (A, t) => {
360
371
  if (A.byteLength * 8 <= t)
361
372
  throw new Error("BitReader: Out of bounds");
@@ -368,59 +379,7 @@ class Sa {
368
379
  }
369
380
  }
370
381
  Zg = new WeakMap(), lt = new WeakMap(), gt = new WeakMap();
371
- function Pg() {
372
- const i = self.MediaSource, A = self.ManagedMediaSource;
373
- return i != null ? i : A;
374
- }
375
- const Sr = new RegExp(
376
- "(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/",
377
- "i"
378
- ), RA = navigator.userAgent.toLowerCase(), mr = Sr.test(RA), yr = () => {
379
- const i = document.createElement("video");
380
- return i.canPlayType("application/vnd.apple.mpegURL") !== "" || i.canPlayType("audio/mpegurl") !== "";
381
- }, fr = () => {
382
- try {
383
- if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
384
- const i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
385
- if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
386
- }
387
- } catch (i) {
388
- return !1;
389
- }
390
- return !1;
391
- }, pr = () => RA.indexOf("CrKey") !== -1, ma = () => navigator.platform === "MacIntel" && navigator.maxTouchPoints === 0, eQ = () => navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, Fr = () => RA.indexOf("iphone") >= 0 && RA.indexOf("like iphone") < 0 || RA.indexOf("ipad") >= 0 && RA.indexOf("like ipad") < 0 || RA.indexOf("ipod") >= 0 && RA.indexOf("like ipod") < 0 || eQ(), Gr = () => {
392
- var i, A;
393
- return eQ() ? !1 : (A = (i = Pg()) == null ? void 0 : i.isTypeSupported('audio/mp4; codecs="opus"')) != null ? A : !1;
394
- }, kr = () => /^(?!.*chrome).*safari/i.test(RA);
395
- function Rr() {
396
- var i, A;
397
- if (/(iPhone|iPod|iPad)/i.test(RA))
398
- return (A = (i = RA == null ? void 0 : RA.match(/OS [\d_]+/i)) == null ? void 0 : i[0]) == null ? void 0 : A.substring(3).split("_").map((t) => parseInt(t))[0];
399
- }
400
- function Ur() {
401
- var i, A;
402
- if (/^((?!chrome|android).)*safari/i.test(RA))
403
- return (A = (i = RA.match(/version\/([\d.]+)/)) == null ? void 0 : i[1]) == null ? void 0 : A.split(".").map((t) => parseInt(t))[0];
404
- }
405
- const To = () => {
406
- var t, e;
407
- const i = !!Pg();
408
- let A = !1;
409
- return i && (A = Gr()), {
410
- isMobile: mr,
411
- supportsMp4Opus: A,
412
- supportsMediaSource: i,
413
- supportsHls: yr(),
414
- supportsWebAssembly: fr(),
415
- platform: {
416
- iosVersion: (t = Rr()) != null ? t : Number.MAX_SAFE_INTEGER,
417
- safariVersion: (e = Ur()) != null ? e : Number.MAX_SAFE_INTEGER,
418
- isIpadOS: eQ(),
419
- isMacOS: ma(),
420
- isIOS: Fr()
421
- }
422
- };
423
- }, Po = (i, A, t) => {
382
+ const To = (i, A, t) => {
424
383
  let e = 0;
425
384
  for (let g = A; g <= t; g++)
426
385
  if (g === A) {
@@ -467,7 +426,7 @@ class eg {
467
426
  return E(this, BA, s(this, BA) + 4), A;
468
427
  }
469
428
  readUint64() {
470
- const A = Po(s(this, Ht), s(this, BA), s(this, BA) + 7);
429
+ const A = To(s(this, Ht), s(this, BA), s(this, BA) + 7);
471
430
  return E(this, BA, s(this, BA) + 8), A;
472
431
  }
473
432
  readBytes(A) {
@@ -486,7 +445,7 @@ class eg {
486
445
  }
487
446
  }
488
447
  BA = new WeakMap(), Ht = new WeakMap(), se = new WeakMap();
489
- class Nr {
448
+ class pr {
490
449
  constructor(A = 100, t = 100) {
491
450
  I(this, "resizeSteps");
492
451
  I(this, "internalBuffer");
@@ -556,6 +515,62 @@ class Nr {
556
515
  }
557
516
  }
558
517
  }
518
+ function ma(i) {
519
+ const A = atob(i), t = new Uint8Array(A.length);
520
+ for (let e = 0; e < A.length; e++)
521
+ t[e] = A.charCodeAt(e);
522
+ return t.buffer;
523
+ }
524
+ function Pg() {
525
+ const i = self.MediaSource, A = self.ManagedMediaSource;
526
+ return i != null ? i : A;
527
+ }
528
+ const Fr = /(android|bbd+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows ce|xda|xiino\/i.test(a)||\/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-\//i, RA = navigator.userAgent.toLowerCase(), Gr = Fr.test(RA), kr = () => {
529
+ const i = document.createElement("video");
530
+ return i.canPlayType("application/vnd.apple.mpegURL") !== "" || i.canPlayType("audio/mpegurl") !== "";
531
+ }, Rr = () => {
532
+ try {
533
+ if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
534
+ const i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
535
+ if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
536
+ }
537
+ } catch (i) {
538
+ return !1;
539
+ }
540
+ return !1;
541
+ }, Ur = () => RA.indexOf("CrKey") !== -1, ya = () => navigator.platform === "MacIntel" && navigator.maxTouchPoints === 0, iQ = () => navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, Nr = () => RA.indexOf("iphone") >= 0 && RA.indexOf("like iphone") < 0 || RA.indexOf("ipad") >= 0 && RA.indexOf("like ipad") < 0 || RA.indexOf("ipod") >= 0 && RA.indexOf("like ipod") < 0 || iQ(), br = () => {
542
+ var i, A;
543
+ return iQ() ? !1 : (A = (i = Pg()) == null ? void 0 : i.isTypeSupported('audio/mp4; codecs="opus"')) != null ? A : !1;
544
+ }, Lr = () => /^(?!.*chrome).*safari/i.test(RA);
545
+ function Jr() {
546
+ var i, A;
547
+ if (/(iPhone|iPod|iPad)/i.test(RA))
548
+ return (A = (i = RA == null ? void 0 : RA.match(/OS [\d_]+/i)) == null ? void 0 : i[0]) == null ? void 0 : A.substring(3).split("_").map((t) => parseInt(t))[0];
549
+ }
550
+ function Mr() {
551
+ var i, A;
552
+ if (/^((?!chrome|android).)*safari/i.test(RA))
553
+ return (A = (i = RA.match(/version\/([\d.]+)/)) == null ? void 0 : i[1]) == null ? void 0 : A.split(".").map((t) => parseInt(t))[0];
554
+ }
555
+ const Po = () => {
556
+ var t, e;
557
+ const i = !!Pg();
558
+ let A = !1;
559
+ return i && (A = br()), {
560
+ isMobile: Gr,
561
+ supportsMp4Opus: A,
562
+ supportsMediaSource: i,
563
+ supportsHls: kr(),
564
+ supportsWebAssembly: Rr(),
565
+ platform: {
566
+ iosVersion: (t = Jr()) != null ? t : Number.MAX_SAFE_INTEGER,
567
+ safariVersion: (e = Mr()) != null ? e : Number.MAX_SAFE_INTEGER,
568
+ isIpadOS: iQ(),
569
+ isMacOS: ya(),
570
+ isIOS: Nr()
571
+ }
572
+ };
573
+ };
559
574
  class Mi {
560
575
  constructor(A, t, e) {
561
576
  I(this, "onSuccess");
@@ -576,19 +591,16 @@ const _t = (i) => i.reduce((A, t) => A + t, 0) / i.length, Ke = (i) => ({
576
591
  average: i.length === 0 ? 0 : _t(i),
577
592
  max: i.length === 0 ? 0 : Math.max(...i),
578
593
  min: i.length === 0 ? 0 : Math.min(...i)
579
- }), br = (i) => {
594
+ }), Hr = (i) => {
580
595
  let A = 0, t = 0, e = 0, g = 0, B = 0;
581
596
  for (let a = 0; a < i.length; a++) {
582
597
  const { x: c, y: h } = i[a];
583
598
  A += c, t += h, e += c * h, g += c * c, B += h * h;
584
599
  }
585
- const C = (i.length * e - A * t) / (i.length * g - A * A), Q = (t - C * A) / i.length, o = Math.pow(
586
- (i.length * e - A * t) / Math.sqrt((i.length * g - A * A) * (i.length * B - t * t)),
587
- 2
588
- );
600
+ const C = (i.length * e - A * t) / (i.length * g - A * A), Q = (t - C * A) / i.length, o = ((i.length * e - A * t) / Math.sqrt((i.length * g - A * A) * (i.length * B - t * t))) ** 2;
589
601
  return { slope: C, intercept: Q, r2: o, predict: (a) => C * (i.length + a) + Q };
590
602
  };
591
- class Lr {
603
+ class qr {
592
604
  constructor(A = 10) {
593
605
  I(this, "rates");
594
606
  I(this, "_total", 0);
@@ -651,7 +663,7 @@ class $A {
651
663
  g ? g.push(B) : this.listeners[A] = [B];
652
664
  }
653
665
  }
654
- const KQ = 1e3, YQ = KQ * 1e3, rn = YQ * 1e3, hQ = (i, A, t) => i % A === 0 ? i / A : (i / A).toFixed(t), Jr = (i, A = 1) => i >= rn ? `${hQ(i, rn, A)} Gbit/s` : i >= YQ ? `${hQ(i, YQ, A)} Mbit/s` : i >= KQ ? `${hQ(i, KQ, A)} Kbit/s` : `${i} bit/s`, Mr = ({ width: i, height: A }) => `${i}x${A}`, Hr = (i) => i % 1e3 === 0 ? `${i / 1e3} kHz` : i > 1e3 ? `${(i / 1e3).toFixed(1)} kHz` : `${i} Hz`, cn = ["off", "error", "warn", "info", "debug", "trace"], qr = {
666
+ const vQ = 1e3, KQ = vQ * 1e3, cn = KQ * 1e3, dQ = (i, A, t) => i % A === 0 ? i / A : (i / A).toFixed(t), vr = (i, A = 1) => i >= cn ? `${dQ(i, cn, A)} Gbit/s` : i >= KQ ? `${dQ(i, KQ, A)} Mbit/s` : i >= vQ ? `${dQ(i, vQ, A)} Kbit/s` : `${i} bit/s`, Kr = ({ width: i, height: A }) => `${i}x${A}`, Yr = (i) => i % 1e3 === 0 ? `${i / 1e3} kHz` : i > 1e3 ? `${(i / 1e3).toFixed(1)} kHz` : `${i} Hz`, hn = ["off", "error", "warn", "info", "debug", "trace"], Tr = {
655
667
  OFF: "off"
656
668
  };
657
669
  var Pe, Xg, xe, tI, eI;
@@ -689,8 +701,8 @@ const ie = class ie {
689
701
  E(this, tI, A);
690
702
  for (const [e, g] of s(this, Pe))
691
703
  g.setLevel(A);
692
- const t = cn.indexOf(A);
693
- for (const [e, g] of cn.entries())
704
+ const t = hn.indexOf(A);
705
+ for (const [e, g] of hn.entries())
694
706
  g !== "off" && (e <= t ? this[g] = console[g].bind(
695
707
  console,
696
708
  "%c%s %c%s",
@@ -738,11 +750,11 @@ function HA(i) {
738
750
  function Nt() {
739
751
  return typeof Symbol.asyncDispose != "symbol" && Object.defineProperty(Symbol, "asyncDispose", { value: Symbol.for("asyncDispose") }), Symbol.asyncDispose;
740
752
  }
741
- function ya() {
753
+ function fa() {
742
754
  return typeof Symbol.dispose != "symbol" && Object.defineProperty(Symbol, "dispose", { value: Symbol.for("dispose") }), Symbol.dispose;
743
755
  }
744
- var jg, TQ;
745
- class vr {
756
+ var jg, YQ;
757
+ class Pr {
746
758
  constructor(A, t) {
747
759
  n(this, jg);
748
760
  I(this, "value");
@@ -753,18 +765,18 @@ class vr {
753
765
  var A;
754
766
  return (A = this.unlocker) == null ? void 0 : A.promise;
755
767
  }
756
- [ya()]() {
757
- d(this, jg, TQ).call(this);
768
+ [fa()]() {
769
+ d(this, jg, YQ).call(this);
758
770
  }
759
771
  [Symbol.dispose]() {
760
- d(this, jg, TQ).call(this);
772
+ d(this, jg, YQ).call(this);
761
773
  }
762
774
  }
763
- jg = new WeakSet(), TQ = function() {
775
+ jg = new WeakSet(), YQ = function() {
764
776
  this.unlocker.resolve(this.value);
765
777
  };
766
778
  var We, Oe;
767
- class Kr {
779
+ class xr {
768
780
  constructor(A) {
769
781
  n(this, We);
770
782
  n(this, Oe, new j());
@@ -783,7 +795,7 @@ class Kr {
783
795
  E(this, We, e);
784
796
  }).catch(q);
785
797
  const t = s(this, Oe).promise.then(() => A);
786
- return E(this, Oe, A), yield t, new vr(s(this, We), A);
798
+ return E(this, Oe, A), yield t, new Pr(s(this, We), A);
787
799
  });
788
800
  }
789
801
  }
@@ -848,27 +860,12 @@ class NA {
848
860
  }
849
861
  }
850
862
  VA = new WeakMap(), st = new WeakMap();
851
- const hn = (i, A) => {
863
+ const dn = (i, A) => {
852
864
  const t = D({}, i);
853
865
  return typeof t != "object" || A.forEach((e) => {
854
866
  delete t[e];
855
867
  }), t;
856
- }, Je = (i, A = Date.now()) => {
857
- const t = i.length;
858
- if (t > 0) {
859
- const e = t - 1, g = i[e];
860
- g.end || (g.end = A);
861
- }
862
- }, Hi = (i, A = Date.now()) => {
863
- Je(i), i.push({ start: A });
864
- }, qi = (i) => i.reduce((A, t) => {
865
- var e;
866
- return A + (((e = t.end) != null ? e : Date.now()) - t.start);
867
- }, 0), dn = (i, A, t = Date.now()) => i.reduce((e, g) => {
868
- var Q;
869
- const B = Math.max(t - A, g.start), C = (Q = g.end) != null ? Q : t;
870
- return Math.max(0, C - B) + e;
871
- }, 0), BC = class BC {
868
+ }, BC = class BC {
872
869
  constructor() {
873
870
  I(this, "pendingTimeouts", /* @__PURE__ */ new Set());
874
871
  I(this, "pendingIntervals", /* @__PURE__ */ new Set());
@@ -897,237 +894,124 @@ const hn = (i, A) => {
897
894
  };
898
895
  I(BC, "create", () => new BC());
899
896
  let mA = BC;
900
- function fa(i) {
897
+ const Je = (i, A = Date.now()) => {
898
+ const t = i.length;
899
+ if (t > 0) {
900
+ const e = t - 1, g = i[e];
901
+ g.end || (g.end = A);
902
+ }
903
+ }, Hi = (i, A = Date.now()) => {
904
+ Je(i), i.push({ start: A });
905
+ }, qi = (i) => i.reduce((A, t) => {
906
+ var e;
907
+ return A + (((e = t.end) != null ? e : Date.now()) - t.start);
908
+ }, 0), ln = (i, A, t = Date.now()) => i.reduce((e, g) => {
909
+ var Q;
910
+ const B = Math.max(t - A, g.start), C = (Q = g.end) != null ? Q : t;
911
+ return Math.max(0, C - B) + e;
912
+ }, 0);
913
+ function pa(i) {
901
914
  try {
902
915
  return i();
903
916
  } catch (A) {
904
917
  return A;
905
918
  }
906
919
  }
907
- const pa = (i) => {
920
+ const Fa = (i) => {
908
921
  try {
909
922
  return JSON.parse(i);
910
923
  } catch (A) {
911
924
  return;
912
925
  }
913
- }, ln = () => {
926
+ }, un = () => {
914
927
  const i = [...Array(256).keys()].map((t) => t.toString(16).padStart(2, "0")), A = crypto.getRandomValues(new Uint8Array(16));
915
928
  return A[6] = A[6] & 15 | 64, A[8] = A[8] & 63 | 128, [...A.entries()].map(([t, e]) => [4, 6, 8, 10].includes(t) ? `-${i[e]}` : i[e]).join("");
916
929
  }, Ge = (i) => r(null, null, function* () {
917
930
  return new Promise((A) => setTimeout(A, i));
918
931
  }), xo = (t, ...e) => r(null, [t, ...e], function* (i, A = new Error("Timeout")) {
919
932
  return new Promise((g, B) => setTimeout(() => B(A), i));
920
- }), Yr = (i, A) => r(null, null, function* () {
933
+ }), Wr = (i, A) => r(null, null, function* () {
921
934
  throw yield i, new Error(A);
922
935
  });
923
- function Fa(i) {
924
- return !(typeof i.edges[0] == "string" || i.channels[0] && !("catalog" in i.channels[0]));
925
- }
926
- function Ga(i) {
927
- return i.tracks.filter((A) => !!A.codec).filter((A) => PQ(A.codec || "")).map((A, t) => {
928
- const e = A.codec, g = A.bitrate;
929
- lA(e, "codec is required"), lA(g != null, "bitrate is required");
930
- const B = PQ(e);
931
- if (lA(B, "codec is required"), vQ(B) === "audio") {
932
- const C = A.samplerate || 0, Q = A.channelConfig === "stereo" ? 2 : 1;
933
- return {
934
- track: A,
935
- id: t,
936
- codec: B,
937
- codecString: e,
938
- bitRate: g,
939
- channels: Q,
940
- sampleRate: C,
941
- language: A.language
942
- };
943
- }
944
- return vQ(B) === "text" ? {
945
- track: A,
946
- id: t,
947
- bitRate: 0,
948
- codec: B,
949
- kind: "subtitles",
950
- codecString: e,
951
- label: A.label,
952
- language: A.language
953
- } : (lA(A.width, "width is required"), lA(A.height, "width is required"), lA(A.framerate, "framerate is required"), {
954
- track: A,
955
- id: t,
956
- codec: B,
957
- bitRate: g,
958
- codecString: e,
959
- width: A.width,
960
- height: A.height,
961
- frameRate: A.framerate
936
+ class wn extends $A {
937
+ constructor(t) {
938
+ super();
939
+ I(this, "config");
940
+ I(this, "hlsUrl");
941
+ I(this, "element");
942
+ I(this, "connectingTimeout");
943
+ I(this, "castingAvailable", !1);
944
+ /**
945
+ * Update authentication token on an already established and authenticated connection.
946
+ * Note: When casting to AirPlay, this will interrupt the current session to apply the new token.
947
+ */
948
+ I(this, "updateAuthenticationToken", (t) => {
949
+ this.config.authenticationToken = t, this.hlsUrl = this.getHlsUrl(), this.castingAvailable && (this.element.src = this.hlsUrl);
962
950
  });
963
- }).sort((A, t) => A.bitRate - t.bitRate);
964
- }
965
- function PQ(i) {
966
- if (i.startsWith("opus"))
967
- return "opus";
968
- if (i.startsWith("mp4a"))
969
- return "aac";
970
- if (i.startsWith("avc1"))
971
- return "h264";
972
- if (i.startsWith("av01"))
973
- return "av1";
974
- if (i.startsWith("webvtt"))
975
- return "webvtt";
976
- }
977
- const fi = (i) => "width" in i && typeof i.width == "number", pi = (i) => "sampleRate" in i && typeof i.sampleRate == "number", Ye = (i) => {
978
- switch (i.codec) {
979
- case "opus":
980
- return 'audio/mp4; codecs="opus"';
981
- case "mp3":
982
- return "audio/mpeg";
983
- case "webvtt":
984
- return "text/vtt";
985
- case "aac":
986
- return i.codecString ? `audio/mp4; codecs="${i.codecString}"` : "audio/mp4";
987
- case "h264":
988
- return i.codecString ? `video/mp4; codecs="${i.codecString}"` : "video/mp4";
989
- case "av1":
990
- return i.codecString ? `video/mp4; codecs="${i.codecString}"` : "video/mp4";
991
- }
992
- }, Fe = () => Number.MAX_SAFE_INTEGER, RB = () => ({
993
- width: Number.MAX_SAFE_INTEGER,
994
- height: Number.MAX_SAFE_INTEGER
995
- }), un = (i) => !(typeof i != "object" || i === null || !("type" in i)), Tr = (i) => i ? {
996
- Authorization: `Bearer ${i}`
997
- } : void 0, Pr = (i, A) => {
998
- try {
999
- const t = i.ancestorOrigins;
1000
- if (t && t.length > 0)
1001
- return Array.from(t).join(",") || void 0;
1002
- } catch (t) {
1003
- }
1004
- try {
1005
- if (A.referrer)
1006
- return new URL(A.referrer).origin || void 0;
1007
- } catch (t) {
1008
- }
1009
- }, xr = (i) => typeof i == "object" && i !== null && "message" in i;
1010
- class Wr extends Error {
1011
- constructor({ status: t, url: e, body: g }) {
1012
- const B = pa(g), C = xr(B) ? B.message : `Url ${e.toString()}, Status code: ${t}, Body: ${g}`;
1013
- super(C);
1014
- I(this, "status");
1015
- I(this, "body");
1016
- I(this, "url");
1017
- this.status = t, this.body = g, this.url = e, Object.setPrototypeOf(this, new.target.prototype);
1018
- }
1019
- }
1020
- const Or = (i) => typeof i.status == "number", Vr = () => {
1021
- if (!(typeof window == "undefined" || typeof document == "undefined"))
1022
- return Pr(window.location, document);
1023
- }, Zr = (i) => {
1024
- const A = Vr();
1025
- if (!A || i.searchParams.has("parentOrigin"))
1026
- return i;
1027
- const t = new URL(i.toString());
1028
- return t.searchParams.append("parentOrigin", A), t;
1029
- }, ka = (i, A) => r(null, null, function* () {
1030
- const t = Zr(i), e = yield fetch(t.toString(), D({ mode: "cors" }, A));
1031
- if (!e.ok)
1032
- throw new Wr({ status: e.status, url: t, body: yield e.text() });
1033
- return e;
1034
- }), dQ = (i, A) => r(null, null, function* () {
1035
- return yield (yield ka(i, D({}, A))).json();
1036
- }), Ra = (i, A) => r(null, null, function* () {
1037
- return ka(i, D({ method: "POST" }, A));
1038
- });
1039
- function Xr(i) {
1040
- var A;
1041
- return !(typeof i.edges[0] == "string" || i.channels[0] && "catalog" in i.channels[0] && typeof ((A = i.channels[0]) == null ? void 0 : A.catalog) == "undefined");
1042
- }
1043
- const wn = {
1044
- lbConnect: (i) => i.channelGroupId ? `connect?channelId=${i.channelId}&channelGroupId=${i.channelGroupId}` : `connect?channelId=${i.channelId}`,
1045
- thumbnails: (i, A) => A ? i.channelGroupId ? `thumbnail/?channelGroupId=${i.channelGroupId}&auth.token=${A}&auth.type=jwt` : i.channelId ? `thumbnail/?channelId=${i.channelId}&auth.token=${A}&auth.type=jwt` : "thumbnail" : "thumbnail"
1046
- };
1047
- class jr {
1048
- constructor(A) {
1049
- I(this, "baseUrl");
1050
- I(this, "tokenFactory");
1051
- this.baseUrl = new URL("/api/v4/", A.publicEndpoint).toString(), this.tokenFactory = A.tokenFactory;
951
+ /**
952
+ * Fully unloads the instance. This disconnects the current listeners.
953
+ */
954
+ I(this, "unload", () => {
955
+ this.element && (this.element.removeEventListener("webkitplaybacktargetavailabilitychanged", this.onAirPlayAvailable), this.element.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged", this.onAirPlayPlaybackChanged), this.element.remove());
956
+ });
957
+ I(this, "onAirPlayAvailable", (t) => {
958
+ switch (t.availability) {
959
+ case "available": {
960
+ this.castingAvailable = !0, this.element.src !== this.hlsUrl && this.checkHlsUrl(this.hlsUrl).then((g) => {
961
+ g && (this.element.src = this.hlsUrl, this.emit("available"));
962
+ });
963
+ break;
964
+ }
965
+ case "not-available":
966
+ this.castingAvailable = !1;
967
+ break;
968
+ }
969
+ });
970
+ I(this, "onAirPlayPlaybackChanged", () => {
971
+ window.clearTimeout(this.connectingTimeout), this.element.webkitCurrentPlaybackTargetIsWireless ? (this.emit("connected"), this.element.style.display = "block", this.element.paused && this.element.play()) : (this.emit("disconnected"), this.element.pause(), this.element.src = "", this.element.src = this.hlsUrl, this.element.style.display = "none");
972
+ });
973
+ this.config = t, this.hlsUrl = this.getHlsUrl(), this.element = document.createElement("video"), this.element.style.position = "absolute", this.element.style.top = "0", this.element.style.bottom = "0", this.element.style.left = "0", this.element.style.right = "0", this.element.style.width = "100%", this.element.style.height = "100%", this.element.style.zIndex = "1001", this.element.style.display = "none", this.element.id = "vindral-airplay-element", this.element.slot = "overlay", this.element.playsInline = !0, this.element.controls = !0, this.element.preload = "metadata", this.element.addEventListener("webkitplaybacktargetavailabilitychanged", this.onAirPlayAvailable), this.element.addEventListener("webkitcurrentplaybacktargetiswirelesschanged", this.onAirPlayPlaybackChanged), this.config.container.appendChild(this.element);
1052
974
  }
1053
975
  /**
1054
- * @ignore
1055
- * Returns everything needed to setup the connection of Vindral instance.
976
+ * True if the instance is casting right now.
1056
977
  */
1057
- connect(A) {
1058
- return r(this, null, function* () {
1059
- const { channelId: t, channelGroupId: e } = A, g = { channelId: t, channelGroupId: e }, B = new URL(wn.lbConnect(A), this.baseUrl), C = this.getAuthToken(g), Q = yield dQ(B, { headers: this.getHeaders(C) });
1060
- if (Xr(Q)) {
1061
- const o = Q.channels.map((a) => {
1062
- const c = this.toChannel(a, g), h = Ga(a.catalog);
1063
- return T(D(D({}, a), c), { renditions: h });
1064
- });
1065
- return T(D({}, Q), { channels: o });
1066
- } else {
1067
- const o = Q.channels.map((a) => {
1068
- const c = this.toChannel(a, g);
1069
- return D(D({}, a), c);
1070
- });
1071
- return T(D({}, Q), { channels: o });
1072
- }
1073
- });
978
+ get casting() {
979
+ return this.element.webkitCurrentPlaybackTargetIsWireless;
1074
980
  }
1075
981
  /**
1076
- * Fetches information regarding a single channel.
1077
- *
1078
- * @param channelId the channel to fetch
1079
- * @returns a [[Channel]] containing information about the requested channel.
982
+ * Set the current channelId.
1080
983
  */
1081
- getChannel(A) {
1082
- return r(this, null, function* () {
1083
- const t = { channelId: A }, e = new URL(`channel/${A}`, this.baseUrl), g = this.getAuthToken(t), B = yield dQ(e, { headers: this.getHeaders(g) });
1084
- return this.toChannel(B, t, g);
1085
- });
984
+ set channelId(t) {
1086
985
  }
1087
986
  /**
1088
- * Fetches channels within a channel group
1089
- *
1090
- * Note: The returned list includes inactive channels - check isLive to filter out only active channels
1091
- *
1092
- * @param channelGroupId the channel group to fetch channels from
1093
- * @returns an array of [[Channel]] that belong to the channel group
987
+ * Show the AirPlay picker.
1094
988
  */
1095
- getChannels(A) {
1096
- return r(this, null, function* () {
1097
- const t = { channelGroupId: A }, e = new URL(`channels/${A}`, this.baseUrl), g = this.getAuthToken(t), B = yield dQ(e, {
1098
- headers: this.getHeaders(g)
1099
- }), C = Array.isArray(B) ? B : B.channels;
1100
- return this.toChannels(C, t, g);
1101
- });
1102
- }
1103
- getHeaders(A) {
1104
- var e;
1105
- return (e = Tr(A)) != null ? e : {};
989
+ showPlaybackTargetPicker() {
990
+ this.element.paused && (this.element.play(), this.connectingTimeout = window.setTimeout(() => {
991
+ this.casting || (this.element.pause(), this.element.src = "", this.element.src = this.hlsUrl);
992
+ }, 3e4)), this.element.webkitShowPlaybackTargetPicker();
1106
993
  }
1107
- getAuthToken(A) {
1108
- return this.tokenFactory ? this.tokenFactory(A) : void 0;
994
+ /**
995
+ * Returns if AirPlay is supported.
996
+ */
997
+ static isAirPlaySupported() {
998
+ return !!window.WebKitPlaybackTargetAvailabilityEvent;
1109
999
  }
1110
- toChannels(A, t, e) {
1111
- return A.map((g) => this.toChannel(g, t, e));
1000
+ getHlsUrl() {
1001
+ const t = new URL(`/api/hls?channelId=${this.config.channelId}`, this.config.url);
1002
+ return this.config.authenticationToken && t.searchParams.set("authenticationToken", this.config.authenticationToken), t.toString();
1112
1003
  }
1113
- toChannel(A, t, e) {
1114
- const { baseUrl: g, sizes: B } = A.thumbnail, C = g || new URL(wn.thumbnails(t, e), this.baseUrl), Q = B.map((o) => new URL(
1115
- `?channelId=${A.channelId}&width=${o.width}&height=${o.height}${zr(
1116
- t,
1117
- e
1118
- )}`,
1119
- C
1120
- ).toString());
1121
- return {
1122
- channelId: A.channelId,
1123
- name: A.name,
1124
- isLive: A.isLive,
1125
- thumbnailUrls: Q
1126
- };
1004
+ checkHlsUrl(t) {
1005
+ return r(this, null, function* () {
1006
+ try {
1007
+ return (yield fetch(t, { method: "HEAD" })).ok;
1008
+ } catch (e) {
1009
+ return !1;
1010
+ }
1011
+ });
1127
1012
  }
1128
1013
  }
1129
- const zr = (i, A) => A ? i.channelGroupId ? `&channelGroupId=${i.channelGroupId}&auth.token=${A}&auth.type=jwt` : `&auth.token=${A}&auth.type=jwt` : "";
1130
- class _r extends $A {
1014
+ class Or extends $A {
1131
1015
  constructor(t) {
1132
1016
  super();
1133
1017
  I(this, "state", "not casting");
@@ -1334,7 +1218,94 @@ class _r extends $A {
1334
1218
  }));
1335
1219
  }
1336
1220
  }
1337
- const $r = {
1221
+ const TQ = (i) => {
1222
+ switch (i) {
1223
+ case "h264":
1224
+ case "av1":
1225
+ return "video";
1226
+ case "aac":
1227
+ case "opus":
1228
+ case "mp3":
1229
+ return "audio";
1230
+ case "webvtt":
1231
+ return "text";
1232
+ default:
1233
+ throw new Error("Unknown codec");
1234
+ }
1235
+ };
1236
+ function Ga(i) {
1237
+ return !(typeof i.edges[0] == "string" || i.channels[0] && !("catalog" in i.channels[0]));
1238
+ }
1239
+ function ka(i) {
1240
+ return i.tracks.filter((A) => !!A.codec).filter((A) => PQ(A.codec || "")).map((A, t) => {
1241
+ const e = A.codec, g = A.bitrate;
1242
+ lA(e, "codec is required"), lA(g != null, "bitrate is required");
1243
+ const B = PQ(e);
1244
+ if (lA(B, "codec is required"), TQ(B) === "audio") {
1245
+ const C = A.samplerate || 0, Q = A.channelConfig === "stereo" ? 2 : 1;
1246
+ return {
1247
+ track: A,
1248
+ id: t,
1249
+ codec: B,
1250
+ codecString: e,
1251
+ bitRate: g,
1252
+ channels: Q,
1253
+ sampleRate: C,
1254
+ language: A.language
1255
+ };
1256
+ }
1257
+ return TQ(B) === "text" ? {
1258
+ track: A,
1259
+ id: t,
1260
+ bitRate: 0,
1261
+ codec: B,
1262
+ kind: "subtitles",
1263
+ codecString: e,
1264
+ label: A.label,
1265
+ language: A.language
1266
+ } : (lA(A.width, "width is required"), lA(A.height, "width is required"), lA(A.framerate, "framerate is required"), {
1267
+ track: A,
1268
+ id: t,
1269
+ codec: B,
1270
+ bitRate: g,
1271
+ codecString: e,
1272
+ width: A.width,
1273
+ height: A.height,
1274
+ frameRate: A.framerate
1275
+ });
1276
+ }).sort((A, t) => A.bitRate - t.bitRate);
1277
+ }
1278
+ function PQ(i) {
1279
+ if (i.startsWith("opus"))
1280
+ return "opus";
1281
+ if (i.startsWith("mp4a"))
1282
+ return "aac";
1283
+ if (i.startsWith("avc1"))
1284
+ return "h264";
1285
+ if (i.startsWith("av01"))
1286
+ return "av1";
1287
+ if (i.startsWith("webvtt"))
1288
+ return "webvtt";
1289
+ }
1290
+ const fi = (i) => "width" in i && typeof i.width == "number", pi = (i) => "sampleRate" in i && typeof i.sampleRate == "number", Ye = (i) => {
1291
+ switch (i.codec) {
1292
+ case "opus":
1293
+ return 'audio/mp4; codecs="opus"';
1294
+ case "mp3":
1295
+ return "audio/mpeg";
1296
+ case "webvtt":
1297
+ return "text/vtt";
1298
+ case "aac":
1299
+ return i.codecString ? `audio/mp4; codecs="${i.codecString}"` : "audio/mp4";
1300
+ case "h264":
1301
+ return i.codecString ? `video/mp4; codecs="${i.codecString}"` : "video/mp4";
1302
+ case "av1":
1303
+ return i.codecString ? `video/mp4; codecs="${i.codecString}"` : "video/mp4";
1304
+ }
1305
+ }, Fe = () => Number.MAX_SAFE_INTEGER, RB = () => ({
1306
+ width: Number.MAX_SAFE_INTEGER,
1307
+ height: Number.MAX_SAFE_INTEGER
1308
+ }), Dn = (i) => !(typeof i != "object" || i === null || !("type" in i)), Vr = {
1338
1309
  sizeBasedResolutionCapEnabled: !0,
1339
1310
  pictureInPictureEnabled: !0,
1340
1311
  abrEnabled: !0,
@@ -1344,7 +1315,7 @@ const $r = {
1344
1315
  muted: !1,
1345
1316
  minBufferTime: 1500,
1346
1317
  maxBufferTime: 1500,
1347
- logLevel: qr.OFF,
1318
+ logLevel: Tr.OFF,
1348
1319
  maxSize: RB(),
1349
1320
  maxVideoBitRate: Fe(),
1350
1321
  maxAudioBitRate: Fe(),
@@ -1366,7 +1337,7 @@ const $r = {
1366
1337
  },
1367
1338
  videoCodecs: ["av1", "h264"],
1368
1339
  webtransportEnabled: !0
1369
- }, Ac = "connection_failed", tc = "connection_failed_will_not_attempt_again", ec = "authentication_error", ic = "authentication_expired", Ic = "channel_not_found", gc = "no_incoming_data_error", sc = "connection_inactivity", Bc = "missing_init_segment", Cc = "no_track_context", Qc = "invalid_track_context_state", oc = "disconnected_by_edge", nc = "decoder_error", ac = "audio_player_error", Ec = "media_source_error", rc = "webgl_context_lost_error", cc = "access_forbidden", hc = "channel_switch_failed", dc = "drm_error";
1340
+ }, Zr = "connection_failed", Xr = "connection_failed_will_not_attempt_again", jr = "authentication_error", zr = "authentication_expired", _r = "channel_not_found", $r = "no_incoming_data_error", Ac = "connection_inactivity", tc = "missing_init_segment", ec = "no_track_context", ic = "invalid_track_context_state", Ic = "disconnected_by_edge", gc = "decoder_error", sc = "audio_player_error", Bc = "media_source_error", Cc = "webgl_context_lost_error", Qc = "access_forbidden", oc = "channel_switch_failed", nc = "drm_error";
1370
1341
  class v extends Error {
1371
1342
  constructor(t, e, g = {}) {
1372
1343
  super(t);
@@ -1409,143 +1380,44 @@ class v extends Error {
1409
1380
  this.props = e, this.extra = g, Object.setPrototypeOf(this, new.target.prototype);
1410
1381
  }
1411
1382
  }
1412
- const lc = (i, A) => new v(
1383
+ const ac = (i, A) => new v(
1413
1384
  "MediaElement Error",
1414
1385
  { isFatal: i, code: "media_element_error", source: A },
1415
1386
  { mediaErrorCode: A.code }
1416
- ), Ua = (i, A) => new v("Decoder Error", { isFatal: i, code: nc, source: A, type: "internal" }), Na = (i, A) => new v("Audio Player Error", { isFatal: i, code: ac, source: A, type: "internal" }), uc = (i, A) => new v(`No init segment for rendition id ${i} for channel ${A}`, {
1387
+ ), Ra = (i, A) => new v("Decoder Error", { isFatal: i, code: gc, source: A, type: "internal" }), Ua = (i, A) => new v("Audio Player Error", { isFatal: i, code: sc, source: A, type: "internal" }), Ec = (i, A) => new v(`No init segment for rendition id ${i} for channel ${A}`, {
1417
1388
  isFatal: !1,
1418
- code: Bc,
1389
+ code: tc,
1419
1390
  type: "internal"
1420
- }), Dn = (i, A, t, e) => new v(
1391
+ }), Sn = (i, A, t, e) => new v(
1421
1392
  "MediaSource Error",
1422
- { isFatal: i, code: Ec, source: A, type: "internal" },
1393
+ { isFatal: i, code: Bc, source: A, type: "internal" },
1423
1394
  { type: e, consecutiveErrorsCount: t }
1424
1395
  ), cB = (i, A) => new v(`No track context for ${i}${A ? `, rendition id ${A}` : ""}`, {
1425
1396
  isFatal: !1,
1426
- code: Cc,
1397
+ code: ec,
1427
1398
  type: "internal"
1428
- }), wc = (i, A) => new v(
1399
+ }), rc = (i, A) => new v(
1429
1400
  `Track context is in an invalid state for ${i}${A ? `, rendition id ${A}` : ""}`,
1430
1401
  {
1431
1402
  isFatal: !1,
1432
- code: Qc,
1403
+ code: ic,
1433
1404
  type: "internal"
1434
1405
  }
1435
- ), Dc = () => new v("Web Audio Context resume timeout", { isFatal: !1, code: "web_audio_context_resume_timeout" }), og = (i) => new v("Disconnected From Edge Server", {
1406
+ ), cc = () => new v("Web Audio Context resume timeout", { isFatal: !1, code: "web_audio_context_resume_timeout" }), og = (i) => new v("Disconnected From Edge Server", {
1436
1407
  type: "external",
1437
1408
  source: i,
1438
1409
  isFatal: !1,
1439
- code: oc
1440
- }), UB = (i) => new v("Authentication Failed", { isFatal: !0, code: ec, source: i }), Sc = (i) => new v("Authentication Expired", { isFatal: !0, code: ic, source: i }), mc = (i, A) => new v("Connection closed due to inactivity", { isFatal: !1, code: sc, source: A, type: i }), ba = (i, A) => new v("Channel not found", { isFatal: !1, code: Ic, source: A, type: i }), yc = (i) => new v("No Incoming Data", { isFatal: !1, code: gc, source: i }), fc = (i) => new v("Connection attempt failed", {
1410
+ code: Ic
1411
+ }), UB = (i) => new v("Authentication Failed", { isFatal: !0, code: jr, source: i }), hc = (i) => new v("Authentication Expired", { isFatal: !0, code: zr, source: i }), dc = (i, A) => new v("Connection closed due to inactivity", { isFatal: !1, code: Ac, source: A, type: i }), Na = (i, A) => new v("Channel not found", { isFatal: !1, code: _r, source: A, type: i }), lc = (i) => new v("No Incoming Data", { isFatal: !1, code: $r, source: i }), uc = (i) => new v("Connection attempt failed", {
1441
1412
  isFatal: !1,
1442
- code: Ac,
1413
+ code: Zr,
1443
1414
  source: i
1444
- }), La = () => new v("Connection failed - no more reconnect attempts", {
1415
+ }), ba = () => new v("Connection failed - no more reconnect attempts", {
1445
1416
  isFatal: !0,
1446
- code: tc
1447
- }), pc = (i) => new v("WebGL Context Lost", { isFatal: !1, code: rc, source: i, type: "internal" }), Sn = (i) => new v(i, { isFatal: !0, code: cc }), mn = (i) => new v(`Channel switch to '${i}' failed`, { isFatal: !1, code: hc }), Ja = (i, A = !1, t) => new v(i, { isFatal: A, code: dc, source: t }), yn = (i, A) => i && typeof i == "object" && A in i, Ma = (i) => !(typeof i != "object" || !yn(i, "channelId") || typeof i.channelId != "string" || !yn(i, "url") || typeof i.url != "string" || i.channelId.length === 0 || i.url.length === 0), Fc = (i) => {
1448
- if (!Ma(i))
1449
- throw new v("Invalid options", { isFatal: !0, code: "invalid_options" });
1450
- const A = D({}, i);
1451
- return Object.keys(A).forEach((t) => {
1452
- const e = A;
1453
- typeof e[t] == "undefined" && delete e[t];
1454
- }), A;
1455
- }, fn = {
1456
- playready: ["150", "2000", "3000"],
1457
- widevine: ["SW_SECURE_CRYPTO", "SW_SECURE_DECODE", "HW_SECURE_CRYPTO", "HW_SECURE_DECODE", "HW_SECURE_ALL"],
1458
- fairplay: [""],
1459
- clearkey: [""]
1460
- }, lQ = {
1461
- initDataTypes: ["cenc"],
1462
- audioCapabilities: [
1463
- {
1464
- contentType: 'audio/mp4; codecs="mp4a.40.2"'
1465
- }
1466
- ],
1467
- videoCapabilities: [
1468
- {
1469
- contentType: 'video/mp4; codecs="avc1.42c01f"'
1470
- }
1471
- ]
1472
- }, Gc = {
1473
- fairplay: {
1474
- keySystem: "com.apple.fps",
1475
- supportedConfig: {
1476
- initDataTypes: ["sinf"],
1477
- videoCapabilities: [
1478
- {
1479
- contentType: 'video/mp4; codecs="avc1.42c01f"'
1480
- }
1481
- ]
1482
- }
1483
- },
1484
- playready: {
1485
- keySystem: "com.microsoft.playready",
1486
- supportedConfig: lQ
1487
- },
1488
- widevine: {
1489
- keySystem: "com.widevine.alpha",
1490
- supportedConfig: lQ
1491
- },
1492
- clearkey: {
1493
- keySystem: "org.w3.clearkey",
1494
- supportedConfig: lQ
1495
- }
1496
- }, Ha = (i, A) => r(null, null, function* () {
1497
- return navigator.requestMediaKeySystemAccess(i, [A]).catch(() => {
1498
- });
1499
- }), pn = (i, A, t, e, g, B) => r(null, null, function* () {
1500
- let C;
1501
- for (const Q of e) {
1502
- const o = t == null ? void 0 : t.map((c) => T(D({}, c), {
1503
- robustness: Q,
1504
- contentType: B ? `${g === "audioCapabilities" ? "audio/mp4" : "video/mp4"}; codecs="${B}"` : c.contentType
1505
- }));
1506
- if (!(yield Ha(i, {
1507
- initDataTypes: A,
1508
- [g]: o
1509
- })))
1510
- break;
1511
- C = o;
1512
- }
1513
- return C;
1514
- }), kc = (i, A, t, e) => r(null, null, function* () {
1515
- const { keySystem: g, supportedConfig: B } = Gc[i], { initDataTypes: C, videoCapabilities: Q, audioCapabilities: o } = B, a = e == null ? void 0 : e[i], c = (a == null ? void 0 : a.videoRobustness) || fn[i], h = (a == null ? void 0 : a.audioRobustness) || fn[i], [l, u] = yield Promise.all([
1516
- pn(
1517
- g,
1518
- C,
1519
- Q,
1520
- c,
1521
- "videoCapabilities",
1522
- A
1523
- ),
1524
- pn(
1525
- g,
1526
- C,
1527
- o,
1528
- h,
1529
- "audioCapabilities",
1530
- t
1531
- )
1532
- ]);
1533
- return !l && !u ? void 0 : yield Ha(g, {
1534
- initDataTypes: C,
1535
- videoCapabilities: l,
1536
- audioCapabilities: u
1537
- });
1538
- }), Rc = (i, A, t, e) => r(null, null, function* () {
1539
- let g;
1540
- for (const B of i)
1541
- if (g = yield kc(B, A, t, e), g)
1542
- return {
1543
- keySystem: B,
1544
- mediaKeySystemAccess: g
1545
- };
1546
- });
1417
+ code: Xr
1418
+ }), wc = (i) => new v("WebGL Context Lost", { isFatal: !1, code: Cc, source: i, type: "internal" }), mn = (i) => new v(i, { isFatal: !0, code: Qc }), yn = (i) => new v(`Channel switch to '${i}' failed`, { isFatal: !1, code: oc }), La = (i, A = !1, t) => new v(i, { isFatal: A, code: nc, source: t });
1547
1419
  var Ve, Ze;
1548
- class iQ {
1420
+ class IQ {
1549
1421
  constructor(A, t, e, g) {
1550
1422
  I(this, "keySystem");
1551
1423
  I(this, "licenseServerUrl");
@@ -1587,20 +1459,20 @@ class iQ {
1587
1459
  }
1588
1460
  }
1589
1461
  Ve = new WeakMap(), Ze = new WeakMap();
1590
- function qa(i) {
1462
+ function Ja(i) {
1591
1463
  const A = window.atob(i.replace(/-/g, "+").replace(/_/g, "/"));
1592
1464
  let t = "";
1593
1465
  for (let e = 0; e < A.length; e++)
1594
1466
  t += ("0" + A.charCodeAt(e).toString(16)).substr(-2);
1595
1467
  return t;
1596
1468
  }
1597
- function Uc(i) {
1469
+ function Dc(i) {
1598
1470
  let A = "";
1599
1471
  for (let t = 0; t < i.length; t += 2)
1600
1472
  A += String.fromCharCode(parseInt(i.substr(t, 2), 16));
1601
1473
  return window.btoa(A).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1602
1474
  }
1603
- function Nc(i, A) {
1475
+ function Sc(i, A) {
1604
1476
  if (i.byteLength !== A.byteLength) return !1;
1605
1477
  const t = new Uint8Array(i), e = new Uint8Array(A);
1606
1478
  for (let g = 0; g < t.length; g++)
@@ -1608,7 +1480,7 @@ function Nc(i, A) {
1608
1480
  return !0;
1609
1481
  }
1610
1482
  var zg;
1611
- class bc extends iQ {
1483
+ class mc extends IQ {
1612
1484
  constructor(t, e) {
1613
1485
  super("clearkey", t, "");
1614
1486
  n(this, zg);
@@ -1619,12 +1491,12 @@ class bc extends iQ {
1619
1491
  for (let a = 0; a < B.kids.length; a++) {
1620
1492
  const c = B.kids[a];
1621
1493
  if (c) {
1622
- const h = qa(c).toLowerCase(), l = s(this, zg)[h];
1494
+ const h = Ja(c).toLowerCase(), l = s(this, zg)[h];
1623
1495
  l && C.push({
1624
1496
  kty: "oct",
1625
1497
  alg: "A128KW",
1626
1498
  kid: c,
1627
- k: Uc(l)
1499
+ k: Dc(l)
1628
1500
  });
1629
1501
  }
1630
1502
  }
@@ -1636,12 +1508,104 @@ class bc extends iQ {
1636
1508
  }
1637
1509
  }
1638
1510
  zg = new WeakMap();
1639
- class Lc extends iQ {
1511
+ const fn = {
1512
+ playready: ["150", "2000", "3000"],
1513
+ widevine: ["SW_SECURE_CRYPTO", "SW_SECURE_DECODE", "HW_SECURE_CRYPTO", "HW_SECURE_DECODE", "HW_SECURE_ALL"],
1514
+ fairplay: [""],
1515
+ clearkey: [""]
1516
+ }, lQ = {
1517
+ initDataTypes: ["cenc"],
1518
+ audioCapabilities: [
1519
+ {
1520
+ contentType: 'audio/mp4; codecs="mp4a.40.2"'
1521
+ }
1522
+ ],
1523
+ videoCapabilities: [
1524
+ {
1525
+ contentType: 'video/mp4; codecs="avc1.42c01f"'
1526
+ }
1527
+ ]
1528
+ }, yc = {
1529
+ fairplay: {
1530
+ keySystem: "com.apple.fps",
1531
+ supportedConfig: {
1532
+ initDataTypes: ["sinf"],
1533
+ videoCapabilities: [
1534
+ {
1535
+ contentType: 'video/mp4; codecs="avc1.42c01f"'
1536
+ }
1537
+ ]
1538
+ }
1539
+ },
1540
+ playready: {
1541
+ keySystem: "com.microsoft.playready",
1542
+ supportedConfig: lQ
1543
+ },
1544
+ widevine: {
1545
+ keySystem: "com.widevine.alpha",
1546
+ supportedConfig: lQ
1547
+ },
1548
+ clearkey: {
1549
+ keySystem: "org.w3.clearkey",
1550
+ supportedConfig: lQ
1551
+ }
1552
+ }, Ma = (i, A) => r(null, null, function* () {
1553
+ return navigator.requestMediaKeySystemAccess(i, [A]).catch(() => {
1554
+ });
1555
+ }), pn = (i, A, t, e, g, B) => r(null, null, function* () {
1556
+ let C;
1557
+ for (const Q of e) {
1558
+ const o = t == null ? void 0 : t.map((c) => T(D({}, c), {
1559
+ robustness: Q,
1560
+ contentType: B ? `${g === "audioCapabilities" ? "audio/mp4" : "video/mp4"}; codecs="${B}"` : c.contentType
1561
+ }));
1562
+ if (!(yield Ma(i, {
1563
+ initDataTypes: A,
1564
+ [g]: o
1565
+ })))
1566
+ break;
1567
+ C = o;
1568
+ }
1569
+ return C;
1570
+ }), fc = (i, A, t, e) => r(null, null, function* () {
1571
+ const { keySystem: g, supportedConfig: B } = yc[i], { initDataTypes: C, videoCapabilities: Q, audioCapabilities: o } = B, a = e == null ? void 0 : e[i], c = (a == null ? void 0 : a.videoRobustness) || fn[i], h = (a == null ? void 0 : a.audioRobustness) || fn[i], [l, u] = yield Promise.all([
1572
+ pn(
1573
+ g,
1574
+ C,
1575
+ Q,
1576
+ c,
1577
+ "videoCapabilities",
1578
+ A
1579
+ ),
1580
+ pn(
1581
+ g,
1582
+ C,
1583
+ o,
1584
+ h,
1585
+ "audioCapabilities",
1586
+ t
1587
+ )
1588
+ ]);
1589
+ return !l && !u ? void 0 : yield Ma(g, {
1590
+ initDataTypes: C,
1591
+ videoCapabilities: l,
1592
+ audioCapabilities: u
1593
+ });
1594
+ }), pc = (i, A, t, e) => r(null, null, function* () {
1595
+ let g;
1596
+ for (const B of i)
1597
+ if (g = yield fc(B, A, t, e), g)
1598
+ return {
1599
+ keySystem: B,
1600
+ mediaKeySystemAccess: g
1601
+ };
1602
+ });
1603
+ class Fc extends IQ {
1640
1604
  constructor(A, t, e) {
1641
1605
  super("fairplay", A, t, e);
1642
1606
  }
1643
1607
  }
1644
- const Jc = (i) => {
1608
+ const Gc = (i) => {
1645
1609
  var Q, o, a, c;
1646
1610
  const A = String.fromCharCode(...new Uint16Array(i)), t = new window.DOMParser().parseFromString(A, "application/xml"), e = t.getElementsByTagName("HttpHeaders")[0];
1647
1611
  let g = {};
@@ -1662,7 +1626,7 @@ const Jc = (i) => {
1662
1626
  message: C
1663
1627
  };
1664
1628
  };
1665
- class Mc extends iQ {
1629
+ class kc extends IQ {
1666
1630
  constructor(A, t) {
1667
1631
  super("playready", A, t);
1668
1632
  }
@@ -1672,7 +1636,7 @@ class Mc extends iQ {
1672
1636
  const t = new URL(this.licenseServerUrl);
1673
1637
  for (const [B, C] of Object.entries(this.queryParams))
1674
1638
  t.searchParams.append(B, C);
1675
- const e = Jc(A), g = yield fetch(t, {
1639
+ const e = Gc(A), g = yield fetch(t, {
1676
1640
  method: "POST",
1677
1641
  headers: D(D({}, e.headers), this.headers),
1678
1642
  body: e.message
@@ -1683,13 +1647,13 @@ class Mc extends iQ {
1683
1647
  });
1684
1648
  }
1685
1649
  }
1686
- class Hc extends iQ {
1650
+ class Rc extends IQ {
1687
1651
  constructor(A, t) {
1688
1652
  super("widevine", A, t);
1689
1653
  }
1690
1654
  }
1691
- const qc = 5e3;
1692
- var V, Xe, qt, Bt, ut, cA, Be, Ce, CC, iI, _g, $g, QA, va, Ka, Ya, Ta, QC, oC, Pa, Eg, nC, xa, Wa;
1655
+ const Uc = 5e3;
1656
+ var V, Xe, qt, Bt, ut, cA, Be, Ce, CC, iI, _g, $g, QA, Ha, qa, va, Ka, QC, oC, Ya, Eg, nC, Ta, Pa;
1693
1657
  class Fn {
1694
1658
  constructor(A, t, e = {}) {
1695
1659
  n(this, QA);
@@ -1701,20 +1665,20 @@ class Fn {
1701
1665
  n(this, cA);
1702
1666
  n(this, Be, /* @__PURE__ */ new Map());
1703
1667
  n(this, Ce);
1704
- n(this, CC, To());
1668
+ n(this, CC, Po());
1705
1669
  /**
1706
1670
  * Timeout to wait for new drm data when channel switch happens
1707
1671
  */
1708
1672
  n(this, iI);
1709
1673
  n(this, _g, (A) => {
1710
1674
  if (s(this, V).info("Received DRM data", { drmData: A }), window.clearTimeout(s(this, iI)), s(this, cA)) {
1711
- const t = d(this, QA, Wa).call(this, A)[s(this, cA).keySystem];
1675
+ const t = d(this, QA, Pa).call(this, A)[s(this, cA).keySystem];
1712
1676
  t && (s(this, cA).licenseServerUrl = t);
1713
1677
  }
1714
1678
  s(this, Bt).resolve(A);
1715
1679
  });
1716
1680
  n(this, $g, (A) => {
1717
- s(this, V).info("Encrypted event received", { event: A }), d(this, QA, va).call(this, A);
1681
+ s(this, V).info("Encrypted event received", { event: A }), d(this, QA, Ha).call(this, A);
1718
1682
  });
1719
1683
  n(this, QC, (A) => {
1720
1684
  var B, C;
@@ -1738,7 +1702,7 @@ class Fn {
1738
1702
  n(this, oC, (A) => {
1739
1703
  const t = A.target;
1740
1704
  s(this, V).debug("Key status changed for session", { sessionId: t.sessionId }), t.keyStatuses.forEach((e, g) => {
1741
- const B = qa(window.btoa(String.fromCharCode(...new Uint8Array(g))));
1705
+ const B = Ja(window.btoa(String.fromCharCode(...new Uint8Array(g))));
1742
1706
  s(this, V).debug("Key status", { base64kid: B, status: e });
1743
1707
  });
1744
1708
  });
@@ -1746,9 +1710,9 @@ class Fn {
1746
1710
  * Get the CDM based on the DRM data and the supported key systems
1747
1711
  */
1748
1712
  n(this, nC, (A) => r(this, null, function* () {
1749
- const t = d(this, QA, xa).call(this, A);
1713
+ const t = d(this, QA, Ta).call(this, A);
1750
1714
  s(this, V).debug("Prioritized key system list", { keySystemList: t });
1751
- const e = yield Rc(t, A.videoCodec, A.audioCodec, {
1715
+ const e = yield pc(t, A.videoCodec, A.audioCodec, {
1752
1716
  widevine: s(this, ut).widevine,
1753
1717
  playready: s(this, ut).playready
1754
1718
  });
@@ -1757,7 +1721,7 @@ class Fn {
1757
1721
  s(this, V).debug("Supported key system found", e.mediaKeySystemAccess.getConfiguration());
1758
1722
  const { keySystem: g, mediaKeySystemAccess: B } = e;
1759
1723
  let C = null;
1760
- return g === "clearkey" ? (lA(A.clearkeys, "No clearkeys found"), C = new bc(B, A.clearkeys)) : g === "playready" ? (lA(A.playreadyLicenseUrl, "No playreadyLicenseUrl found"), C = new Mc(B, A.playreadyLicenseUrl)) : g === "widevine" ? (lA(A.widevineLicenseUrl, "No widevineLicenseUrl found"), C = new Hc(B, A.widevineLicenseUrl)) : g === "fairplay" && (lA(A.fairplayLicenseUrl, "No fairplayLicenseUrl found"), lA(A.fairplayCertificate, "No fairplayCertificate found"), C = new Lc(B, A.fairplayLicenseUrl, A.fairplayCertificate)), C && (C.headers = s(this, ut).headers || {}, C.queryParams = s(this, ut).queryParams || {}), C;
1724
+ return g === "clearkey" ? (lA(A.clearkeys, "No clearkeys found"), C = new mc(B, A.clearkeys)) : g === "playready" ? (lA(A.playreadyLicenseUrl, "No playreadyLicenseUrl found"), C = new kc(B, A.playreadyLicenseUrl)) : g === "widevine" ? (lA(A.widevineLicenseUrl, "No widevineLicenseUrl found"), C = new Rc(B, A.widevineLicenseUrl)) : g === "fairplay" && (lA(A.fairplayLicenseUrl, "No fairplayLicenseUrl found"), lA(A.fairplayCertificate, "No fairplayCertificate found"), C = new Fc(B, A.fairplayLicenseUrl, A.fairplayCertificate)), C && (C.headers = s(this, ut).headers || {}, C.queryParams = s(this, ut).queryParams || {}), C;
1761
1725
  }));
1762
1726
  E(this, Xe, A), E(this, V, t), E(this, ut, e), s(this, Xe).on("received drm data", s(this, _g));
1763
1727
  }
@@ -1788,25 +1752,25 @@ class Fn {
1788
1752
  s(this, V).debug("DRM is not used, skipping channel switch handling");
1789
1753
  return;
1790
1754
  }
1791
- kr() && s(this, CC).platform.safariVersion < 18 && d(this, QA, Eg).call(this, {
1755
+ Lr() && s(this, CC).platform.safariVersion < 18 && d(this, QA, Eg).call(this, {
1792
1756
  message: "DRM channel switch not supported on Safari < 18",
1793
1757
  isFatal: !0
1794
1758
  }), window.clearTimeout(s(this, iI));
1795
1759
  const A = s(this, Bt).resolved;
1796
1760
  E(this, Bt, new j()), E(this, iI, window.setTimeout(() => {
1797
1761
  s(this, Bt).resolve(A);
1798
- }, qc));
1762
+ }, Uc));
1799
1763
  }
1800
1764
  }
1801
- V = new WeakMap(), Xe = new WeakMap(), qt = new WeakMap(), Bt = new WeakMap(), ut = new WeakMap(), cA = new WeakMap(), Be = new WeakMap(), Ce = new WeakMap(), CC = new WeakMap(), iI = new WeakMap(), _g = new WeakMap(), $g = new WeakMap(), QA = new WeakSet(), va = function(A) {
1765
+ V = new WeakMap(), Xe = new WeakMap(), qt = new WeakMap(), Bt = new WeakMap(), ut = new WeakMap(), cA = new WeakMap(), Be = new WeakMap(), Ce = new WeakMap(), CC = new WeakMap(), iI = new WeakMap(), _g = new WeakMap(), $g = new WeakMap(), QA = new WeakSet(), Ha = function(A) {
1802
1766
  return r(this, null, function* () {
1803
1767
  try {
1804
- yield d(this, QA, Ka).call(this), s(this, V).debug("Media keys initialization completed"), yield d(this, QA, Ya).call(this, A.initData, A.initDataType);
1768
+ yield d(this, QA, qa).call(this), s(this, V).debug("Media keys initialization completed"), yield d(this, QA, va).call(this, A.initData, A.initDataType);
1805
1769
  } catch (t) {
1806
1770
  d(this, QA, Eg).call(this, { message: "Failed to handle encrypted event", isFatal: !0, error: t });
1807
1771
  }
1808
1772
  });
1809
- }, Ka = function() {
1773
+ }, qa = function() {
1810
1774
  return r(this, null, function* () {
1811
1775
  var t;
1812
1776
  s(this, V).debug("Initializing media keys");
@@ -1823,14 +1787,14 @@ V = new WeakMap(), Xe = new WeakMap(), qt = new WeakMap(), Bt = new WeakMap(), u
1823
1787
  const e = yield s(this, nC).call(this, A);
1824
1788
  s(this, V).debug("CDM obtained", { cdm: e }), lA(s(this, qt), "No media element found"), lA(e, "No CDM found");
1825
1789
  const g = yield e.getMediaKeys();
1826
- e.certificate && (yield d(this, QA, Pa).call(this, g, e.certificate)), s(this, V).debug("Setting media keys on media element"), yield s(this, qt).setMediaKeys(g), E(this, cA, e);
1790
+ e.certificate && (yield d(this, QA, Ya).call(this, g, e.certificate)), s(this, V).debug("Setting media keys on media element"), yield s(this, qt).setMediaKeys(g), E(this, cA, e);
1827
1791
  })), yield s(this, Ce);
1828
1792
  });
1829
- }, Ya = function(A, t) {
1793
+ }, va = function(A, t) {
1830
1794
  return r(this, null, function* () {
1831
1795
  lA(s(this, cA), "No CDM manager found");
1832
1796
  const e = yield s(this, cA).getMediaKeys();
1833
- if (!A || !d(this, QA, Ta).call(this, A)) {
1797
+ if (!A || !d(this, QA, Ka).call(this, A)) {
1834
1798
  s(this, V).debug("Duplicate initData, no need to create new session", { initData: A });
1835
1799
  return;
1836
1800
  }
@@ -1839,11 +1803,11 @@ V = new WeakMap(), Xe = new WeakMap(), qt = new WeakMap(), Bt = new WeakMap(), u
1839
1803
  s(this, V).info("Session is closed", { reason: B });
1840
1804
  }), g.addEventListener("message", s(this, QC)), s(this, Be).set(g, A), s(this, V).debug("Generating request for session", { session: g, initDataType: t, initData: A }), yield g.generateRequest(t, A);
1841
1805
  });
1842
- }, Ta = function(A) {
1806
+ }, Ka = function(A) {
1843
1807
  for (const [t, e] of s(this, Be))
1844
- if (Nc(A, e)) return !1;
1808
+ if (Sc(A, e)) return !1;
1845
1809
  return !0;
1846
- }, QC = new WeakMap(), oC = new WeakMap(), Pa = function(A, t) {
1810
+ }, QC = new WeakMap(), oC = new WeakMap(), Ya = function(A, t) {
1847
1811
  return r(this, null, function* () {
1848
1812
  try {
1849
1813
  s(this, V).debug("Setting server certificate", { certificate: t }), (yield A.setServerCertificate(t)) || s(this, V).warn("Server certificates are not supported by the CDM.");
@@ -1853,17 +1817,17 @@ V = new WeakMap(), Xe = new WeakMap(), qt = new WeakMap(), Bt = new WeakMap(), u
1853
1817
  });
1854
1818
  }, Eg = function(A) {
1855
1819
  const { message: t, isFatal: e, error: g } = A;
1856
- s(this, V).error(t, { error: g }), s(this, Xe).emit("error", Ja(t, e, g));
1820
+ s(this, V).error(t, { error: g }), s(this, Xe).emit("error", La(t, e, g));
1857
1821
  }, nC = new WeakMap(), /**
1858
1822
  * Get the prioritized key system list based on the DRM data provided.
1859
1823
  * The order of the key systems in the list is the order in which they will be tried.
1860
1824
  * If clearkeys are provided, it will be the first in the list.
1861
1825
  * Playready will be prioritized over Widevine, some browsers support both but playready may support higher robustness level.
1862
1826
  */
1863
- xa = function(A) {
1827
+ Ta = function(A) {
1864
1828
  const t = [];
1865
1829
  return A.clearkeys && t.push("clearkey"), A.playreadyLicenseUrl && t.push("playready"), A.widevineLicenseUrl && t.push("widevine"), A.fairplayLicenseUrl && A.fairplayCertificate && t.push("fairplay"), t;
1866
- }, Wa = function(A) {
1830
+ }, Pa = function(A) {
1867
1831
  return {
1868
1832
  fairplay: A.fairplayLicenseUrl,
1869
1833
  playready: A.playreadyLicenseUrl,
@@ -1871,17 +1835,17 @@ xa = function(A) {
1871
1835
  clearkey: void 0
1872
1836
  };
1873
1837
  };
1874
- const vc = 7, Kc = 8, Yc = (i) => {
1838
+ const Nc = 7, bc = 8, Lc = (i) => {
1875
1839
  const A = i.getUint32(0, !1), t = i.getUint8(0) << 16 | i.getUint16(1, !1);
1876
1840
  let e = 0;
1877
1841
  return t === 1 ? e += 3 : A === 1 && (e += 4), e;
1878
- }, Tc = (i) => Yc(new DataView(i, 0)) !== 0, Gn = (i, A = 0) => {
1842
+ }, Jc = (i) => Lc(new DataView(i, 0)) !== 0, Gn = (i, A = 0) => {
1879
1843
  for (let t = A; t < i.byteLength - 4; t++) {
1880
1844
  const e = i.getUint32(t) === 1, g = (i.getUint8(t) << 16 | i.getUint16(t + 1)) === 1;
1881
1845
  if (e || g)
1882
1846
  return { position: t, nalPrefixSize: e ? 4 : 3 };
1883
1847
  }
1884
- }, Pc = (i) => i & 31, xc = (i, A) => {
1848
+ }, Mc = (i) => i & 31, Hc = (i, A) => {
1885
1849
  const t = new DataView(i, 0);
1886
1850
  let e = Gn(t);
1887
1851
  for (; e; ) {
@@ -1890,9 +1854,9 @@ const vc = 7, Kc = 8, Yc = (i) => {
1890
1854
  return;
1891
1855
  e = C;
1892
1856
  }
1893
- }, Oa = (i) => {
1857
+ }, xa = (i) => {
1894
1858
  const A = [], t = [];
1895
- if (!Tc(i)) {
1859
+ if (!Jc(i)) {
1896
1860
  const e = new DataView(i, 0), g = e.getUint8(5) & 31;
1897
1861
  let B = 6;
1898
1862
  for (let Q = 0; Q < g; Q++) {
@@ -1910,19 +1874,19 @@ const vc = 7, Kc = 8, Yc = (i) => {
1910
1874
  pictureParameterSets: t
1911
1875
  };
1912
1876
  }
1913
- return xc(i, (e) => {
1877
+ return Hc(i, (e) => {
1914
1878
  const g = e.byteOffset + e.byteLength;
1915
- switch (Pc(e.getUint8(0))) {
1916
- case Kc:
1879
+ switch (Mc(e.getUint8(0))) {
1880
+ case bc:
1917
1881
  t.push(e.buffer.slice(e.byteOffset, g));
1918
1882
  break;
1919
- case vc:
1883
+ case Nc:
1920
1884
  A.push(e.buffer.slice(e.byteOffset, g));
1921
1885
  break;
1922
1886
  }
1923
1887
  return !0;
1924
1888
  }), { sequenceParameterSets: A, pictureParameterSets: t };
1925
- }, Wc = (i) => {
1889
+ }, qc = (i) => {
1926
1890
  var S;
1927
1891
  const A = new DataView(i), t = A.getUint8(1), e = A.getUint8(2), g = A.getUint8(3), B = new Sa(i, 32);
1928
1892
  B.readUnsignedExpGolomb();
@@ -1969,7 +1933,7 @@ const vc = 7, Kc = 8, Yc = (i) => {
1969
1933
  numerator: 1,
1970
1934
  denumerator: 1
1971
1935
  };
1972
- return B.readBit() && B.readBit() && (u = (S = Oc[B.readBits(8)]) != null ? S : { numerator: 0, denumerator: 0 }), {
1936
+ return B.readBit() && B.readBit() && (u = (S = vc[B.readBits(8)]) != null ? S : { numerator: 0, denumerator: 0 }), {
1973
1937
  width: h,
1974
1938
  height: l,
1975
1939
  pixelAspectRatio: u,
@@ -1977,7 +1941,7 @@ const vc = 7, Kc = 8, Yc = (i) => {
1977
1941
  constraintFlags: e,
1978
1942
  levelIdc: g
1979
1943
  };
1980
- }, Oc = [
1944
+ }, vc = [
1981
1945
  { numerator: 0, denumerator: 0 },
1982
1946
  { numerator: 1, denumerator: 1 },
1983
1947
  { numerator: 12, denumerator: 11 },
@@ -1995,20 +1959,20 @@ const vc = 7, Kc = 8, Yc = (i) => {
1995
1959
  { numerator: 4, denumerator: 3 },
1996
1960
  { numerator: 3, denumerator: 2 },
1997
1961
  { numerator: 2, denumerator: 1 }
1998
- ], Vc = 184549376;
1999
- function Zc(i) {
2000
- const A = new eg(i), t = Xc(A);
2001
- (t.flags & Vc) !== 0 && jc(A);
2002
- const e = zc(A);
1962
+ ], Kc = 184549376;
1963
+ function Yc(i) {
1964
+ const A = new eg(i), t = Tc(A);
1965
+ (t.flags & Kc) !== 0 && Pc(A);
1966
+ const e = xc(A);
2003
1967
  if (String.fromCharCode(...e.frameId) === "TXXX") {
2004
1968
  const B = new eg(A.readBytes(e.size));
2005
1969
  return {
2006
1970
  header: t,
2007
- txx: _c(B)
1971
+ txx: Wc(B)
2008
1972
  };
2009
1973
  }
2010
1974
  }
2011
- function Xc(i) {
1975
+ function Tc(i) {
2012
1976
  const A = i.readBytes(3), t = i.readUint8(), e = i.readUint8(), g = i.readUint8(), B = i.readUint32();
2013
1977
  return {
2014
1978
  id: A,
@@ -2018,11 +1982,11 @@ function Xc(i) {
2018
1982
  size: B
2019
1983
  };
2020
1984
  }
2021
- function jc(i) {
1985
+ function Pc(i) {
2022
1986
  const A = i.readUint32();
2023
1987
  return i.readBytes(A - 4), {};
2024
1988
  }
2025
- function zc(i) {
1989
+ function xc(i) {
2026
1990
  const A = i.readBytes(4), t = i.readUint32(), e = i.readUint16();
2027
1991
  return {
2028
1992
  frameId: A,
@@ -2030,7 +1994,7 @@ function zc(i) {
2030
1994
  flags: e
2031
1995
  };
2032
1996
  }
2033
- function _c(i) {
1997
+ function Wc(i) {
2034
1998
  const A = i.readUint8(), t = i.readUtf8String(), e = i.readUtf8String();
2035
1999
  return {
2036
2000
  encoding: A,
@@ -2038,7 +2002,7 @@ function _c(i) {
2038
2002
  value: e
2039
2003
  };
2040
2004
  }
2041
- function Va(i) {
2005
+ function Wa(i) {
2042
2006
  let A = i.readUint32();
2043
2007
  const t = [i.readUint8(), i.readUint8(), i.readUint8(), i.readUint8()], e = String.fromCharCode.apply(null, t);
2044
2008
  return A === 1 && (A = i.readUint64() - 8), {
@@ -2047,8 +2011,8 @@ function Va(i) {
2047
2011
  type: e
2048
2012
  };
2049
2013
  }
2050
- function $c(i, A) {
2051
- const t = Va(A), e = new eg(A.readBytes(t.size));
2014
+ function Oc(i, A) {
2015
+ const t = Wa(A), e = new eg(A.readBytes(t.size));
2052
2016
  if (t.type !== i.type)
2053
2017
  throw new Error(`invalid error type: ${t.type}, expected ${i.type}`);
2054
2018
  const g = i.decodeData(e);
@@ -2141,6 +2105,23 @@ const Sg = class Sg {
2141
2105
  };
2142
2106
  I(Sg, "type", "tfdt");
2143
2107
  let LB = Sg;
2108
+ const Vc = 1, Zc = 2, Xc = 8, jc = 16, zc = 32, mg = class mg {
2109
+ constructor(A, t, e, g) {
2110
+ I(this, "type", mg.type);
2111
+ I(this, "extra");
2112
+ I(this, "defaultSampleDuration");
2113
+ I(this, "defaultSampleSize");
2114
+ I(this, "defaultSampleFlags");
2115
+ this.extra = A, this.defaultSampleDuration = t, this.defaultSampleSize = e, this.defaultSampleFlags = g;
2116
+ }
2117
+ static decodeData(A) {
2118
+ const t = Ae(A);
2119
+ let e, g, B;
2120
+ return A.readUint32(), (t.flags & Vc) > 0 && A.readUint64(), (t.flags & Zc) > 0 && A.readUint32(), (t.flags & Xc) > 0 && (e = A.readUint32()), (t.flags & jc) > 0 && (g = A.readUint32()), (t.flags & zc) > 0 && (B = A.readUint32()), new mg(t, e, g, B);
2121
+ }
2122
+ };
2123
+ I(mg, "type", "tfhd");
2124
+ let JB = mg;
2144
2125
  const IA = class IA {
2145
2126
  constructor(A, t, e) {
2146
2127
  I(this, "type", IA.type);
@@ -2172,23 +2153,6 @@ const IA = class IA {
2172
2153
  };
2173
2154
  I(IA, "TRUN_DATA_OFFSET", 1), I(IA, "TRUN_FIRST_SAMPLE_FLAGS", 4), I(IA, "SAMPLE_DURATION", 256), I(IA, "SAMPLE_SIZE", 512), I(IA, "SAMPLE_FLAGS", 1024), I(IA, "SAMPLE_CTS", 2048), I(IA, "FLAG_SAMPLE_FLAG_IS_NON_SYNC", 65536), I(IA, "FLAG_SAMPLE_DEPENDS_NO", 33554432), I(IA, "FLAG_SAMPLE_DEPENDS_YES", 16777216), I(IA, "type", "trun");
2174
2155
  let xg = IA;
2175
- const Ah = 1, th = 2, eh = 8, ih = 16, Ih = 32, mg = class mg {
2176
- constructor(A, t, e, g) {
2177
- I(this, "type", mg.type);
2178
- I(this, "extra");
2179
- I(this, "defaultSampleDuration");
2180
- I(this, "defaultSampleSize");
2181
- I(this, "defaultSampleFlags");
2182
- this.extra = A, this.defaultSampleDuration = t, this.defaultSampleSize = e, this.defaultSampleFlags = g;
2183
- }
2184
- static decodeData(A) {
2185
- const t = Ae(A);
2186
- let e, g, B;
2187
- return A.readUint32(), (t.flags & Ah) > 0 && A.readUint64(), (t.flags & th) > 0 && A.readUint32(), (t.flags & eh) > 0 && (e = A.readUint32()), (t.flags & ih) > 0 && (g = A.readUint32()), (t.flags & Ih) > 0 && (B = A.readUint32()), new mg(t, e, g, B);
2188
- }
2189
- };
2190
- I(mg, "type", "tfhd");
2191
- let JB = mg;
2192
2156
  const yg = class yg {
2193
2157
  constructor(A, t, e) {
2194
2158
  I(this, "type", yg.type);
@@ -2562,7 +2526,7 @@ const qg = class qg {
2562
2526
  A.readUint16(), A.readUint32();
2563
2527
  const g = A.readUint16();
2564
2528
  A.readUint16(), t === 1 && (A.readUint64(), A.readUint64());
2565
- const B = $c(OQ, A);
2529
+ const B = Oc(OQ, A);
2566
2530
  return new qg(B, e, g);
2567
2531
  }
2568
2532
  };
@@ -2594,7 +2558,7 @@ const Vi = class Vi {
2594
2558
  I(Vi, "type", "prft");
2595
2559
  let ZB = Vi;
2596
2560
  var As, ts;
2597
- class gh {
2561
+ class _c {
2598
2562
  constructor(A, t) {
2599
2563
  n(this, As);
2600
2564
  n(this, ts);
@@ -2608,7 +2572,7 @@ class gh {
2608
2572
  }
2609
2573
  }
2610
2574
  As = new WeakMap(), ts = new WeakMap();
2611
- const sh = {
2575
+ const $c = {
2612
2576
  moov: VB,
2613
2577
  trak: OB,
2614
2578
  tkhd: WB,
@@ -2632,15 +2596,15 @@ const sh = {
2632
2596
  emsg: NB
2633
2597
  };
2634
2598
  function rt(i) {
2635
- const A = Va(i), t = sh[A.type], e = new eg(i.readBytes(A.size));
2599
+ const A = Wa(i), t = $c[A.type], e = new eg(i.readBytes(A.size));
2636
2600
  if (!t) {
2637
- const B = new gh(A, e);
2601
+ const B = new _c(A, e);
2638
2602
  return e.readRemaining(), B;
2639
2603
  }
2640
2604
  const g = t.decodeData(e);
2641
2605
  return e.readRemaining(), g;
2642
2606
  }
2643
- function Bh(i) {
2607
+ function Ah(i) {
2644
2608
  if (i.byteLength < 8)
2645
2609
  throw new Error("Buffer too small");
2646
2610
  const A = new eg(i), t = /* @__PURE__ */ new Map();
@@ -2658,7 +2622,7 @@ function Bh(i) {
2658
2622
  moov: g
2659
2623
  };
2660
2624
  }
2661
- function Ch(i) {
2625
+ function th(i) {
2662
2626
  if (i.byteLength < 8)
2663
2627
  throw new Error("Buffer too small");
2664
2628
  const A = new eg(i), t = /* @__PURE__ */ new Map(), e = [];
@@ -2681,11 +2645,11 @@ function Ch(i) {
2681
2645
  };
2682
2646
  }
2683
2647
  var es, is;
2684
- class Qh {
2648
+ class eh {
2685
2649
  constructor(A) {
2686
2650
  n(this, es);
2687
2651
  n(this, is);
2688
- E(this, es, A), E(this, is, Bh(A));
2652
+ E(this, es, A), E(this, is, Ah(A));
2689
2653
  }
2690
2654
  rawBytes() {
2691
2655
  return s(this, es);
@@ -2701,7 +2665,7 @@ const _o = class _o {
2701
2665
  n(this, GA);
2702
2666
  n(this, JA);
2703
2667
  n(this, _);
2704
- E(this, GA, t), E(this, JA, A), E(this, _, Ch(t));
2668
+ E(this, GA, t), E(this, JA, A), E(this, _, th(t));
2705
2669
  }
2706
2670
  /**
2707
2671
  * @returns a new fragment with a clone of the raw bytes
@@ -2822,7 +2786,7 @@ var II;
2822
2786
  class kn {
2823
2787
  constructor(A) {
2824
2788
  n(this, II);
2825
- E(this, II, new Qh(A));
2789
+ E(this, II, new eh(A));
2826
2790
  }
2827
2791
  header() {
2828
2792
  return s(this, II);
@@ -2878,7 +2842,7 @@ const Z = {
2878
2842
  prft: N("prft"),
2879
2843
  dOps: N("dOps"),
2880
2844
  emsg: N("emsg")
2881
- }, oh = 1e3, Wg = N("iso6"), Rn = new Uint8Array([0, 0, 2, 0]), nh = [
2845
+ }, ih = 1e3, Wg = N("iso6"), Rn = new Uint8Array([0, 0, 2, 0]), Ih = [
2882
2846
  Wg,
2883
2847
  new Uint8Array([105, 115, 111, 109]),
2884
2848
  // isom
@@ -2888,7 +2852,7 @@ const Z = {
2888
2852
  // avc1
2889
2853
  new Uint8Array([109, 112, 52, 49])
2890
2854
  // mp41
2891
- ], ah = [
2855
+ ], gh = [
2892
2856
  Wg,
2893
2857
  new Uint8Array([105, 115, 111, 109]),
2894
2858
  // isom
@@ -2898,7 +2862,7 @@ const Z = {
2898
2862
  // av01
2899
2863
  new Uint8Array([109, 112, 52, 49])
2900
2864
  // mp41
2901
- ], Eh = [
2865
+ ], sh = [
2902
2866
  Wg,
2903
2867
  new Uint8Array([105, 115, 111, 109]),
2904
2868
  // isom
@@ -2907,9 +2871,9 @@ const Z = {
2907
2871
  new Uint8Array([109, 112, 52, 49])
2908
2872
  // mp41
2909
2873
  ];
2910
- class Za {
2874
+ class Oa {
2911
2875
  constructor() {
2912
- I(this, "writer", new Nr());
2876
+ I(this, "writer", new pr());
2913
2877
  I(this, "moofOffset", 0);
2914
2878
  }
2915
2879
  }
@@ -2923,11 +2887,11 @@ const CA = (i, A, t) => {
2923
2887
  Z.ftyp,
2924
2888
  Wg.byteLength + Rn.byteLength + A.reduce((t, e) => t + e.byteLength, 0)
2925
2889
  ), i.writer.writeBytes(Wg), i.writer.writeBytes(Rn), A.forEach((t) => i.writer.writeBytes(t));
2926
- }, rh = Math.pow(2, 32), ch = 2208988800, hh = (i, A, t, e) => {
2890
+ }, Bh = 2 ** 32, Ch = 2208988800, Qh = (i, A, t, e) => {
2927
2891
  oA(i, Z.prft, 20, 1, 0);
2928
- const B = t / 1e3, C = Math.floor(B), o = (B - C) * 1e3 * 1e3 * rh / 1e6;
2929
- i.writer.writeUint32(A), i.writer.writeUint32(C + ch), i.writer.writeUint32(o), i.writer.writeUint64(e);
2930
- }, dh = (i, A, t) => {
2892
+ const B = t / 1e3, C = Math.floor(B), o = (B - C) * 1e3 * 1e3 * Bh / 1e6;
2893
+ i.writer.writeUint32(A), i.writer.writeUint32(C + Ch), i.writer.writeUint32(o), i.writer.writeUint64(e);
2894
+ }, oh = (i, A, t) => {
2931
2895
  oA(i, Z.mvhd, 96, 0, 0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(t), i.writer.writeUint32(A), i.writer.writeUint32(65536), i.writer.writeUint16(256), i.writer.writeBytes(new Uint8Array([
2932
2896
  // reserved and unused junk
2933
2897
  0,
@@ -3001,7 +2965,7 @@ const CA = (i, A, t) => {
3001
2965
  0,
3002
2966
  0
3003
2967
  ])), i.writer.writeUint32(2);
3004
- }, Xa = (i) => "sequenceParameterSets" in i, XQ = (i) => "sequenceHeader" in i, Fi = (i) => i.type == "video", lg = (i) => i.type == "audio", lh = (i, A, t) => {
2968
+ }, Va = (i) => "sequenceParameterSets" in i, XQ = (i) => "sequenceHeader" in i, Fi = (i) => i.type == "video", lg = (i) => i.type == "audio", nh = (i, A, t) => {
3005
2969
  const e = i.writer.position();
3006
2970
  oA(i, Z.tkhd, 0, 0, 3), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(A.trackId), i.writer.writeUint32(0), i.writer.writeUint32(A.duration * t / A.timescale), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint16(0), i.writer.writeUint16(lg(A) ? 1 : 0), i.writer.writeUint16(lg(A) ? 256 : 0), i.writer.writeUint16(0), i.writer.writeBytes(new Uint8Array(
3007
2971
  [
@@ -3043,24 +3007,24 @@ const CA = (i, A, t) => {
3043
3007
  0
3044
3008
  ]
3045
3009
  )), Fi(A) ? (i.writer.writeUint32(A.width * 65536), i.writer.writeUint32(A.height * 65536)) : lg(A) && (i.writer.writeUint32(0), i.writer.writeUint32(0)), i.writer.writeUint32At(e, i.writer.position() - e);
3046
- }, uh = (i, A) => {
3010
+ }, ah = (i, A) => {
3047
3011
  oA(i, Z.mdhd, 20, 0, 0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(A.timescale), i.writer.writeUint32(A.duration);
3048
3012
  const t = A.lang || "und", e = (t.charCodeAt(0) & 31) << 10 | (t.charCodeAt(1) & 31) << 5 | t.charCodeAt(2) & 31;
3049
3013
  i.writer.writeUint16(e), i.writer.writeUint16(0);
3050
- }, wh = (i, A) => {
3014
+ }, Eh = (i, A) => {
3051
3015
  const t = i.writer.position();
3052
3016
  oA(i, Z.hdlr, 0, 0, 0), i.writer.writeUint32(0), i.writer.writeBytes(N(Fi(A) ? "vide" : "soun")), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeBytes(N(Fi(A) ? "VideoHandler\0" : "SoundHandler\0")), i.writer.writeUint32At(t, i.writer.position() - t);
3053
- }, Dh = (i) => {
3017
+ }, rh = (i) => {
3054
3018
  const A = i.writer.position();
3055
3019
  CA(i, Z.dinf, 0), oA(i, Z.dref, 16, 0, 0), i.writer.writeUint32(1), oA(i, N("url "), 0, 0, 1), i.writer.writeUint32At(A, i.writer.position() - A);
3056
- }, Sh = (i, A) => {
3020
+ }, ch = (i, A) => {
3057
3021
  const t = i.writer.position();
3058
3022
  CA(i, Z.avcC, 0), i.writer.writeUint8(1), i.writer.writeUint8(A.sequenceParameterSets[0][1]), i.writer.writeUint8(A.sequenceParameterSets[0][2]), i.writer.writeUint8(A.sequenceParameterSets[0][3]), i.writer.writeUint8(255), i.writer.writeUint8(224 | A.sequenceParameterSets.length), A.sequenceParameterSets.forEach((e) => {
3059
3023
  i.writer.writeUint16(e.byteLength), i.writer.writeBytes(e);
3060
3024
  }), i.writer.writeUint8(A.pictureParameterSets.length), A.pictureParameterSets.forEach((e) => {
3061
3025
  i.writer.writeUint16(e.byteLength), i.writer.writeBytes(e);
3062
3026
  }), i.writer.writeUint32At(t, i.writer.position() - t);
3063
- }, mh = (i, A) => {
3027
+ }, hh = (i, A) => {
3064
3028
  var Q, o;
3065
3029
  const t = i.writer.position();
3066
3030
  CA(i, Z.av1C, 0);
@@ -3068,20 +3032,20 @@ const CA = (i, A, t) => {
3068
3032
  i.writer.writeUint8(129), i.writer.writeUint8(e << 5 | ((Q = C == null ? void 0 : C.seqLevelIdx) != null ? Q : 0)), i.writer.writeUint8(
3069
3033
  ((o = C == null ? void 0 : C.tier) != null ? o : 0) | (B.highBitDepth ? 1 : 0) | (B.bitDepth === 12 ? 1 : 0) << 5 | (B.monoChrome ? 1 : 0) << 4 | B.subsamplingX << 3 | B.subsamplingY << 2 | B.chromaSamplePosition & 65535
3070
3034
  ), i.writer.writeUint8(0), i.writer.writeBytes(A.sequenceHeader), i.writer.writeUint32At(t, i.writer.position() - t);
3071
- }, yh = (i, A) => {
3035
+ }, dh = (i, A) => {
3072
3036
  const t = i.writer.position(), e = XQ(A) ? Z.av01 : Z.avc1;
3073
- CA(i, e, 0), i.writer.writeUint32(0), i.writer.writeUint16(0), i.writer.writeUint16(1), i.writer.writeUint16(0), i.writer.writeUint16(0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint16(A.width), i.writer.writeUint16(A.height), i.writer.writeUint32(4718592), i.writer.writeUint32(4718592), i.writer.writeUint32(0), i.writer.writeUint16(1), i.writer.writeUint8(0), i.writer.writeBytes(new Uint8Array(31)), i.writer.writeUint16(24), i.writer.writeUint16(-1), Xa(A) ? Sh(i, A) : XQ(A) && (mh(i, A), A.parsedSequenceHeader.colorConfig && (CA(i, N("colr"), 11), i.writer.writeBytes(Z.nclx), i.writer.writeUint16(A.parsedSequenceHeader.colorConfig.colorPrimaries), i.writer.writeUint16(A.parsedSequenceHeader.colorConfig.transferCharacteristics), i.writer.writeUint16(A.parsedSequenceHeader.colorConfig.matrixCoefficients), i.writer.writeUint8(A.parsedSequenceHeader.colorConfig.colorRange ? 1 : 0))), A.pixelAspectRatio && (CA(i, N("pasp"), 8), i.writer.writeUint32(A.pixelAspectRatio.numerator), i.writer.writeUint32(A.pixelAspectRatio.denumerator)), A.bitrate && (CA(i, N("btrt"), 12), i.writer.writeUint32(0), i.writer.writeUint32(A.bitrate), i.writer.writeUint32(A.bitrate)), i.writer.writeUint32At(t, i.writer.position() - t);
3037
+ CA(i, e, 0), i.writer.writeUint32(0), i.writer.writeUint16(0), i.writer.writeUint16(1), i.writer.writeUint16(0), i.writer.writeUint16(0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint16(A.width), i.writer.writeUint16(A.height), i.writer.writeUint32(4718592), i.writer.writeUint32(4718592), i.writer.writeUint32(0), i.writer.writeUint16(1), i.writer.writeUint8(0), i.writer.writeBytes(new Uint8Array(31)), i.writer.writeUint16(24), i.writer.writeUint16(-1), Va(A) ? ch(i, A) : XQ(A) && (hh(i, A), A.parsedSequenceHeader.colorConfig && (CA(i, N("colr"), 11), i.writer.writeBytes(Z.nclx), i.writer.writeUint16(A.parsedSequenceHeader.colorConfig.colorPrimaries), i.writer.writeUint16(A.parsedSequenceHeader.colorConfig.transferCharacteristics), i.writer.writeUint16(A.parsedSequenceHeader.colorConfig.matrixCoefficients), i.writer.writeUint8(A.parsedSequenceHeader.colorConfig.colorRange ? 1 : 0))), A.pixelAspectRatio && (CA(i, N("pasp"), 8), i.writer.writeUint32(A.pixelAspectRatio.numerator), i.writer.writeUint32(A.pixelAspectRatio.denumerator)), A.bitrate && (CA(i, N("btrt"), 12), i.writer.writeUint32(0), i.writer.writeUint32(A.bitrate), i.writer.writeUint32(A.bitrate)), i.writer.writeUint32At(t, i.writer.position() - t);
3074
3038
  }, hB = (i, A, t) => {
3075
3039
  let e = 3;
3076
3040
  for (i.writer.writeUint8(A); e > 0; e--)
3077
3041
  i.writer.writeUint8(t >> 7 * e | 128);
3078
3042
  i.writer.writeUint8(t & 127);
3079
- }, fh = (i, A) => {
3043
+ }, lh = (i, A) => {
3080
3044
  const t = A.decoderConfig.byteLength > 0 ? A.decoderConfig.byteLength + 5 : 0, e = i.writer.position();
3081
3045
  oA(i, Z.esds, 0, 0, 0), hB(i, 3, 21 + t + 5 + 1), i.writer.writeUint16(A.trackId), i.writer.writeUint8(0), hB(i, 4, 13 + t);
3082
3046
  const g = A.codec === "mp3" && A.sampleRate > 24e3 ? 107 : 64;
3083
3047
  i.writer.writeUint8(g), i.writer.writeUint8(21), i.writer.writeUint24(0), i.writer.writeUint32(A.bitrate || 0), i.writer.writeUint32(A.bitrate || 0), A.decoderConfig.byteLength > 0 && (hB(i, 5, A.decoderConfig.byteLength), i.writer.writeBytes(A.decoderConfig)), hB(i, 6, 1), i.writer.writeUint8(2), i.writer.writeUint32At(e, i.writer.position() - e);
3084
- }, ph = (i) => {
3048
+ }, uh = (i) => {
3085
3049
  switch (i) {
3086
3050
  case "aac":
3087
3051
  case "mp3":
@@ -3089,54 +3053,54 @@ const CA = (i, A, t) => {
3089
3053
  case "opus":
3090
3054
  return "Opus";
3091
3055
  }
3092
- }, Fh = (i, A) => {
3056
+ }, wh = (i, A) => {
3093
3057
  const t = i.writer.position();
3094
3058
  CA(i, N("dOps"), 0), i.writer.writeUint8(0);
3095
3059
  const e = A.decoderConfig, g = new DataView(e.buffer, e.byteOffset, e.byteLength);
3096
3060
  i.writer.writeUint8(g.getUint8(9)), i.writer.writeUint16(g.getUint16(10, !0)), i.writer.writeUint32(g.getUint32(12, !0)), i.writer.writeUint16(g.getUint16(16, !0)), i.writer.writeBytes(A.decoderConfig.slice(18)), i.writer.writeUint32At(t, i.writer.position() - t);
3097
- }, Gh = (i, A) => {
3061
+ }, Dh = (i, A) => {
3098
3062
  const t = i.writer.position();
3099
- switch (CA(i, N(ph(A.codec)), 0), i.writer.writeUint32(0), i.writer.writeUint16(0), i.writer.writeUint16(1), i.writer.writeUint16(0), i.writer.writeUint16(0), i.writer.writeUint32(0), i.writer.writeUint16(A.channelCount), i.writer.writeUint16(16), i.writer.writeUint32(0), i.writer.writeUint16(A.sampleRate), i.writer.writeUint16(0), A.codec) {
3063
+ switch (CA(i, N(uh(A.codec)), 0), i.writer.writeUint32(0), i.writer.writeUint16(0), i.writer.writeUint16(1), i.writer.writeUint16(0), i.writer.writeUint16(0), i.writer.writeUint32(0), i.writer.writeUint16(A.channelCount), i.writer.writeUint16(16), i.writer.writeUint32(0), i.writer.writeUint16(A.sampleRate), i.writer.writeUint16(0), A.codec) {
3100
3064
  case "aac":
3101
3065
  case "mp3":
3102
- fh(i, A);
3066
+ lh(i, A);
3103
3067
  break;
3104
3068
  case "opus":
3105
- Fh(i, A);
3069
+ wh(i, A);
3106
3070
  break;
3107
3071
  }
3108
3072
  A.bitrate && (CA(i, N("btrt"), 12), i.writer.writeUint32(0), i.writer.writeUint32(A.bitrate), i.writer.writeUint32(A.bitrate)), i.writer.writeUint32At(t, i.writer.position() - t);
3109
- }, kh = (i, A) => {
3073
+ }, Sh = (i, A) => {
3110
3074
  const t = i.writer.position();
3111
3075
  CA(i, Z.stbl, 0);
3112
3076
  const e = i.writer.position();
3113
- oA(i, Z.stsd, 0, 0, 0), i.writer.writeUint32(1), Fi(A) ? yh(i, A) : lg(A) && Gh(i, A), i.writer.writeUint32At(e, i.writer.position() - e), oA(i, N("stts"), 4, 0, 0), i.writer.writeUint32(0), oA(i, N("stsc"), 4, 0, 0), i.writer.writeUint32(0), oA(i, N("stsz"), 8, 0, 0), i.writer.writeUint32(0), i.writer.writeUint32(0), oA(i, N("stco"), 4, 0, 0), i.writer.writeUint32(0), i.writer.writeUint32At(t, i.writer.position() - t);
3114
- }, Rh = (i, A) => {
3077
+ oA(i, Z.stsd, 0, 0, 0), i.writer.writeUint32(1), Fi(A) ? dh(i, A) : lg(A) && Dh(i, A), i.writer.writeUint32At(e, i.writer.position() - e), oA(i, N("stts"), 4, 0, 0), i.writer.writeUint32(0), oA(i, N("stsc"), 4, 0, 0), i.writer.writeUint32(0), oA(i, N("stsz"), 8, 0, 0), i.writer.writeUint32(0), i.writer.writeUint32(0), oA(i, N("stco"), 4, 0, 0), i.writer.writeUint32(0), i.writer.writeUint32At(t, i.writer.position() - t);
3078
+ }, mh = (i, A) => {
3115
3079
  const t = i.writer.position();
3116
- CA(i, Z.minf, 0), Fi(A) ? (oA(i, Z.vmhd, 8, 0, 1), i.writer.writeUint32(0), i.writer.writeUint32(0)) : lg(A) && (oA(i, Z.smhd, 4, 0, 0), i.writer.writeUint16(0), i.writer.writeUint16(0)), Dh(i), kh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3117
- }, Uh = (i, A) => {
3080
+ CA(i, Z.minf, 0), Fi(A) ? (oA(i, Z.vmhd, 8, 0, 1), i.writer.writeUint32(0), i.writer.writeUint32(0)) : lg(A) && (oA(i, Z.smhd, 4, 0, 0), i.writer.writeUint16(0), i.writer.writeUint16(0)), rh(i), Sh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3081
+ }, yh = (i, A) => {
3118
3082
  const t = i.writer.position();
3119
- CA(i, Z.mdia, 0), uh(i, A), wh(i, A), Rh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3120
- }, Nh = (i, A, t) => {
3083
+ CA(i, Z.mdia, 0), ah(i, A), Eh(i, A), mh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3084
+ }, fh = (i, A, t) => {
3121
3085
  const e = i.writer.position();
3122
- CA(i, Z.trak, 0), lh(i, A, t), Uh(i, A), i.writer.writeUint32At(e, i.writer.position() - e);
3123
- }, bh = (i, A) => {
3086
+ CA(i, Z.trak, 0), nh(i, A, t), yh(i, A), i.writer.writeUint32At(e, i.writer.position() - e);
3087
+ }, ph = (i, A) => {
3124
3088
  oA(i, Z.trex, 20, 0, 0), i.writer.writeUint32(A.trackId), i.writer.writeUint32(1), i.writer.writeUint32(0), i.writer.writeUint32(0), i.writer.writeUint32(0);
3125
- }, Lh = (i, A) => {
3089
+ }, Fh = (i, A) => {
3126
3090
  const t = i.writer.position();
3127
- CA(i, Z.mvex, 0), A.forEach((e) => bh(i, e)), i.writer.writeUint32At(t, i.writer.position() - t);
3128
- }, Jh = (i, A, t, e) => {
3091
+ CA(i, Z.mvex, 0), A.forEach((e) => ph(i, e)), i.writer.writeUint32At(t, i.writer.position() - t);
3092
+ }, Gh = (i, A, t, e) => {
3129
3093
  const g = i.writer.position();
3130
- CA(i, Z.moov, 0), dh(i, 0, t), A.forEach((B) => Nh(i, B, t)), Lh(i, A), i.writer.writeUint32At(g, i.writer.position() - g);
3131
- }, Mh = (i, A) => {
3094
+ CA(i, Z.moov, 0), oh(i, 0, t), A.forEach((B) => fh(i, B, t)), Fh(i, A), i.writer.writeUint32At(g, i.writer.position() - g);
3095
+ }, kh = (i, A) => {
3132
3096
  const t = i.writer.position();
3133
3097
  oA(i, Z.tfhd, 16, 0, 56), i.writer.writeUint32(A.trackId), i.writer.writeUint32(A.defaultDuration || 0), i.writer.writeUint32(A.defaultSize || 0), i.writer.writeUint32(A.defaultFlags || 0), i.writer.writeUint32At(t, i.writer.position() - t);
3134
- }, Hh = (i, A) => {
3098
+ }, Rh = (i, A) => {
3135
3099
  const t = i.writer.position();
3136
3100
  oA(i, Z.tfdt, 8, 1, 0);
3137
3101
  const e = Math.floor(A.timestamp / 4294967296), g = (A.timestamp & 4294967295) >>> 0;
3138
3102
  i.writer.writeUint32(e), i.writer.writeUint32(g), i.writer.writeUint32At(t, i.writer.position() - t);
3139
- }, qh = (i, A) => {
3103
+ }, Uh = (i, A) => {
3140
3104
  if (!A.samples[0])
3141
3105
  throw new Error("At least one sample must be provided");
3142
3106
  const t = A.samples.some((o) => !!o.compositionTimeOffset), e = wQ(A.samples[0]) !== A.defaultFlags, g = A.samples.length > 1;
@@ -3149,32 +3113,32 @@ const CA = (i, A, t) => {
3149
3113
  for (const o of A.samples)
3150
3114
  g && (i.writer.writeUint32(o.duration), i.writer.writeUint32(o.data.byteLength), i.writer.writeUint32(wQ(o))), t && i.writer.writeUint32(o.compositionTimeOffset || 0);
3151
3115
  i.writer.writeUint32At(Q, i.writer.position() - i.moofOffset + 8), i.writer.writeUint32At(C, i.writer.position() - C);
3152
- }, wQ = (i) => i.isSync ? 33554432 : 16842752, vh = (i, A) => {
3116
+ }, wQ = (i) => i.isSync ? 33554432 : 16842752, Nh = (i, A) => {
3153
3117
  const t = i.writer.position();
3154
- CA(i, Z.traf, 0), Mh(i, A), Hh(i, A), qh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3155
- }, Kh = (i, A) => {
3118
+ CA(i, Z.traf, 0), kh(i, A), Rh(i, A), Uh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3119
+ }, bh = (i, A) => {
3156
3120
  oA(i, Z.mfhd, 4, 0, 0), i.writer.writeUint32(A);
3157
- }, Yh = (i, A) => {
3121
+ }, Lh = (i, A) => {
3158
3122
  const t = i.writer.position();
3159
- CA(i, Z.moof, 0), Kh(i, A.sequenceNumber), vh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3160
- }, Th = (i, A) => {
3123
+ CA(i, Z.moof, 0), bh(i, A.sequenceNumber), Nh(i, A), i.writer.writeUint32At(t, i.writer.position() - t);
3124
+ }, Jh = (i, A) => {
3161
3125
  const t = A.samples.reduce((e, g) => e + g.data.byteLength, 0);
3162
3126
  CA(i, Z.mdat, t), A.samples.forEach((e) => i.writer.writeBytes(e.data));
3163
- }, IQ = (i, A) => {
3164
- const t = new Za(), e = i.filter((B) => Fi(B) && Xa(B)).length > 0;
3165
- return i.filter((B) => Fi(B) && XQ(B)).length > 0 ? uQ(t, ah) : e ? uQ(t, nh) : uQ(t, Eh), Jh(t, i, oh), t.writer.buffer();
3166
- }, gQ = (i) => {
3127
+ }, gQ = (i, A) => {
3128
+ const t = new Oa(), e = i.filter((B) => Fi(B) && Va(B)).length > 0;
3129
+ return i.filter((B) => Fi(B) && XQ(B)).length > 0 ? uQ(t, gh) : e ? uQ(t, Ih) : uQ(t, sh), Gh(t, i, ih), t.writer.buffer();
3130
+ }, sQ = (i) => {
3167
3131
  var t;
3168
- const A = new Za();
3169
- return ((t = i.samples[0]) == null ? void 0 : t.producerReferenceTime) !== void 0 && hh(A, i.trackId, i.samples[0].producerReferenceTime, i.timestamp), A.moofOffset = A.writer.position(), Yh(A, i), Th(A, i), A.writer.buffer();
3170
- }, Ph = (i, A) => {
3132
+ const A = new Oa();
3133
+ return ((t = i.samples[0]) == null ? void 0 : t.producerReferenceTime) !== void 0 && Qh(A, i.trackId, i.samples[0].producerReferenceTime, i.timestamp), A.moofOffset = A.writer.position(), Lh(A, i), Jh(A, i), A.writer.buffer();
3134
+ }, Mh = (i, A) => {
3171
3135
  const t = i.map((C) => T(D({}, C), {
3172
3136
  data: new Uint8Array(C.data)
3173
3137
  }));
3174
3138
  if (!t[0])
3175
3139
  throw new Error("At least one sample must be provided");
3176
3140
  const { timestamp: e, data: g, duration: B } = t[0];
3177
- return gQ({
3141
+ return sQ({
3178
3142
  trackId: 1,
3179
3143
  timestamp: e,
3180
3144
  sequenceNumber: A,
@@ -3183,7 +3147,7 @@ const CA = (i, A, t) => {
3183
3147
  defaultDuration: B,
3184
3148
  samples: t
3185
3149
  });
3186
- }, xh = (i, A, t, e) => IQ([
3150
+ }, Hh = (i, A, t, e) => gQ([
3187
3151
  {
3188
3152
  type: "audio",
3189
3153
  codec: "aac",
@@ -3194,19 +3158,19 @@ const CA = (i, A, t) => {
3194
3158
  duration: 0,
3195
3159
  trackId: 1
3196
3160
  }
3197
- ]), ja = (i) => {
3198
- const { sequenceParameterSets: A, pictureParameterSets: t } = Oa(i), e = A[0], g = t[0];
3161
+ ]), Za = (i) => {
3162
+ const { sequenceParameterSets: A, pictureParameterSets: t } = xa(i), e = A[0], g = t[0];
3199
3163
  if (!e || !g)
3200
3164
  throw new Error("No sps or pps provided");
3201
- return Wc(e);
3202
- }, Wh = (i, A) => {
3165
+ return qc(e);
3166
+ }, qh = (i, A) => {
3203
3167
  const t = i.map((Q) => T(D({}, Q), {
3204
3168
  data: new Uint8Array(Q.data)
3205
3169
  }));
3206
3170
  if (!t[0])
3207
3171
  throw new Error("At least one sample must be provided");
3208
3172
  const { isSync: e, timestamp: g, data: B, duration: C } = t[0];
3209
- return gQ({
3173
+ return sQ({
3210
3174
  trackId: 1,
3211
3175
  timestamp: g,
3212
3176
  sequenceNumber: A,
@@ -3215,9 +3179,9 @@ const CA = (i, A, t) => {
3215
3179
  defaultDuration: C,
3216
3180
  samples: t
3217
3181
  });
3218
- }, Oh = (i, A) => {
3219
- const { sequenceParameterSets: t, pictureParameterSets: e } = Oa(i), g = ja(i);
3220
- return IQ([
3182
+ }, vh = (i, A) => {
3183
+ const { sequenceParameterSets: t, pictureParameterSets: e } = xa(i), g = Za(i);
3184
+ return gQ([
3221
3185
  {
3222
3186
  type: "video",
3223
3187
  sequenceParameterSets: t.map((B) => new Uint8Array(B)),
@@ -3229,7 +3193,7 @@ const CA = (i, A, t) => {
3229
3193
  trackId: 1
3230
3194
  }
3231
3195
  ]);
3232
- }, Vh = (i, A, t) => IQ([
3196
+ }, Kh = (i, A, t) => gQ([
3233
3197
  {
3234
3198
  type: "audio",
3235
3199
  trackId: 1,
@@ -3240,14 +3204,14 @@ const CA = (i, A, t) => {
3240
3204
  duration: 0,
3241
3205
  sampleRate: 48e3
3242
3206
  }
3243
- ]), Zh = (i, A) => {
3207
+ ]), Yh = (i, A) => {
3244
3208
  const t = i.map((C) => T(D({}, C), {
3245
3209
  data: new Uint8Array(C.data)
3246
3210
  }));
3247
3211
  if (!t[0])
3248
3212
  throw new Error("At least one sample must be provided");
3249
3213
  const { timestamp: e, data: g, duration: B } = t[0];
3250
- return gQ({
3214
+ return sQ({
3251
3215
  trackId: 1,
3252
3216
  timestamp: e,
3253
3217
  sequenceNumber: A,
@@ -3256,10 +3220,10 @@ const CA = (i, A, t) => {
3256
3220
  defaultDuration: B,
3257
3221
  samples: t
3258
3222
  });
3259
- }, za = (i) => {
3223
+ }, Xa = (i) => {
3260
3224
  const A = new Sa(i);
3261
- return A.peekBit() === 1 && A.readBits(32), zh(A), gd(A);
3262
- }, Xh = (i) => {
3225
+ return A.peekBit() === 1 && A.readBits(32), xh(A), _h(A);
3226
+ }, Th = (i) => {
3263
3227
  let A = 0, t = 0;
3264
3228
  for (let e = 0; e < 8; e++) {
3265
3229
  const g = i.readBits(8);
@@ -3267,40 +3231,40 @@ const CA = (i, A, t) => {
3267
3231
  break;
3268
3232
  }
3269
3233
  return [t, A];
3270
- }, jh = (i) => {
3234
+ }, Ph = (i) => {
3271
3235
  let A = 0;
3272
3236
  for (; A < 100 && i.readBit() === 0; )
3273
3237
  A++;
3274
3238
  return A >= 32 ? 0 : i.readBits(A) + (1 << A) - 1;
3275
- }, zh = (i) => {
3239
+ }, xh = (i) => {
3276
3240
  const A = i.remainingBits() / 8, t = i.readBits(8);
3277
3241
  if ((t >> 7 & 1) !== 0)
3278
3242
  return;
3279
3243
  const g = t >> 3 & 15, B = t >> 2 & 1, C = t >> 1 & 1;
3280
3244
  B == 1 && i.readBits(8);
3281
- const [Q, o] = C ? Xh(i) : [0, A];
3245
+ const [Q, o] = C ? Th(i) : [0, A];
3282
3246
  return {
3283
3247
  headerLength: 1 + B + Q,
3284
3248
  type: g,
3285
3249
  obuSize: o
3286
3250
  };
3287
- }, _h = (i) => {
3251
+ }, Wh = (i) => {
3288
3252
  const A = i.readBits(32), t = i.readBits(32), e = i.readBit() !== 0;
3289
3253
  let g = 0;
3290
- return e && (g = jh(i) + 1), {
3254
+ return e && (g = Ph(i) + 1), {
3291
3255
  timescale: t,
3292
3256
  equalPictureInterval: e,
3293
3257
  numUnitsInDisplayTick: A,
3294
3258
  numTicksPerPicture: g
3295
3259
  };
3296
- }, Un = 2, DQ = 2, $h = 1, Ad = 2, td = 2, ed = 13, id = 0, Id = 2, Nn = 0, gd = (i) => {
3260
+ }, Un = 2, DQ = 2, Oh = 1, Vh = 2, Zh = 2, Xh = 13, jh = 0, zh = 2, Nn = 0, _h = (i) => {
3297
3261
  const A = i.readBits(3), e = i.readBit() !== 0, g = i.readBit() !== 0;
3298
3262
  let B, C = !1, Q = !1, o = !1, a = 0, c = 0;
3299
3263
  const h = [];
3300
3264
  if (g)
3301
3265
  i.readBits(5);
3302
3266
  else {
3303
- if (Q = i.readBit() !== 0, Q && (B = _h(i), C = i.readBit() !== 0, C))
3267
+ if (Q = i.readBit() !== 0, Q && (B = Wh(i), C = i.readBit() !== 0, C))
3304
3268
  throw new Error("Not implemented");
3305
3269
  o = i.readBit() !== 0;
3306
3270
  const yA = i.readBits(5) + 1;
@@ -3356,15 +3320,15 @@ const CA = (i, A, t) => {
3356
3320
  enableSuperres: O,
3357
3321
  enableCdef: Y,
3358
3322
  enableRestoration: P,
3359
- colorConfig: sd(i, A),
3323
+ colorConfig: $h(i, A),
3360
3324
  filmGrainParamsPresent: i.readBit() !== 0
3361
3325
  };
3362
- }, sd = (i, A) => {
3326
+ }, $h = (i, A) => {
3363
3327
  const t = i.readBit() !== 0;
3364
3328
  let e = 8, g = !1;
3365
3329
  A === 2 && t ? e = i.readBit() !== 0 ? 12 : 10 : A <= 2 && (e = t ? 10 : 8), A === 1 ? g = !1 : g = i.readBit() !== 0;
3366
3330
  const B = g ? 1 : 3, C = i.readBit() !== 0;
3367
- let Q = Ad, o = td, a = Id, c = !1, h = 0, l = 0, u = Nn, S = !1;
3331
+ let Q = Vh, o = Zh, a = zh, c = !1, h = 0, l = 0, u = Nn, S = !1;
3368
3332
  return C && (Q = i.readBits(8), o = i.readBits(8), a = i.readBits(8)), g ? (c = i.readBit() !== 0, h = 1, l = 1, u = Nn, S = !1, {
3369
3333
  highBitDepth: t,
3370
3334
  bitDepth: e,
@@ -3378,7 +3342,7 @@ const CA = (i, A, t) => {
3378
3342
  subsamplingX: h,
3379
3343
  subsamplingY: l,
3380
3344
  transferCharacteristics: o
3381
- }) : Q === $h && o == ed && a == id ? (c = !0, h = 0, l = 0, {
3345
+ }) : Q === Oh && o == Xh && a == jh ? (c = !0, h = 0, l = 0, {
3382
3346
  highBitDepth: t,
3383
3347
  bitDepth: e,
3384
3348
  monoChrome: g,
@@ -3405,21 +3369,21 @@ const CA = (i, A, t) => {
3405
3369
  subsamplingY: l,
3406
3370
  transferCharacteristics: o
3407
3371
  });
3408
- }, Bd = (i) => {
3409
- const A = za(i);
3372
+ }, Ad = (i) => {
3373
+ const A = Xa(i);
3410
3374
  if (A)
3411
3375
  return {
3412
3376
  width: A.maxFrameWidth,
3413
3377
  height: A.maxFrameHeight
3414
3378
  };
3415
- }, Cd = (i, A) => {
3379
+ }, td = (i, A) => {
3416
3380
  const t = i.map((Q) => T(D({}, Q), {
3417
3381
  data: new Uint8Array(Q.data)
3418
3382
  }));
3419
3383
  if (!t[0])
3420
3384
  throw new Error("At least one sample must be provided");
3421
3385
  const { isSync: e, timestamp: g, data: B, duration: C } = t[0];
3422
- return gQ({
3386
+ return sQ({
3423
3387
  trackId: 1,
3424
3388
  timestamp: g,
3425
3389
  sequenceNumber: A,
@@ -3428,11 +3392,11 @@ const CA = (i, A, t) => {
3428
3392
  defaultDuration: C,
3429
3393
  samples: t
3430
3394
  });
3431
- }, Qd = (i, A) => {
3432
- const t = za(i);
3395
+ }, ed = (i, A) => {
3396
+ const t = Xa(i);
3433
3397
  if (!t)
3434
3398
  throw new Error("Failed to parse sequence header");
3435
- return IQ([
3399
+ return gQ([
3436
3400
  {
3437
3401
  type: "video",
3438
3402
  parsedSequenceHeader: t,
@@ -3444,47 +3408,47 @@ const CA = (i, A, t) => {
3444
3408
  trackId: 1
3445
3409
  }
3446
3410
  ]);
3447
- }, od = (i) => {
3411
+ }, id = (i) => {
3448
3412
  const { codec: A, initData: t, timescale: e } = i;
3449
3413
  switch (A) {
3450
3414
  case "h264":
3451
- return ad(t, e);
3415
+ return gd(t, e);
3452
3416
  case "av1":
3453
- return Ed(t, e);
3417
+ return sd(t, e);
3454
3418
  case "opus":
3455
- return rd(t, e, i.channelCount || 2);
3419
+ return Bd(t, e, i.channelCount || 2);
3456
3420
  case "aac":
3457
- return cd(t, e, i.channelCount || 2);
3421
+ return Cd(t, e, i.channelCount || 2);
3458
3422
  default:
3459
3423
  throw new Error(`Failed to initialize ${A} segment`);
3460
3424
  }
3461
- }, nd = (i, A) => {
3425
+ }, Id = (i, A) => {
3462
3426
  switch (i) {
3463
3427
  case "h264":
3464
- return ja(A);
3428
+ return Za(A);
3465
3429
  case "av1":
3466
- return Bd(A);
3430
+ return Ad(A);
3467
3431
  }
3468
- }, ad = (i, A) => Oh(i, A), Ed = (i, A) => Qd(i, A), rd = (i, A, t) => Vh(new Uint8Array(i), t, A), cd = (i, A, t) => xh(new Uint8Array(i), t, A, A), hd = (i, A) => {
3432
+ }, gd = (i, A) => vh(i, A), sd = (i, A) => ed(i, A), Bd = (i, A, t) => Kh(new Uint8Array(i), t, A), Cd = (i, A, t) => Hh(new Uint8Array(i), t, A, A), Qd = (i, A) => {
3469
3433
  if (!i[0])
3470
3434
  throw new Error("At least one sample must be provided");
3471
3435
  switch (i[0].codec) {
3472
3436
  case "h264":
3473
- return Wh(i, A);
3437
+ return qh(i, A);
3474
3438
  case "opus":
3475
- return Zh(i, A);
3439
+ return Yh(i, A);
3476
3440
  case "aac":
3477
- return Ph(i, A);
3441
+ return Mh(i, A);
3478
3442
  case "av1":
3479
- return Cd(i, A);
3443
+ return td(i, A);
3480
3444
  default:
3481
3445
  throw new Error(`Unsupported codec ${i[0].codec}`);
3482
3446
  }
3483
- }, ug = (i) => !!(i & 1), dd = (i) => !!(i & 2), ld = (i) => !!(i & 4), ud = (i) => !!(i & 8), wd = (i) => !!(i & 16), Dd = (i) => {
3484
- const A = new DataView(i, 0), t = A.getUint8(0), e = A.getUint16(1), g = A.getUint8(3), B = A.getUint8(4), C = Po(new Uint8Array(i), 5, 12), Q = A.getUint32(13), o = wd(g) ? A.getInt16(17) : void 0, a = i.slice(e);
3447
+ }, ug = (i) => !!(i & 1), od = (i) => !!(i & 2), nd = (i) => !!(i & 4), ad = (i) => !!(i & 8), Ed = (i) => !!(i & 16), rd = (i) => {
3448
+ const A = new DataView(i, 0), t = A.getUint8(0), e = A.getUint16(1), g = A.getUint8(3), B = A.getUint8(4), C = To(new Uint8Array(i), 5, 12), Q = A.getUint32(13), o = Ed(g) ? A.getInt16(17) : void 0, a = i.slice(e);
3485
3449
  return { version: t, renditionId: B, flags: g, timestamp: C, timescale: Q, payload: a, compositionTimeOffset: o };
3486
- }, Sd = "data:video/mp4;base64,AAAAHGZ0eXBNNFYgAAACAGlzb21pc28yYXZjMQAAAAhmcmVlAAAGF21kYXTeBAAAbGliZmFhYyAxLjI4AABCAJMgBDIARwAAArEGBf//rdxF6b3m2Ui3lizYINkj7u94MjY0IC0gY29yZSAxNDIgcjIgOTU2YzhkOCAtIEguMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMTQgLSBodHRwOi8vd3d3LnZpZGVvbGFuLm9yZy94MjY0Lmh0bWwgLSBvcHRpb25zOiBjYWJhYz0wIHJlZj0zIGRlYmxvY2s9MTowOjAgYW5hbHlzZT0weDE6MHgxMTEgbWU9aGV4IHN1Ym1lPTcgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0xNiBjaHJvbWFfbWU9MSB0cmVsbGlzPTEgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV9xcF9vZmZzZXQ9LTIgdGhyZWFkcz02IGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3RocmVhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTI1MCBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NDAgcmM9Y3JmIG1idHJlZT0xIGNyZj0yMy4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCB2YnZfbWF4cmF0ZT03NjggdmJ2X2J1ZnNpemU9MzAwMCBjcmZfbWF4PTAuMCBuYWxfaHJkPW5vbmUgZmlsbGVyPTAgaXBfcmF0aW89MS40MCBhcT0xOjEuMDAAgAAAAFZliIQL8mKAAKvMnJycnJycnJycnXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXiEASZACGQAjgCEASZACGQAjgAAAAAdBmjgX4GSAIQBJkAIZACOAAAAAB0GaVAX4GSAhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZpgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGagC/AySEASZACGQAjgAAAAAZBmqAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZrAL8DJIQBJkAIZACOAAAAABkGa4C/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmwAvwMkhAEmQAhkAI4AAAAAGQZsgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGbQC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBm2AvwMkhAEmQAhkAI4AAAAAGQZuAL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGboC/AySEASZACGQAjgAAAAAZBm8AvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZvgL8DJIQBJkAIZACOAAAAABkGaAC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmiAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZpAL8DJIQBJkAIZACOAAAAABkGaYC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmoAvwMkhAEmQAhkAI4AAAAAGQZqgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGawC/AySEASZACGQAjgAAAAAZBmuAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZsAL8DJIQBJkAIZACOAAAAABkGbIC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBm0AvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZtgL8DJIQBJkAIZACOAAAAABkGbgCvAySEASZACGQAjgCEASZACGQAjgAAAAAZBm6AnwMkhAEmQAhkAI4AhAEmQAhkAI4AhAEmQAhkAI4AhAEmQAhkAI4AAAAhubW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAD6AAABDcAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAzB0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAA+kAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAALAAAACQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAPpAAAAAAABAAAAAAKobWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAAB1MAAAdU5VxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAACU21pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAhNzdGJsAAAAr3N0c2QAAAAAAAAAAQAAAJ9hdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAALAAkABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAALWF2Y0MBQsAN/+EAFWdCwA3ZAsTsBEAAAPpAADqYA8UKkgEABWjLg8sgAAAAHHV1aWRraEDyXyRPxbo5pRvPAyPzAAAAAAAAABhzdHRzAAAAAAAAAAEAAAAeAAAD6QAAABRzdHNzAAAAAAAAAAEAAAABAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAAIxzdHN6AAAAAAAAAAAAAAAeAAADDwAAAAsAAAALAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAAiHN0Y28AAAAAAAAAHgAAAEYAAANnAAADewAAA5gAAAO0AAADxwAAA+MAAAP2AAAEEgAABCUAAARBAAAEXQAABHAAAASMAAAEnwAABLsAAATOAAAE6gAABQYAAAUZAAAFNQAABUgAAAVkAAAFdwAABZMAAAWmAAAFwgAABd4AAAXxAAAGDQAABGh0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAACAAAAAAAABDcAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAQkAAADcAABAAAAAAPgbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAAC7gAAAykBVxAAAAAAALWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAADi21pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAADT3N0YmwAAABnc3RzZAAAAAAAAAABAAAAV21wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAAC7gAAAAAAAM2VzZHMAAAAAA4CAgCIAAgAEgICAFEAVBbjYAAu4AAAADcoFgICAAhGQBoCAgAECAAAAIHN0dHMAAAAAAAAAAgAAADIAAAQAAAAAAQAAAkAAAAFUc3RzYwAAAAAAAAAbAAAAAQAAAAEAAAABAAAAAgAAAAIAAAABAAAAAwAAAAEAAAABAAAABAAAAAIAAAABAAAABgAAAAEAAAABAAAABwAAAAIAAAABAAAACAAAAAEAAAABAAAACQAAAAIAAAABAAAACgAAAAEAAAABAAAACwAAAAIAAAABAAAADQAAAAEAAAABAAAADgAAAAIAAAABAAAADwAAAAEAAAABAAAAEAAAAAIAAAABAAAAEQAAAAEAAAABAAAAEgAAAAIAAAABAAAAFAAAAAEAAAABAAAAFQAAAAIAAAABAAAAFgAAAAEAAAABAAAAFwAAAAIAAAABAAAAGAAAAAEAAAABAAAAGQAAAAIAAAABAAAAGgAAAAEAAAABAAAAGwAAAAIAAAABAAAAHQAAAAEAAAABAAAAHgAAAAIAAAABAAAAHwAAAAQAAAABAAAA4HN0c3oAAAAAAAAAAAAAADMAAAAaAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAACMc3RjbwAAAAAAAAAfAAAALAAAA1UAAANyAAADhgAAA6IAAAO+AAAD0QAAA+0AAAQAAAAEHAAABC8AAARLAAAEZwAABHoAAASWAAAEqQAABMUAAATYAAAE9AAABRAAAAUjAAAFPwAABVIAAAVuAAAFgQAABZ0AAAWwAAAFzAAABegAAAX7AAAGFwAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTUuMzMuMTAw", dB = () => "wakeLock" in navigator && window.navigator.userAgent.indexOf("Samsung") === -1;
3487
- class md {
3450
+ }, cd = "data:video/mp4;base64,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", dB = () => "wakeLock" in navigator && window.navigator.userAgent.indexOf("Samsung") === -1;
3451
+ class hd {
3488
3452
  constructor() {
3489
3453
  I(this, "enabled", !1);
3490
3454
  I(this, "wakeLockVideo");
@@ -3505,7 +3469,7 @@ class md {
3505
3469
  if (!dB()) {
3506
3470
  if (!this.wakeLockVideo) {
3507
3471
  const t = document.createElement("video");
3508
- this.wakeLockVideo = t, this.wakeLockVideo.setAttribute("title", "Live Stream"), this.wakeLockVideo.setAttribute("playsinline", ""), this._addSourceToVideo(this.wakeLockVideo, "mp4", Sd), Object.assign(this.wakeLockVideo.style, {
3472
+ this.wakeLockVideo = t, this.wakeLockVideo.setAttribute("title", "Live Stream"), this.wakeLockVideo.setAttribute("playsinline", ""), this._addSourceToVideo(this.wakeLockVideo, "mp4", cd), Object.assign(this.wakeLockVideo.style, {
3509
3473
  position: "absolute",
3510
3474
  left: "-100%",
3511
3475
  top: "-100%"
@@ -3539,7 +3503,7 @@ class md {
3539
3503
  document.removeEventListener("visibilitychange", this.handleVisibilityChange), document.removeEventListener("fullscreenchange", this.handleVisibilityChange), this.disable();
3540
3504
  }
3541
3505
  }
3542
- const yd = /\r\n|\r|\n/;
3506
+ const dd = /\r\n|\r|\n/;
3543
3507
  var Qe, vt;
3544
3508
  class bn {
3545
3509
  constructor(A) {
@@ -3571,25 +3535,25 @@ class bn {
3571
3535
  }
3572
3536
  }
3573
3537
  Qe = new WeakMap(), vt = new WeakMap();
3574
- var Gi, $a, jQ;
3575
- class _a {
3538
+ var Gi, za, jQ;
3539
+ class ja {
3576
3540
  constructor() {
3577
3541
  n(this, Gi);
3578
3542
  }
3579
3543
  parse(A) {
3580
- const t = [], e = A.split(yd), g = new bn(e), B = g.readLine();
3544
+ const t = [], e = A.split(dd), g = new bn(e), B = g.readLine();
3581
3545
  if (!B || !B.startsWith("WEBVTT"))
3582
3546
  throw new Error("missing 'WEBVTT' signature");
3583
3547
  for (; g.readLine() !== ""; )
3584
3548
  ;
3585
3549
  for (; g.linesLeft() > 0; ) {
3586
- const C = d(this, Gi, $a).call(this, g);
3550
+ const C = d(this, Gi, za).call(this, g);
3587
3551
  C && t.push(C), g.skipEmptyLines();
3588
3552
  }
3589
3553
  return t;
3590
3554
  }
3591
3555
  }
3592
- Gi = new WeakSet(), $a = function(A) {
3556
+ Gi = new WeakSet(), za = function(A) {
3593
3557
  A.skipEmptyLines();
3594
3558
  const t = A.takeUntilEmptyLine(), e = new bn(t);
3595
3559
  let g = e.readLine(), B;
@@ -3622,6 +3586,10 @@ Gi = new WeakSet(), $a = function(A) {
3622
3586
  const [e = 0, g = 0, B = 0] = t.map((Q) => parseFloat(Q));
3623
3587
  return e * 60 * 60 + g * 60 + B;
3624
3588
  };
3589
+ const ld = (i) => {
3590
+ const A = window;
3591
+ A.vindralInstances = A.vindralInstances || {}, A.vindralInstances[i.getStatistics().clientId.substring(0, 8)] = i;
3592
+ };
3625
3593
  class zQ extends $A {
3626
3594
  constructor({ type: t, autoplay: e, muted: g, logger: B, poster: C }) {
3627
3595
  super();
@@ -3778,77 +3746,7 @@ class zQ extends $A {
3778
3746
  return this._isPaused;
3779
3747
  }
3780
3748
  }
3781
- const fd = [
3782
- "minBufferTime",
3783
- "maxBufferTime",
3784
- "burstEnabled",
3785
- "sizeBasedResolutionCapEnabled",
3786
- "separateVideoSocketEnabled",
3787
- "videoCodecs"
3788
- ];
3789
- function pd(i) {
3790
- return fd.includes(i);
3791
- }
3792
- class Fd {
3793
- constructor(A) {
3794
- I(this, "options");
3795
- I(this, "overrides", /* @__PURE__ */ new Map());
3796
- this.options = A;
3797
- }
3798
- /**
3799
- *
3800
- * @returns the options excluding any overrides
3801
- */
3802
- getOptions() {
3803
- return this.options;
3804
- }
3805
- /**
3806
- * Add overrides for a specific channel
3807
- * @param channelId the channel to add overrides to
3808
- * @param overrides the overrides to insert
3809
- */
3810
- addOverrides(A, t) {
3811
- this.overrides.set(A, t);
3812
- }
3813
- /**
3814
- * Sets an option value
3815
- * @param key the option key to set
3816
- * @param value the option value to insert into the key
3817
- */
3818
- set(A, t) {
3819
- this.options[A] = t;
3820
- }
3821
- /**
3822
- * Gets the option value for a specific key. If a channelId is provided, it will also apply any overrides
3823
- * to the options value.
3824
- * @param key the key to get from the options
3825
- * @param channelId the channelId to get channel specific overrides from
3826
- * @returns the option value, potentially overridden by channel overrides if a channelId is provided
3827
- */
3828
- get(A, t) {
3829
- var e;
3830
- if (t && pd(A)) {
3831
- const g = (e = this.overrides.get(t)) == null ? void 0 : e[A];
3832
- if (typeof g != "undefined")
3833
- return g;
3834
- }
3835
- return this.options[A];
3836
- }
3837
- /**
3838
- *
3839
- * @param key the key to get from the overrides
3840
- * @param channelId the channel overrides to get the override from
3841
- * @returns the override value for that channel
3842
- */
3843
- getOverride(A, t) {
3844
- var e;
3845
- return (e = this.overrides.get(t)) == null ? void 0 : e[A];
3846
- }
3847
- }
3848
- const Gd = (i) => {
3849
- const A = window;
3850
- A.vindralInstances = A.vindralInstances || {}, A.vindralInstances[i.getStatistics().clientId.substring(0, 8)] = i;
3851
- }, kd = (i) => {
3749
+ const ud = (i) => {
3852
3750
  if (!navigator.mediaCapabilities)
3853
3751
  return Promise.resolve({ smooth: !0, supported: !0, powerEfficient: !0, failedToQuery: !0 });
3854
3752
  if (i.codec === "webvtt")
@@ -3872,7 +3770,7 @@ const Gd = (i) => {
3872
3770
  framerate: i.frameRate[0] / i.frameRate[1]
3873
3771
  }
3874
3772
  }, navigator.mediaCapabilities.decodingInfo(A);
3875
- }, Rd = 0.15, Ud = 0.2, Ln = 0.4, Nd = 0.5, bd = 0.6, SQ = 15, Ld = {
3773
+ }, wd = 0.15, Dd = 0.2, Ln = 0.4, Sd = 0.5, md = 0.6, SQ = 15, yd = {
3876
3774
  cooldownTime: 3e3,
3877
3775
  maxBufferingEvents: {
3878
3776
  last10Seconds: 0
@@ -3944,7 +3842,7 @@ const Gd = (i) => {
3944
3842
  const { bufferFullness: t, general: e } = this.qualityOfServiceSource.getMetrics(), g = this.qualityOfServiceSource.getBufferFullnessRegression();
3945
3843
  if (!g)
3946
3844
  return;
3947
- const B = 10 * 1e3, { slope: C } = g, Q = g.predict(SQ), o = C < 0, a = g.predict(SQ) < Ln && g.slope < 0, c = g.predict(SQ) > bd, h = this.qualityOfServiceSource.timeSpentBufferingLast(30 * 1e3), l = this.qualityOfServiceSource.timeSpentActiveLast(30 * 1e3), u = h / l;
3845
+ const B = 10 * 1e3, { slope: C } = g, Q = g.predict(SQ), o = C < 0, a = g.predict(SQ) < Ln && g.slope < 0, c = g.predict(SQ) > md, h = this.qualityOfServiceSource.timeSpentBufferingLast(30 * 1e3), l = this.qualityOfServiceSource.timeSpentActiveLast(30 * 1e3), u = h / l;
3948
3846
  if (t < 0.15 && u > 0.8) {
3949
3847
  this.adaptLevel("reconnect");
3950
3848
  return;
@@ -3953,84 +3851,219 @@ const Gd = (i) => {
3953
3851
  this.adaptLevel("downgrade");
3954
3852
  return;
3955
3853
  }
3956
- a || t < Rd ? o && t < Ln && Q < Ud && this.adaptLevel(A.playbackState === "buffering" ? "double downgrade" : "downgrade") : t > Nd && c && !this.tooMuchTimeBuffering(B) && !this.tooManyBufferingEvents(B) && this.adaptLevel("upgrade");
3854
+ a || t < wd ? o && t < Ln && Q < Dd && this.adaptLevel(A.playbackState === "buffering" ? "double downgrade" : "downgrade") : t > Sd && c && !this.tooMuchTimeBuffering(B) && !this.tooManyBufferingEvents(B) && this.adaptLevel("upgrade");
3957
3855
  });
3958
3856
  I(this, "onAdaptedLevel", () => {
3959
3857
  this.reset();
3960
3858
  });
3961
- I(this, "adaptLevel", (A) => this.emitter.emit("adapt level", A));
3962
- this.qualityOfServiceSource = e, this.config = D(D({}, Ld), g), this.emitter = A, this.logger = t;
3859
+ I(this, "adaptLevel", (A) => this.emitter.emit("adapt level", A));
3860
+ this.qualityOfServiceSource = e, this.config = D(D({}, yd), g), this.emitter = A, this.logger = t;
3861
+ }
3862
+ tooMuchTimeBuffering(A) {
3863
+ return this.qualityOfServiceSource.timeSpentBufferingLast(A) / this.qualityOfServiceSource.timeSpentActiveLast(A) > this.config.maxBufferingRatio.last10Seconds;
3864
+ }
3865
+ tooManyBufferingEvents(A) {
3866
+ return this.qualityOfServiceSource.timeSpentBufferingLast(A) > this.config.maxBufferingEvents.last10Seconds;
3867
+ }
3868
+ };
3869
+ I(aC, "create", (A, t, e, g = {}) => new aC(A, t, e, g));
3870
+ let _Q = aC;
3871
+ const fd = {
3872
+ minBufferTime: 1500,
3873
+ maxBufferTime: 1500,
3874
+ cooldownTime: 3e4,
3875
+ maxBufferingEvents: {
3876
+ last30Seconds: 3
3877
+ },
3878
+ maxBufferingRatio: {
3879
+ last30Seconds: 0.15
3880
+ }
3881
+ }, Ie = class Ie {
3882
+ constructor(A, t, e, g, B) {
3883
+ I(this, "qualityOfServiceSource");
3884
+ I(this, "targetBufferTimeTarget");
3885
+ I(this, "config");
3886
+ I(this, "emitter");
3887
+ I(this, "logger");
3888
+ I(this, "isSuspended", !1);
3889
+ I(this, "lastIncreaseTime", Date.now());
3890
+ I(this, "bufferTimeAdjustmentCount", 0);
3891
+ I(this, "load", () => {
3892
+ this.emitter.on("buffer state", this.onBufferState);
3893
+ });
3894
+ I(this, "unload", () => {
3895
+ this.emitter.off("buffer state", this.onBufferState);
3896
+ });
3897
+ I(this, "suspend", () => {
3898
+ this.isSuspended = !0;
3899
+ });
3900
+ I(this, "unsuspend", () => {
3901
+ this.reset(), this.isSuspended = !1;
3902
+ });
3903
+ I(this, "reset", () => {
3904
+ this.lastIncreaseTime = Date.now();
3905
+ });
3906
+ I(this, "getStatistics", () => ({
3907
+ bufferTimeAdjustmentCount: this.bufferTimeAdjustmentCount
3908
+ }));
3909
+ I(this, "onBufferState", (A) => {
3910
+ const { minBufferTime: t, maxBufferTime: e, cooldownTime: g } = this.config;
3911
+ if (this.isSuspended || this.lastIncreaseTime + g > Date.now() || this.targetBufferTimeTarget.targetBufferTime >= e)
3912
+ return;
3913
+ const B = this.qualityOfServiceSource.timeSpentBufferingLast(30 * 1e3), C = this.qualityOfServiceSource.bufferingEventsLast(30 * 1e3), Q = this.qualityOfServiceSource.timeSpentActiveLast(30 * 1e3), o = B / Q, a = Math.ceil(
3914
+ Math.max(
3915
+ (e - t) / (Ie.BUFFER_TIME_MAX_STEPS - 1),
3916
+ Ie.BUFFER_TIME_STEP_SIZE
3917
+ )
3918
+ );
3919
+ (o > this.config.maxBufferingRatio.last30Seconds || C > this.config.maxBufferingEvents.last30Seconds) && (this.targetBufferTimeTarget.targetBufferTime = Math.min(
3920
+ e,
3921
+ this.targetBufferTimeTarget.targetBufferTime + a
3922
+ ), this.bufferTimeAdjustmentCount++, this.reset());
3923
+ });
3924
+ this.qualityOfServiceSource = e, this.targetBufferTimeTarget = g, this.config = D(D({}, fd), B), this.emitter = A, this.logger = t;
3925
+ }
3926
+ updateConfig(A) {
3927
+ this.config = D(D({}, this.config), A);
3928
+ }
3929
+ };
3930
+ I(Ie, "BUFFER_TIME_STEP_SIZE", 500), I(Ie, "BUFFER_TIME_MAX_STEPS", 3), I(Ie, "create", (A, t, e, g, B = {}) => new Ie(A, t, e, g, B));
3931
+ let $Q = Ie;
3932
+ const pd = (i) => i ? {
3933
+ Authorization: `Bearer ${i}`
3934
+ } : void 0, Fd = (i, A) => {
3935
+ try {
3936
+ const t = i.ancestorOrigins;
3937
+ if (t && t.length > 0)
3938
+ return Array.from(t).join(",") || void 0;
3939
+ } catch (t) {
3940
+ }
3941
+ try {
3942
+ if (A.referrer)
3943
+ return new URL(A.referrer).origin || void 0;
3944
+ } catch (t) {
3945
+ }
3946
+ }, Gd = (i) => typeof i == "object" && i !== null && "message" in i;
3947
+ class kd extends Error {
3948
+ constructor({ status: t, url: e, body: g }) {
3949
+ const B = Fa(g), C = Gd(B) ? B.message : `Url ${e.toString()}, Status code: ${t}, Body: ${g}`;
3950
+ super(C);
3951
+ I(this, "status");
3952
+ I(this, "body");
3953
+ I(this, "url");
3954
+ this.status = t, this.body = g, this.url = e, Object.setPrototypeOf(this, new.target.prototype);
3955
+ }
3956
+ }
3957
+ const Rd = (i) => typeof i.status == "number", Ud = () => {
3958
+ if (!(typeof window == "undefined" || typeof document == "undefined"))
3959
+ return Fd(window.location, document);
3960
+ }, Nd = (i) => {
3961
+ const A = Ud();
3962
+ if (!A || i.searchParams.has("parentOrigin"))
3963
+ return i;
3964
+ const t = new URL(i.toString());
3965
+ return t.searchParams.append("parentOrigin", A), t;
3966
+ }, _a = (i, A) => r(null, null, function* () {
3967
+ const t = Nd(i), e = yield fetch(t.toString(), D({ mode: "cors" }, A));
3968
+ if (!e.ok)
3969
+ throw new kd({ status: e.status, url: t, body: yield e.text() });
3970
+ return e;
3971
+ }), yQ = (i, A) => r(null, null, function* () {
3972
+ return yield (yield _a(i, D({}, A))).json();
3973
+ }), $a = (i, A) => r(null, null, function* () {
3974
+ return _a(i, D({ method: "POST" }, A));
3975
+ });
3976
+ function bd(i) {
3977
+ var A;
3978
+ return !(typeof i.edges[0] == "string" || i.channels[0] && "catalog" in i.channels[0] && typeof ((A = i.channels[0]) == null ? void 0 : A.catalog) == "undefined");
3979
+ }
3980
+ const Jn = {
3981
+ lbConnect: (i) => i.channelGroupId ? `connect?channelId=${i.channelId}&channelGroupId=${i.channelGroupId}` : `connect?channelId=${i.channelId}`,
3982
+ thumbnails: (i, A) => A ? i.channelGroupId ? `thumbnail/?channelGroupId=${i.channelGroupId}&auth.token=${A}&auth.type=jwt` : i.channelId ? `thumbnail/?channelId=${i.channelId}&auth.token=${A}&auth.type=jwt` : "thumbnail" : "thumbnail"
3983
+ };
3984
+ class Ld {
3985
+ constructor(A) {
3986
+ I(this, "baseUrl");
3987
+ I(this, "tokenFactory");
3988
+ this.baseUrl = new URL("/api/v4/", A.publicEndpoint).toString(), this.tokenFactory = A.tokenFactory;
3989
+ }
3990
+ /**
3991
+ * @ignore
3992
+ * Returns everything needed to setup the connection of Vindral instance.
3993
+ */
3994
+ connect(A) {
3995
+ return r(this, null, function* () {
3996
+ const { channelId: t, channelGroupId: e } = A, g = { channelId: t, channelGroupId: e }, B = new URL(Jn.lbConnect(A), this.baseUrl), C = this.getAuthToken(g), Q = yield yQ(B, { headers: this.getHeaders(C) });
3997
+ if (bd(Q)) {
3998
+ const o = Q.channels.map((a) => {
3999
+ const c = this.toChannel(a, g), h = ka(a.catalog);
4000
+ return T(D(D({}, a), c), { renditions: h });
4001
+ });
4002
+ return T(D({}, Q), { channels: o });
4003
+ } else {
4004
+ const o = Q.channels.map((a) => {
4005
+ const c = this.toChannel(a, g);
4006
+ return D(D({}, a), c);
4007
+ });
4008
+ return T(D({}, Q), { channels: o });
4009
+ }
4010
+ });
4011
+ }
4012
+ /**
4013
+ * Fetches information regarding a single channel.
4014
+ *
4015
+ * @param channelId the channel to fetch
4016
+ * @returns a [[Channel]] containing information about the requested channel.
4017
+ */
4018
+ getChannel(A) {
4019
+ return r(this, null, function* () {
4020
+ const t = { channelId: A }, e = new URL(`channel/${A}`, this.baseUrl), g = this.getAuthToken(t), B = yield yQ(e, { headers: this.getHeaders(g) });
4021
+ return this.toChannel(B, t, g);
4022
+ });
3963
4023
  }
3964
- tooMuchTimeBuffering(A) {
3965
- return this.qualityOfServiceSource.timeSpentBufferingLast(A) / this.qualityOfServiceSource.timeSpentActiveLast(A) > this.config.maxBufferingRatio.last10Seconds;
4024
+ /**
4025
+ * Fetches channels within a channel group
4026
+ *
4027
+ * Note: The returned list includes inactive channels - check isLive to filter out only active channels
4028
+ *
4029
+ * @param channelGroupId the channel group to fetch channels from
4030
+ * @returns an array of [[Channel]] that belong to the channel group
4031
+ */
4032
+ getChannels(A) {
4033
+ return r(this, null, function* () {
4034
+ const t = { channelGroupId: A }, e = new URL(`channels/${A}`, this.baseUrl), g = this.getAuthToken(t), B = yield yQ(e, {
4035
+ headers: this.getHeaders(g)
4036
+ }), C = Array.isArray(B) ? B : B.channels;
4037
+ return this.toChannels(C, t, g);
4038
+ });
3966
4039
  }
3967
- tooManyBufferingEvents(A) {
3968
- return this.qualityOfServiceSource.timeSpentBufferingLast(A) > this.config.maxBufferingEvents.last10Seconds;
4040
+ getHeaders(A) {
4041
+ var e;
4042
+ return (e = pd(A)) != null ? e : {};
3969
4043
  }
3970
- };
3971
- I(aC, "create", (A, t, e, g = {}) => new aC(A, t, e, g));
3972
- let _Q = aC;
3973
- const Jd = {
3974
- minBufferTime: 1500,
3975
- maxBufferTime: 1500,
3976
- cooldownTime: 3e4,
3977
- maxBufferingEvents: {
3978
- last30Seconds: 3
3979
- },
3980
- maxBufferingRatio: {
3981
- last30Seconds: 0.15
4044
+ getAuthToken(A) {
4045
+ return this.tokenFactory ? this.tokenFactory(A) : void 0;
3982
4046
  }
3983
- }, Ie = class Ie {
3984
- constructor(A, t, e, g, B) {
3985
- I(this, "qualityOfServiceSource");
3986
- I(this, "targetBufferTimeTarget");
3987
- I(this, "config");
3988
- I(this, "emitter");
3989
- I(this, "logger");
3990
- I(this, "isSuspended", !1);
3991
- I(this, "lastIncreaseTime", Date.now());
3992
- I(this, "bufferTimeAdjustmentCount", 0);
3993
- I(this, "load", () => {
3994
- this.emitter.on("buffer state", this.onBufferState);
3995
- });
3996
- I(this, "unload", () => {
3997
- this.emitter.off("buffer state", this.onBufferState);
3998
- });
3999
- I(this, "suspend", () => {
4000
- this.isSuspended = !0;
4001
- });
4002
- I(this, "unsuspend", () => {
4003
- this.reset(), this.isSuspended = !1;
4004
- });
4005
- I(this, "reset", () => {
4006
- this.lastIncreaseTime = Date.now();
4007
- });
4008
- I(this, "getStatistics", () => ({
4009
- bufferTimeAdjustmentCount: this.bufferTimeAdjustmentCount
4010
- }));
4011
- I(this, "onBufferState", (A) => {
4012
- const { minBufferTime: t, maxBufferTime: e, cooldownTime: g } = this.config;
4013
- if (this.isSuspended || this.lastIncreaseTime + g > Date.now() || this.targetBufferTimeTarget.targetBufferTime >= e)
4014
- return;
4015
- const B = this.qualityOfServiceSource.timeSpentBufferingLast(30 * 1e3), C = this.qualityOfServiceSource.bufferingEventsLast(30 * 1e3), Q = this.qualityOfServiceSource.timeSpentActiveLast(30 * 1e3), o = B / Q, a = Math.ceil(
4016
- Math.max(
4017
- (e - t) / (Ie.BUFFER_TIME_MAX_STEPS - 1),
4018
- Ie.BUFFER_TIME_STEP_SIZE
4019
- )
4020
- );
4021
- (o > this.config.maxBufferingRatio.last30Seconds || C > this.config.maxBufferingEvents.last30Seconds) && (this.targetBufferTimeTarget.targetBufferTime = Math.min(
4022
- e,
4023
- this.targetBufferTimeTarget.targetBufferTime + a
4024
- ), this.bufferTimeAdjustmentCount++, this.reset());
4025
- });
4026
- this.qualityOfServiceSource = e, this.targetBufferTimeTarget = g, this.config = D(D({}, Jd), B), this.emitter = A, this.logger = t;
4047
+ toChannels(A, t, e) {
4048
+ return A.map((g) => this.toChannel(g, t, e));
4027
4049
  }
4028
- updateConfig(A) {
4029
- this.config = D(D({}, this.config), A);
4050
+ toChannel(A, t, e) {
4051
+ const { baseUrl: g, sizes: B } = A.thumbnail, C = g || new URL(Jn.thumbnails(t, e), this.baseUrl), Q = B.map((o) => new URL(
4052
+ `?channelId=${A.channelId}&width=${o.width}&height=${o.height}${Jd(
4053
+ t,
4054
+ e
4055
+ )}`,
4056
+ C
4057
+ ).toString());
4058
+ return {
4059
+ channelId: A.channelId,
4060
+ name: A.name,
4061
+ isLive: A.isLive,
4062
+ thumbnailUrls: Q
4063
+ };
4030
4064
  }
4031
- };
4032
- I(Ie, "BUFFER_TIME_STEP_SIZE", 500), I(Ie, "BUFFER_TIME_MAX_STEPS", 3), I(Ie, "create", (A, t, e, g, B = {}) => new Ie(A, t, e, g, B));
4033
- let $Q = Ie;
4065
+ }
4066
+ const Jd = (i, A) => A ? i.channelGroupId ? `&channelGroupId=${i.channelGroupId}&auth.token=${A}&auth.type=jwt` : `&auth.token=${A}&auth.type=jwt` : "";
4034
4067
  var XB = /* @__PURE__ */ ((i) => (i[i.StreamHeaderGroup = 4] = "StreamHeaderGroup", i[i.FetchHeader = 5] = "FetchHeader", i[i.StreamHeaderTrack = 60] = "StreamHeaderTrack", i))(XB || {});
4035
4068
  const UA = {
4036
4069
  Normal: 0,
@@ -4281,7 +4314,7 @@ class vd {
4281
4314
  const e = new Uint8Array(t.data);
4282
4315
  e[0] == s(this, rs) && A.enqueue(e.subarray(1));
4283
4316
  }
4284
- }), s(this, oe).addEventListener("error", () => A.error(new Error("WebSocket error"))), s(this, oe).addEventListener("close", () => fa(() => A.close()));
4317
+ }), s(this, oe).addEventListener("error", () => A.error(new Error("WebSocket error"))), s(this, oe).addEventListener("close", () => pa(() => A.close()));
4285
4318
  }
4286
4319
  cancel(A) {
4287
4320
  s(this, oe).close(void 0, A);
@@ -4306,7 +4339,7 @@ class Kd {
4306
4339
  A.enqueue([C, B, Q]);
4307
4340
  }
4308
4341
  }
4309
- }), E(this, ze, () => fa(() => A.close())), E(this, _e, () => A.error(new Error("WebSocket error"))), s(this, St).addEventListener("message", s(this, je)), s(this, St).addEventListener("error", s(this, _e)), s(this, St).addEventListener("close", s(this, ze));
4342
+ }), E(this, ze, () => pa(() => A.close())), E(this, _e, () => A.error(new Error("WebSocket error"))), s(this, St).addEventListener("message", s(this, je)), s(this, St).addEventListener("error", s(this, _e)), s(this, St).addEventListener("close", s(this, ze));
4310
4343
  }
4311
4344
  cancel(A) {
4312
4345
  s(this, je) && s(this, St).removeEventListener("message", s(this, je)), s(this, _e) && s(this, St).removeEventListener("error", s(this, _e)), s(this, ze) && s(this, St).removeEventListener("close", s(this, ze));
@@ -4365,7 +4398,7 @@ class jB {
4365
4398
  const t = d(this, X, ee).call(this, 8), e = new DataView(t.buffer, t.byteOffset, t.byteLength);
4366
4399
  if (typeof e.getBigUint64 != "undefined")
4367
4400
  return M(e.getBigUint64(0));
4368
- const g = Po(t, 0, 7);
4401
+ const g = To(t, 0, 7);
4369
4402
  return M(g);
4370
4403
  }
4371
4404
  default:
@@ -4447,7 +4480,7 @@ class IE {
4447
4480
  return s(this, Kt).write(A);
4448
4481
  }
4449
4482
  writeUnsigned8(A) {
4450
- return s(this, Kt).write(sQ(A, s(this, EI)));
4483
+ return s(this, Kt).write(BQ(A, s(this, EI)));
4451
4484
  }
4452
4485
  writeVarInt(A) {
4453
4486
  return s(this, Kt).write(EE(A, s(this, EI)));
@@ -4494,7 +4527,7 @@ const vg = class vg {
4494
4527
  return this.ensureBufferSpace(A.length), s(this, vA).set(A, s(this, MA)), E(this, MA, s(this, MA) + A.byteLength), Promise.resolve();
4495
4528
  }
4496
4529
  writeUnsigned8(A) {
4497
- return this.ensureBufferSpace(1), sQ(A, s(this, vA).subarray(s(this, MA))), E(this, MA, s(this, MA) + 1), Promise.resolve();
4530
+ return this.ensureBufferSpace(1), BQ(A, s(this, vA).subarray(s(this, MA))), E(this, MA, s(this, MA) + 1), Promise.resolve();
4498
4531
  }
4499
4532
  writeVarInt(A) {
4500
4533
  if (A < 0)
@@ -4517,8 +4550,8 @@ const vg = class vg {
4517
4550
  };
4518
4551
  MA = new WeakMap(), vA = new WeakMap(), Ai = new WeakMap(), hC = new WeakMap(), I(vg, "DEFAULT_BUFFER_SIZE", 1024);
4519
4552
  let Og = vg;
4520
- const sE = Math.pow(2, 6) - 1, BE = Math.pow(2, 14) - 1, CE = Math.pow(2, 30) - 1, Yd = Number.MAX_SAFE_INTEGER, Td = typeof BigInt == "function" ? M(2) ** M(62) - M(1) : M(Number.MAX_SAFE_INTEGER);
4521
- function sQ(i, A) {
4553
+ const sE = 2 ** 6 - 1, BE = 2 ** 14 - 1, CE = 2 ** 30 - 1, Yd = Number.MAX_SAFE_INTEGER, Td = typeof BigInt == "function" ? M(2) ** M(62) - M(1) : M(Number.MAX_SAFE_INTEGER);
4554
+ function BQ(i, A) {
4522
4555
  return A[0] = i, A.subarray(0, 1);
4523
4556
  }
4524
4557
  function QE(i, A) {
@@ -4539,7 +4572,7 @@ function aE(i, A) {
4539
4572
  }
4540
4573
  function EE(i, A) {
4541
4574
  if (i <= sE)
4542
- return sQ(i, A);
4575
+ return BQ(i, A);
4543
4576
  if (i <= BE)
4544
4577
  return QE(i | 16384, A);
4545
4578
  if (i <= CE)
@@ -4550,7 +4583,7 @@ function EE(i, A) {
4550
4583
  }
4551
4584
  function rE(i, A) {
4552
4585
  if (i < sE)
4553
- return sQ(Number(i), A);
4586
+ return BQ(Number(i), A);
4554
4587
  if (i < BE)
4555
4588
  return QE(Number(i) | 16384, A);
4556
4589
  if (i <= CE)
@@ -4560,7 +4593,7 @@ function rE(i, A) {
4560
4593
  throw new Error(`overflow, value larger than 62-bits: ${i}`);
4561
4594
  }
4562
4595
  var R = /* @__PURE__ */ ((i) => (i[i.SubscribeUpdate = 2] = "SubscribeUpdate", i[i.Subscribe = 3] = "Subscribe", i[i.SubscribeOk = 4] = "SubscribeOk", i[i.SubscribeError = 5] = "SubscribeError", i[i.Announce = 6] = "Announce", i[i.AnnounceOk = 7] = "AnnounceOk", i[i.AnnounceError = 8] = "AnnounceError", i[i.Unannounce = 9] = "Unannounce", i[i.Unsubscribe = 10] = "Unsubscribe", i[i.SubscribeDone = 11] = "SubscribeDone", i[i.AnnounceCancel = 12] = "AnnounceCancel", i[i.TrackStatusRequest = 13] = "TrackStatusRequest", i[i.TrackStatus = 14] = "TrackStatus", i[i.Goaway = 16] = "Goaway", i[i.ClientSetup = 64] = "ClientSetup", i[i.ServerSetup = 65] = "ServerSetup", i[i.Unknown = 255] = "Unknown", i))(R || {});
4563
- function BQ(i) {
4596
+ function CQ(i) {
4564
4597
  return r(this, null, function* () {
4565
4598
  const A = yield i.readVarInt();
4566
4599
  if (A < 1 || A > 32)
@@ -4600,7 +4633,7 @@ function Pd(i) {
4600
4633
  return r(this, null, function* () {
4601
4634
  return {
4602
4635
  type: R.Announce,
4603
- namespace: yield BQ(i),
4636
+ namespace: yield CQ(i),
4604
4637
  params: yield gg(i)
4605
4638
  };
4606
4639
  });
@@ -4614,7 +4647,7 @@ function Wd(i) {
4614
4647
  return r(this, null, function* () {
4615
4648
  return {
4616
4649
  type: R.AnnounceOk,
4617
- namespace: yield BQ(i)
4650
+ namespace: yield CQ(i)
4618
4651
  };
4619
4652
  });
4620
4653
  }
@@ -4624,73 +4657,12 @@ function Od(i, A) {
4624
4657
  });
4625
4658
  }
4626
4659
  const Vd = {
4627
- Subscriber: 2
4628
- }, _B = {
4629
- Role: M(0)
4630
- }, cE = {
4631
- Draft07: 4278190087
4632
- };
4633
- function hE(i) {
4634
- return r(this, null, function* () {
4635
- const A = yield i.readVarInt();
4636
- switch (A) {
4637
- case cE.Draft07:
4638
- return { type: "known", value: A };
4639
- default:
4640
- return { type: "unknown", value: A };
4641
- }
4642
- });
4643
- }
4644
- function Zd(i, A) {
4645
- return r(this, null, function* () {
4646
- yield i.writeVarInt(A.supportedVersions.length);
4647
- for (const t of A.supportedVersions)
4648
- yield i.writeVarInt(t.value);
4649
- yield sg(i, A.parameters);
4650
- });
4651
- }
4652
- function Xd(i) {
4653
- return r(this, null, function* () {
4654
- const A = [], t = yield i.readVarInt();
4655
- for (let g = 0; g < t; g++)
4656
- A.push(yield hE(i));
4657
- const e = yield gg(i);
4658
- if (!e.has(_B.Role))
4659
- throw new Error("Role parameter is required");
4660
- return {
4661
- type: R.ClientSetup,
4662
- supportedVersions: A,
4663
- parameters: e
4664
- };
4665
- });
4666
- }
4667
- function jd(i, A) {
4668
- return r(this, null, function* () {
4669
- yield i.writeVarInt(A.selectedVersion.value), yield sg(i, A.parameters);
4670
- });
4671
- }
4672
- function zd(i) {
4673
- return r(this, null, function* () {
4674
- const A = yield hE(i);
4675
- if (A.type !== "known")
4676
- throw new Error("Expected known version");
4677
- const t = yield gg(i);
4678
- if (!t.has(_B.Role))
4679
- throw new Error("Role parameter is required");
4680
- return {
4681
- type: R.ServerSetup,
4682
- selectedVersion: A,
4683
- parameters: t
4684
- };
4685
- });
4686
- }
4687
- const _d = {
4688
4660
  "latest-group": 1,
4689
4661
  "latest-object": 2,
4690
4662
  "absolute-start": 3,
4691
4663
  "absolute-range": 4
4692
4664
  };
4693
- function $d(i) {
4665
+ function Zd(i) {
4694
4666
  return r(this, null, function* () {
4695
4667
  const A = yield i.readVarInt();
4696
4668
  switch (A) {
@@ -4723,9 +4695,9 @@ function $d(i) {
4723
4695
  }
4724
4696
  });
4725
4697
  }
4726
- function Al(i, A) {
4698
+ function Xd(i, A) {
4727
4699
  return r(this, null, function* () {
4728
- const t = _d[A.type];
4700
+ const t = Vd[A.type];
4729
4701
  switch (yield i.writeVarInt(t), A.type) {
4730
4702
  case "absolute-range":
4731
4703
  yield i.writeBigVarInt(A.start.group), yield i.writeBigVarInt(A.start.object), yield i.writeBigVarInt(A.end.group), yield i.writeBigVarInt(A.end.object);
@@ -4741,7 +4713,7 @@ function Al(i, A) {
4741
4713
  }
4742
4714
  });
4743
4715
  }
4744
- function dE(i) {
4716
+ function cE(i) {
4745
4717
  return r(this, null, function* () {
4746
4718
  const A = yield i.readUnsigned8();
4747
4719
  switch (A) {
@@ -4756,7 +4728,7 @@ function dE(i) {
4756
4728
  }
4757
4729
  });
4758
4730
  }
4759
- function lE(i, A) {
4731
+ function hE(i, A) {
4760
4732
  return r(this, null, function* () {
4761
4733
  switch (A) {
4762
4734
  case "inherit-publisher":
@@ -4771,9 +4743,9 @@ function lE(i, A) {
4771
4743
  }
4772
4744
  });
4773
4745
  }
4774
- function tl(i) {
4746
+ function jd(i) {
4775
4747
  return r(this, null, function* () {
4776
- const A = yield i.readBigVarInt(), t = yield i.readBigVarInt(), e = yield BQ(i), g = yield i.readString(), B = yield i.readUnsigned8(), C = yield dE(i), Q = yield $d(i), o = yield gg(i);
4748
+ const A = yield i.readBigVarInt(), t = yield i.readBigVarInt(), e = yield CQ(i), g = yield i.readString(), B = yield i.readUnsigned8(), C = yield cE(i), Q = yield Zd(i), o = yield gg(i);
4777
4749
  if (Q.type === "absolute-range") {
4778
4750
  const a = Q.start.group > Q.end.group, c = Q.start.group === Q.end.group && Q.start.object > Q.end.object;
4779
4751
  if (a || c)
@@ -4792,16 +4764,16 @@ function tl(i) {
4792
4764
  };
4793
4765
  });
4794
4766
  }
4795
- function el(i, A) {
4767
+ function zd(i, A) {
4796
4768
  return r(this, null, function* () {
4797
- yield i.writeBigVarInt(A.id), yield i.writeBigVarInt(A.trackAlias), yield Wo(i, A.namespace), yield i.writeString(A.name), yield i.writeUnsigned8(A.subscriberPriority), yield lE(i, A.groupOrder), yield Al(i, A.filterType), yield sg(i, A.params);
4769
+ yield i.writeBigVarInt(A.id), yield i.writeBigVarInt(A.trackAlias), yield Wo(i, A.namespace), yield i.writeString(A.name), yield i.writeUnsigned8(A.subscriberPriority), yield hE(i, A.groupOrder), yield Xd(i, A.filterType), yield sg(i, A.params);
4798
4770
  });
4799
4771
  }
4800
4772
  const eo = {
4801
4773
  TrackEnded: 3,
4802
4774
  Expired: 6
4803
4775
  };
4804
- function il(i) {
4776
+ function _d(i) {
4805
4777
  return r(this, null, function* () {
4806
4778
  const A = yield i.readBigVarInt(), t = yield i.readVarInt(), e = yield i.readString(), g = (yield i.readUnsigned8()) == 1;
4807
4779
  let B;
@@ -4817,12 +4789,12 @@ function il(i) {
4817
4789
  };
4818
4790
  });
4819
4791
  }
4820
- function Il(i, A) {
4792
+ function $d(i, A) {
4821
4793
  return r(this, null, function* () {
4822
4794
  yield i.writeBigVarInt(A.id), yield i.writeVarInt(A.errorCode), yield i.writeString(A.reason), yield i.writeUnsigned8(A.finalInfo ? 1 : 0), A.finalInfo && (yield i.writeBigVarInt(A.finalInfo.group), yield i.writeBigVarInt(A.finalInfo.object));
4823
4795
  });
4824
4796
  }
4825
- function gl(i) {
4797
+ function Al(i) {
4826
4798
  return r(this, null, function* () {
4827
4799
  return {
4828
4800
  type: R.SubscribeError,
@@ -4833,14 +4805,14 @@ function gl(i) {
4833
4805
  };
4834
4806
  });
4835
4807
  }
4836
- function sl(i, A) {
4808
+ function tl(i, A) {
4837
4809
  return r(this, null, function* () {
4838
4810
  yield i.writeBigVarInt(A.id), yield i.writeBigVarInt(A.errorCode), yield i.writeString(A.reason), yield i.writeBigVarInt(A.trackAlias);
4839
4811
  });
4840
4812
  }
4841
- function Bl(i) {
4813
+ function el(i) {
4842
4814
  return r(this, null, function* () {
4843
- const A = yield i.readBigVarInt(), t = yield i.readBigVarInt(), e = yield dE(i), g = (yield i.readUnsigned8()) == 1;
4815
+ const A = yield i.readBigVarInt(), t = yield i.readBigVarInt(), e = yield cE(i), g = (yield i.readUnsigned8()) == 1;
4844
4816
  let B;
4845
4817
  if (e == "inherit-publisher")
4846
4818
  throw new Error("SusbcribeOk cannot have inherit publisher group order");
@@ -4859,12 +4831,12 @@ function Bl(i) {
4859
4831
  };
4860
4832
  });
4861
4833
  }
4862
- function Cl(i, A) {
4834
+ function il(i, A) {
4863
4835
  return r(this, null, function* () {
4864
- yield i.writeBigVarInt(A.id), yield i.writeBigVarInt(A.expires), yield lE(i, A.groupOrder), yield i.writeUnsigned8(A.largestInfo ? 1 : 0), A.largestInfo && (yield i.writeBigVarInt(A.largestInfo.group), yield i.writeBigVarInt(A.largestInfo.object)), yield sg(i, A.params);
4836
+ yield i.writeBigVarInt(A.id), yield i.writeBigVarInt(A.expires), yield hE(i, A.groupOrder), yield i.writeUnsigned8(A.largestInfo ? 1 : 0), A.largestInfo && (yield i.writeBigVarInt(A.largestInfo.group), yield i.writeBigVarInt(A.largestInfo.object)), yield sg(i, A.params);
4865
4837
  });
4866
4838
  }
4867
- function Ql(i) {
4839
+ function Il(i) {
4868
4840
  return r(this, null, function* () {
4869
4841
  const A = yield i.readBigVarInt(), t = yield i.readBigVarInt(), e = yield i.readBigVarInt(), g = yield i.readBigVarInt(), B = yield i.readBigVarInt(), C = yield i.readUnsigned8(), Q = yield gg(i), o = t > g, a = t === g && e > B;
4870
4842
  if (o || a)
@@ -4879,11 +4851,72 @@ function Ql(i) {
4879
4851
  };
4880
4852
  });
4881
4853
  }
4882
- function ol(i, A) {
4854
+ function gl(i, A) {
4883
4855
  return r(this, null, function* () {
4884
4856
  yield i.writeBigVarInt(A.id), yield i.writeBigVarInt(A.start.group), yield i.writeBigVarInt(A.start.object), yield i.writeBigVarInt(A.end.group), yield i.writeBigVarInt(A.end.object), yield i.writeUnsigned8(A.subscriberPriority), yield sg(i, A.params);
4885
4857
  });
4886
4858
  }
4859
+ const sl = {
4860
+ Subscriber: 2
4861
+ }, _B = {
4862
+ Role: M(0)
4863
+ }, dE = {
4864
+ Draft07: 4278190087
4865
+ };
4866
+ function lE(i) {
4867
+ return r(this, null, function* () {
4868
+ const A = yield i.readVarInt();
4869
+ switch (A) {
4870
+ case dE.Draft07:
4871
+ return { type: "known", value: A };
4872
+ default:
4873
+ return { type: "unknown", value: A };
4874
+ }
4875
+ });
4876
+ }
4877
+ function Bl(i, A) {
4878
+ return r(this, null, function* () {
4879
+ yield i.writeVarInt(A.supportedVersions.length);
4880
+ for (const t of A.supportedVersions)
4881
+ yield i.writeVarInt(t.value);
4882
+ yield sg(i, A.parameters);
4883
+ });
4884
+ }
4885
+ function Cl(i) {
4886
+ return r(this, null, function* () {
4887
+ const A = [], t = yield i.readVarInt();
4888
+ for (let g = 0; g < t; g++)
4889
+ A.push(yield lE(i));
4890
+ const e = yield gg(i);
4891
+ if (!e.has(_B.Role))
4892
+ throw new Error("Role parameter is required");
4893
+ return {
4894
+ type: R.ClientSetup,
4895
+ supportedVersions: A,
4896
+ parameters: e
4897
+ };
4898
+ });
4899
+ }
4900
+ function Ql(i, A) {
4901
+ return r(this, null, function* () {
4902
+ yield i.writeVarInt(A.selectedVersion.value), yield sg(i, A.parameters);
4903
+ });
4904
+ }
4905
+ function ol(i) {
4906
+ return r(this, null, function* () {
4907
+ const A = yield lE(i);
4908
+ if (A.type !== "known")
4909
+ throw new Error("Expected known version");
4910
+ const t = yield gg(i);
4911
+ if (!t.has(_B.Role))
4912
+ throw new Error("Role parameter is required");
4913
+ return {
4914
+ type: R.ServerSetup,
4915
+ selectedVersion: A,
4916
+ parameters: t
4917
+ };
4918
+ });
4919
+ }
4887
4920
  function nl(i) {
4888
4921
  return r(this, null, function* () {
4889
4922
  return {
@@ -4963,31 +4996,31 @@ class uE {
4963
4996
  }
4964
4997
  Yt = new WeakMap(), cI = new WeakMap(), sA = new WeakSet(), wE = function(A, t) {
4965
4998
  return r(this, null, function* () {
4966
- yield Zd(A, t);
4999
+ yield Bl(A, t);
4967
5000
  });
4968
5001
  }, DE = function(A, t) {
4969
5002
  return r(this, null, function* () {
4970
- yield jd(A, t);
5003
+ yield Ql(A, t);
4971
5004
  });
4972
5005
  }, SE = function(A, t) {
4973
5006
  return r(this, null, function* () {
4974
- yield el(A, t);
5007
+ yield zd(A, t);
4975
5008
  });
4976
5009
  }, mE = function(A, t) {
4977
5010
  return r(this, null, function* () {
4978
- yield Cl(A, t);
5011
+ yield il(A, t);
4979
5012
  });
4980
5013
  }, yE = function(A, t) {
4981
5014
  return r(this, null, function* () {
4982
- yield sl(A, t);
5015
+ yield tl(A, t);
4983
5016
  });
4984
5017
  }, fE = function(A, t) {
4985
5018
  return r(this, null, function* () {
4986
- yield ol(A, t);
5019
+ yield gl(A, t);
4987
5020
  });
4988
5021
  }, pE = function(A, t) {
4989
5022
  return r(this, null, function* () {
4990
- yield Il(A, t);
5023
+ yield $d(A, t);
4991
5024
  });
4992
5025
  }, FE = function(A, t) {
4993
5026
  return r(this, null, function* () {
@@ -5024,7 +5057,7 @@ function rl(i) {
5024
5057
  return r(this, null, function* () {
5025
5058
  return {
5026
5059
  type: R.AnnounceError,
5027
- namespace: yield BQ(i),
5060
+ namespace: yield CQ(i),
5028
5061
  errorCode: yield i.readBigVarInt(),
5029
5062
  reason: yield i.readString()
5030
5063
  };
@@ -5040,7 +5073,7 @@ function cl(i, A, t) {
5040
5073
  });
5041
5074
  }
5042
5075
  var EA;
5043
- class Jn {
5076
+ class Mn {
5044
5077
  constructor(A) {
5045
5078
  n(this, EA);
5046
5079
  E(this, EA, A);
@@ -5053,19 +5086,19 @@ class Jn {
5053
5086
  const A = yield s(this, EA).readVarInt(), t = yield s(this, EA).readVarInt();
5054
5087
  switch (A) {
5055
5088
  case R.ServerSetup:
5056
- return zd(s(this, EA));
5089
+ return ol(s(this, EA));
5057
5090
  case R.ClientSetup:
5058
- return Xd(s(this, EA));
5091
+ return Cl(s(this, EA));
5059
5092
  case R.Subscribe:
5060
- return tl(s(this, EA));
5093
+ return jd(s(this, EA));
5061
5094
  case R.SubscribeOk:
5062
- return Bl(s(this, EA));
5095
+ return el(s(this, EA));
5063
5096
  case R.SubscribeDone:
5064
- return il(s(this, EA));
5097
+ return _d(s(this, EA));
5065
5098
  case R.SubscribeError:
5066
- return gl(s(this, EA));
5099
+ return Al(s(this, EA));
5067
5100
  case R.SubscribeUpdate:
5068
- return Ql(s(this, EA));
5101
+ return Il(s(this, EA));
5069
5102
  case R.Unsubscribe:
5070
5103
  return nl(s(this, EA));
5071
5104
  case R.Announce:
@@ -5118,14 +5151,14 @@ const Zi = class Zi {
5118
5151
  static wrapWebsocket(A) {
5119
5152
  const t = new ReadableStream(
5120
5153
  new vd(A, s(Zi, lC))
5121
- ), e = new Jn(new jB(new Uint8Array([]), t)), g = new El(new Og(A), new Uint8Array([0]));
5154
+ ), e = new Mn(new jB(new Uint8Array([]), t)), g = new El(new Og(A), new Uint8Array([0]));
5122
5155
  return new Zi(g, e);
5123
5156
  }
5124
5157
  static wrapWebTransport(A) {
5125
5158
  const t = A.writable, e = A.readable;
5126
5159
  return new Zi(
5127
5160
  new uE(new IE(t)),
5128
- new Jn(new jB(new Uint8Array(), e))
5161
+ new Mn(new jB(new Uint8Array(), e))
5129
5162
  );
5130
5163
  }
5131
5164
  };
@@ -5138,7 +5171,7 @@ function UE(i, A) {
5138
5171
  return r(this, null, function* () {
5139
5172
  yield i.write({
5140
5173
  type: R.ClientSetup,
5141
- supportedVersions: [{ type: "known", value: cE.Draft07 }],
5174
+ supportedVersions: [{ type: "known", value: dE.Draft07 }],
5142
5175
  parameters: /* @__PURE__ */ new Map([[_B.Role, { type: _B.Role, payload: new Uint8Array([A]) }]])
5143
5176
  });
5144
5177
  const t = yield i.read();
@@ -5470,7 +5503,7 @@ class io {
5470
5503
  n(this, gi, SA.get().createContext("Publisher"));
5471
5504
  n(this, Ee, new NA(/* @__PURE__ */ new Map()));
5472
5505
  n(this, re, new NA(/* @__PURE__ */ new Map()));
5473
- n(this, ce, new tQ(10));
5506
+ n(this, ce, new eQ(10));
5474
5507
  E(this, yI, A), E(this, Gs, t), E(this, fI, e);
5475
5508
  }
5476
5509
  announce(A) {
@@ -5894,7 +5927,7 @@ class Oo {
5894
5927
  s(this, RI).warn("Error closing session", A);
5895
5928
  }
5896
5929
  }
5897
- [(ha = [HA({ context: "Session", return: "info", error: "error" })], ca = [HA({ context: "Session", return: "info", error: "error" })], ra = [HA({ context: "Session", return: "info", error: "error" })], Ea = [HA({ context: "Session", enter: "debug" })], ya())]() {
5930
+ [(ha = [HA({ context: "Session", return: "info", error: "error" })], ca = [HA({ context: "Session", return: "info", error: "error" })], ra = [HA({ context: "Session", return: "info", error: "error" })], Ea = [HA({ context: "Session", enter: "debug" })], fa())]() {
5898
5931
  d(this, rA, hg).call(this);
5899
5932
  }
5900
5933
  [Symbol.dispose]() {
@@ -6121,7 +6154,7 @@ class kl {
6121
6154
  n(this, mC);
6122
6155
  n(this, Wt);
6123
6156
  n(this, Ot);
6124
- n(this, de, new tQ(100));
6157
+ n(this, de, new eQ(100));
6125
6158
  n(this, Ns);
6126
6159
  n(this, bs, 0);
6127
6160
  n(this, SC, SA.get().createContext("WebTransportConnection"));
@@ -6184,7 +6217,7 @@ Wt = new WeakMap(), Ot = new WeakMap(), de = new WeakMap(), Ns = new WeakMap(),
6184
6217
  }
6185
6218
  });
6186
6219
  };
6187
- function yQ(i) {
6220
+ function fQ(i) {
6188
6221
  return r(this, null, function* () {
6189
6222
  const A = new WebSocket(i.wsUrl || i.url);
6190
6223
  A.binaryType = "arraybuffer", yield new Promise((B, C) => {
@@ -6219,10 +6252,10 @@ function Rl(i) {
6219
6252
  function Ul(i) {
6220
6253
  return r(this, null, function* () {
6221
6254
  if (self.WebTransport && (i == null ? void 0 : i.preferredTransport) !== "websocket" && i.url.protocol.startsWith("https")) {
6222
- const A = Rl(i).catch(() => yQ(i)), t = yield Promise.race([A, Ge(i.websocketFallbackTimeoutMs)]);
6223
- return t || yQ(i);
6255
+ const A = Rl(i).catch(() => fQ(i)), t = yield Promise.race([A, Ge(i.websocketFallbackTimeoutMs)]);
6256
+ return t || fQ(i);
6224
6257
  }
6225
- return yQ(i);
6258
+ return fQ(i);
6226
6259
  });
6227
6260
  }
6228
6261
  var Vt;
@@ -6397,7 +6430,7 @@ const An = class An {
6397
6430
  // The current group iterator - gets replaced by the next in #groups when it runs out
6398
6431
  n(this, Ei);
6399
6432
  // The next group iterators to switch to when the current one runs out
6400
- n(this, Zt, new tQ(10));
6433
+ n(this, Zt, new eQ(10));
6401
6434
  n(this, pt);
6402
6435
  n(this, qs, (A, t) => r(this, null, function* () {
6403
6436
  var h = [];
@@ -6441,7 +6474,7 @@ const An = class An {
6441
6474
  WA(h, u, S);
6442
6475
  }
6443
6476
  }));
6444
- E(this, nt, new Kr(A)), E(this, Ei, A), E(this, pt, SA.get().createContext(`Renewable '${A.name()}'`));
6477
+ E(this, nt, new xr(A)), E(this, Ei, A), E(this, pt, SA.get().createContext(`Renewable '${A.name()}'`));
6445
6478
  }
6446
6479
  static subscribe(A, t, e) {
6447
6480
  return r(this, null, function* () {
@@ -6575,7 +6608,7 @@ nt = new WeakMap(), Ei = new WeakMap(), Zt = new WeakMap(), pt = new WeakMap(),
6575
6608
  }, qs = new WeakMap();
6576
6609
  let ke = An;
6577
6610
  const Jl = "catalog";
6578
- function Mn(i) {
6611
+ function Hn(i) {
6579
6612
  const A = Ll(i.payload);
6580
6613
  if (!bl(A))
6581
6614
  throw new Error("unexpected catalog type");
@@ -6615,7 +6648,7 @@ const pC = class pC {
6615
6648
  const C = yield (yield g.promise).next();
6616
6649
  if (!C.value)
6617
6650
  throw new Error("No catalog found");
6618
- const Q = Mn(C.value);
6651
+ const Q = Hn(C.value);
6619
6652
  return new pC(e, new NA(Q), g);
6620
6653
  });
6621
6654
  }
@@ -6628,7 +6661,7 @@ le = new WeakMap(), vs = new WeakMap(), Ks = new WeakMap(), Ys = new WeakMap(),
6628
6661
  const C = g.value;
6629
6662
  if (C.objectStatus !== UA.Normal)
6630
6663
  continue;
6631
- const Q = Mn(C);
6664
+ const Q = Hn(C);
6632
6665
  s(this, le).update(Q);
6633
6666
  }
6634
6667
  } catch (g) {
@@ -6737,7 +6770,7 @@ const ji = class ji {
6737
6770
  return new ji(t, A.namespace(), b, y, e);
6738
6771
  }
6739
6772
  lA(t.initData, "no init data found on track");
6740
- const h = Da(t.initData), l = new kn(new Uint8Array(h)), u = yield ke.subscribe(A, c, {
6773
+ const h = ma(t.initData), l = new kn(new Uint8Array(h)), u = yield ke.subscribe(A, c, {
6741
6774
  params: B,
6742
6775
  largestGroupId: g ? g - M(1) : void 0
6743
6776
  });
@@ -6809,7 +6842,7 @@ Ws = new WeakMap(), Ft = new WeakMap(), Os = new WeakMap(), Vs = new WeakMap(),
6809
6842
  });
6810
6843
  }, n(ji, FC);
6811
6844
  let Co = ji;
6812
- const Hn = 1e4, Hl = 3e4;
6845
+ const qn = 1e4, Hl = 3e4;
6813
6846
  var GC, ue, ri, Zs, Xs, js, Ui, oo, YE;
6814
6847
  const tn = class tn {
6815
6848
  constructor(A, t, e) {
@@ -6856,7 +6889,7 @@ const tn = class tn {
6856
6889
  return r(this, null, function* () {
6857
6890
  return yield s(this, ue).waitFor((A) => {
6858
6891
  const t = A[0], e = A[A.length - 1];
6859
- return !t || !e ? !1 : e.wallclock - t.wallclock > Hn;
6892
+ return !t || !e ? !1 : e.wallclock - t.wallclock > qn;
6860
6893
  }), this.timeline();
6861
6894
  });
6862
6895
  }
@@ -6916,7 +6949,7 @@ GC = new WeakMap(), ue = new WeakMap(), ri = new WeakMap(), Zs = new WeakMap(),
6916
6949
  }, YE = function(A) {
6917
6950
  return r(this, null, function* () {
6918
6951
  const t = A - M(1), e = this.timeline(), g = e[0], B = e[e.length - 1];
6919
- if (!g || !B || B.wallclock - g.wallclock > Hn)
6952
+ if (!g || !B || B.wallclock - g.wallclock > qn)
6920
6953
  return;
6921
6954
  const C = j.fromPromise(
6922
6955
  ke.subscribe(
@@ -6951,7 +6984,7 @@ function vl(i) {
6951
6984
  var kC, zs, we, vI;
6952
6985
  const en = class en {
6953
6986
  constructor(A, t, e, g, B) {
6954
- n(this, kC, new _a());
6987
+ n(this, kC, new ja());
6955
6988
  n(this, zs);
6956
6989
  n(this, we);
6957
6990
  n(this, vI, 0);
@@ -7082,6 +7115,13 @@ qQ = Ue(null), ci = new WeakMap(), hi = new WeakMap(), di = new WeakMap(), De =
7082
7115
  });
7083
7116
  }, FA(qQ, 9, "start", da, zi), te(qQ, zi), Ne(qQ, 3, zi);
7084
7117
  let eC = zi;
7118
+ const Kl = M(8);
7119
+ function Yl(i) {
7120
+ if (i < 0 || i > 65535)
7121
+ throw new RangeError("burstMs must be between 0 and 65535 inclusive");
7122
+ const A = new Uint8Array([i >> 8 & 255, i & 255]);
7123
+ return { type: Kl, payload: A };
7124
+ }
7085
7125
  var li, _s, RC, TE;
7086
7126
  const In = class In {
7087
7127
  constructor(A) {
@@ -7136,23 +7176,23 @@ let ao = In;
7136
7176
  function lB(i) {
7137
7177
  return typeof i == "string" || i === null || i === void 0;
7138
7178
  }
7139
- function Kl(i) {
7179
+ function Tl(i) {
7140
7180
  return "provider" in i && typeof i.provider == "string" && (!("widevineLicenseUrl" in i) || lB(i.widevineLicenseUrl)) && (!("playreadyLicenseUrl" in i) || lB(i.playreadyLicenseUrl)) && (!("fairplayLicenseUrl" in i) || lB(i.fairplayLicenseUrl)) && (!("fairplayCertificate" in i) || lB(i.fairplayCertificate));
7141
7181
  }
7142
- function Yl(i) {
7182
+ function Pl(i) {
7143
7183
  try {
7144
- return Da(i);
7184
+ return ma(i);
7145
7185
  } catch (A) {
7146
7186
  throw new Error("Failed to convert fairplayCertificate");
7147
7187
  }
7148
7188
  }
7149
- function Tl(i) {
7189
+ function xl(i) {
7150
7190
  const A = new TextDecoder().decode(i), t = JSON.parse(A);
7151
- if (!Kl(t))
7191
+ if (!Tl(t))
7152
7192
  throw new Error("Invalid drm object");
7153
7193
  const B = t, { fairplayCertificate: e } = B, g = nn(B, ["fairplayCertificate"]);
7154
7194
  return T(D({}, g), {
7155
- fairplayCertificate: e ? Yl(e) : void 0
7195
+ fairplayCertificate: e ? Pl(e) : void 0
7156
7196
  });
7157
7197
  }
7158
7198
  class Vo {
@@ -7169,7 +7209,7 @@ class Vo {
7169
7209
  const C = yield B.next();
7170
7210
  if (C.done)
7171
7211
  throw new Error("No drm object received");
7172
- const Q = Tl(C.value.payload);
7212
+ const Q = xl(C.value.payload);
7173
7213
  return new Vo(T(D({}, Q), { videoCodec: t, audioCodec: e }));
7174
7214
  } catch (a) {
7175
7215
  var c = a, h = !0;
@@ -7180,16 +7220,16 @@ class Vo {
7180
7220
  });
7181
7221
  }
7182
7222
  }
7183
- function Pl(i) {
7223
+ function Wl(i) {
7184
7224
  return "rtt" in i && typeof i.rtt == "number" && "ntpTimestamp" in i && typeof i.ntpTimestamp == "number" && "estimatedBandwidth" in i && typeof i.estimatedBandwidth == "number";
7185
7225
  }
7186
- function qn(i) {
7226
+ function vn(i) {
7187
7227
  const A = new TextDecoder().decode(i), t = JSON.parse(A);
7188
- if (!Pl(t))
7228
+ if (!Wl(t))
7189
7229
  throw new Error("Invalid stats object");
7190
7230
  return t;
7191
7231
  }
7192
- const xl = 1e4;
7232
+ const Ol = 1e4;
7193
7233
  var $s, UC, PE;
7194
7234
  const gn = class gn {
7195
7235
  constructor(A, t, e) {
@@ -7207,7 +7247,7 @@ const gn = class gn {
7207
7247
  for (; ; ) {
7208
7248
  const [A, t] = this.value.value();
7209
7249
  try {
7210
- yield Promise.race([xo(xl, new Error("Idle timeout")), t]);
7250
+ yield Promise.race([xo(Ol, new Error("Idle timeout")), t]);
7211
7251
  } catch (e) {
7212
7252
  return e;
7213
7253
  }
@@ -7219,7 +7259,7 @@ const gn = class gn {
7219
7259
  const e = (yield A.subscribe(new $t().name("stats").groupOrder("ascending").build())).objects(), g = yield e.next();
7220
7260
  if (g.done)
7221
7261
  throw new Error("No stats object received");
7222
- const B = qn(g.value.payload);
7262
+ const B = vn(g.value.payload);
7223
7263
  if (!B.ip)
7224
7264
  throw new Error("Expected IP in initial stats object");
7225
7265
  return new gn(e, B, B.ip);
@@ -7233,7 +7273,7 @@ $s = new WeakMap(), UC = new WeakSet(), PE = function(A) {
7233
7273
  const C = g.value;
7234
7274
  if (C.objectStatus !== UA.Normal)
7235
7275
  continue;
7236
- const Q = qn(C.payload);
7276
+ const Q = vn(C.payload);
7237
7277
  this.value.update(Q);
7238
7278
  }
7239
7279
  } catch (g) {
@@ -7250,7 +7290,7 @@ $s = new WeakMap(), UC = new WeakSet(), PE = function(A) {
7250
7290
  };
7251
7291
  let Eo = gn;
7252
7292
  var NC, YI;
7253
- class Wl {
7293
+ class Vl {
7254
7294
  constructor(A) {
7255
7295
  n(this, NC, SA.get().createContext("UpstreamWatcher"));
7256
7296
  n(this, YI);
@@ -7280,15 +7320,8 @@ class Wl {
7280
7320
  }
7281
7321
  }
7282
7322
  NC = new WeakMap(), YI = new WeakMap();
7283
- const Ol = M(8);
7284
- function Vl(i) {
7285
- if (i < 0 || i > 65535)
7286
- throw new RangeError("burstMs must be between 0 and 65535 inclusive");
7287
- const A = new Uint8Array([i >> 8 & 255, i & 255]);
7288
- return { type: Ol, payload: A };
7289
- }
7290
7323
  var TI, AB, tB;
7291
- class fQ {
7324
+ class pQ {
7292
7325
  constructor(A, t) {
7293
7326
  n(this, TI, SA.get().createContext("TracksIterator"));
7294
7327
  n(this, AB);
@@ -7338,10 +7371,10 @@ let Zl = (wa = [HA({ context: "Player", enter: "info" })], ua = [HA({ context: "
7338
7371
  n(this, Se, new NA(void 0));
7339
7372
  n(this, WI);
7340
7373
  n(this, eB);
7341
- I(this, "subtitles", new fQ(s(this, Se), "subtitles"));
7342
- I(this, "video", new fQ(s(this, Et), "video"));
7343
- I(this, "audio", new fQ(s(this, at), "audio"));
7344
- E(this, PI, A), E(this, xI, ao.start(e)), E(this, ui, e), E(this, wA, new NA(t)), E(this, WI, new Wl(t)), E(this, eB, Promise.race([e.idleTimeout(), d(this, bA, xE).call(this), s(this, WI).closed()])), s(this, PI).closed().then(() => this.close()).catch(q);
7374
+ I(this, "subtitles", new pQ(s(this, Se), "subtitles"));
7375
+ I(this, "video", new pQ(s(this, Et), "video"));
7376
+ I(this, "audio", new pQ(s(this, at), "audio"));
7377
+ E(this, PI, A), E(this, xI, ao.start(e)), E(this, ui, e), E(this, wA, new NA(t)), E(this, WI, new Vl(t)), E(this, eB, Promise.race([e.idleTimeout(), d(this, bA, xE).call(this), s(this, WI).closed()])), s(this, PI).closed().then(() => this.close()).catch(q);
7345
7378
  }
7346
7379
  closed() {
7347
7380
  return s(this, eB);
@@ -7350,7 +7383,7 @@ let Zl = (wa = [HA({ context: "Player", enter: "info" })], ua = [HA({ context: "
7350
7383
  return r(this, null, function* () {
7351
7384
  const e = /* @__PURE__ */ new Map();
7352
7385
  if (t.burstMs !== void 0) {
7353
- const c = Vl(t.burstMs);
7386
+ const c = Yl(t.burstMs);
7354
7387
  e.set(c.type, c);
7355
7388
  }
7356
7389
  const g = new qE(A, { namespace: Nl("auxiliary") }), [[B, C, Q], o] = yield Promise.all([
@@ -7514,7 +7547,7 @@ let Zl = (wa = [HA({ context: "Player", enter: "info" })], ua = [HA({ context: "
7514
7547
  }
7515
7548
  });
7516
7549
  }, FA(ag, 1, "close", wa, Xt), FA(ag, 1, "zap", ua, Xt), dg = FA(ag, 17, "#replaceTrack", la, bA, dg), te(ag, Xt), Xt);
7517
- function pQ(i, A, t) {
7550
+ function FQ(i, A, t) {
7518
7551
  const e = new URL("/voq/subscribe", i);
7519
7552
  return e.searchParams.set("sessionId", A.sessionId), e.searchParams.set("clientId", A.clientId), e.searchParams.set("channelId", A.channelId), t && e.searchParams.set("authToken", t), e;
7520
7553
  }
@@ -7559,7 +7592,7 @@ const sn = class sn {
7559
7592
  }
7560
7593
  break;
7561
7594
  case "telemetry":
7562
- Ra(new URL("/api/telemetry", s(this, zA).url().replace("wss://", "https://")), {
7595
+ $a(new URL("/api/telemetry", s(this, zA).url().replace("wss://", "https://")), {
7563
7596
  body: A.body,
7564
7597
  headers: { "Content-Type": "text/plain" }
7565
7598
  }).catch(q);
@@ -7597,17 +7630,17 @@ const sn = class sn {
7597
7630
  const C = new Map(
7598
7631
  g.connectInfo.channels.map((J) => [
7599
7632
  be(J.catalog.namespace),
7600
- new FQ(new NA(J.catalog))
7633
+ new GQ(new NA(J.catalog))
7601
7634
  ])
7602
7635
  ), Q = yield g.onConnectInfo(g.connectInfo), o = g.options.get("authenticationToken");
7603
7636
  let a, c;
7604
7637
  switch (typeof g.edgeUrl) {
7605
7638
  case "string": {
7606
- a = pQ(g.edgeUrl, Q, o);
7639
+ a = FQ(g.edgeUrl, Q, o);
7607
7640
  break;
7608
7641
  }
7609
7642
  default:
7610
- a = pQ(g.edgeUrl.moqUrl || g.edgeUrl.moqWsUrl, Q, o), c = pQ(g.edgeUrl.moqWsUrl, Q, o);
7643
+ a = FQ(g.edgeUrl.moqUrl || g.edgeUrl.moqWsUrl, Q, o), c = FQ(g.edgeUrl.moqWsUrl, Q, o);
7611
7644
  break;
7612
7645
  }
7613
7646
  const h = (y = g.connectInfo.channels.find((J) => J.channelId === Q.channelId)) == null ? void 0 : y.catalog;
@@ -7617,7 +7650,7 @@ const sn = class sn {
7617
7650
  wsUrl: c,
7618
7651
  authToken: g.options.get("authenticationToken"),
7619
7652
  preferredTransport: g.options.get("webtransportEnabled") ? "webtransport" : "websocket",
7620
- role: Vd.Subscriber,
7653
+ role: sl.Subscriber,
7621
7654
  websocketFallbackTimeoutMs: 2e3
7622
7655
  }), f = yield Promise.race([
7623
7656
  Zl.start(S.subscriber, {
@@ -7628,8 +7661,8 @@ const sn = class sn {
7628
7661
  burstMs: Q.burstMs || 0
7629
7662
  }),
7630
7663
  xo(Xl, new Error("Timeout waiting for player to start")),
7631
- Yr(S.closed(), "Session closed before player started")
7632
- ]), F = new FQ(f.catalog());
7664
+ Wr(S.closed(), "Session closed before player started")
7665
+ ]), F = new GQ(f.catalog());
7633
7666
  C.set(be(h.namespace), F), A.emit("received signal", {
7634
7667
  type: "client ip",
7635
7668
  ip: f.connectionInfo().ip
@@ -7675,7 +7708,7 @@ dA = new WeakMap(), kA = new WeakMap(), zA = new WeakMap(), wi = new WeakMap(),
7675
7708
  return r(this, null, function* () {
7676
7709
  var g;
7677
7710
  const t = yield s(this, iB).connect({ channelId: A });
7678
- if (!Fa(t))
7711
+ if (!Ga(t))
7679
7712
  throw new Error("no moq connect info found");
7680
7713
  const e = (g = t.channels.find((B) => B.channelId === A)) == null ? void 0 : g.catalog;
7681
7714
  if (!e)
@@ -7688,7 +7721,7 @@ dA = new WeakMap(), kA = new WeakMap(), zA = new WeakMap(), wi = new WeakMap(),
7688
7721
  s(this, kA).info("handle subscription", A);
7689
7722
  const t = s(this, gA);
7690
7723
  let e = s(this, me).get(A.channelId);
7691
- if (e || (e = new FQ(new NA(yield d(this, LA, OE).call(this, A.channelId))), s(this, me).set(A.channelId, e)), t.namespace().join("/") !== e.namespace().join("/")) {
7724
+ if (e || (e = new GQ(new NA(yield d(this, LA, OE).call(this, A.channelId))), s(this, me).set(A.channelId, e)), t.namespace().join("/") !== e.namespace().join("/")) {
7692
7725
  s(this, kA).info("changing channel", A.channelId);
7693
7726
  const a = e.getVideoTrack(A.video), c = e.getAudioTrack(A.audio);
7694
7727
  yield t.zap(
@@ -7828,7 +7861,7 @@ function jl(i) {
7828
7861
  );
7829
7862
  }
7830
7863
  var jt, Di, bC, jE;
7831
- class FQ {
7864
+ class GQ {
7832
7865
  constructor(A) {
7833
7866
  n(this, bC);
7834
7867
  n(this, jt);
@@ -7865,7 +7898,7 @@ class FQ {
7865
7898
  }
7866
7899
  jt = new WeakMap(), Di = new WeakMap(), bC = new WeakSet(), jE = function() {
7867
7900
  const [A, t] = s(this, jt).value();
7868
- return Ga(A);
7901
+ return ka(A);
7869
7902
  };
7870
7903
  const zl = (i, A) => {
7871
7904
  const t = new URL("/subscribe", i);
@@ -7939,13 +7972,13 @@ class _l extends $A {
7939
7972
  this.emit("error", UB(og()));
7940
7973
  break;
7941
7974
  case 4002:
7942
- this.emit("error", Sc(og()));
7975
+ this.emit("error", hc(og()));
7943
7976
  break;
7944
7977
  case 4003:
7945
- this.emit("error", ba("internal", og()));
7978
+ this.emit("error", Na("internal", og()));
7946
7979
  break;
7947
7980
  case 4010:
7948
- this.emit("error", mc("internal", og()));
7981
+ this.emit("error", dc("internal", og()));
7949
7982
  break;
7950
7983
  }
7951
7984
  this.emit("close", this);
@@ -7966,7 +7999,7 @@ class _l extends $A {
7966
7999
  this.logger.info("Waiting for reconnect delay", D({}, this.options)), yield Ge(this.options.reconnectDelay);
7967
8000
  const e = yield this.options.reconnectHandler(this.reconnectState);
7968
8001
  if (this.reconnectState.reconnectRetries++, !e)
7969
- return this._isConnectInProgress = !1, this.emit("error", La()), !1;
8002
+ return this._isConnectInProgress = !1, this.emit("error", ba()), !1;
7970
8003
  }
7971
8004
  this._connectionAttemptCount++;
7972
8005
  try {
@@ -8066,7 +8099,7 @@ const $l = 65536 * 8, Au = 0.9, tu = (i) => $l * Au * 1e3 / i, dt = class dt {
8066
8099
  if (this.contextSwitchesInProgress.has(A)) {
8067
8100
  if (!(t instanceof ArrayBuffer)) {
8068
8101
  const g = JSON.parse(t);
8069
- if (un(g) && g.type === "context switch complete") {
8102
+ if (Dn(g) && g.type === "context switch complete") {
8070
8103
  this.logger.info("context switch completed", { socketId: A }), this.emitter.emit("context switch complete"), this.contextSwitchesCompleted.add(A);
8071
8104
  return;
8072
8105
  }
@@ -8101,7 +8134,7 @@ const $l = 65536 * 8, Au = 0.9, tu = (i) => $l * Au * 1e3 / i, dt = class dt {
8101
8134
  this.emitter.emit("received data", t);
8102
8135
  else {
8103
8136
  const e = JSON.parse(t);
8104
- if (!un(e))
8137
+ if (!Dn(e))
8105
8138
  return;
8106
8139
  switch (e.type) {
8107
8140
  case "pong":
@@ -8273,14 +8306,14 @@ const _i = class _i {
8273
8306
  try {
8274
8307
  return yield this.apiClient.connect(this.config.options.getOptions());
8275
8308
  } catch (A) {
8276
- if (Or(A))
8309
+ if (Rd(A))
8277
8310
  switch (A.status) {
8278
8311
  case 401:
8279
8312
  throw this.emitter.emit("error", UB(A)), UB(A);
8280
8313
  case 403:
8281
- throw this.emitter.emit("error", Sn(A.message)), Sn(A.message);
8314
+ throw this.emitter.emit("error", mn(A.message)), mn(A.message);
8282
8315
  }
8283
- throw this.emitter.emit("error", fc(A instanceof Error ? A : void 0)), A;
8316
+ throw this.emitter.emit("error", uc(A instanceof Error ? A : void 0)), A;
8284
8317
  }
8285
8318
  }));
8286
8319
  n(this, JC, () => r(this, null, function* () {
@@ -8292,7 +8325,7 @@ const _i = class _i {
8292
8325
  })
8293
8326
  ]).then(t, t);
8294
8327
  }));
8295
- this.logger = t, this.emitter = A, this.config = e, this.apiClient = new jr({
8328
+ this.logger = t, this.emitter = A, this.config = e, this.apiClient = new Ld({
8296
8329
  publicEndpoint: this.config.options.get("url").toString(),
8297
8330
  tokenFactory: () => this.config.options.get("authenticationToken")
8298
8331
  });
@@ -8329,7 +8362,7 @@ Gt = new WeakMap(), kt = new WeakMap(), _I = new WeakMap(), zt = new WeakMap(),
8329
8362
  const Q = A.select(g.edges);
8330
8363
  if (!Q)
8331
8364
  throw new v("Failed to resolve edge url", { isFatal: !0, code: "failed_to_resolve_edge_url" });
8332
- Fa(g) ? this.connectionImpl = yield co.start(
8365
+ Ga(g) ? this.connectionImpl = yield co.start(
8333
8366
  this.emitter,
8334
8367
  this.logger,
8335
8368
  this.apiClient,
@@ -8360,7 +8393,7 @@ Gt = new WeakMap(), kt = new WeakMap(), _I = new WeakMap(), zt = new WeakMap(),
8360
8393
  if (!(yield this.config.reconnectHandler({
8361
8394
  reconnectRetries: s(this, zt)
8362
8395
  }))) {
8363
- this.emitter.emit("error", La());
8396
+ this.emitter.emit("error", ba());
8364
8397
  break;
8365
8398
  }
8366
8399
  if (yield Ge(1e3), !s(this, kt))
@@ -8370,7 +8403,7 @@ Gt = new WeakMap(), kt = new WeakMap(), _I = new WeakMap(), zt = new WeakMap(),
8370
8403
  });
8371
8404
  }, I(_i, "PING_TIMEOUT", 1e3), I(_i, "create", (A, t, e) => new _i(A, t, e));
8372
8405
  let uo = _i;
8373
- const GQ = () => ({
8406
+ const kQ = () => ({
8374
8407
  video: T(D({}, RB()), {
8375
8408
  bitRate: Fe()
8376
8409
  }),
@@ -8408,7 +8441,7 @@ const GQ = () => ({
8408
8441
  });
8409
8442
  I(this, "setUserSpecifiedCap", (A) => {
8410
8443
  var e;
8411
- const t = (e = this.getUserSpecifiedCap()) != null ? e : GQ();
8444
+ const t = (e = this.getUserSpecifiedCap()) != null ? e : kQ();
8412
8445
  this.userSpecifiedCap = T(D({}, t), {
8413
8446
  video: D(D({}, t.video), A.video),
8414
8447
  audio: D(D({}, t.audio), A.audio)
@@ -8435,7 +8468,7 @@ const GQ = () => ({
8435
8468
  });
8436
8469
  I(this, "evaluateConstraintCap", () => {
8437
8470
  var C, Q, o, a, c;
8438
- const A = this.sizeBasedResolutionCapEnabled ? T(D({}, GQ()), { video: iu() }) : GQ();
8471
+ const A = this.sizeBasedResolutionCapEnabled ? T(D({}, kQ()), { video: iu() }) : kQ();
8439
8472
  if (!this.resizeObserver) {
8440
8473
  const h = this.element.getBoundingClientRect();
8441
8474
  this.elementSize = { width: h.width, height: h.height };
@@ -8542,7 +8575,7 @@ class Zo {
8542
8575
  var g, B;
8543
8576
  let e;
8544
8577
  for (; (e = (B = (g = t.decoderContext).error) == null ? void 0 : B.call(g)) !== void 0; )
8545
- this.emitter.emit("error", Ua(!1, e));
8578
+ this.emitter.emit("error", Ra(!1, e));
8546
8579
  for (; (A = t.decoderContext.take()) !== void 0; ) {
8547
8580
  const { statistics: C } = A;
8548
8581
  C && (t.decodeTime.push(C.decodeTime), t.transportTime.push(
@@ -8729,7 +8762,7 @@ const et = class et {
8729
8762
  });
8730
8763
  I(this, "add", (A, t) => {
8731
8764
  let e = this.bytesReceived.get(A);
8732
- e || (e = new Lr(20), this.bytesReceived.set(A, e)), t > 0 && (this.lastBytesUpdated = Date.now(), this.timeoutInterval || (this.timeoutInterval = this.timers.setInterval(
8765
+ e || (e = new qr(20), this.bytesReceived.set(A, e)), t > 0 && (this.lastBytesUpdated = Date.now(), this.timeoutInterval || (this.timeoutInterval = this.timers.setInterval(
8733
8766
  this.checkTimeout,
8734
8767
  et.UPDATE_RECEIVED_BYTES_INTERVAL
8735
8768
  ))), e.add(t);
@@ -8748,7 +8781,7 @@ const et = class et {
8748
8781
  I(this, "checkTimeout", () => {
8749
8782
  const A = Date.now() - this.lastBytesUpdated;
8750
8783
  if (this.totalBytesReceived() === 0 && A > et.NO_DATA_ERROR_TIMEOUT) {
8751
- this.emitter.emit("error", yc()), this.emitter.emit("reconnect", "no incoming data"), this.clearTimeoutInterval();
8784
+ this.emitter.emit("error", lc()), this.emitter.emit("reconnect", "no incoming data"), this.clearTimeoutInterval();
8752
8785
  return;
8753
8786
  }
8754
8787
  A > et.NO_DATA_TIMEOUT && this.totalBytesReceived() > 0 && (this.emitter.emit("no data timeout", this.totalBytesReceived()), this.clearTimeoutInterval());
@@ -8779,7 +8812,7 @@ const Cu = () => window.AudioContext || window.webkitAudioContext, qC = class qC
8779
8812
  I(this, "createSplitter", () => this.context.createChannelSplitter(2));
8780
8813
  I(this, "resume", () => r(this, null, function* () {
8781
8814
  try {
8782
- return yield Promise.race([this.context.resume(), xo(1e3, Dc())]);
8815
+ return yield Promise.race([this.context.resume(), xo(1e3, cc())]);
8783
8816
  } catch (t) {
8784
8817
  throw this.suspend().catch(q), t;
8785
8818
  }
@@ -8960,85 +8993,29 @@ const vC = class vC extends $A {
8960
8993
  }
8961
8994
  get currentTime() {
8962
8995
  var t;
8963
- return !this.audio || !this.audio.isRunning || this.audio.isStuck ? this.clockSource.currentTime : this.audio.currentTime * 1e3 + ((t = this.clockDelta) != null ? t : 0);
8964
- }
8965
- set currentTime(t) {
8966
- this.logger.debug("setting current time to", { currentTime: t }), this.startTimeIsInvalidated = !0;
8967
- }
8968
- get audioNode() {
8969
- return this.splitter;
8970
- }
8971
- useMediaStreamDestination() {
8972
- var g;
8973
- const e = this.getAudioContext().getMediaStreamDestination();
8974
- return (g = this.gainNode) == null || g.connect(e), e;
8975
- }
8976
- useDefaultDestination() {
8977
- var g;
8978
- const e = this.getAudioContext().getDefaultDestination();
8979
- return (g = this.gainNode) == null || g.connect(e), e;
8980
- }
8981
- };
8982
- I(vC, "create", (t, e, g) => new vC(t, e, g));
8983
- let iC = vC;
8984
- var fe;
8985
- class _E {
8986
- constructor() {
8987
- n(this, fe, []);
8988
- E(this, fe, []);
8989
- }
8990
- addTextTrack(A, t, e) {
8991
- const g = [], B = {
8992
- kind: A,
8993
- label: t,
8994
- language: e,
8995
- mode: "disabled",
8996
- cues: g,
8997
- addCue: (C) => {
8998
- g.push(C);
8999
- },
9000
- removeCue: (C) => {
9001
- const Q = g.findIndex((o) => o === C);
9002
- Q !== -1 && g.splice(Q, 1);
9003
- }
9004
- };
9005
- return s(this, fe).push(B), B;
8996
+ return !this.audio || !this.audio.isRunning || this.audio.isStuck ? this.clockSource.currentTime : this.audio.currentTime * 1e3 + ((t = this.clockDelta) != null ? t : 0);
9006
8997
  }
9007
- set language(A) {
9008
- s(this, fe).forEach((t) => {
9009
- t.language === A ? t.mode = "showing" : t.mode = "hidden";
9010
- });
8998
+ set currentTime(t) {
8999
+ this.logger.debug("setting current time to", { currentTime: t }), this.startTimeIsInvalidated = !0;
9011
9000
  }
9012
- get language() {
9013
- var A;
9014
- return (A = s(this, fe).find((t) => t.mode === "showing")) == null ? void 0 : A.language;
9001
+ get audioNode() {
9002
+ return this.splitter;
9015
9003
  }
9016
- getActiveCues(A) {
9017
- const t = s(this, fe).find((e) => e.mode === "showing");
9018
- return t ? t.cues.filter(({ startTime: e, endTime: g }) => A >= e && A <= g) : [];
9004
+ useMediaStreamDestination() {
9005
+ var g;
9006
+ const e = this.getAudioContext().getMediaStreamDestination();
9007
+ return (g = this.gainNode) == null || g.connect(e), e;
9008
+ }
9009
+ useDefaultDestination() {
9010
+ var g;
9011
+ const e = this.getAudioContext().getDefaultDestination();
9012
+ return (g = this.gainNode) == null || g.connect(e), e;
9019
9013
  }
9020
- }
9021
- fe = new WeakMap();
9022
- const Le = (i, A) => {
9023
- let t;
9024
- for (t = A; i > 1; i--) t += A;
9025
- return t;
9026
9014
  };
9015
+ I(vC, "create", (t, e, g) => new vC(t, e, g));
9016
+ let iC = vC;
9017
+ var sB, Rt, DA, Si, _A, _E, Pi, $E;
9027
9018
  class Qu {
9028
- constructor() {
9029
- I(this, "audio");
9030
- I(this, "unmute", () => this.audio.play().catch(q));
9031
- const A = document.createElement("div");
9032
- A.innerHTML = "<audio x-webkit-airplay='deny'></audio>";
9033
- const t = A.children.item(0);
9034
- if (t instanceof HTMLAudioElement)
9035
- this.audio = t, this.audio.controls = !1, this.audio.disableRemotePlayback = !0, this.audio.preload = "auto", this.audio.src = "data:audio/mpeg;base64,//uQx" + Le(23, "A") + "WGluZwAAAA8AAAACAAACcQCA" + Le(16, "gICA") + Le(66, "/") + "8AAABhTEFNRTMuMTAwA8MAAAAAAAAAABQgJAUHQQAB9AAAAnGMHkkI" + Le(320, "A") + "//sQxAADgnABGiAAQBCqgCRMAAgEAH" + Le(15, "/") + "7+n/9FTuQsQH//////2NG0jWUGlio5gLQTOtIoeR2WX////X4s9Atb/JRVCbBUpeRUq" + Le(18, "/") + "9RUi0f2jn/+xDECgPCjAEQAABN4AAANIAAAAQVTEFNRTMuMTAw" + Le(97, "V") + "Q==", this.audio.loop = !1, this.audio.load();
9036
- else
9037
- throw new Error("Failed to create audio tag");
9038
- }
9039
- }
9040
- var sB, Rt, DA, Si, _A, $E, Pi, Ar;
9041
- class ou {
9042
9019
  constructor() {
9043
9020
  n(this, _A);
9044
9021
  n(this, sB, []);
@@ -9064,7 +9041,7 @@ class ou {
9064
9041
  }
9065
9042
  render(A, t = !1) {
9066
9043
  const e = s(this, sB).flatMap((Q) => Q.text.split(`
9067
- `).flatMap((a) => d(this, _A, Ar).call(this, a, A.width)).map((a) => {
9044
+ `).flatMap((a) => d(this, _A, $E).call(this, a, A.width)).map((a) => {
9068
9045
  d(this, _A, Pi).call(this);
9069
9046
  const c = s(this, DA).measureText(a);
9070
9047
  return {
@@ -9077,17 +9054,17 @@ class ou {
9077
9054
  };
9078
9055
  })), g = Math.max(...e.map((Q) => Q.size.width)), B = e.reduce((Q, { size: o }) => Q + o.height, 0) + (e.length - 1) * this.config.lineGap;
9079
9056
  let C = 0;
9080
- d(this, _A, $E).call(this, g, B), s(this, DA).clearRect(0, 0, s(this, Rt).width, s(this, Rt).height);
9057
+ d(this, _A, _E).call(this, g, B), s(this, DA).clearRect(0, 0, s(this, Rt).width, s(this, Rt).height);
9081
9058
  for (const { size: Q, text: o } of e)
9082
9059
  d(this, _A, Pi).call(this), s(this, DA).fillStyle = this.config.backgroundColor, s(this, DA).fillRect(0, C, Q.width, Q.height), d(this, _A, Pi).call(this), s(this, DA).fillText(o, this.config.textPadding, C + this.config.textPadding), C += Q.height + this.config.lineGap;
9083
9060
  t && (s(this, DA).strokeStyle = "red", s(this, DA).strokeRect(0, 0, A.width, s(this, Rt).height));
9084
9061
  }
9085
9062
  }
9086
- sB = new WeakMap(), Rt = new WeakMap(), DA = new WeakMap(), Si = new WeakMap(), _A = new WeakSet(), $E = function(A, t) {
9063
+ sB = new WeakMap(), Rt = new WeakMap(), DA = new WeakMap(), Si = new WeakMap(), _A = new WeakSet(), _E = function(A, t) {
9087
9064
  s(this, Rt).width = A * s(this, Si), s(this, Rt).height = t * s(this, Si), s(this, DA).scale(s(this, Si), s(this, Si)), this.canvas.style.width = `${A}px`, this.canvas.style.height = `${t}px`;
9088
9065
  }, Pi = function() {
9089
9066
  s(this, DA).fillStyle = "white", s(this, DA).textAlign = "left", s(this, DA).textBaseline = "top", s(this, DA).font = `${this.config.fontSize} sans-serif`;
9090
- }, Ar = function(A, t) {
9067
+ }, $E = function(A, t) {
9091
9068
  const e = [], g = A.split(" ");
9092
9069
  let B = "";
9093
9070
  for (; g.length > 0; ) {
@@ -9103,7 +9080,7 @@ sB = new WeakMap(), Rt = new WeakMap(), DA = new WeakMap(), Si = new WeakMap(),
9103
9080
  }
9104
9081
  return e;
9105
9082
  };
9106
- const nu = `
9083
+ const ou = `
9107
9084
  precision mediump float;
9108
9085
  uniform sampler2D texture;
9109
9086
 
@@ -9115,7 +9092,7 @@ void main() {
9115
9092
 
9116
9093
  gl_FragColor = vec4(y, y, y, a);
9117
9094
  }
9118
- `, au = `
9095
+ `, nu = `
9119
9096
  attribute vec2 position;
9120
9097
  varying vec2 texture_coordinate;
9121
9098
  uniform mat4 model;
@@ -9124,7 +9101,7 @@ void main() {
9124
9101
  texture_coordinate = position;
9125
9102
  gl_Position = model * vec4(position, 0.0, 1.0);
9126
9103
  }
9127
- `, vn = (i, A) => {
9104
+ `, Kn = (i, A) => {
9128
9105
  let t = i.getContext("webgl", A);
9129
9106
  if (t || (t = i.getContext("experimental-webgl", A)), !t)
9130
9107
  throw new v("Failed to create webgl context", {
@@ -9152,7 +9129,7 @@ void main() {
9152
9129
  code: "failed_to_create_texture"
9153
9130
  });
9154
9131
  return i.bindTexture(i.TEXTURE_2D, A), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.NEAREST), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, i.NEAREST), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), A;
9155
- }, Kn = (i, A) => {
9132
+ }, Yn = (i, A) => {
9156
9133
  const t = i.createBuffer();
9157
9134
  if (!t)
9158
9135
  throw new v("Failed to create buffer", {
@@ -9176,8 +9153,8 @@ void main() {
9176
9153
  }
9177
9154
  return e;
9178
9155
  };
9179
- var KC, W, BB, CB, QB, pe, ig, tr, er, YC;
9180
- class Eu {
9156
+ var KC, W, BB, CB, QB, fe, ig, Ar, tr, YC;
9157
+ class au {
9181
9158
  constructor(A) {
9182
9159
  n(this, ig);
9183
9160
  n(this, KC, 96);
@@ -9185,9 +9162,9 @@ class Eu {
9185
9162
  n(this, BB);
9186
9163
  n(this, CB);
9187
9164
  n(this, QB);
9188
- n(this, pe);
9189
- I(this, "subtitleRenderer", new ou());
9190
- // prettier-ignore
9165
+ n(this, fe);
9166
+ I(this, "subtitleRenderer", new Qu());
9167
+ // biome-ignore format: special formatting
9191
9168
  n(this, YC, (A, t, e, g) => [
9192
9169
  A,
9193
9170
  0,
@@ -9206,14 +9183,14 @@ class Eu {
9206
9183
  0,
9207
9184
  1
9208
9185
  ]);
9209
- E(this, W, A), E(this, BB, ve(A)), E(this, CB, xi(A, A.FRAGMENT_SHADER, nu)), E(this, QB, xi(A, A.VERTEX_SHADER, au)), E(this, pe, fo(A, s(this, QB), s(this, CB))), this.subtitleRenderer.config.fontSize = "64px";
9186
+ E(this, W, A), E(this, BB, ve(A)), E(this, CB, xi(A, A.FRAGMENT_SHADER, ou)), E(this, QB, xi(A, A.VERTEX_SHADER, nu)), E(this, fe, fo(A, s(this, QB), s(this, CB))), this.subtitleRenderer.config.fontSize = "64px";
9210
9187
  }
9211
9188
  setActiveCues(A, t) {
9212
9189
  this.subtitleRenderer.setActiveCues(A), this.subtitleRenderer.render(t);
9213
9190
  }
9214
9191
  render(A) {
9215
9192
  const t = this.subtitleRenderer.canvas, e = (A.padding + s(this, KC)) * window.devicePixelRatio;
9216
- t.width !== 0 && (s(this, W).useProgram(s(this, pe)), d(this, ig, tr).call(this), d(this, ig, er).call(this, this.subtitleRenderer.canvas.width / A.width, this.subtitleRenderer.canvas.height / A.height, -this.subtitleRenderer.canvas.width / A.width / 2, -(1 - (this.subtitleRenderer.canvas.height + e) / A.height)), s(this, W).uniform1i(s(this, W).getUniformLocation(s(this, pe), "texture"), 4), s(this, W).activeTexture(s(this, W).TEXTURE4), s(this, W).bindTexture(s(this, W).TEXTURE_2D, s(this, BB)), s(this, W).enable(s(this, W).BLEND), s(this, W).blendFunc(s(this, W).SRC_ALPHA, s(this, W).ONE_MINUS_SRC_ALPHA), s(this, W).texImage2D(
9193
+ t.width !== 0 && (s(this, W).useProgram(s(this, fe)), d(this, ig, Ar).call(this), d(this, ig, tr).call(this, this.subtitleRenderer.canvas.width / A.width, this.subtitleRenderer.canvas.height / A.height, -this.subtitleRenderer.canvas.width / A.width / 2, -(1 - (this.subtitleRenderer.canvas.height + e) / A.height)), s(this, W).uniform1i(s(this, W).getUniformLocation(s(this, fe), "texture"), 4), s(this, W).activeTexture(s(this, W).TEXTURE4), s(this, W).bindTexture(s(this, W).TEXTURE_2D, s(this, BB)), s(this, W).enable(s(this, W).BLEND), s(this, W).blendFunc(s(this, W).SRC_ALPHA, s(this, W).ONE_MINUS_SRC_ALPHA), s(this, W).texImage2D(
9217
9194
  s(this, W).TEXTURE_2D,
9218
9195
  0,
9219
9196
  s(this, W).RGBA,
@@ -9223,14 +9200,14 @@ class Eu {
9223
9200
  ), s(this, W).texParameteri(s(this, W).TEXTURE_2D, s(this, W).TEXTURE_MAG_FILTER, s(this, W).LINEAR), s(this, W).drawArrays(s(this, W).TRIANGLE_STRIP, 0, 4));
9224
9201
  }
9225
9202
  }
9226
- KC = new WeakMap(), W = new WeakMap(), BB = new WeakMap(), CB = new WeakMap(), QB = new WeakMap(), pe = new WeakMap(), ig = new WeakSet(), tr = function() {
9227
- const A = s(this, W).getAttribLocation(s(this, pe), "position");
9203
+ KC = new WeakMap(), W = new WeakMap(), BB = new WeakMap(), CB = new WeakMap(), QB = new WeakMap(), fe = new WeakMap(), ig = new WeakSet(), Ar = function() {
9204
+ const A = s(this, W).getAttribLocation(s(this, fe), "position");
9228
9205
  s(this, W).enableVertexAttribArray(A), s(this, W).vertexAttribPointer(A, 2, s(this, W).FLOAT, !1, 0, 0);
9229
- }, er = function(A, t, e, g) {
9230
- const B = s(this, W).getUniformLocation(s(this, pe), "model");
9206
+ }, tr = function(A, t, e, g) {
9207
+ const B = s(this, W).getUniformLocation(s(this, fe), "model");
9231
9208
  s(this, W).uniformMatrix4fv(B, !1, s(this, YC).call(this, A, t, e, g));
9232
9209
  }, YC = new WeakMap();
9233
- const Yn = `
9210
+ const Tn = `
9234
9211
  precision mediump float;
9235
9212
  uniform sampler2D y_texture;
9236
9213
  uniform sampler2D u_texture;
@@ -9246,7 +9223,7 @@ void main() {
9246
9223
 
9247
9224
  gl_FragColor = vec4(y, u, v, 1) * conversion;
9248
9225
  }
9249
- `, Tn = `
9226
+ `, Pn = `
9250
9227
  attribute vec2 position;
9251
9228
  varying vec2 texture_coordinate;
9252
9229
  uniform mat4 model;
@@ -9255,12 +9232,12 @@ void main() {
9255
9232
  texture_coordinate = position;
9256
9233
  gl_Position = model * vec4(position, 0.0, 1.0);
9257
9234
  }
9258
- `, Pn = {
9235
+ `, xn = {
9259
9236
  width: 256,
9260
9237
  codedWidth: 256,
9261
9238
  height: 144,
9262
9239
  codedHeight: 144
9263
- }, xn = {
9240
+ }, Wn = {
9264
9241
  preserveDrawingBuffer: !1,
9265
9242
  alpha: !1,
9266
9243
  depth: !1,
@@ -9271,10 +9248,10 @@ void main() {
9271
9248
  constructor() {
9272
9249
  super();
9273
9250
  I(this, "canvas", document.createElement("canvas"));
9274
- I(this, "context", vn(this.canvas, xn));
9275
- I(this, "pixelShader", xi(this.context, this.context.FRAGMENT_SHADER, Yn));
9276
- I(this, "vertexShader", xi(this.context, this.context.VERTEX_SHADER, Tn));
9277
- I(this, "buffer", Kn(this.context, Kg.SQUARE_VERTICES));
9251
+ I(this, "context", Kn(this.canvas, Wn));
9252
+ I(this, "pixelShader", xi(this.context, this.context.FRAGMENT_SHADER, Tn));
9253
+ I(this, "vertexShader", xi(this.context, this.context.VERTEX_SHADER, Pn));
9254
+ I(this, "buffer", Yn(this.context, Kg.SQUARE_VERTICES));
9278
9255
  I(this, "program", fo(this.context, this.vertexShader, this.pixelShader));
9279
9256
  I(this, "textures", {
9280
9257
  y: ve(this.context),
@@ -9283,21 +9260,21 @@ void main() {
9283
9260
  });
9284
9261
  // Lazy loaded when needed
9285
9262
  I(this, "textRenderer");
9286
- I(this, "size", Pn);
9263
+ I(this, "size", xn);
9287
9264
  I(this, "onContextLost", (t) => {
9288
9265
  this.textRenderer = void 0;
9289
9266
  const e = new Error(t instanceof WebGLContextEvent ? t.statusMessage : "webgl context lost");
9290
- this.emit("context lost", pc(e)), t.preventDefault();
9267
+ this.emit("context lost", wc(e)), t.preventDefault();
9291
9268
  });
9292
9269
  I(this, "onContextRestored", () => {
9293
- this.emit("context restored"), this.context = vn(this.canvas, xn), this.pixelShader = xi(this.context, this.context.FRAGMENT_SHADER, Yn), this.vertexShader = xi(this.context, this.context.VERTEX_SHADER, Tn), this.buffer = Kn(this.context, Kg.SQUARE_VERTICES), this.program = fo(this.context, this.vertexShader, this.pixelShader), this.textures = {
9270
+ this.emit("context restored"), this.context = Kn(this.canvas, Wn), this.pixelShader = xi(this.context, this.context.FRAGMENT_SHADER, Tn), this.vertexShader = xi(this.context, this.context.VERTEX_SHADER, Pn), this.buffer = Yn(this.context, Kg.SQUARE_VERTICES), this.program = fo(this.context, this.vertexShader, this.pixelShader), this.textures = {
9294
9271
  y: ve(this.context),
9295
9272
  u: ve(this.context),
9296
9273
  v: ve(this.context)
9297
9274
  }, this.load();
9298
9275
  });
9299
9276
  I(this, "load", () => {
9300
- this.context.useProgram(this.program), this.setupPositionVertexAttributes(), this.setSize(Pn), this.context.uniform1i(this.context.getUniformLocation(this.program, "y_texture"), 0), this.context.uniform1i(this.context.getUniformLocation(this.program, "u_texture"), 1), this.context.uniform1i(this.context.getUniformLocation(this.program, "v_texture"), 2), this.setConversionMatrix(this.rec709());
9277
+ this.context.useProgram(this.program), this.setupPositionVertexAttributes(), this.setSize(xn), this.context.uniform1i(this.context.getUniformLocation(this.program, "y_texture"), 0), this.context.uniform1i(this.context.getUniformLocation(this.program, "u_texture"), 1), this.context.uniform1i(this.context.getUniformLocation(this.program, "v_texture"), 2), this.setConversionMatrix(this.rec709());
9301
9278
  });
9302
9279
  I(this, "unload", () => {
9303
9280
  var e;
@@ -9343,7 +9320,7 @@ void main() {
9343
9320
  const e = this.context.getUniformLocation(this.program, "conversion");
9344
9321
  this.context.uniformMatrix4fv(e, !1, t);
9345
9322
  });
9346
- // prettier-ignore
9323
+ // biome-ignore format: special formatting
9347
9324
  I(this, "transformMatrix", (t, e) => [
9348
9325
  2 / t,
9349
9326
  0,
@@ -9362,7 +9339,7 @@ void main() {
9362
9339
  0,
9363
9340
  1
9364
9341
  ]);
9365
- // prettier-ignore
9342
+ // biome-ignore format: special formatting
9366
9343
  I(this, "rec709", () => [
9367
9344
  1.16438,
9368
9345
  0,
@@ -9381,7 +9358,7 @@ void main() {
9381
9358
  0,
9382
9359
  1
9383
9360
  ]);
9384
- // prettier-ignore
9361
+ // biome-ignore format: special formatting
9385
9362
  I(this, "rec601", () => [
9386
9363
  1.16438,
9387
9364
  0,
@@ -9403,7 +9380,7 @@ void main() {
9403
9380
  this.canvas.addEventListener("webglcontextlost", this.onContextLost), this.canvas.addEventListener("webglcontextrestored", this.onContextRestored, !1), this.canvas.style.width = "100%", this.canvas.style.position = "relative";
9404
9381
  }
9405
9382
  getTextRenderer() {
9406
- return this.textRenderer || (this.textRenderer = new Eu(this.context)), this.textRenderer;
9383
+ return this.textRenderer || (this.textRenderer = new au(this.context)), this.textRenderer;
9407
9384
  }
9408
9385
  };
9409
9386
  I(Kg, "SQUARE_VERTICES", new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]));
@@ -9476,6 +9453,62 @@ const TC = class TC {
9476
9453
  };
9477
9454
  I(TC, "create", (A, t, e, g) => new TC(A, t, e, g));
9478
9455
  let IC = TC;
9456
+ var pe;
9457
+ class er {
9458
+ constructor() {
9459
+ n(this, pe, []);
9460
+ E(this, pe, []);
9461
+ }
9462
+ addTextTrack(A, t, e) {
9463
+ const g = [], B = {
9464
+ kind: A,
9465
+ label: t,
9466
+ language: e,
9467
+ mode: "disabled",
9468
+ cues: g,
9469
+ addCue: (C) => {
9470
+ g.push(C);
9471
+ },
9472
+ removeCue: (C) => {
9473
+ const Q = g.findIndex((o) => o === C);
9474
+ Q !== -1 && g.splice(Q, 1);
9475
+ }
9476
+ };
9477
+ return s(this, pe).push(B), B;
9478
+ }
9479
+ set language(A) {
9480
+ s(this, pe).forEach((t) => {
9481
+ t.language === A ? t.mode = "showing" : t.mode = "hidden";
9482
+ });
9483
+ }
9484
+ get language() {
9485
+ var A;
9486
+ return (A = s(this, pe).find((t) => t.mode === "showing")) == null ? void 0 : A.language;
9487
+ }
9488
+ getActiveCues(A) {
9489
+ const t = s(this, pe).find((e) => e.mode === "showing");
9490
+ return t ? t.cues.filter(({ startTime: e, endTime: g }) => A >= e && A <= g) : [];
9491
+ }
9492
+ }
9493
+ pe = new WeakMap();
9494
+ const Le = (i, A) => {
9495
+ let t;
9496
+ for (t = A; i > 1; i--) t += A;
9497
+ return t;
9498
+ };
9499
+ class Eu {
9500
+ constructor() {
9501
+ I(this, "audio");
9502
+ I(this, "unmute", () => this.audio.play().catch(q));
9503
+ const A = document.createElement("div");
9504
+ A.innerHTML = "<audio x-webkit-airplay='deny'></audio>";
9505
+ const t = A.children.item(0);
9506
+ if (t instanceof HTMLAudioElement)
9507
+ this.audio = t, this.audio.controls = !1, this.audio.disableRemotePlayback = !0, this.audio.preload = "auto", this.audio.src = "data:audio/mpeg;base64,//uQx" + Le(23, "A") + "WGluZwAAAA8AAAACAAACcQCA" + Le(16, "gICA") + Le(66, "/") + "8AAABhTEFNRTMuMTAwA8MAAAAAAAAAABQgJAUHQQAB9AAAAnGMHkkI" + Le(320, "A") + "//sQxAADgnABGiAAQBCqgCRMAAgEAH" + Le(15, "/") + "7+n/9FTuQsQH//////2NG0jWUGlio5gLQTOtIoeR2WX////X4s9Atb/JRVCbBUpeRUq" + Le(18, "/") + "9RUi0f2jn/+xDECgPCjAEQAABN4AAANIAAAAQVTEFNRTMuMTAw" + Le(97, "V") + "Q==", this.audio.loop = !1, this.audio.load();
9508
+ else
9509
+ throw new Error("Failed to create audio tag");
9510
+ }
9511
+ }
9479
9512
  const PC = class PC {
9480
9513
  constructor(A, t, e, g, B) {
9481
9514
  I(this, "logger");
@@ -9483,11 +9516,11 @@ const PC = class PC {
9483
9516
  I(this, "audioPlayer");
9484
9517
  I(this, "videoPlayer");
9485
9518
  I(this, "pool");
9486
- I(this, "unmuter", new Qu());
9519
+ I(this, "unmuter", new Eu());
9487
9520
  I(this, "_isPaused", !1);
9488
9521
  I(this, "isDisconnected", !1);
9489
9522
  I(this, "timers", new mA());
9490
- I(this, "textTracks", new _E());
9523
+ I(this, "textTracks", new er());
9491
9524
  I(this, "playbackRate");
9492
9525
  I(this, "reset", () => {
9493
9526
  });
@@ -9521,7 +9554,7 @@ const PC = class PC {
9521
9554
  try {
9522
9555
  this.audioPlayer.onDecodedFrame(A);
9523
9556
  } catch (t) {
9524
- t instanceof Error && this.emitter.emit("error", Na(!1, t));
9557
+ t instanceof Error && this.emitter.emit("error", Ua(!1, t));
9525
9558
  }
9526
9559
  this.videoPlayer.onDecodedFrame(A);
9527
9560
  });
@@ -9602,7 +9635,7 @@ const xC = class xC {
9602
9635
  I(this, "_userProvidedMuted", !1);
9603
9636
  I(this, "timers", new mA());
9604
9637
  I(this, "volumeState");
9605
- I(this, "textTracks", new _E());
9638
+ I(this, "textTracks", new er());
9606
9639
  I(this, "reset", () => {
9607
9640
  });
9608
9641
  I(this, "load", () => {
@@ -9644,7 +9677,7 @@ const xC = class xC {
9644
9677
  try {
9645
9678
  this.audioPlayer.onDecodedFrame(A);
9646
9679
  } catch (t) {
9647
- t instanceof Error && this.emitter.emit("error", Na(!1, t));
9680
+ t instanceof Error && this.emitter.emit("error", Ua(!1, t));
9648
9681
  }
9649
9682
  this.videoPlayer.onDecodedFrame(A);
9650
9683
  });
@@ -9736,7 +9769,7 @@ const xC = class xC {
9736
9769
  };
9737
9770
  I(xC, "create", (A, t, e, g, B) => new xC(A, t, e, g, B));
9738
9771
  let Go = xC;
9739
- const ru = () => (i) => ir(i.buffered.start(0), i.buffered.end(i.buffered.length - 1)), ir = (i, A) => (t) => t.remove(Math.max(0, i), Math.min(Number.POSITIVE_INFINITY, A)), Wn = (i) => (A) => A.appendBuffer(i), cu = (i) => (A) => A.changeType(i), hu = (i) => (A) => i(A);
9772
+ const ru = () => (i) => ir(i.buffered.start(0), i.buffered.end(i.buffered.length - 1)), ir = (i, A) => (t) => t.remove(Math.max(0, i), Math.min(Number.POSITIVE_INFINITY, A)), On = (i) => (A) => A.appendBuffer(i), cu = (i) => (A) => A.changeType(i), hu = (i) => (A) => i(A);
9740
9773
  class du {
9741
9774
  constructor(A) {
9742
9775
  I(this, "commandQueue", []);
@@ -9748,10 +9781,10 @@ class du {
9748
9781
  });
9749
9782
  I(this, "appendBuffer", (A, t) => new Promise((e, g) => {
9750
9783
  if (t && this.currentInit !== t) {
9751
- const C = new Mi(Wn(t), e, g);
9784
+ const C = new Mi(On(t), e, g);
9752
9785
  this.commandQueue.push(C), this.currentInit = t;
9753
9786
  }
9754
- const B = new Mi(Wn(A), e, g);
9787
+ const B = new Mi(On(A), e, g);
9755
9788
  this.commandQueue.push(B), this.handleQueue();
9756
9789
  }));
9757
9790
  I(this, "execute", (A) => new Promise((t, e) => {
@@ -9864,7 +9897,7 @@ function lu(i, { mediaSource: A, mimeType: t, codec: e }) {
9864
9897
  lastBufferCleanupTime: Date.now()
9865
9898
  });
9866
9899
  }
9867
- function On({
9900
+ function Vn({
9868
9901
  initSegments: i,
9869
9902
  pendingSamples: A
9870
9903
  }) {
@@ -9930,7 +9963,7 @@ const WC = class WC {
9930
9963
  const g = (Q = (C = A.get(e)) == null ? void 0 : C.pendingSamples) != null ? Q : [], B = (o = A.get(e)) == null ? void 0 : o.initSegments;
9931
9964
  for (; g.length > 0 && !((a = g[0]) != null && a.isSync); )
9932
9965
  g.shift();
9933
- this.trackContexts.set(e, On({ pendingSamples: g, initSegments: B }));
9966
+ this.trackContexts.set(e, Vn({ pendingSamples: g, initSegments: B }));
9934
9967
  });
9935
9968
  });
9936
9969
  I(this, "setSourceBuffers", (A) => r(this, null, function* () {
@@ -9952,7 +9985,7 @@ const WC = class WC {
9952
9985
  }
9953
9986
  for (const e of A) {
9954
9987
  let g = this.trackContexts.get(e.type);
9955
- g || (g = On({ pendingSamples: [], initSegments: new gr() }), this.trackContexts.set(e.type, g)), g.state === "initialized" ? e.mimeType !== g.mimeType && (yield g.sourceBuffer.changeType(e.mimeType)) : this.trackContexts.set(
9988
+ g || (g = Vn({ pendingSamples: [], initSegments: new gr() }), this.trackContexts.set(e.type, g)), g.state === "initialized" ? e.mimeType !== g.mimeType && (yield g.sourceBuffer.changeType(e.mimeType)) : this.trackContexts.set(
9956
9989
  e.type,
9957
9990
  lu(g, {
9958
9991
  mimeType: e.mimeType,
@@ -9986,7 +10019,7 @@ const WC = class WC {
9986
10019
  if (!e)
9987
10020
  throw cB(A.type, A.renditionId);
9988
10021
  e.state === "initialized" && (e.mimeType = t);
9989
- const g = od({
10022
+ const g = id({
9990
10023
  codec: A.codec,
9991
10024
  timescale: A.timescale,
9992
10025
  initData: A.data
@@ -10002,11 +10035,11 @@ const WC = class WC {
10002
10035
  if (this.mediaSource.isClosed())
10003
10036
  return;
10004
10037
  if (!B)
10005
- throw uc(e.renditionId, e.channelId);
10038
+ throw Ec(e.renditionId, e.channelId);
10006
10039
  if (!g)
10007
10040
  throw cB(e.type, e.renditionId);
10008
10041
  if (g.state === "uninitialized")
10009
- throw wc(e.type, e.renditionId);
10042
+ throw rc(e.type, e.renditionId);
10010
10043
  if (t) {
10011
10044
  const o = (e.timestamp + ((Q = e.compositionTimeOffset) != null ? Q : 0)) / e.timescale;
10012
10045
  yield g.sourceBuffer.removeBuffer(o, Number.POSITIVE_INFINITY);
@@ -10026,7 +10059,7 @@ const WC = class WC {
10026
10059
  for (const a of A)
10027
10060
  "initData" in a && (yield g.sourceBuffer.appendBuffer(a.data, a.initData));
10028
10061
  else {
10029
- const a = hd(A, o++);
10062
+ const a = Qd(A, o++);
10030
10063
  yield g.sourceBuffer.appendBuffer(a);
10031
10064
  }
10032
10065
  g.sequenceNumber = o, g.consecutiveQuotaExceededErrorCount = 0, g.successfulAppendCalls++;
@@ -10087,11 +10120,11 @@ const WC = class WC {
10087
10120
  if (t.isWorkingOnPendingSamples = !1, e instanceof Error) {
10088
10121
  if (this.logger.error("append failed", { message: e.message, name: e.name }), e instanceof DOMException && e.code === DOMException.QUOTA_EXCEEDED_ERR) {
10089
10122
  if (t.consecutiveQuotaExceededErrorCount >= this.minConsecutiveErrorsBeforeEmit) {
10090
- const g = Dn(!1, e, t.consecutiveQuotaExceededErrorCount, A.type);
10123
+ const g = Sn(!1, e, t.consecutiveQuotaExceededErrorCount, A.type);
10091
10124
  this.emitter.emit("error", g);
10092
10125
  }
10093
10126
  } else {
10094
- const g = Dn(!1, e, t.consecutiveQuotaExceededErrorCount, A.type);
10127
+ const g = Sn(!1, e, t.consecutiveQuotaExceededErrorCount, A.type);
10095
10128
  this.emitter.emit("error", g);
10096
10129
  }
10097
10130
  this.mediaElement.error && this.onSourceEnded();
@@ -10105,7 +10138,7 @@ const WC = class WC {
10105
10138
  I(this, "onSourceEnded", () => {
10106
10139
  const { error: A } = this.mediaElement;
10107
10140
  if (A) {
10108
- const t = /AUDIO_RENDERER/.test(A.message) || !this.autoRecoverFromMediaErrors, e = lc(t, A);
10141
+ const t = /AUDIO_RENDERER/.test(A.message) || !this.autoRecoverFromMediaErrors, e = ac(t, A);
10109
10142
  if (this.logger.error("MediaElement error", { error: e }), this.emitter.emit("error", e), !e.isFatal()) {
10110
10143
  this.logger.info("Re-opening MediaSource"), this.emitter.emit("recovered from media error", { error: e, count: this.recoveredFromErrorCount }), this.recoveredFromErrorCount++;
10111
10144
  const g = !this.mediaElement.paused, B = [];
@@ -10124,7 +10157,7 @@ I(WC, "create", (A, t, e) => {
10124
10157
  return g.setTrackContexts(), g.mediaSource.on("source ended", g.onSourceEnded), g.mediaSource.on("source open", g.onSourceOpen), g.mediaSource.attach(e), g;
10125
10158
  });
10126
10159
  let ko = WC;
10127
- const Vn = (i, A) => {
10160
+ const Zn = (i, A) => {
10128
10161
  var Q;
10129
10162
  const t = i.renditionId !== A.renditionId, e = i.channelId !== A.channelId, g = ((Q = i.timestamp) != null ? Q : 0) > A.timestamp, B = i.type === "video" && A.type === "video" && "levelIdc" in i && "levelIdc" in A && i.levelIdc !== A.levelIdc;
10130
10163
  let C = !1;
@@ -10137,7 +10170,7 @@ const Vn = (i, A) => {
10137
10170
  g = Q;
10138
10171
  const o = i.pendingSamples[Q], a = i.pendingSamples[Q + 1];
10139
10172
  if (o && (e.push(o), a)) {
10140
- if (Vn(o, a))
10173
+ if (Zn(o, a))
10141
10174
  break;
10142
10175
  const c = (o.timestamp + o.duration) / o.timescale;
10143
10176
  if (a.timestamp / a.timescale - c > 0.1)
@@ -10149,7 +10182,7 @@ const Vn = (i, A) => {
10149
10182
  const B = e[0];
10150
10183
  if (!B)
10151
10184
  break;
10152
- const C = i.previousSample ? Vn(i.previousSample, B) : !0;
10185
+ const C = i.previousSample ? Zn(i.previousSample, B) : !0;
10153
10186
  yield A(e, C), i.pendingSamples = i.pendingSamples.slice(g + 1), i.previousSample = e[e.length - 1];
10154
10187
  }
10155
10188
  i.isWorkingOnPendingSamples = !1;
@@ -10177,7 +10210,6 @@ const Vn = (i, A) => {
10177
10210
  I(this, "getStatistics", () => ({
10178
10211
  isPictureInPictureActive: this.isPictureInPictureActive()
10179
10212
  }));
10180
- /* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-call */
10181
10213
  I(this, "requestStandardPictureInPicture", () => r(this, null, function* () {
10182
10214
  return yield this.element.requestPictureInPicture();
10183
10215
  }));
@@ -10193,7 +10225,6 @@ const Vn = (i, A) => {
10193
10225
  I(this, "isWebkitPresentationModeSupported", () => !!this.element && !!this.element.webkitSetPresentationMode);
10194
10226
  this.emitter = A, this.logger = t, this.emitter.on("add picture in picture listener", this.onEnablePictureInPicture);
10195
10227
  }
10196
- /* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-call */
10197
10228
  };
10198
10229
  I(OC, "create", (A, t) => new OC(A, t));
10199
10230
  let Ro = OC;
@@ -10317,8 +10348,8 @@ const No = () => ({
10317
10348
  return A;
10318
10349
  });
10319
10350
  I(this, "bufferingEventsLast", (A) => this.metrics.general.bufferingRanges.filter((t) => t.start >= Date.now() - A).length);
10320
- I(this, "timeSpentBufferingLast", (A) => dn(this.metrics.general.bufferingRanges, A));
10321
- I(this, "timeSpentActiveLast", (A) => dn(this.metrics.general.activeRanges, A));
10351
+ I(this, "timeSpentBufferingLast", (A) => ln(this.metrics.general.bufferingRanges, A));
10352
+ I(this, "timeSpentActiveLast", (A) => ln(this.metrics.general.activeRanges, A));
10322
10353
  I(this, "timeSpentPlayingInAtLeastLevelRatio", (A) => {
10323
10354
  var o, a, c, h;
10324
10355
  const t = this.timeSpentBuffering(), e = this.timeActive(), g = this.bufferingRatios(), B = this.activeRatios(), C = ((a = (o = A.video) == null ? void 0 : o.bitRate) != null ? a : 0) + ((h = (c = A.audio) == null ? void 0 : c.bitRate) != null ? h : 0), Q = t / e;
@@ -10374,7 +10405,7 @@ const No = () => ({
10374
10405
  const t = this.metrics.levels[(e = this.currentLevel) != null ? e : 0];
10375
10406
  t && (t.decodeRate = A);
10376
10407
  });
10377
- I(this, "calculateLinearRegression", () => br(
10408
+ I(this, "calculateLinearRegression", () => Hr(
10378
10409
  this.bufferFullness.items().map((A, t) => ({
10379
10410
  x: t,
10380
10411
  y: A
@@ -10568,7 +10599,7 @@ const ng = (i) => JSON.parse(JSON.stringify(i)), Du = 1e4, jC = class jC {
10568
10599
  });
10569
10600
  I(this, "isNewSubscription", () => {
10570
10601
  const A = ["burstMs", "meta", "initiator", "channelGroupId"];
10571
- return !Ni(hn(this.currentSubscription, A), hn(this.targetSubscription, A));
10602
+ return !Ni(dn(this.currentSubscription, A), dn(this.targetSubscription, A));
10572
10603
  });
10573
10604
  I(this, "onSubscriptionChanged", ({ to: A, reset: t }) => {
10574
10605
  this.logger.debug("onSubscriptionChanged", { to: A, reset: t }), t ? this.targetSubscription = ng(this.currentSubscription) : this.currentSubscription = ng(A), this._isSwitchingSubscription = this.isNewSubscription();
@@ -10591,7 +10622,7 @@ const ng = (i) => JSON.parse(JSON.stringify(i)), Du = 1e4, jC = class jC {
10591
10622
  };
10592
10623
  I(jC, "create", (A, t, e) => new jC(A, e, t));
10593
10624
  let Jo = jC;
10594
- const Zn = 5e3, Su = () => ma() || eQ() || pr(), Xn = () => Su() ? 100 : 0, jn = (i) => (A) => A > i, zC = class zC {
10625
+ const Xn = 5e3, Su = () => ya() || iQ() || Ur(), jn = () => Su() ? 100 : 0, zn = (i) => (A) => A > i, zC = class zC {
10595
10626
  constructor(A, t, e, g, B) {
10596
10627
  I(this, "emitter");
10597
10628
  I(this, "logger");
@@ -10623,8 +10654,8 @@ const Zn = 5e3, Su = () => ma() || eQ() || pr(), Xn = () => Su() ? 100 : 0, jn =
10623
10654
  maxBehind: 50,
10624
10655
  multiplier: 1,
10625
10656
  maxBehindAllowed: 600,
10626
- overshoot: Xn(),
10627
- minOvershootAllowed: Xn(),
10657
+ overshoot: jn(),
10658
+ minOvershootAllowed: jn(),
10628
10659
  maxOvershootAllowed: 500
10629
10660
  });
10630
10661
  /**
@@ -10720,7 +10751,7 @@ const Zn = 5e3, Su = () => ma() || eQ() || pr(), Xn = () => Su() ? 100 : 0, jn =
10720
10751
  var g;
10721
10752
  if (!A.channelId)
10722
10753
  throw new Error("Sample must be assigned to a channel");
10723
- this.currentChannelId || (this.currentChannelId = A.channelId), this.timestampOffset || (this.timestampOffset = A.timestamp / A.timescale * 1e3 - Zn);
10754
+ this.currentChannelId || (this.currentChannelId = A.channelId), this.timestampOffset || (this.timestampOffset = A.timestamp / A.timescale * 1e3 - Xn);
10724
10755
  const t = A.type === "video" && A.isSync;
10725
10756
  if (this.currentChannelId !== A.channelId) {
10726
10757
  let B = Number.MAX_SAFE_INTEGER;
@@ -10743,7 +10774,7 @@ const Zn = 5e3, Su = () => ma() || eQ() || pr(), Xn = () => Su() ? 100 : 0, jn =
10743
10774
  const e = t.mediaType();
10744
10775
  if (!e)
10745
10776
  throw new Error("Fragment must have a media type");
10746
- this.timestampOffset || (this.timestampOffset = t.baseMediaDecodeTime() / t.timescale() * 1e3 - Zn);
10777
+ this.timestampOffset || (this.timestampOffset = t.baseMediaDecodeTime() / t.timescale() * 1e3 - Xn);
10747
10778
  const g = t.mediaType() === "video" && t.startsWithKeyframe();
10748
10779
  this.currentChannelId !== A ? (console.assert(this.highestSeenTimestamps.size !== 0, "no known timestamps"), this.highestSeenTimestamps.forEach((Q) => {
10749
10780
  }), this.currentChannelId = A) : (g || this.timeshiftOnAudio) && this.tryTimeshiftSync();
@@ -10789,7 +10820,7 @@ const Zn = 5e3, Su = () => ma() || eQ() || pr(), Xn = () => Su() ? 100 : 0, jn =
10789
10820
  }
10790
10821
  if (!this.timestampOffset)
10791
10822
  return;
10792
- const t = Date.now() - this.seekTimeoutTime * this.timeshiftSync.multiplier, e = this.timeShiftAdjustments.filter(jn(t)).length;
10823
+ const t = Date.now() - this.seekTimeoutTime * this.timeshiftSync.multiplier, e = this.timeShiftAdjustments.filter(zn(t)).length;
10793
10824
  if (e && this.timeshiftSync.multiplier > 2)
10794
10825
  return this.logger.debug("Too many diff timeShifts within sliding window", {
10795
10826
  timeShiftsCooldownMs: t,
@@ -10817,7 +10848,7 @@ const Zn = 5e3, Su = () => ma() || eQ() || pr(), Xn = () => Su() ? 100 : 0, jn =
10817
10848
  const A = (Q = this.drift) != null ? Q : 0;
10818
10849
  if (A < 0 && -A < this.currentSyncMaxAhead() || A > 0 && A < this.currentSyncMaxBehind() || Math.abs(A) < 1 || !this.isSeekCooldownExpired())
10819
10850
  return;
10820
- const t = Date.now() - this.seekTimeoutTime * this.syncMaxBehindMultiplier, e = this.driftAdjustments.filter(jn(t)).length;
10851
+ const t = Date.now() - this.seekTimeoutTime * this.syncMaxBehindMultiplier, e = this.driftAdjustments.filter(zn(t)).length;
10821
10852
  if (e && this.syncMaxBehindMultiplier > 2)
10822
10853
  return this.logger.debug("Too many diff adjustments within sliding window", {
10823
10854
  adjustmentsCooldownMs: t,
@@ -10911,7 +10942,7 @@ const mu = {
10911
10942
  maxRetries: 10,
10912
10943
  maxErrorReports: 50,
10913
10944
  maxEvents: 50
10914
- }, kQ = (i, A) => T(D({}, A), { type: i, timestamp: (/* @__PURE__ */ new Date()).toISOString(), discriminator: "web" }), _C = class _C {
10945
+ }, RQ = (i, A) => T(D({}, A), { type: i, timestamp: (/* @__PURE__ */ new Date()).toISOString(), discriminator: "web" }), _C = class _C {
10915
10946
  constructor(A, t, e, g) {
10916
10947
  I(this, "logger");
10917
10948
  I(this, "timers", new mA());
@@ -10934,13 +10965,13 @@ const mu = {
10934
10965
  I(this, "addStats", ({ isFinal: A, initiator: t } = { isFinal: !1, initiator: "interval" }, e = {}) => {
10935
10966
  if (!this.options.includeStats)
10936
10967
  return;
10937
- const g = this.parentContext.getStatistics(), B = kQ("stats", T(D(D({}, e), g), { isFinal: A, initiator: t, count: this.statsCount++ }));
10968
+ const g = this.parentContext.getStatistics(), B = RQ("stats", T(D(D({}, e), g), { isFinal: A, initiator: t, count: this.statsCount++ }));
10938
10969
  this.unsentLines.push(B);
10939
10970
  });
10940
10971
  I(this, "addEvent", (A) => {
10941
10972
  if (!this.options.includeEvents || this.eventCount > this.options.maxEvents)
10942
10973
  return;
10943
- const t = this.parentContext.getStatistics(), e = kQ("event", D(D({}, t), A));
10974
+ const t = this.parentContext.getStatistics(), e = RQ("event", D(D({}, t), A));
10944
10975
  this.eventCount++, this.unsentLines.push(e);
10945
10976
  });
10946
10977
  I(this, "getStatistics", () => ({
@@ -10961,7 +10992,7 @@ const mu = {
10961
10992
  this.parentContext.connectionState === "connected" ? this.emitter.emit("send signal", {
10962
10993
  type: "telemetry",
10963
10994
  body: t
10964
- }) : yield Ra(new URL(this.options.url), { body: t, headers: { "Content-Type": "text/plain" } });
10995
+ }) : yield $a(new URL(this.options.url), { body: t, headers: { "Content-Type": "text/plain" } });
10965
10996
  break;
10966
10997
  }
10967
10998
  this.retries = 0, this.unsentLines.clear();
@@ -10985,7 +11016,7 @@ const mu = {
10985
11016
  return;
10986
11017
  const g = this.parentContext.getStatistics();
10987
11018
  this.unsentLines.push(
10988
- kQ("error", D(D({}, g), A.toStringifiable()))
11019
+ RQ("error", D(D({}, g), A.toStringifiable()))
10989
11020
  );
10990
11021
  }
10991
11022
  });
@@ -11011,7 +11042,74 @@ const $C = class $C {
11011
11042
  };
11012
11043
  I($C, "create", (A, t, e) => new $C(A, t, e));
11013
11044
  let sC = $C;
11014
- const yu = 6, fu = (i) => {
11045
+ const yu = [
11046
+ "minBufferTime",
11047
+ "maxBufferTime",
11048
+ "burstEnabled",
11049
+ "sizeBasedResolutionCapEnabled",
11050
+ "separateVideoSocketEnabled",
11051
+ "videoCodecs"
11052
+ ];
11053
+ function fu(i) {
11054
+ return yu.includes(i);
11055
+ }
11056
+ class pu {
11057
+ constructor(A) {
11058
+ I(this, "options");
11059
+ I(this, "overrides", /* @__PURE__ */ new Map());
11060
+ this.options = A;
11061
+ }
11062
+ /**
11063
+ *
11064
+ * @returns the options excluding any overrides
11065
+ */
11066
+ getOptions() {
11067
+ return this.options;
11068
+ }
11069
+ /**
11070
+ * Add overrides for a specific channel
11071
+ * @param channelId the channel to add overrides to
11072
+ * @param overrides the overrides to insert
11073
+ */
11074
+ addOverrides(A, t) {
11075
+ this.overrides.set(A, t);
11076
+ }
11077
+ /**
11078
+ * Sets an option value
11079
+ * @param key the option key to set
11080
+ * @param value the option value to insert into the key
11081
+ */
11082
+ set(A, t) {
11083
+ this.options[A] = t;
11084
+ }
11085
+ /**
11086
+ * Gets the option value for a specific key. If a channelId is provided, it will also apply any overrides
11087
+ * to the options value.
11088
+ * @param key the key to get from the options
11089
+ * @param channelId the channelId to get channel specific overrides from
11090
+ * @returns the option value, potentially overridden by channel overrides if a channelId is provided
11091
+ */
11092
+ get(A, t) {
11093
+ var e;
11094
+ if (t && fu(A)) {
11095
+ const g = (e = this.overrides.get(t)) == null ? void 0 : e[A];
11096
+ if (typeof g != "undefined")
11097
+ return g;
11098
+ }
11099
+ return this.options[A];
11100
+ }
11101
+ /**
11102
+ *
11103
+ * @param key the key to get from the overrides
11104
+ * @param channelId the channel overrides to get the override from
11105
+ * @returns the override value for that channel
11106
+ */
11107
+ getOverride(A, t) {
11108
+ var e;
11109
+ return (e = this.overrides.get(t)) == null ? void 0 : e[A];
11110
+ }
11111
+ }
11112
+ const Fu = 6, Gu = (i) => {
11015
11113
  let A = [i], t = 0, e = 0, g = !1;
11016
11114
  const B = (Q, o) => {
11017
11115
  var F, b, y;
@@ -11026,7 +11124,7 @@ const yu = 6, fu = (i) => {
11026
11124
  });
11027
11125
  };
11028
11126
  return (Q, o = !1) => {
11029
- if (Q.flags && ug(Q.flags) && o && (g = !g), !(o && A.length < yu && g) && A.length > 0) {
11127
+ if (Q.flags && ug(Q.flags) && o && (g = !g), !(o && A.length < Fu && g) && A.length > 0) {
11030
11128
  g = !1;
11031
11129
  let c = Q;
11032
11130
  for (let l = A.length - 1; l > 0; l--) {
@@ -11042,7 +11140,7 @@ const yu = 6, fu = (i) => {
11042
11140
  }
11043
11141
  return A.push(Q), [];
11044
11142
  };
11045
- }, pu = (i, A, t) => {
11143
+ }, ku = (i, A, t) => {
11046
11144
  if (fi(A))
11047
11145
  return D(T(D({}, i), {
11048
11146
  type: "video",
@@ -11066,7 +11164,7 @@ const yu = 6, fu = (i) => {
11066
11164
  duration: 0
11067
11165
  });
11068
11166
  };
11069
- class Fu {
11167
+ class Ru {
11070
11168
  constructor() {
11071
11169
  I(this, "highEntropyValues");
11072
11170
  var A;
@@ -11111,7 +11209,15 @@ class Fu {
11111
11209
  }, g);
11112
11210
  }
11113
11211
  }
11114
- const Gu = (i) => {
11212
+ const _n = (i, A) => i && typeof i == "object" && A in i, sr = (i) => !(typeof i != "object" || !_n(i, "channelId") || typeof i.channelId != "string" || !_n(i, "url") || typeof i.url != "string" || i.channelId.length === 0 || i.url.length === 0), Uu = (i) => {
11213
+ if (!sr(i))
11214
+ throw new v("Invalid options", { isFatal: !0, code: "invalid_options" });
11215
+ const A = D({}, i);
11216
+ return Object.keys(A).forEach((t) => {
11217
+ const e = A;
11218
+ typeof e[t] == "undefined" && delete e[t];
11219
+ }), A;
11220
+ }, Nu = (i) => {
11115
11221
  if (typeof i != "object" || i === null)
11116
11222
  throw new Error("not an object");
11117
11223
  if (!("video" in i))
@@ -11132,7 +11238,7 @@ const OA = class OA extends $A {
11132
11238
  */
11133
11239
  I(this, "pictureInPicture");
11134
11240
  I(this, "drm");
11135
- I(this, "browser", To());
11241
+ I(this, "browser", Po());
11136
11242
  I(this, "options");
11137
11243
  I(this, "element");
11138
11244
  I(this, "playbackSource");
@@ -11141,14 +11247,14 @@ const OA = class OA extends $A {
11141
11247
  I(this, "modules");
11142
11248
  I(this, "clientIp");
11143
11249
  I(this, "sessionId");
11144
- I(this, "clientId", ln());
11250
+ I(this, "clientId", un());
11145
11251
  I(this, "_channels", []);
11146
11252
  I(this, "createdAt", Date.now());
11147
11253
  I(this, "hasCalledConnect", !1);
11148
11254
  I(this, "latestEmittedLanguages", []);
11149
11255
  I(this, "wakeLock");
11150
- I(this, "pool", new En(OA.MAX_POOL_SIZE));
11151
- I(this, "userAgentInformation", new Fu());
11256
+ I(this, "pool", new rn(OA.MAX_POOL_SIZE));
11257
+ I(this, "userAgentInformation", new Ru());
11152
11258
  I(this, "encryptedMediaExtensions");
11153
11259
  n(this, mi, 0);
11154
11260
  n(this, TA, []);
@@ -11222,14 +11328,14 @@ const OA = class OA extends $A {
11222
11328
  }));
11223
11329
  I(this, "onConnectInfo", (t) => r(this, null, function* () {
11224
11330
  var a;
11225
- this.sessionId = ln();
11331
+ this.sessionId = un();
11226
11332
  const e = this.modules.subscription.getTargetSubscription(), g = t.channels.find((c) => c.channelId === e.channelId);
11227
11333
  if (this.emitter.emit("connect info", t), this._channels = t.channels, this.updateTextTracks((a = g == null ? void 0 : g.renditions) != null ? a : []), !this.textTrack && this.options.get("textTrack") && (this.textTrack = this.options.get("textTrack")), yield Promise.all(
11228
11334
  t.channels.map((c) => r(this, null, function* () {
11229
11335
  c.overrides && this.options.addOverrides(c.channelId, c.overrides), c.renditions = yield this.filterRenditions(c.renditions), this.modules.renditions.setRenditions(c.channelId, c.renditions);
11230
11336
  }))
11231
11337
  ), !g)
11232
- throw ba("external");
11338
+ throw Na("external");
11233
11339
  const B = this.options.getOverride(
11234
11340
  "sizeBasedResolutionCapEnabled",
11235
11341
  this.channelId
@@ -11303,7 +11409,7 @@ const OA = class OA extends $A {
11303
11409
  const u = this.options.get("advanced"), S = (c = u.wasmDecodingConstraint.bitRate) != null ? c : Number.MAX_SAFE_INTEGER, f = (h = u.wasmDecodingConstraint.width) != null ? h : Number.MAX_SAFE_INTEGER, F = (l = u.wasmDecodingConstraint.height) != null ? l : Number.MAX_SAFE_INTEGER;
11304
11410
  return Q.bitRate <= S && Q.width <= f && Q.height <= F;
11305
11411
  }
11306
- const o = yield kd(Q);
11412
+ const o = yield ud(Q);
11307
11413
  if (!o.supported || Q.codec == "av1" && !o.smooth && !o.powerEfficient)
11308
11414
  return !1;
11309
11415
  const a = this.options.getOverride("maxVideoBitRate", this.channelId);
@@ -11399,7 +11505,7 @@ const OA = class OA extends $A {
11399
11505
  */
11400
11506
  I(this, "unload", () => r(this, null, function* () {
11401
11507
  var t, e, g;
11402
- this.logger.debug("Unloading modules..."), yield Promise.all(Object.values(this.modules).map((B) => B == null ? void 0 : B.unload())), (t = this.wakeLock) == null || t.unload(), this.pool = new En(OA.MAX_POOL_SIZE), (g = (e = this.playbackSource).unload) == null || g.call(e), this.element.remove(), this.emitter.reset(), this.encryptedMediaExtensions.unload(), this.reset(), this.logger.debug("Unloaded modules");
11508
+ this.logger.debug("Unloading modules..."), yield Promise.all(Object.values(this.modules).map((B) => B == null ? void 0 : B.unload())), (t = this.wakeLock) == null || t.unload(), this.pool = new rn(OA.MAX_POOL_SIZE), (g = (e = this.playbackSource).unload) == null || g.call(e), this.element.remove(), this.emitter.reset(), this.encryptedMediaExtensions.unload(), this.reset(), this.logger.debug("Unloaded modules");
11403
11509
  }));
11404
11510
  /**
11405
11511
  * @deprecated since 3.0.0 Use play instead.
@@ -11425,7 +11531,7 @@ const OA = class OA extends $A {
11425
11531
  this.options.get("pauseSupportEnabled") && this.playbackState !== "paused" && (this.playbackSource.pause(), this.hasCalledConnect && this.suspend());
11426
11532
  });
11427
11533
  I(this, "registerDebugInstance", () => {
11428
- Gd(this);
11534
+ ld(this);
11429
11535
  });
11430
11536
  /**
11431
11537
  *
@@ -11467,7 +11573,7 @@ const OA = class OA extends $A {
11467
11573
  const t = this.modules.canvasModule ? this.options.get("iosMediaElementEnabled") : void 0;
11468
11574
  return D({
11469
11575
  uptime: Date.now() - this.createdAt,
11470
- version: "4.1.4-4-g5b507b07",
11576
+ version: "4.1.4-6-g7bc4e5ae",
11471
11577
  clientId: this.clientId,
11472
11578
  sessionId: this.sessionId,
11473
11579
  channelId: this.channelId,
@@ -11499,7 +11605,7 @@ const OA = class OA extends $A {
11499
11605
  if (e && t)
11500
11606
  return t - e;
11501
11607
  });
11502
- this.options = new Fd(D(D({}, $r), Fc(t)));
11608
+ this.options = new pu(D(D({}, Vr), Uu(t)));
11503
11609
  const e = ["localhost", "127.0.0.1"];
11504
11610
  t.telemetryEnabled === void 0 && e.includes(location.hostname) && this.options.set("telemetryEnabled", !1);
11505
11611
  const g = {
@@ -11579,7 +11685,7 @@ const OA = class OA extends $A {
11579
11685
  this,
11580
11686
  this.options.get("muted") || this.options.get("media") === "video"
11581
11687
  );
11582
- this.element = w.element(), this.playbackSource = w, y = w, this.options.get("iosWakeLockEnabled") && (this.wakeLock = new md());
11688
+ this.element = w.element(), this.playbackSource = w, y = w, this.options.get("iosWakeLockEnabled") && (this.wakeLock = new hd());
11583
11689
  }
11584
11690
  this.emitter.on("channel reset", this.resetModules), this.emitter.on("no data timeout", this.resetModules), this.emitter.on("media element state", (w) => this.onMediaElementState(w)), this.emitter.on("volume state", (w) => this.emit("volume state", w)), this.options.get("pauseSupportEnabled") || this.emitter.on("exit picture in picture", () => Q.setTimeout(() => this.play(), 0)), this.emitter.on("constraint cap changed", (w) => {
11585
11691
  this.logger.info("new cap set", { cap: w }), this.alignSizeAndBitRate(this.targetSubscription);
@@ -11754,7 +11860,7 @@ const OA = class OA extends $A {
11754
11860
  break;
11755
11861
  case "subscription changed":
11756
11862
  try {
11757
- Gu(p.subscription);
11863
+ Nu(p.subscription);
11758
11864
  } catch (Y) {
11759
11865
  this.emitter.emit(
11760
11866
  "error",
@@ -11769,16 +11875,16 @@ const OA = class OA extends $A {
11769
11875
  reset: p.reset,
11770
11876
  to: p.subscription,
11771
11877
  from: this.modules.subscription.getCurrentSubscription()
11772
- }), p.reset && H.channelId !== p.subscription.channelId && (this.emit("error", mn(p.subscription.channelId)), this.emit("channel switch failed", { channelId: H.channelId })), this.modules.sync.timeshiftOnAudio = !((O = p.subscription.video) != null && O.codec), this.modules.adaptivity.reset();
11878
+ }), p.reset && H.channelId !== p.subscription.channelId && (this.emit("error", yn(p.subscription.channelId)), this.emit("channel switch failed", { channelId: H.channelId })), this.modules.sync.timeshiftOnAudio = !((O = p.subscription.video) != null && O.codec), this.modules.adaptivity.reset();
11773
11879
  break;
11774
11880
  case "timing info":
11775
11881
  this.modules.sync.updateChannelSyncInfo(p.timingInfo.channelId, p.timingInfo), this.emit("server wallclock time", p.timingInfo.wallclockTime);
11776
11882
  break;
11777
11883
  }
11778
11884
  }), this.emitter.on("channel switch timeout", (w) => {
11779
- this.emit("error", mn(w)), this.emit("channel switch failed", { channelId: this.currentSubscription.channelId });
11885
+ this.emit("error", yn(w)), this.emit("channel switch failed", { channelId: this.currentSubscription.channelId });
11780
11886
  }), this.emitter.on("received data", (w) => {
11781
- const p = this.modules.subscription.getCurrentSubscription(), H = Dd(w);
11887
+ const p = this.modules.subscription.getCurrentSubscription(), H = rd(w);
11782
11888
  if (!p) {
11783
11889
  this.logger.warn("Received unwanted message", D({}, H));
11784
11890
  return;
@@ -11787,7 +11893,7 @@ const OA = class OA extends $A {
11787
11893
  }), this.emitter.on("received moq data", (w) => {
11788
11894
  var P, tA, yA;
11789
11895
  const p = w.payload.mediaType(), H = w.channelId, O = w.renditionId, Y = this.modules.sync.processFragment(H, w.payload);
11790
- if (w.switchInfo.channelId && (w.switchInfo.drmTransition && this.emitter.emit("error", Ja("Switching between DRM and non-DRM channels is not supported", !0)), this.encryptedMediaExtensions.onChannelSwitch(), this.emit("rendition levels", this.modules.renditions.getRenditionLevels()), this.modules.event.addEvent({
11896
+ if (w.switchInfo.channelId && (w.switchInfo.drmTransition && this.emitter.emit("error", La("Switching between DRM and non-DRM channels is not supported", !0)), this.encryptedMediaExtensions.onChannelSwitch(), this.emit("rendition levels", this.modules.renditions.getRenditionLevels()), this.modules.event.addEvent({
11791
11897
  type: "channel switch",
11792
11898
  channelId: w.switchInfo.channelId,
11793
11899
  timestamp: Y.baseMediaDecodeTime() / Y.timescale() * 1e3
@@ -11798,7 +11904,7 @@ const OA = class OA extends $A {
11798
11904
  }), this.modules.incomingData.add(p, w.payload.rawBytes().byteLength), Y.fragment().emsgs.forEach((m) => {
11799
11905
  if (!m.presentationTime)
11800
11906
  return;
11801
- const L = Zc(m.data);
11907
+ const L = Yc(m.data);
11802
11908
  L && this.modules.event.addEvent({
11803
11909
  id: m.id,
11804
11910
  timestamp: m.presentationTime / m.timescale * 1e3 - this.modules.sync.getTimeshiftOffset(),
@@ -11841,13 +11947,13 @@ const OA = class OA extends $A {
11841
11947
  const p = w.channelId;
11842
11948
  s(this, yi) && (yield s(this, yi));
11843
11949
  const H = this.modules.renditions.getRendition(w.renditionId, p);
11844
- if (!ld(w.flags)) {
11845
- if (ud(w.flags)) {
11950
+ if (!nd(w.flags)) {
11951
+ if (ad(w.flags)) {
11846
11952
  const Y = new TextDecoder().decode(w.payload), P = this.modules.sync.getTimeshiftOffset();
11847
11953
  if (w.renditionId !== 0) {
11848
- const tA = pa(Y);
11954
+ const tA = Fa(Y);
11849
11955
  if (tA && tA.language !== void 0) {
11850
- const m = new _a().parse(tA.content || ""), L = P / 1e3, x = s(this, TA).find((k) => k.language === tA.language), AA = L - s(this, mi);
11956
+ const m = new ja().parse(tA.content || ""), L = P / 1e3, x = s(this, TA).find((k) => k.language === tA.language), AA = L - s(this, mi);
11851
11957
  if (E(this, mi, L), x) {
11852
11958
  if (x.cues)
11853
11959
  for (const k of x.cues)
@@ -11865,25 +11971,25 @@ const OA = class OA extends $A {
11865
11971
  type: "metadata"
11866
11972
  });
11867
11973
  } else if (H != null && H.codec) {
11868
- const O = vQ(H.codec);
11974
+ const O = TQ(H.codec);
11869
11975
  if (O === "text")
11870
11976
  throw new Error("Subtitles are not supported");
11871
- if (this.modules.incomingData.add(O, w.payload.byteLength), dd(w.flags)) {
11977
+ if (this.modules.incomingData.add(O, w.payload.byteLength), od(w.flags)) {
11872
11978
  const Y = T(D({
11873
11979
  type: O,
11874
11980
  data: w.payload,
11875
11981
  codec: H.codec
11876
11982
  }, w), {
11877
11983
  channelId: p
11878
- }), P = nd(Y.codec, Y.payload);
11984
+ }), P = Id(Y.codec, Y.payload);
11879
11985
  P && this.sizes.set(Y.renditionId, P);
11880
11986
  const tA = Ye({ codec: H.codec, codecString: H.codecString });
11881
11987
  this.emitter.emit("init segment", { initSegment: Y, mimeType: tA }), this.emit("initialized media");
11882
11988
  } else {
11883
- const Y = pu(w, H, this.sizes.get(w.renditionId));
11989
+ const Y = ku(w, H, this.sizes.get(w.renditionId));
11884
11990
  let P = this.sampleProcessingSesssions.get(O);
11885
11991
  if (!P)
11886
- P = fu(
11992
+ P = Gu(
11887
11993
  this.modules.sync.processSample(Y)
11888
11994
  ), this.sampleProcessingSesssions.set(O, P);
11889
11995
  else {
@@ -12317,120 +12423,7 @@ const OA = class OA extends $A {
12317
12423
  };
12318
12424
  mi = new WeakMap(), TA = new WeakMap(), yi = new WeakMap(), I(OA, "MAX_POOL_SIZE", 10), I(OA, "INITIAL_MAX_BIT_RATE", 2.5 * 1e3 * 1e3), I(OA, "DISCONNECT_TIMEOUT", 15 * 1e3), I(OA, "REMOVE_CUE_THRESHOLD", 1e3 * 10);
12319
12425
  let Ho = OA;
12320
- const ku = "_buffering_1ccif_1", Ru = "_hidden_1ccif_25", CQ = {
12321
- buffering: ku,
12322
- "buffering-fullscreen": "_buffering-fullscreen_1ccif_16",
12323
- hidden: Ru,
12324
- "buffering-indicator": "_buffering-indicator_1ccif_31"
12325
- };
12326
- class At {
12327
- constructor(A) {
12328
- I(this, "attach", (A) => {
12329
- this.detach(), A.appendChild(this.element);
12330
- });
12331
- I(this, "attachBefore", (A, t) => {
12332
- this.detach(), A.insertBefore(this.element, t);
12333
- });
12334
- I(this, "detach", () => this.element.remove());
12335
- this.element = A;
12336
- }
12337
- }
12338
- const RQ = CQ.hidden, Uu = CQ.buffering, zn = CQ["buffering-fullscreen"], Nu = CQ["buffering-indicator"];
12339
- class sr extends At {
12340
- constructor() {
12341
- super(document.createElement("div"));
12342
- I(this, "indicator", document.createElement("div"));
12343
- I(this, "isHidden", () => this.element.classList.contains(RQ));
12344
- I(this, "setHidden", (t) => t ? this.hide() : this.show());
12345
- I(this, "hide", () => this.element.classList.add(RQ));
12346
- I(this, "show", () => this.element.classList.remove(RQ));
12347
- I(this, "fullscreen", (t) => {
12348
- t ? this.element.classList.add(zn) : this.element.classList.remove(zn);
12349
- });
12350
- this.element.className = Uu, this.indicator.className = Nu, this.element.appendChild(this.indicator);
12351
- }
12352
- }
12353
- class _n extends $A {
12354
- constructor(t) {
12355
- super();
12356
- I(this, "config");
12357
- I(this, "hlsUrl");
12358
- I(this, "element");
12359
- I(this, "connectingTimeout");
12360
- I(this, "castingAvailable", !1);
12361
- /**
12362
- * Update authentication token on an already established and authenticated connection.
12363
- * Note: When casting to AirPlay, this will interrupt the current session to apply the new token.
12364
- */
12365
- I(this, "updateAuthenticationToken", (t) => {
12366
- this.config.authenticationToken = t, this.hlsUrl = this.getHlsUrl(), this.castingAvailable && (this.element.src = this.hlsUrl);
12367
- });
12368
- /**
12369
- * Fully unloads the instance. This disconnects the current listeners.
12370
- */
12371
- I(this, "unload", () => {
12372
- this.element && (this.element.removeEventListener("webkitplaybacktargetavailabilitychanged", this.onAirPlayAvailable), this.element.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged", this.onAirPlayPlaybackChanged), this.element.remove());
12373
- });
12374
- I(this, "onAirPlayAvailable", (t) => {
12375
- switch (t.availability) {
12376
- case "available": {
12377
- this.castingAvailable = !0, this.element.src !== this.hlsUrl && this.checkHlsUrl(this.hlsUrl).then((g) => {
12378
- g && (this.element.src = this.hlsUrl, this.emit("available"));
12379
- });
12380
- break;
12381
- }
12382
- case "not-available":
12383
- this.castingAvailable = !1;
12384
- break;
12385
- }
12386
- });
12387
- I(this, "onAirPlayPlaybackChanged", () => {
12388
- window.clearTimeout(this.connectingTimeout), this.element.webkitCurrentPlaybackTargetIsWireless ? (this.emit("connected"), this.element.style.display = "block", this.element.paused && this.element.play()) : (this.emit("disconnected"), this.element.pause(), this.element.src = "", this.element.src = this.hlsUrl, this.element.style.display = "none");
12389
- });
12390
- this.config = t, this.hlsUrl = this.getHlsUrl(), this.element = document.createElement("video"), this.element.style.position = "absolute", this.element.style.top = "0", this.element.style.bottom = "0", this.element.style.left = "0", this.element.style.right = "0", this.element.style.width = "100%", this.element.style.height = "100%", this.element.style.zIndex = "1001", this.element.style.display = "none", this.element.id = "vindral-airplay-element", this.element.slot = "overlay", this.element.playsInline = !0, this.element.controls = !0, this.element.preload = "metadata", this.element.addEventListener("webkitplaybacktargetavailabilitychanged", this.onAirPlayAvailable), this.element.addEventListener("webkitcurrentplaybacktargetiswirelesschanged", this.onAirPlayPlaybackChanged), this.config.container.appendChild(this.element);
12391
- }
12392
- /**
12393
- * True if the instance is casting right now.
12394
- */
12395
- get casting() {
12396
- return this.element.webkitCurrentPlaybackTargetIsWireless;
12397
- }
12398
- /**
12399
- * Set the current channelId.
12400
- */
12401
- set channelId(t) {
12402
- }
12403
- /* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-call */
12404
- /**
12405
- * Show the AirPlay picker.
12406
- */
12407
- showPlaybackTargetPicker() {
12408
- this.element.paused && (this.element.play(), this.connectingTimeout = window.setTimeout(() => {
12409
- this.casting || (this.element.pause(), this.element.src = "", this.element.src = this.hlsUrl);
12410
- }, 3e4)), this.element.webkitShowPlaybackTargetPicker();
12411
- }
12412
- /**
12413
- * Returns if AirPlay is supported.
12414
- */
12415
- static isAirPlaySupported() {
12416
- return !!window.WebKitPlaybackTargetAvailabilityEvent;
12417
- }
12418
- getHlsUrl() {
12419
- const t = new URL(`/api/hls?channelId=${this.config.channelId}`, this.config.url);
12420
- return this.config.authenticationToken && t.searchParams.set("authenticationToken", this.config.authenticationToken), t.toString();
12421
- }
12422
- checkHlsUrl(t) {
12423
- return r(this, null, function* () {
12424
- try {
12425
- return (yield fetch(t, { method: "HEAD" })).ok;
12426
- } catch (e) {
12427
- return !1;
12428
- }
12429
- });
12430
- }
12431
- /* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-call */
12432
- }
12433
- const bu = "_bar_zames_1", Lu = "_hidden_zames_45", Br = {
12426
+ const bu = "_bar_qm7bl_1", Lu = "_hidden_qm7bl_47", Br = {
12434
12427
  bar: bu,
12435
12428
  hidden: Lu
12436
12429
  }, Ju = "_withThumbnails_suenn_19", oB = {
@@ -12519,10 +12512,10 @@ class Te extends At {
12519
12512
  this.element.style.cursor = "pointer", this.element.setAttribute("role", "button"), this.element.setAttribute("aria-label", t), this.iconElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.iconElement.setAttribute("width", "40px"), this.iconElement.setAttribute("height", "40px"), this.iconElement.setAttribute("class", ju), this.setIcon(e), this.element.addEventListener("click", g), this.element.appendChild(this.iconElement);
12520
12513
  }
12521
12514
  }
12522
- const zu = "_list_pxz62_1", _u = "_hidden_pxz62_18", QQ = {
12515
+ const zu = "_list_1vkum_1", _u = "_hidden_1vkum_20", QQ = {
12523
12516
  list: zu,
12524
- "list-item": "_list-item_pxz62_10",
12525
- "list-item-disabled": "_list-item-disabled_pxz62_14",
12517
+ "list-item": "_list-item_1vkum_12",
12518
+ "list-item-disabled": "_list-item-disabled_1vkum_16",
12526
12519
  hidden: _u
12527
12520
  }, Aa = QQ.hidden, $u = QQ.list, Aw = QQ["list-item"], tw = QQ["list-item-disabled"];
12528
12521
  class ew extends At {
@@ -12679,8 +12672,8 @@ class fw extends oQ {
12679
12672
  var S, f, F;
12680
12673
  const C = document.createElement("div");
12681
12674
  C.className = [Dw, B === A.currentRenditionLevel ? Sw : ""].join(" ");
12682
- const Q = document.createElement("span"), o = document.createElement("span"), { audio: a, video: c } = B, h = c ? Mr(c) : void 0, l = a ? Hr(a.sampleRate) : void 0;
12683
- let u = Jr(((S = c == null ? void 0 : c.bitRate) != null ? S : 0) + ((f = a == null ? void 0 : a.bitRate) != null ? f : 0));
12675
+ const Q = document.createElement("span"), o = document.createElement("span"), { audio: a, video: c } = B, h = c ? Kr(c) : void 0, l = a ? Yr(a.sampleRate) : void 0;
12676
+ let u = vr(((S = c == null ? void 0 : c.bitRate) != null ? S : 0) + ((f = a == null ? void 0 : a.bitRate) != null ? f : 0));
12684
12677
  if (c) {
12685
12678
  const b = c.frameRate[0] / c.frameRate[1], y = c.frameRate[0] % c.frameRate[1] === 0 ? `${b}p` : `${b.toFixed(2)}p`;
12686
12679
  u += `, ${y}`;
@@ -12851,7 +12844,7 @@ class Lw extends At {
12851
12844
  this.element.classList.add(bw), this.element.classList.add(UQ), this.element.innerText = "device";
12852
12845
  }
12853
12846
  }
12854
- const Jw = "_button_137xm_21", Mw = "_image_137xm_96", Hw = "_overlay_137xm_116", qw = "_selected_137xm_134", vw = "_hidden_137xm_139", aB = {
12847
+ const Jw = "_button_4ybkq_21", Mw = "_image_4ybkq_98", Hw = "_overlay_4ybkq_118", qw = "_selected_4ybkq_136", vw = "_hidden_4ybkq_141", aB = {
12855
12848
  button: Jw,
12856
12849
  image: Mw,
12857
12850
  overlay: Hw,
@@ -12884,7 +12877,7 @@ class Tw extends At {
12884
12877
  I(this, "show", () => this.element.classList.remove(NQ));
12885
12878
  this.element.className = Kw, B && this.setSelected(B), this.element.onclick = () => {
12886
12879
  this.loadingOverlay.show(), e();
12887
- }, this.imageHolder1 = document.createElement("div"), this.imageHolder1.className = Ia, this.imageHolder1.style.animationFillMode = "forwards", this.imageHolder2 = document.createElement("div"), this.imageHolder2.className = Ia, this.imageHolder2.style.animationFillMode = "forwards", g && (this.imageHolder1.style.backgroundImage = `url(${g})`, this.isImageHolder1Active = !0), this.loadingOverlay = new sr(), this.loadingOverlay.attach(this.element), this.loadingOverlay.hide(), this.element.appendChild(this.imageHolder1), this.element.appendChild(this.imageHolder2), this.overlay = document.createElement("div"), this.overlay.className = Yw, this.element.appendChild(this.overlay);
12880
+ }, this.imageHolder1 = document.createElement("div"), this.imageHolder1.className = Ia, this.imageHolder1.style.animationFillMode = "forwards", this.imageHolder2 = document.createElement("div"), this.imageHolder2.className = Ia, this.imageHolder2.style.animationFillMode = "forwards", g && (this.imageHolder1.style.backgroundImage = `url(${g})`, this.isImageHolder1Active = !0), this.loadingOverlay = new Da(), this.loadingOverlay.attach(this.element), this.loadingOverlay.hide(), this.element.appendChild(this.imageHolder1), this.element.appendChild(this.imageHolder2), this.overlay = document.createElement("div"), this.overlay.className = Yw, this.element.appendChild(this.overlay);
12888
12881
  const C = document.createElement("span");
12889
12882
  C.innerHTML = t, this.element.appendChild(C), this.show();
12890
12883
  }
@@ -13068,7 +13061,7 @@ const eD = jo.player, JQ = jo["one-to-one"], iD = jo["audio-only"], ID = {
13068
13061
  airPlayButtonEnabled: !1,
13069
13062
  playOverlayEnabled: !0,
13070
13063
  bufferingOverlayEnabled: !0
13071
- }, gD = (i) => !Ma(i);
13064
+ }, gD = (i) => !sr(i);
13072
13065
  class nD {
13073
13066
  constructor(A, t) {
13074
13067
  /**
@@ -13093,7 +13086,7 @@ class nD {
13093
13086
  I(this, "bar");
13094
13087
  I(this, "stateInterval");
13095
13088
  I(this, "thumbnailModule");
13096
- I(this, "browser", To());
13089
+ I(this, "browser", Po());
13097
13090
  /**
13098
13091
  * Fully unloads the Player and the Vindral instance.
13099
13092
  */
@@ -13231,11 +13224,11 @@ class nD {
13231
13224
  onAirPlayClicked: () => this.showAirPlayPicker()
13232
13225
  })), this.core.media === "audio" && (this.playerElement.classList.add(iD), this.options.controlsEnabled && this.bar.show());
13233
13226
  const Q = this.core.getCastOptions();
13234
- this.castSender = new _r({
13227
+ this.castSender = new Or({
13235
13228
  background: this.options.castBackground,
13236
13229
  receiverApplicationId: this.options.castReceiverApplicationId,
13237
13230
  options: Q
13238
- }), this.setupCastSender(), this.options.airPlayButtonEnabled && _n.isAirPlaySupported() && (this.airPlaySender = new _n({
13231
+ }), this.setupCastSender(), this.options.airPlayButtonEnabled && wn.isAirPlaySupported() && (this.airPlaySender = new wn({
13239
13232
  url: Q.url,
13240
13233
  channelId: Q.channelId,
13241
13234
  authenticationToken: Q.authenticationToken,
@@ -13265,7 +13258,7 @@ class nD {
13265
13258
  break;
13266
13259
  }
13267
13260
  }
13268
- }), this.core.attach(this.playerElement), this.castOverlay.attach(this.playerElement), this.options.bufferingOverlayEnabled && (this.bufferingOverlay = new sr(), this.bufferingOverlay.attach(this.playerElement)), this.options.playOverlayEnabled && (this.playOverlay = new AD(), this.playOverlay.attach(this.playerElement), this.playOverlay.onClick = () => {
13261
+ }), this.core.attach(this.playerElement), this.castOverlay.attach(this.playerElement), this.options.bufferingOverlayEnabled && (this.bufferingOverlay = new Da(), this.bufferingOverlay.attach(this.playerElement)), this.options.playOverlayEnabled && (this.playOverlay = new AD(), this.playOverlay.attach(this.playerElement), this.playOverlay.onClick = () => {
13269
13262
  var f;
13270
13263
  this.core.userInput(), (f = this.playOverlay) == null || f.hide();
13271
13264
  }), this.channelSelectionList && this.channelSelectionList.attach(this.playerElement), this.bar.attach(this.playerElement), this.playerElement.addEventListener("click", this.onClick), this.playerElement.addEventListener("mousemove", this.onMouseMove), this.state.fullscreen.on("on fullscreen change", (f) => {
@@ -13540,7 +13533,7 @@ const Yg = class Yg {
13540
13533
  }
13541
13534
  }));
13542
13535
  } catch (t) {
13543
- t instanceof Error && this.errors.push(Ua(!1, t));
13536
+ t instanceof Error && this.errors.push(Ra(!1, t));
13544
13537
  }
13545
13538
  });
13546
13539
  I(this, "initSegment", q);
@@ -13665,16 +13658,16 @@ const QD = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
13665
13658
  H264DecoderWorkerContext: Ko
13666
13659
  }, Symbol.toStringTag, { value: "Module" }));
13667
13660
  export {
13668
- ic as AUTHENTICATION_EXPIRED_CODE,
13669
- ec as AUTHENTICATION_FAILED_CODE,
13670
- jr as ApiClient,
13671
- Ic as CHANNEL_NOT_FOUND_CODE,
13672
- tc as CONNECTION_FAILED_AFTER_RETRIES_CODE,
13673
- Ac as CONNECTION_FAILED_CODE,
13674
- _r as CastSender,
13675
- oc as DISCONNECTED_BY_EDGE,
13676
- sc as INACTIVITY_CODE,
13677
- gc as NO_INCOMING_DATA,
13661
+ zr as AUTHENTICATION_EXPIRED_CODE,
13662
+ jr as AUTHENTICATION_FAILED_CODE,
13663
+ Ld as ApiClient,
13664
+ _r as CHANNEL_NOT_FOUND_CODE,
13665
+ Xr as CONNECTION_FAILED_AFTER_RETRIES_CODE,
13666
+ Zr as CONNECTION_FAILED_CODE,
13667
+ Or as CastSender,
13668
+ Ic as DISCONNECTED_BY_EDGE,
13669
+ Ac as INACTIVITY_CODE,
13670
+ $r as NO_INCOMING_DATA,
13678
13671
  nD as Player,
13679
13672
  Ho as Vindral,
13680
13673
  v as VindralError